Skip to content

Commit

Permalink
- fix compilation dont crash on null geometry
Browse files Browse the repository at this point in the history
 - command line should not require req, and just take gnuplot from path
  • Loading branch information
fbergmann committed Apr 14, 2021
1 parent e1323b2 commit 198f995
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions SpatialCL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ int main(int argc, const char *argv[])

cout << "SpatialPlugin: " << (doc->getModel()->getPlugin("spatial") != NULL ? "not null": "null") <<endl;
cout << "spatial required: "<< (doc->getPkgRequired("spatial") ? "yes": "no") << endl;
cout << "req required: "<< (doc->getPkgRequired("req") ? "yes": "no") << endl;

if (doc->getModel()->getPlugin("spatial") != NULL &&
doc->getPkgRequired("spatial") &&
doc->getPkgRequired("req")) {
doc->getPkgRequired("spatial")) {
// probably a spatial simulation
SpatialSimulator sim(doc, 101, 101);
#ifdef WIN32
sim.setGnuplotExecutable("C:/gnuplot/bin/gnuplot.exe");
#else
// just pick gnuplot from the path
sim.setGnuplotExecutable("gnuplot");
#endif
sim.run(1001, 0.01);
//spatialSimulator(doc, argc, argv);
}
Expand Down
4 changes: 2 additions & 2 deletions SpatialSBML/spatialsimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void SpatialSimulator::initFromModel(SBMLDocument* doc, int xdim, int ydim, int
}
if (samVol == NULL) continue;
unsigned int uncomprLen = samField->getUncompressedLength();
int *uncompr = (int*)calloc(sizeof(int), uncomprLen);
double *uncompr = (double*)calloc(sizeof(double), uncomprLen);
samField->getUncompressed(uncompr);

GeometryInfo *geoInfo = new GeometryInfo;
Expand Down Expand Up @@ -1463,7 +1463,7 @@ void SpatialSimulator::performStep(double t, double dt)
//diffusion
for (size_t i = 0; i < numOfSpecies; ++i) {
variableInfo *sInfo = searchInfoById(varInfoList, los->get(i)->getId().c_str());
if (sInfo == NULL) continue;
if (sInfo == NULL || sInfo->geoi == NULL) continue;
//volume diffusion
if (sInfo->diffCInfo != 0 && sInfo->geoi->isVol) {
calcDiffusion(sInfo, deltaX, deltaY, deltaZ, Xindex, Yindex, Zindex, m, dt, dimension);
Expand Down

0 comments on commit 198f995

Please sign in to comment.