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

generalized Plugin(Evaluate) to work on any (even non-scalar) views
parent 9bc17d5a
No related branches found
No related tags found
No related merge requests found
// $Id: DecomposeInSimplex.cpp,v 1.9 2004-03-13 21:00:19 geuzaine Exp $ // $Id: DecomposeInSimplex.cpp,v 1.10 2004-05-13 17:48:56 geuzaine Exp $
// //
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -140,7 +140,7 @@ Post_View *GMSH_DecomposeInSimplexPlugin::execute(Post_View * v) ...@@ -140,7 +140,7 @@ Post_View *GMSH_DecomposeInSimplexPlugin::execute(Post_View * v)
// Bail out if the view is a duplicate or if other views duplicate it // Bail out if the view is a duplicate or if other views duplicate it
if(vv->DuplicateOf || vv->Links) { if(vv->DuplicateOf || vv->Links) {
Msg(WARNING, "DecomposeInSimplex cannot be applied to a duplicated view"); Msg(GERROR, "DecomposeInSimplex cannot be applied to a duplicated view");
return 0; return 0;
} }
......
// $Id: DisplacementRaise.cpp,v 1.13 2004-03-13 22:59:03 geuzaine Exp $ // $Id: DisplacementRaise.cpp,v 1.14 2004-05-13 17:48:56 geuzaine Exp $
// //
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -96,7 +96,7 @@ static void displacementRaiseList(Post_View * iView, List_T * iList, int iNbElm, ...@@ -96,7 +96,7 @@ static void displacementRaiseList(Post_View * iView, List_T * iList, int iNbElm,
return; return;
if(iNbElm != dNbElm){ if(iNbElm != dNbElm){
Msg(WARNING, "View[%d] and View[%d] have a different number of elements (%d != %d)", Msg(GERROR, "View[%d] and View[%d] have a different number of elements (%d != %d)",
iView->Index, dView->Index, iNbElm, dNbElm); iView->Index, dView->Index, iNbElm, dNbElm);
return; return;
} }
...@@ -104,9 +104,8 @@ static void displacementRaiseList(Post_View * iView, List_T * iList, int iNbElm, ...@@ -104,9 +104,8 @@ static void displacementRaiseList(Post_View * iView, List_T * iList, int iNbElm,
// should we treat multiple time steps by generating new views // should we treat multiple time steps by generating new views
// (cf. time dependent CutMaps)? // (cf. time dependent CutMaps)?
if(dTimeStep < 0 || dTimeStep > dView->NbTimeStep - 1){ if(dTimeStep < 0 || dTimeStep > dView->NbTimeStep - 1){
Msg(WARNING, "Invalid TimeStep (%d) in View[%d]: choosing TimeStep 0", Msg(GERROR, "Invalid TimeStep (%d) in View[%d]", dTimeStep, dView->Index);
dTimeStep, dView->Index); return;
dTimeStep = 0;
} }
iView->Changed = 1; iView->Changed = 1;
......
// $Id: Evaluate.cpp,v 1.5 2004-05-13 15:54:56 geuzaine Exp $ // $Id: Evaluate.cpp,v 1.6 2004-05-13 17:48:56 geuzaine Exp $
// //
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -34,6 +34,7 @@ extern Context_T CTX; ...@@ -34,6 +34,7 @@ extern Context_T CTX;
StringXNumber EvaluateOptions_Number[] = { StringXNumber EvaluateOptions_Number[] = {
{GMSH_FULLRC, "TimeStep", NULL, 0.}, {GMSH_FULLRC, "TimeStep", NULL, 0.},
{GMSH_FULLRC, "Component", NULL, 0.},
{GMSH_FULLRC, "iView", NULL, -1.} {GMSH_FULLRC, "iView", NULL, -1.}
}; };
...@@ -66,16 +67,17 @@ void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright, ...@@ -66,16 +67,17 @@ void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright,
strcpy(author, "C. Geuzaine (geuz@geuz.org)"); strcpy(author, "C. Geuzaine (geuz@geuz.org)");
strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(copyright, "DGR (www.multiphysics.com)");
strcpy(help_text, strcpy(help_text,
"Plugin(Evaluate) sets the values associated\n" "Plugin(Evaluate) sets the `Component'-th\n"
"with the `TimeStep'-th time step in the scalar\n" "component of the `TimeStep'-th time step\n"
"view `iView' to the expression `Expression'. In\n" "in the view `iView' to the expression\n"
"addition to the usual mathematical functions\n" "`Expression'. In addition to the usual\n"
"(Exp, Log, Sqrt, Sin, Cos, Fabs, etc.) and\n" "mathematical functions (Exp, Log, Sqrt, Sin,\n"
"operators (+, -, *, /, ^), `Expression' can\n" "Cos, Fabs, etc.) and operators (+, -, *, /, ^),\n"
"contain the symbols x, y, z and v, which\n" "`Expression' can contain the symbols x, y, z\n"
"represent the three spatial coordinates and the\n" "and v, which represent the three spatial\n"
"value of the field, respectively. If `iView' < 0,\n" "coordinates and the value of the field,\n"
"the plugin is run on the current view.\n" "respectively. If `iView' < 0, the plugin is run\n"
"on the current view.\n"
"\n" "\n"
"Plugin(Evaluate) is executed in-place.\n"); "Plugin(Evaluate) is executed in-place.\n");
} }
...@@ -105,8 +107,9 @@ void GMSH_EvaluatePlugin::catchErrorMessage(char *errorMessage) const ...@@ -105,8 +107,9 @@ void GMSH_EvaluatePlugin::catchErrorMessage(char *errorMessage) const
strcpy(errorMessage, "Evaluate failed..."); strcpy(errorMessage, "Evaluate failed...");
} }
static void evaluateList(Post_View * v, List_T * list, int nbElm, static void evaluate(Post_View * v, List_T * list, int nbElm,
int nbNod, int timeStep, char *expression) int nbNod, int nbComp, int comp, int timeStep,
char *expression)
{ {
#if !defined(HAVE_MATH_EVAL) #if !defined(HAVE_MATH_EVAL)
...@@ -114,18 +117,17 @@ static void evaluateList(Post_View * v, List_T * list, int nbElm, ...@@ -114,18 +117,17 @@ static void evaluateList(Post_View * v, List_T * list, int nbElm,
#else #else
double *x, *y, *z, *val;
int nb, i, j;
if(!nbElm) if(!nbElm)
return; return;
v->Changed = 1;
if(timeStep < 0 || timeStep > v->NbTimeStep - 1){ if(timeStep < 0 || timeStep > v->NbTimeStep - 1){
Msg(WARNING, "Invalid TimeStep (%d) in View[%d]: choosing TimeStep 0", Msg(GERROR, "Invalid TimeStep (%d) in View[%d]", timeStep, v->Index);
timeStep, v->Index); return;
timeStep = 0; }
if(comp < 0 || comp > nbComp - 1){
Msg(GERROR, "Invalid Component (%d) in View[%d]", comp, v->Index);
return;
} }
void *f = evaluator_create(expression); void *f = evaluator_create(expression);
...@@ -135,27 +137,35 @@ static void evaluateList(Post_View * v, List_T * list, int nbElm, ...@@ -135,27 +137,35 @@ static void evaluateList(Post_View * v, List_T * list, int nbElm,
return; return;
} }
v->Changed = 1;
double min = VAL_INF; double min = VAL_INF;
double max = -VAL_INF; double max = -VAL_INF;
nb = List_Nbr(list) / nbElm; int nb = List_Nbr(list) / nbElm;
for(i = 0; i < List_Nbr(list); i += nb) { for(int i = 0; i < List_Nbr(list); i += nb) {
x = (double *)List_Pointer_Fast(list, i); double *x = (double *)List_Pointer_Fast(list, i);
y = (double *)List_Pointer_Fast(list, i + nbNod); double *y = (double *)List_Pointer_Fast(list, i + nbNod);
z = (double *)List_Pointer_Fast(list, i + 2 * nbNod); double *z = (double *)List_Pointer_Fast(list, i + 2 * nbNod);
val = (double *)List_Pointer_Fast(list, i + 3 * nbNod); for(int j = 0; j < nbNod; j++) {
for(j = 0; j < nbNod; j++) { double *val = (double *)List_Pointer_Fast(list,
i + 3 * nbNod +
nbNod * nbComp * timeStep + nbComp * j);
double xx = x[j]; double xx = x[j];
double yy = y[j]; double yy = y[j];
double zz = z[j]; double zz = z[j];
double vv = val[nbNod * timeStep + j]; double vv = val[comp];
char *names[] = { "x", "y" , "z", "v" }; char *names[] = { "x", "y" , "z", "v" };
double values[] = { xx , yy, zz, vv }; double values[] = { xx , yy, zz, vv };
double res = evaluator_evaluate(f, sizeof(names)/sizeof(names[0]), names, values); double res = evaluator_evaluate(f, sizeof(names)/sizeof(names[0]), names, values);
val[nbNod * timeStep + j] = res; val[comp] = res;
if(nbComp == 3)
res = sqrt(DSQR(val[0]) + DSQR(val[1]) + DSQR(val[2]));
else if(nbComp == 9)
res = ComputeVonMises(val);
if(res < min) min = res; if(res < min) min = res;
if(res > max) max = res; if(res > max) max = res;
} }
...@@ -175,24 +185,13 @@ static void evaluateList(Post_View * v, List_T * list, int nbElm, ...@@ -175,24 +185,13 @@ static void evaluateList(Post_View * v, List_T * list, int nbElm,
#endif #endif
} }
static void evaluate(Post_View * v, int timeStep, char *expression)
{
evaluateList(v, v->SP, v->NbSP, 1, timeStep, expression);
evaluateList(v, v->SL, v->NbSL, 2, timeStep, expression);
evaluateList(v, v->ST, v->NbST, 3, timeStep, expression);
evaluateList(v, v->SQ, v->NbSQ, 4, timeStep, expression);
evaluateList(v, v->SS, v->NbSS, 4, timeStep, expression);
evaluateList(v, v->SH, v->NbSH, 8, timeStep, expression);
evaluateList(v, v->SI, v->NbSI, 6, timeStep, expression);
evaluateList(v, v->SY, v->NbSY, 5, timeStep, expression);
}
Post_View *GMSH_EvaluatePlugin::execute(Post_View * v) Post_View *GMSH_EvaluatePlugin::execute(Post_View * v)
{ {
Post_View *vv; Post_View *vv;
int timeStep = (int)EvaluateOptions_Number[0].def; int timeStep = (int)EvaluateOptions_Number[0].def;
int iView = (int)EvaluateOptions_Number[1].def; int comp = (int)EvaluateOptions_Number[1].def;
int iView = (int)EvaluateOptions_Number[2].def;
char *expr = EvaluateOptions_String[0].def; char *expr = EvaluateOptions_String[0].def;
if(v && iView < 0) if(v && iView < 0)
...@@ -206,7 +205,38 @@ Post_View *GMSH_EvaluatePlugin::execute(Post_View * v) ...@@ -206,7 +205,38 @@ Post_View *GMSH_EvaluatePlugin::execute(Post_View * v)
} }
} }
evaluate(vv, timeStep, expr); evaluate(vv, vv->SP, vv->NbSP, 1, 1, comp, timeStep, expr);
evaluate(vv, vv->VP, vv->NbVP, 1, 3, comp, timeStep, expr);
evaluate(vv, vv->TP, vv->NbTP, 1, 9, comp, timeStep, expr);
evaluate(vv, vv->SL, vv->NbSL, 2, 1, comp, timeStep, expr);
evaluate(vv, vv->VL, vv->NbVL, 2, 3, comp, timeStep, expr);
evaluate(vv, vv->TL, vv->NbTL, 2, 9, comp, timeStep, expr);
evaluate(vv, vv->ST, vv->NbST, 3, 1, comp, timeStep, expr);
evaluate(vv, vv->VT, vv->NbVT, 3, 3, comp, timeStep, expr);
evaluate(vv, vv->TT, vv->NbTT, 3, 9, comp, timeStep, expr);
evaluate(vv, vv->SQ, vv->NbSQ, 4, 1, comp, timeStep, expr);
evaluate(vv, vv->VQ, vv->NbVQ, 4, 3, comp, timeStep, expr);
evaluate(vv, vv->TQ, vv->NbTQ, 4, 9, comp, timeStep, expr);
evaluate(vv, vv->SS, vv->NbSS, 4, 1, comp, timeStep, expr);
evaluate(vv, vv->VS, vv->NbVS, 4, 3, comp, timeStep, expr);
evaluate(vv, vv->TS, vv->NbTS, 4, 9, comp, timeStep, expr);
evaluate(vv, vv->SH, vv->NbSH, 8, 1, comp, timeStep, expr);
evaluate(vv, vv->VH, vv->NbVH, 8, 3, comp, timeStep, expr);
evaluate(vv, vv->TH, vv->NbTH, 8, 9, comp, timeStep, expr);
evaluate(vv, vv->SI, vv->NbSI, 6, 1, comp, timeStep, expr);
evaluate(vv, vv->VI, vv->NbVI, 6, 3, comp, timeStep, expr);
evaluate(vv, vv->TI, vv->NbTI, 6, 9, comp, timeStep, expr);
evaluate(vv, vv->SY, vv->NbSY, 5, 1, comp, timeStep, expr);
evaluate(vv, vv->VY, vv->NbVY, 5, 3, comp, timeStep, expr);
evaluate(vv, vv->TY, vv->NbTY, 5, 9, comp, timeStep, expr);
return vv; return vv;
} }
// $Id: Levelset.cpp,v 1.13 2004-03-13 19:24:12 geuzaine Exp $ // $Id: Levelset.cpp,v 1.14 2004-05-13 17:48:56 geuzaine Exp $
// //
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -231,16 +231,15 @@ void GMSH_LevelsetPlugin::executeList(Post_View * iView, List_T * iList, ...@@ -231,16 +231,15 @@ void GMSH_LevelsetPlugin::executeList(Post_View * iView, List_T * iList,
return; return;
if(iNbElm != dNbElm) { if(iNbElm != dNbElm) {
Msg(WARNING, "View[%d] and View[%d] have a different number of elements (%d != %d)", Msg(GERROR, "View[%d] and View[%d] have a different number of elements (%d != %d)",
iView->Index, dView->Index, iNbElm, dNbElm); iView->Index, dView->Index, iNbElm, dNbElm);
return; return;
} }
int dTimeStep = _valueTimeStep; int dTimeStep = _valueTimeStep;
if(dTimeStep >= dView->NbTimeStep) { if(dTimeStep >= dView->NbTimeStep) {
Msg(WARNING, "Wrong time step %d in View[%d]: reverting to time step 0", Msg(GERROR, "Wrong time step %d in View[%d]", dTimeStep, dView->Index);
dTimeStep, dView->Index); return;
dTimeStep = 0;
} }
int iNb = List_Nbr(iList) / iNbElm; int iNb = List_Nbr(iList) / iNbElm;
......
// $Id: SphericalRaise.cpp,v 1.15 2004-04-24 04:08:39 geuzaine Exp $ // $Id: SphericalRaise.cpp,v 1.16 2004-05-13 17:48:56 geuzaine Exp $
// //
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -101,14 +101,13 @@ static void sphericalRaiseList(Post_View * v, List_T * list, int nbElm, ...@@ -101,14 +101,13 @@ static void sphericalRaiseList(Post_View * v, List_T * list, int nbElm,
if(!nbElm) if(!nbElm)
return; return;
v->Changed = 1;
if(timeStep < 0 || timeStep > v->NbTimeStep - 1){ if(timeStep < 0 || timeStep > v->NbTimeStep - 1){
Msg(WARNING, "Invalid TimeStep (%d) in View[%d]: choosing TimeStep 0", Msg(GERROR, "Invalid TimeStep (%d) in View[%d]", timeStep, v->Index);
timeStep, v->Index); return;
timeStep = 0;
} }
v->Changed = 1;
// for each element // for each element
// for each node // for each node
// compute d=(x-Xc,y-Yc,z-Zc) // compute d=(x-Xc,y-Yc,z-Zc)
......
$Id: VERSIONS,v 1.204 2004-05-13 15:09:45 geuzaine Exp $ $Id: VERSIONS,v 1.205 2004-05-13 17:48:56 geuzaine Exp $
New since 1.52: various background mesh fixes and enhancements; new New since 1.52: various background mesh fixes and enhancements; new
Plugin(Evaluate) to evaluate arbitrary expressions on scalar Plugin(Evaluate) to evaluate arbitrary expressions on post-processing
post-processing views; generalized Plugin(Extract) to handle any views; generalized Plugin(Extract) to handle any combination of
combination of components; generalized "Coherence" to handle components; generalized "Coherence" to handle transfinite
transfinite surface/volume attributes; plugin options can now be set surface/volume attributes; plugin options can now be set in the option
in the option file (like all other options); file (like all other options);
New in 1.52: new raster ("bitmap") PostScript/EPS/PDF output formats; New in 1.52: new raster ("bitmap") PostScript/EPS/PDF output formats;
new Plugin(Extract) to extract a given component from a new Plugin(Extract) to extract a given component from a
......
...@@ -148,16 +148,17 @@ Default value: @code{-1} ...@@ -148,16 +148,17 @@ Default value: @code{-1}
@end table @end table
@item Plugin(Evaluate) @item Plugin(Evaluate)
Plugin(Evaluate) sets the values associated Plugin(Evaluate) sets the `Component'-th
with the `TimeStep'-th time step in the scalar component of the `TimeStep'-th time step
view `iView' to the expression `Expression'. In in the view `iView' to the expression
addition to the usual mathematical functions `Expression'. In addition to the usual
(Exp, Log, Sqrt, Sin, Cos, Fabs, etc.) and mathematical functions (Exp, Log, Sqrt, Sin,
operators (+, -, *, /, ^), `Expression' can Cos, Fabs, etc.) and operators (+, -, *, /, ^),
contain the symbols x, y, z and v, which `Expression' can contain the symbols x, y, z
represent the three spatial coordinates and the and v, which represent the three spatial
value of the field, respectively. If `iView' < 0, coordinates and the value of the field,
the plugin is run on the current view. respectively. If `iView' < 0, the plugin is run
on the current view.
Plugin(Evaluate) is executed in-place. Plugin(Evaluate) is executed in-place.
...@@ -170,6 +171,8 @@ Numeric options: ...@@ -170,6 +171,8 @@ Numeric options:
@table @code @table @code
@item TimeStep @item TimeStep
Default value: @code{0} Default value: @code{0}
@item Component
Default value: @code{0}
@item iView @item iView
Default value: @code{-1} Default value: @code{-1}
@end table @end table
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment