From 20d7b4caa3372c978205efe4bb38d4ed6936fec7 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 28 Apr 2014 20:46:23 +0000 Subject: [PATCH] handle errors more gracefully --- Plugin/MathEval.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Plugin/MathEval.cpp b/Plugin/MathEval.cpp index 1e52daa25c..9c232aa5ca 100644 --- a/Plugin/MathEval.cpp +++ b/Plugin/MathEval.cpp @@ -126,14 +126,6 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) return view; } - OctreePost *octree = 0; - if(forceInterpolation || - (data1->getNumEntities() != otherData->getNumEntities()) || - (data1->getNumElements() != otherData->getNumElements())){ - Msg::Info("Other view based on different grid: interpolating..."); - octree = new OctreePost(otherView); - } - if(otherTimeStep < 0 && otherData->getNumTimeSteps() != data1->getNumTimeSteps()){ Msg::Error("Number of time steps don't match: using step 0"); otherTimeStep = 0; @@ -171,6 +163,14 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) if(expr.empty()) return view; std::vector<double> values(numVariables), res(numComp2); + OctreePost *octree = 0; + if(forceInterpolation || + (data1->getNumEntities() != otherData->getNumEntities()) || + (data1->getNumElements() != otherData->getNumElements())){ + Msg::Info("Other view based on different grid: interpolating..."); + octree = new OctreePost(otherView); + } + PView *v2 = new PView(); PViewDataList *data2 = getDataList(v2); @@ -236,14 +236,19 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) values[0] = x[nod]; values[1] = y[nod]; values[2] = z[nod]; for(int i = 0; i < 9; i++) values[3 + i] = v[i]; for(int i = 0; i < 9; i++) values[12 + i] = w[i]; - if(f.eval(values, res)) + if(f.eval(values, res)){ for(int i = 0; i < numComp2; i++) out->push_back(res[i]); + } + else{ + goto end; + } } } } } + end: if(octree) delete octree; if(timeStep < 0){ -- GitLab