From a5fd349a7c53cae6aebb987353e21a5c30682ff8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 22 Nov 2003 18:45:40 +0000 Subject: [PATCH] The new levelset stuff is too powerful ;-) - don't cut the timestep in the levelset view if the timestep is used to get the field value. I think this makes it less confusing (and matches the behaviour of JF's old 'iField' option). - rename the 'TimeStep' option to 'dTimeStep', also to avoid confusing people about which view the time step refers to. --- Plugin/CutMap.cpp | 13 +++--- Plugin/CutPlane.cpp | 6 +-- Plugin/CutSphere.cpp | 6 +-- Plugin/DisplacementRaise.cpp | 10 ++--- Plugin/Levelset.cpp | 77 ++++++++++++++++++++---------------- Plugin/Levelset.h | 2 +- 6 files changed, 62 insertions(+), 52 deletions(-) diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp index 482f687dd0..b546d7e2b0 100644 --- a/Plugin/CutMap.cpp +++ b/Plugin/CutMap.cpp @@ -1,4 +1,4 @@ -// $Id: CutMap.cpp,v 1.32 2003-11-21 07:56:31 geuzaine Exp $ +// $Id: CutMap.cpp,v 1.33 2003-11-22 18:45:40 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -27,7 +27,7 @@ extern Context_T CTX; StringXNumber CutMapOptions_Number[] = { {GMSH_FULLRC, "A", NULL, 1.}, - {GMSH_FULLRC, "TimeStep", NULL, -1.}, + {GMSH_FULLRC, "dTimeStep", NULL, -1.}, {GMSH_FULLRC, "dView", NULL, -1.}, {GMSH_FULLRC, "iView", NULL, -1.} }; @@ -58,9 +58,9 @@ void GMSH_CutMapPlugin::getInfos(char *author, char *copyright, strcpy(help_text, "Plugin(CutMap) extracts the isovalue surface of\n" "value 'A' from the view 'iView' and draws the\n" - "'TimeStep'-th value of the view 'dView' on this\n" + "'dTimeStep'-th value of the view 'dView' on this\n" "isovalue surface. If 'iView' < 0, the plugin is\n" - "run on the current view. If 'TimeStep' < 0, the\n" + "run on the current view. If 'dTimeStep' < 0, the\n" "plugin uses, for each time step in 'iView', the\n" "corresponding time step in 'dView'. If 'dView'\n" "< 0, the plugin uses 'iView' as the field source.\n"); @@ -95,9 +95,10 @@ Post_View *GMSH_CutMapPlugin::execute(Post_View * v) int iView = (int)CutMapOptions_Number[3].def; _valueIndependent = 0; - _targetView = (int)CutMapOptions_Number[2].def; + _valueView = (int)CutMapOptions_Number[2].def; + _valueTimeStep = (int)CutMapOptions_Number[1].def; _orientation = GMSH_LevelsetPlugin::MAP; - _timeStep = (int)CutMapOptions_Number[1].def; + if(v && iView < 0) vv = v; diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index dbc972e225..e3a2eb6a03 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -1,4 +1,4 @@ -// $Id: CutPlane.cpp,v 1.28 2003-11-21 07:56:31 geuzaine Exp $ +// $Id: CutPlane.cpp,v 1.29 2003-11-22 18:45:40 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -95,9 +95,9 @@ Post_View *GMSH_CutPlanePlugin::execute(Post_View * v) _ref[1] = CutPlaneOptions_Number[1].def; _ref[2] = CutPlaneOptions_Number[2].def; _valueIndependent = 1; - _targetView = -1; + _valueView = -1; + _valueTimeStep = -1; _orientation = GMSH_LevelsetPlugin::PLANE; - _timeStep = -1; if(v && iView < 0) vv = v; diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp index c13efb5818..ba748c6b69 100644 --- a/Plugin/CutSphere.cpp +++ b/Plugin/CutSphere.cpp @@ -1,4 +1,4 @@ -// $Id: CutSphere.cpp,v 1.27 2003-11-21 07:56:32 geuzaine Exp $ +// $Id: CutSphere.cpp,v 1.28 2003-11-22 18:45:40 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -99,9 +99,9 @@ Post_View *GMSH_CutSpherePlugin::execute(Post_View * v) _ref[1] = CutSphereOptions_Number[1].def; _ref[2] = CutSphereOptions_Number[2].def; _valueIndependent = 1; - _targetView = -1; + _valueView = -1; + _valueTimeStep = -1; _orientation = GMSH_LevelsetPlugin::SPHERE; - _timeStep = -1; if(v && iView < 0) vv = v; diff --git a/Plugin/DisplacementRaise.cpp b/Plugin/DisplacementRaise.cpp index b220af3f6e..bbed035a51 100644 --- a/Plugin/DisplacementRaise.cpp +++ b/Plugin/DisplacementRaise.cpp @@ -1,4 +1,4 @@ -// $Id: DisplacementRaise.cpp,v 1.8 2003-11-21 07:56:32 geuzaine Exp $ +// $Id: DisplacementRaise.cpp,v 1.9 2003-11-22 18:45:40 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -30,7 +30,7 @@ extern Context_T CTX; StringXNumber DisplacementRaiseOptions_Number[] = { {GMSH_FULLRC, "Factor", NULL, 1.}, - {GMSH_FULLRC, "TimeStep", NULL, 0.}, + {GMSH_FULLRC, "dTimeStep", NULL, 0.}, {GMSH_FULLRC, "dView", NULL, -1.}, {GMSH_FULLRC, "iView", NULL, -1.} }; @@ -63,7 +63,7 @@ void GMSH_DisplacementRaisePlugin::getInfos(char *author, char *copyright, "Plugin(DisplacementRaise) transforms the\n" "coordinates of the elements in the view 'iView'\n" "using the vectorial values (the displacements)\n" - "stored in the 'TimeStep'-th time step of the\n" + "stored in the 'dTimeStep'-th time step of the\n" "view 'dView'. If 'iView' < 0, the plugin is\n" "run on the current view. If 'dView' < 0, the\n" "plugin looks for the displacements in the\n" @@ -164,7 +164,7 @@ Post_View *GMSH_DisplacementRaisePlugin::execute(Post_View * v) Post_View *vv, *ww; double factor = DisplacementRaiseOptions_Number[0].def; - int timeStep = (int)DisplacementRaiseOptions_Number[1].def; + int dTimeStep = (int)DisplacementRaiseOptions_Number[1].def; int dView = (int)DisplacementRaiseOptions_Number[2].def; int iView = (int)DisplacementRaiseOptions_Number[3].def; @@ -187,7 +187,7 @@ Post_View *GMSH_DisplacementRaisePlugin::execute(Post_View * v) return 0; } - displacementRaise(vv, ww, factor, timeStep); + displacementRaise(vv, ww, factor, dTimeStep); return vv; } diff --git a/Plugin/Levelset.cpp b/Plugin/Levelset.cpp index 25e6a3a985..e97cdcf9a4 100644 --- a/Plugin/Levelset.cpp +++ b/Plugin/Levelset.cpp @@ -1,4 +1,4 @@ -// $Id: Levelset.cpp,v 1.4 2003-11-22 05:12:36 geuzaine Exp $ +// $Id: Levelset.cpp,v 1.5 2003-11-22 18:45:40 geuzaine Exp $ // // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // @@ -35,8 +35,8 @@ GMSH_LevelsetPlugin::GMSH_LevelsetPlugin() _invert = 0.; _ref[0] = _ref[1] = _ref[2] = 0.; _valueIndependent = 0; // "moving" levelset - _targetView = -1; // use same view for levelset and field data - _timeStep = -1; // use same time step in levelset and field data views + _valueView = -1; // use same view for levelset and field data + _valueTimeStep = -1; // use same time step in levelset and field data views _orientation = GMSH_LevelsetPlugin::NONE; } @@ -259,13 +259,16 @@ void GMSH_LevelsetPlugin::executeList(Post_View * iView, List_T * iList, if(nbVert == 2 || nbVert == 3 || (nbVert == 4 && nbEdg == 6)) { // easy for simplices: at most one element is created per time step for(int iTS = 0; iTS < iView->NbTimeStep; iTS++) { - int dTS = getTimeStep(_timeStep, iTS, dView); - double *iVal = (double *)List_Pointer_Fast(iList, i + 3 * nbVert + - iNbComp * nbVert * iTS); - double *dVal = (double *)List_Pointer_Fast(dList, j + 3 * nbVert + - dNbComp * nbVert * dTS); - zeroLevelset(iTS, nbVert, nbEdg, exn, x, y, z, - iVal, iNbComp, dVal, dNbComp, out); + int dTS = getTimeStep(_valueTimeStep, iTS, dView); + // don't compute the zero levelset of the value view + if(_valueTimeStep < 0 || iView != dView || dTS != iTS){ + double *iVal = (double *)List_Pointer_Fast(iList, i + 3 * nbVert + + iNbComp * nbVert * iTS); + double *dVal = (double *)List_Pointer_Fast(dList, j + 3 * nbVert + + dNbComp * nbVert * dTS); + zeroLevelset(iTS, nbVert, nbEdg, exn, x, y, z, + iVal, iNbComp, dVal, dNbComp, out); + } } } else{ @@ -290,15 +293,18 @@ void GMSH_LevelsetPlugin::executeList(Post_View * iView, List_T * iList, NULL, 0, out)) { for(int k = 0; k < iDec.numSimplices(); k++) { for(int iTS = 0; iTS < iView->NbTimeStep; iTS++) { - int dTS = getTimeStep(_timeStep, iTS, dView); - double *iVal = (double *)List_Pointer_Fast(iList, i + 3 * nbVert + - iNbComp * nbVert * iTS); - double *dVal = (double *)List_Pointer_Fast(dList, j + 3 * nbVert + - dNbComp * nbVert * dTS); - iDec.decompose(k, x, y, z, iVal, xNew, yNew, zNew, iValNew); - dDec.decompose(k, x, y, z, dVal, xNew, yNew, zNew, dValNew); - zeroLevelset(iTS, nbVertNew, nbEdgNew, (nbVertNew == 4) ? exnTet : exnTri, - xNew, yNew, zNew, iValNew, iNbComp, dValNew, dNbComp, out); + int dTS = getTimeStep(_valueTimeStep, iTS, dView); + // don't compute the zero levelset of the value view + if(_valueTimeStep < 0 || iView != dView || dTS != iTS){ + double *iVal = (double *)List_Pointer_Fast(iList, i + 3 * nbVert + + iNbComp * nbVert * iTS); + double *dVal = (double *)List_Pointer_Fast(dList, j + 3 * nbVert + + dNbComp * nbVert * dTS); + iDec.decompose(k, x, y, z, iVal, xNew, yNew, zNew, iValNew); + dDec.decompose(k, x, y, z, dVal, xNew, yNew, zNew, dValNew); + zeroLevelset(iTS, nbVertNew, nbEdgNew, (nbVertNew == 4) ? exnTet : exnTri, + xNew, yNew, zNew, iValNew, iNbComp, dValNew, dNbComp, out); + } } } } @@ -307,18 +313,21 @@ void GMSH_LevelsetPlugin::executeList(Post_View * iView, List_T * iList, // since we generate one view for each time step, we can // generate multiple elements per time step without problem. for(int iTS = 0; iTS < iView->NbTimeStep; iTS++) { - double *iVal = (double *)List_Pointer_Fast(iList, i + 3 * nbVert + - iNbComp * nbVert * iTS); - if(zeroLevelset(iTS, nbVert, nbEdg, exn, x, y, z, iVal, iNbComp, - NULL, 0, out)) { - int dTS = getTimeStep(_timeStep, iTS, dView); - double *dVal = (double *)List_Pointer_Fast(dList, j + 3 * nbVert + - dNbComp * nbVert * dTS); - for(int k = 0; k < iDec.numSimplices(); k++) { - iDec.decompose(k, x, y, z, iVal, xNew, yNew, zNew, iValNew); - dDec.decompose(k, x, y, z, dVal, xNew, yNew, zNew, dValNew); - zeroLevelset(iTS, nbVertNew, nbEdgNew, (nbVertNew == 4) ? exnTet : exnTri, - xNew, yNew, zNew, iValNew, iNbComp, dValNew, dNbComp, out); + int dTS = getTimeStep(_valueTimeStep, iTS, dView); + // don't compute the zero levelset of the value view + if(_valueTimeStep < 0 || iView != dView || dTS != iTS){ + double *iVal = (double *)List_Pointer_Fast(iList, i + 3 * nbVert + + iNbComp * nbVert * iTS); + if(zeroLevelset(iTS, nbVert, nbEdg, exn, x, y, z, iVal, iNbComp, + NULL, 0, out)) { + double *dVal = (double *)List_Pointer_Fast(dList, j + 3 * nbVert + + dNbComp * nbVert * dTS); + for(int k = 0; k < iDec.numSimplices(); k++) { + iDec.decompose(k, x, y, z, iVal, xNew, yNew, zNew, iValNew); + dDec.decompose(k, x, y, z, dVal, xNew, yNew, zNew, dValNew); + zeroLevelset(iTS, nbVertNew, nbEdgNew, (nbVertNew == 4) ? exnTet : exnTri, + xNew, yNew, zNew, iValNew, iNbComp, dValNew, dNbComp, out); + } } } } @@ -336,11 +345,11 @@ Post_View *GMSH_LevelsetPlugin::execute(Post_View * v) Post_View *w; vector<Post_View *> out; - if(_targetView < 0) { + if(_valueView < 0) { w = v; } - else if(!(w = (Post_View *)List_Pointer_Test(CTX.post.list, _targetView))) { - Msg(GERROR, "View[%d] does not exist: reverting to View[%d]", _targetView, + else if(!(w = (Post_View *)List_Pointer_Test(CTX.post.list, _valueView))) { + Msg(GERROR, "View[%d] does not exist: reverting to View[%d]", _valueView, v->Index); w = v; } diff --git a/Plugin/Levelset.h b/Plugin/Levelset.h index 6440629b96..78b805d041 100644 --- a/Plugin/Levelset.h +++ b/Plugin/Levelset.h @@ -31,7 +31,7 @@ public: typedef enum {NONE, PLANE, SPHERE, MAP} ORIENTATION ; protected: double _ref[3]; - int _timeStep, _targetView, _valueIndependent; + int _valueTimeStep, _valueView, _valueIndependent; ORIENTATION _orientation; private: double _invert; -- GitLab