diff --git a/Plugin/ExtractElements.cpp b/Plugin/ExtractElements.cpp index 44537ae6d9782f864380354c001db63f2f0cc7e5..110b6e336e4e88eeb02f943a2d07d6e7aec3bb87 100644 --- a/Plugin/ExtractElements.cpp +++ b/Plugin/ExtractElements.cpp @@ -11,6 +11,7 @@ StringXNumber ExtractElementsOptions_Number[] = { {GMSH_FULLRC, "MaxVal", NULL, 0.}, {GMSH_FULLRC, "TimeStep", NULL, 0.}, {GMSH_FULLRC, "Visible", NULL, 1.}, + {GMSH_FULLRC, "Dimension", NULL, -1.}, {GMSH_FULLRC, "View", NULL, -1.} }; @@ -48,20 +49,20 @@ PView *GMSH_ExtractElementsPlugin::execute(PView *v) { double MinVal = ExtractElementsOptions_Number[0].def; double MaxVal = ExtractElementsOptions_Number[1].def; - int step = (int)ExtractElementsOptions_Number[2].def; + int thisStep = (int)ExtractElementsOptions_Number[2].def; int visible = (int)ExtractElementsOptions_Number[3].def; - int iView = (int)ExtractElementsOptions_Number[4].def; + int dimension = (int)ExtractElementsOptions_Number[4].def; + int iView = (int)ExtractElementsOptions_Number[5].def; PView *v1 = getView(iView, v); if(!v1) return v; - PViewData *data1 = getPossiblyAdaptiveData(v1); - bool checkMinMax = MinVal != MaxVal; - if(step < 0 || step > data1->getNumTimeSteps() - 1){ + int step = (thisStep < 0) ? 0 : thisStep; + if(thisStep > data1->getNumTimeSteps() - 1){ Msg::Error("Invalid time step (%d) in View[%d]: using first step instead", - step, v1->getIndex()); + thisStep, v1->getIndex()); step = 0; } @@ -72,41 +73,59 @@ PView *GMSH_ExtractElementsPlugin::execute(PView *v) if(visible && data1->skipEntity(step, ent)) continue; for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){ if(data1->skipElement(step, ent, ele, visible)) continue; + + int dim = data1->getDimension(step, ent, ele); + if((dimension>0) && (dim!=dimension)) continue; + int numNodes = data1->getNumNodes(step, ent, ele); if(checkMinMax){ - double d = 0.; - for(int nod = 0; nod < numNodes; nod++){ - double val; - data1->getScalarValue(step, ent, ele, nod, val); - d += val; - } - d /= (double)numNodes; - // use '>=' and '<' so that we can do segmentation without - // worrying about roundoff errors - if(d < MinVal || d >= MaxVal) continue; + double d = 0.; + for(int nod = 0; nod < numNodes; nod++){ + double val; + data1->getScalarValue(step, ent, ele, nod, val); + d += val; + } + d /= (double)numNodes; + // use '>=' and '<' so that we can do segmentation without + // worrying about roundoff errors + if(d < MinVal || d >= MaxVal) continue; } + int type = data1->getType(step, ent, ele); int numComp = data1->getNumComponents(step, ent, ele); std::vector<double> *out = data2->incrementList(numComp, type, numNodes); std::vector<double> x(numNodes), y(numNodes), z(numNodes); std::vector<double> v(numNodes * numComp); - for(int nod = 0; nod < numNodes; nod++){ - data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]); - for(int comp = 0; comp < numComp; comp++) - data1->getValue(step, ent, ele, nod, comp, v[numComp * nod + comp]); - } + for(int nod = 0; nod < numNodes; nod++) + data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]); for(int nod = 0; nod < numNodes; nod++) out->push_back(x[nod]); for(int nod = 0; nod < numNodes; nod++) out->push_back(y[nod]); for(int nod = 0; nod < numNodes; nod++) out->push_back(z[nod]); - for(int nod = 0; nod < numNodes; nod++) { - for(int comp = 0; comp < numComp; comp++) { - out->push_back(v[numComp * nod + comp]); - } + + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + if(!data1->hasTimeStep(step)) continue; + if ((thisStep>=0) && (thisStep!=step)) continue; + + for(int nod = 0; nod < numNodes; nod++){ + for(int comp = 0; comp < numComp; comp++){ + double temp; + data1->getValue(step, ent, ele, nod, comp, temp); + out->push_back(temp); + } + } } } } + + + if(thisStep>=0) + data2->Time.push_back(data1->getTime(thisStep)); + else{ + for(int step = 0; step < data1->getNumTimeSteps(); step++){ + data2->Time.push_back(data1->getTime(step)); + } + } - data2->Time.push_back(data1->getTime(step)); data2->setName(data1->getName() + "_ExtractElements"); data2->setFileName(data1->getName() + "_ExtractElements.pos"); data2->finalize(); diff --git a/Plugin/Integrate.cpp b/Plugin/Integrate.cpp index afc4750ed79021b2de71ef6659643acb4bd72196..17491eae4d350fcbaaf4d47f4395e8f373ca0aa6 100644 --- a/Plugin/Integrate.cpp +++ b/Plugin/Integrate.cpp @@ -30,7 +30,6 @@ std::string GMSH_IntegratePlugin::getHelp() const "the circulation/flux of the field over " "line/surface elements is calculated.\n\n" "If `View' < 0, the plugin is run on the current view.\n\n" - "Plugin(Integrate) creates one new view." "If `OverTime' = 1 , the plugin integrates the scalar view " "over time instead of over space.\n\n" "Plugin(Integrate) creates one new view."; @@ -129,6 +128,9 @@ PView *GMSH_IntegratePlugin::execute(PView * v) for(int ent = 0; ent < data1->getNumEntities(timeBeg); ent++){ for(int ele = 0; ele < data1->getNumElements(timeBeg, ent); ele++){ if(data1->skipElement(timeBeg, ent, ele)) continue; + int dim = data1->getDimension(timeBeg, ent, ele); + if((dimension>0) && (dim!=dimension)) continue; + int numNodes = data1->getNumNodes(timeBeg, ent, ele); int type = data1->getType(timeBeg, ent, ele); int numComp = data1->getNumComponents(timeBeg, ent, ele);