From: Eric F. <efe...@ph...> - 2008-09-29 15:59:24
|
Hi, Thanks for the answer, I'll work on an example very soon and will post it. Eric > -----Original Message----- > From: Rainer Machne [mailto:ra...@tb...] > Sent: 29 September 2008 11:00 > To: Eric Fernandez > Cc: sbm...@li... > Subject: Re: [SOSlib-discuss] encapsulating an > integratorInstance leads to integration segfault[Scanned] > > Hi Eric, > > We also couldn't come up with any ideas here, unfortunately. > Maybe, could you supply us with a full example .cpp file > which reproduces the problem for testing? > > The only thing I could find is this: > > > cout << "DNA: " << IntegratorInstance_getVariableValue(engine, > > > > ODEModel_getVariableIndex(odeModel, "dna")) << endl; // OK > > ODEModel_getVariableIndex allocates memory for the > variableIndex_t structure. This must be freed again! > > So it should be: > > variableIndex_t *vi = ODEModel_getVariableIndex(odeModel, > "dna"); IntegratorInstance_getVariableValue(engine, vi); > VariableIndex_free(vi); > > But I doubt that this would cause such severe problems. > > As said, a working example file or some debug information > would be helpful. > > Rainer > > > Eric Fernandez wrote: > > Hi, > > > > I want to encapsulate the odeSolver data structures and > > integratorInstance in a C++ class but integration segfaults in some > > conditions. > > > > class Engine > > { > > private: > > odeModel_t* odeModel; > > cvodeSettings_t* settings; > > integratorInstance_t* engine; > > double simTime; > > > > public: > > Engine(odeModel_t*, double); > > ~Engine(); > > void integrateSimple(); > > }; > > > > ---> in the constructor I build the integratorInstance and try to > > integrate one step: > > > > Engine::Engine(odeModel_t* om, double time) : odeModel(om), > > simTime(time) > > { > > cout << "Engine Constr" << endl; > > > > // Create the settings and the integrator instance > > cvodeSettings_t* settings = CvodeSettings_createWith(simTime, > > simTime * > > PSFACTOR, > > ABS_ERR, > > REL_ERR, > > 10000, > > 0, > > 0, > > 1, > > 0, > > 0, > > 0, > > 1, > > 0, > > 2); > > CvodeSettings_setCompileFunctions(settings, 1); > > CvodeSettings_setSteadyStateThreshold(settings, 1e-11); > > CvodeSettings_setResetCvodeOnEvent(settings, 1); > > integratorInstance_t* engine = IntegratorInstance_create(om, > > settings); > > > > IntegratorInstance_integrateOneStep(engine); //// TESTING > > cout << IntegratorInstance_getTime(engine) << endl; > > } > > > > ----> this works: my constructor creates the engine object and > > integrates one step succesfully. > > > > ----> However, if my constructor calls : > > > > Engine::Engine(odeModel_t* om, double time) : odeModel(om), > > simTime(time) > > { > > cout << "Engine Constr" << endl; > > > > // Create the settings and the integrator instance > > cvodeSettings_t* settings = CvodeSettings_createWith(simTime, > > simTime * > > PSFACTOR, > > ABS_ERR, > > REL_ERR, > > 10000, > > 0, > > 0, > > 1, > > 0, > > 0, > > 0, > > 1, > > 0, > > 2); > > CvodeSettings_setCompileFunctions(settings, 1); > > CvodeSettings_setSteadyStateThreshold(settings, 1e-11); > > CvodeSettings_setResetCvodeOnEvent(settings, 1); > > integratorInstance_t* engine = IntegratorInstance_create(om, > > settings); > > > > integrateSimple(); > > > > } > > > > void Engine::integrateSimple() > > { > > cout << IntegratorInstance_getTime(engine) << endl; //OK > > > > cout << "DNA: " << IntegratorInstance_getVariableValue(engine, > > > > ODEModel_getVariableIndex(odeModel, "dna")) << endl; // OK > > > > IntegratorInstance_integrateOneStep(engine); // SEGFAULTS!! > > } > > > > > > This crash also occurs if, of course, I create an Engine > instance in > > another class or main and try to call integrateSimple() > independently > > from the constructor. This call inside the constructor was just for > > testing purpose. > > > > Am I doing something wrong there ? There must be something > obvious I > > overlooked there but cannot find it. > > > > Eric > > > > > ---------------------------------------------------------------------- > > --- This SF.Net email is sponsored by the Moblin Your Move > Developer's > > challenge Build the coolest Linux based applications with > Moblin SDK & > > win great prizes Grand prize is a trip for two to an Open > Source event > > anywhere in the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > sbmlsolver-discuss mailing list > > sbm...@li... > > https://lists.sourceforge.net/lists/listinfo/sbmlsolver-discuss > > |