Skip to content
Snippets Groups Projects
Commit 94013971 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix plugins with model-based ElementNodeData datasets

parent 7187a751
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ PView *GMSH_LongituteLatitudePlugin::execute(PView *v)
if(!v1) return v;
PViewData *data1 = v1->getData();
if(data1->isNodeData()){
// tag all the nodes with "0" (the default tag)
for(int step = 0; step < data1->getNumTimeSteps(); step++){
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
......@@ -54,6 +55,7 @@ PView *GMSH_LongituteLatitudePlugin::execute(PView *v)
}
}
}
}
double gxmin = 180, gxmax = -180, gymin = 90, gymax = -90;
// transform all "0" nodes
for(int step = 0; step < data1->getNumTimeSteps(); step++){
......@@ -66,7 +68,7 @@ PView *GMSH_LongituteLatitudePlugin::execute(PView *v)
for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
double x, y, z;
int tag = data1->getNode(step, ent, ele, nod, x, y, z);
if(!tag){
if(data1->isNodeData() && tag) continue;
double x2, y2, z2;
z2 = sqrt(x * x + y * y + z * z);
y2 = asin(z / z2);
......@@ -78,7 +80,7 @@ PView *GMSH_LongituteLatitudePlugin::execute(PView *v)
gymin = std::min(y2 * 180 / M_PI, gymin);
gymax = std::max(y2 * 180 / M_PI, gymax);
data1->setNode(step, ent, ele, nod, x2 * 180 / M_PI, y2 * 180 / M_PI, 0);
data1->tagNode(step, ent, ele, nod, 1);
if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
if(nbComp == 3){
for(int i = 0; i < 3; i++)
data1->getValue(step, ent, ele, nod, i, vin[i]);
......@@ -93,7 +95,6 @@ PView *GMSH_LongituteLatitudePlugin::execute(PView *v)
data1->setValue(step, ent, ele, nod, i, vout[i]);
}
}
}
if(xmax - xmin > M_PI){ // periodicity check (broken for continuous views)
for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
double x, y, z;
......
......@@ -157,6 +157,7 @@ PView *GMSH_ModifyComponentPlugin::execute(PView *view)
double time = data1->getTime(step);
int step2 = (otherTimeStep < 0) ? step : otherTimeStep;
if(data1->isNodeData()){
// tag all the nodes with "0" (the default tag)
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
......@@ -165,6 +166,7 @@ PView *GMSH_ModifyComponentPlugin::execute(PView *view)
data1->tagNode(step, ent, ele, nod, 0);
}
}
}
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
......@@ -172,12 +174,14 @@ PView *GMSH_ModifyComponentPlugin::execute(PView *view)
int numComp = data1->getNumComponents(step, ent, ele);
int numComp2 = octree ? 9 : data2->getNumComponents(step2, ent, ele);
int numNodes = data1->getNumNodes(step, ent, ele);
std::vector<int> tag(numNodes);
std::vector<double> x(numNodes), y(numNodes), z(numNodes);
std::vector<int> tag(numNodes, 0.);
if(data1->isNodeData()){
for(int nod = 0; nod < numNodes; nod++)
tag[nod] = data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]);
}
for(int nod = 0; nod < numNodes; nod++){
if(tag[nod]) continue; // node has already been modified
if(data1->isNodeData() && tag[nod]) continue; // node has already been modified
std::vector<double> v(std::max(9, numComp), 0.);
for(int comp = 0; comp < numComp; comp++)
data1->getValue(step, ent, ele, nod, comp, v[comp]);
......@@ -204,7 +208,7 @@ PView *GMSH_ModifyComponentPlugin::execute(PView *view)
for(int i = 0; i < 9; i++) values[16 + i] = w[i];
if(f.eval(values, res))
data1->setValue(step, ent, ele, nod, comp, res[0]);
data1->tagNode(step, ent, ele, nod, 1);
if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
}
}
}
......
......@@ -61,6 +61,7 @@ PView *GMSH_ModulusPhasePlugin::execute(PView *v)
return v1;
}
if(data1->isNodeData()){
// tag all the nodes with "0" (the default tag)
for(int step = 0; step < data1->getNumTimeSteps(); step++){
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
......@@ -71,6 +72,7 @@ PView *GMSH_ModulusPhasePlugin::execute(PView *v)
}
}
}
}
// transform all "0" nodes
for(int ent = 0; ent < data1->getNumEntities(rIndex); ent++){
......@@ -79,7 +81,7 @@ PView *GMSH_ModulusPhasePlugin::execute(PView *v)
for(int nod = 0; nod < data1->getNumNodes(rIndex, ent, ele); nod++){
double x, y, z;
int tag = data1->getNode(rIndex, ent, ele, nod, x, y, z);
if(tag) continue;
if(data1->isNodeData() && tag) continue;
for(int comp = 0; comp < data1->getNumComponents(rIndex, ent, ele); comp++){
double vr, vi;
data1->getValue(rIndex, ent, ele, nod, comp, vr);
......@@ -88,12 +90,14 @@ PView *GMSH_ModulusPhasePlugin::execute(PView *v)
double phase = atan2(vi, vr);
data1->setValue(rIndex, ent, ele, nod, comp, modulus);
data1->setValue(iIndex, ent, ele, nod, comp, phase);
if(data1->isNodeData()){
data1->tagNode(rIndex, ent, ele, nod, 1);
data1->tagNode(iIndex, ent, ele, nod, 1);
}
}
}
}
}
data1->setName(data1->getName() + "_ModulusPhase");
data1->setName(data1->getName() + ".pos");
......
......@@ -74,6 +74,7 @@ PView *GMSH_SphericalRaisePlugin::execute(PView *v)
return v;
}
if(data1->isNodeData()){
// tag all the nodes with "0" (the default tag)
for(int step = 0; step < data1->getNumTimeSteps(); step++){
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
......@@ -84,6 +85,7 @@ PView *GMSH_SphericalRaisePlugin::execute(PView *v)
}
}
}
}
// transform all "0" nodes
for(int step = 0; step < data1->getNumTimeSteps(); step++){
......@@ -93,7 +95,7 @@ PView *GMSH_SphericalRaisePlugin::execute(PView *v)
for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
double x, y, z;
int tag = data1->getNode(step, ent, ele, nod, x, y, z);
if(!tag){
if(data1->isNodeData() && tag) continue;
double r[3], val;
r[0] = x - center[0];
r[1] = y - center[1];
......@@ -105,8 +107,7 @@ PView *GMSH_SphericalRaisePlugin::execute(PView *v)
y += coef * r[1];
z += coef * r[2];
data1->setNode(step, ent, ele, nod, x, y, z);
data1->tagNode(step, ent, ele, nod, 1);
}
if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
}
}
}
......
......@@ -80,6 +80,7 @@ PView *GMSH_TransformPlugin::execute(PView *v)
PViewData *data1 = v1->getData();
if(data1->isNodeData()){
// tag all the nodes with "0" (the default tag)
for(int step = 0; step < data1->getNumTimeSteps(); step++){
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
......@@ -91,6 +92,7 @@ PView *GMSH_TransformPlugin::execute(PView *v)
}
}
}
}
// transform all "0" nodes
for(int step = 0; step < data1->getNumTimeSteps(); step++){
......@@ -100,14 +102,13 @@ PView *GMSH_TransformPlugin::execute(PView *v)
for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++){
double x, y, z;
int tag = data1->getNode(step, ent, ele, nod, x, y, z);
if(!tag){
if(data1->isNodeData() && tag) continue;
double x2, y2, z2;
x2 = mat[0][0] * x + mat[0][1] * y + mat[0][2] * z + mat[0][3];
y2 = mat[1][0] * x + mat[1][1] * y + mat[1][2] * z + mat[1][3];
z2 = mat[2][0] * x + mat[2][1] * y + mat[2][2] * z + mat[2][3];
data1->setNode(step, ent, ele, nod, x2, y2, z2);
data1->tagNode(step, ent, ele, nod, 1);
}
if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
}
}
}
......
......@@ -96,6 +96,7 @@ PView *GMSH_WarpPlugin::execute(PView *v)
}
}
if(data1->isNodeData()){
// tag all the nodes with "0" (the default tag)
for(int step = 0; step < data1->getNumTimeSteps(); step++){
for(int ent = 0; ent < data1->getNumEntities(step); ent++){
......@@ -106,6 +107,7 @@ PView *GMSH_WarpPlugin::execute(PView *v)
}
}
}
}
// transform each "0" node: (x,y,z) += factor * mult * (valx, valy, valz)
for(int step = 0; step < data1->getNumTimeSteps(); step++){
......@@ -115,14 +117,16 @@ PView *GMSH_WarpPlugin::execute(PView *v)
int numNodes = data1->getNumNodes(step, ent, ele);
if(numNodes < 2) continue;
double x[8], y[8], z[8], n[3] = {0., 0., 0.};
int tag[8];
std::vector<int> tag(8, 0);
if(data1->isNodeData()){
for(int nod = 0; nod < numNodes; nod++)
tag[nod] = data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]);
}
int dim = data1->getDimension(step, ent, ele);
if(normals && dim == 2)
normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n);
for(int nod = 0; nod < numNodes; nod++){
if(tag[nod]) continue; // already transformed
if(data1->isNodeData() && tag[nod]) continue; // already transformed
double mult = 1., val[3] = {n[0], n[1], n[2]};
if(normals){
if(dim == 2){
......@@ -139,7 +143,7 @@ PView *GMSH_WarpPlugin::execute(PView *v)
y[nod] += factor * mult * val[1];
z[nod] += factor * mult * val[2];
data1->setNode(step, ent, ele, nod, x[nod], y[nod], z[nod]);
data1->tagNode(step, ent, ele, nod, 1);
if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
}
}
}
......
......@@ -189,6 +189,7 @@ class PViewData {
virtual bool hasPartition(int step, int part){ return false; }
virtual bool hasMultipleMeshes(){ return false; }
virtual bool hasModel(GModel *model, int step=-1){ return false; }
virtual bool isNodeData(){ return false; }
// true if data is given at Gauss points (instead of vertices)
virtual bool useGaussPoints(){ return false; }
......
......@@ -227,6 +227,7 @@ class PViewDataGModel : public PViewData {
bool hasPartition(int step, int part);
bool hasMultipleMeshes();
bool hasModel(GModel *model, int step=-1);
bool isNodeData(){ return _type == NodeData; }
bool useGaussPoints(){ return _type == GaussPointData; }
GModel* getModel(int step){ return _steps[step]->getModel(); }
GEntity *getEntity(int step, int ent);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment