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

Generalized Plugin(Extract) so that it can also create tensor views
parent 036f789b
Branches
Tags
No related merge requests found
// $Id: Extract.cpp,v 1.17 2005-01-01 19:35:39 geuzaine Exp $ // $Id: Extract.cpp,v 1.18 2005-03-03 22:06:06 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -39,7 +39,13 @@ StringXNumber ExtractOptions_Number[] = { ...@@ -39,7 +39,13 @@ StringXNumber ExtractOptions_Number[] = {
StringXString ExtractOptions_String[] = { StringXString ExtractOptions_String[] = {
{GMSH_FULLRC, "Expression0", NULL, "v0"}, {GMSH_FULLRC, "Expression0", NULL, "v0"},
{GMSH_FULLRC, "Expression1", NULL, ""}, {GMSH_FULLRC, "Expression1", NULL, ""},
{GMSH_FULLRC, "Expression2", NULL, ""} {GMSH_FULLRC, "Expression2", NULL, ""},
{GMSH_FULLRC, "Expression3", NULL, ""},
{GMSH_FULLRC, "Expression4", NULL, ""},
{GMSH_FULLRC, "Expression5", NULL, ""},
{GMSH_FULLRC, "Expression6", NULL, ""},
{GMSH_FULLRC, "Expression7", NULL, ""},
{GMSH_FULLRC, "Expression8", NULL, ""}
}; };
extern "C" extern "C"
...@@ -66,19 +72,22 @@ void GMSH_ExtractPlugin::getInfos(char *author, char *copyright, char *help_text ...@@ -66,19 +72,22 @@ void GMSH_ExtractPlugin::getInfos(char *author, char *copyright, char *help_text
strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(copyright, "DGR (www.multiphysics.com)");
strcpy(help_text, strcpy(help_text,
"Plugin(Extract) extracts a combination of\n" "Plugin(Extract) extracts a combination of\n"
"components from the view `iView'. If\n" "components from the view `iView'. If only\n"
"`Expression1' or `Expression2' is empty, the\n" "`Expression0' is given (and `Expression1',\n"
"plugin creates a scalar view using\n" "..., `Expression8' are all empty), the plugin\n"
"`Expression0'; otherwise the plugin creates\n" "creates a scalar view. If `Expression0',\n"
"a vector view. In addition to the usual\n" "`Expression1' and/or `Expression2' are given\n"
"mathematical functions (Exp, Log, Sqrt, Sin,\n" "(and `Expression3', ..., `Expression8' are all\n"
"Cos, Fabs, etc.) and operators (+, -, *, /, ^),\n" "empty) the plugin creates a vector view.\n"
"the expressions can contain the symbols v0,\n" "Otherwise the plugin creates a tensor view.\n"
"v1, v2, ..., vn, which represent the n\n" "In addition to the usual mathematical functions\n"
"components of the field, and the symbols x, y\n" "(Exp, Log, Sqrt, Sin, Cos, Fabs, etc.) and\n"
"and z, which represent the three spatial\n" "operators (+, -, *, /, ^), all expressions\n"
"coordinates. If `iView' < 0, the plugin is\n" "can contain the symbols v0, v1, v2, ..., vn,\n"
"run on the current view.\n" "which represent the n components of the field,\n"
"and the symbols x, y and z, which represent\n"
"the three spatial coordinates. If `iView' < 0,\n"
"the plugin is run on the current view.\n"
"\n" "\n"
"Plugin(Extract) creates one new view.\n"); "Plugin(Extract) creates one new view.\n");
} }
...@@ -108,9 +117,10 @@ void GMSH_ExtractPlugin::catchErrorMessage(char *errorMessage) const ...@@ -108,9 +117,10 @@ void GMSH_ExtractPlugin::catchErrorMessage(char *errorMessage) const
strcpy(errorMessage, "Extract failed..."); strcpy(errorMessage, "Extract failed...");
} }
static void extract(char *expr[3], List_T *inList, int inNb, static void extract(char *expr[9], List_T *inList, int inNb,
List_T *outListScalar, int *outNbScalar, List_T *outListScalar, int *outNbScalar,
List_T *outListVector, int *outNbVector, List_T *outListVector, int *outNbVector,
List_T *outListTensor, int *outNbTensor,
int nbTime, int nbNod, int nbComp) int nbTime, int nbNod, int nbComp)
{ {
if(!inNb) if(!inNb)
...@@ -119,22 +129,32 @@ static void extract(char *expr[3], List_T *inList, int inNb, ...@@ -119,22 +129,32 @@ static void extract(char *expr[3], List_T *inList, int inNb,
int outNbComp, *outNb; int outNbComp, *outNb;
List_T *outList; List_T *outList;
if(!strlen(expr[1]) || !strlen(expr[2])){ if(strlen(expr[3]) || strlen(expr[4]) || strlen(expr[5]) ||
outNbComp = 1; strlen(expr[6]) || strlen(expr[7]) || strlen(expr[8])){
outNb = outNbScalar; outNbComp = 9;
outList = outListScalar; outNb = outNbTensor;
outList = outListTensor;
for(int i = 0; i < 9; i++)
if(!strlen(expr[i])) expr[i] = "0";
} }
else{ else if(strlen(expr[1]) || strlen(expr[2])){
outNbComp = 3; outNbComp = 3;
outNb = outNbVector; outNb = outNbVector;
outList = outListVector; outList = outListVector;
for(int i = 0; i < 3; i++)
if(!strlen(expr[i])) expr[i] = "0";
}
else{
outNbComp = 1;
outNb = outNbScalar;
outList = outListScalar;
} }
// if we have MathEval, we can evaluate arbitrary expressions; // if we have MathEval, we can evaluate arbitrary expressions;
// otherwise, we only allow to extract single components // otherwise, we only allow to extract single components
#if defined(HAVE_MATH_EVAL) #if defined(HAVE_MATH_EVAL)
void *f[3] = { NULL, NULL, NULL }; void *f[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
for(int i = 0; i < outNbComp; i++){ for(int i = 0; i < outNbComp; i++){
f[i] = evaluator_create(expr[i]); f[i] = evaluator_create(expr[i]);
if(!f[i]){ if(!f[i]){
...@@ -145,7 +165,7 @@ static void extract(char *expr[3], List_T *inList, int inNb, ...@@ -145,7 +165,7 @@ static void extract(char *expr[3], List_T *inList, int inNb,
} }
} }
#else #else
int comp[3] = { 0, 0, 0 }; int comp[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for(int i = 0; i < outNbComp; i++){ for(int i = 0; i < outNbComp; i++){
if (!strcmp(expr[i], "v0")) comp[i] = 0; if (!strcmp(expr[i], "v0")) comp[i] = 0;
else if(!strcmp(expr[i], "v1")) comp[i] = 1; else if(!strcmp(expr[i], "v1")) comp[i] = 1;
...@@ -202,9 +222,15 @@ static void extract(char *expr[3], List_T *inList, int inNb, ...@@ -202,9 +222,15 @@ static void extract(char *expr[3], List_T *inList, int inNb,
Post_View *GMSH_ExtractPlugin::execute(Post_View * v) Post_View *GMSH_ExtractPlugin::execute(Post_View * v)
{ {
int iView = (int)ExtractOptions_Number[0].def; int iView = (int)ExtractOptions_Number[0].def;
char *expr[3] = { ExtractOptions_String[0].def, char *expr[9] = { ExtractOptions_String[0].def,
ExtractOptions_String[1].def, ExtractOptions_String[1].def,
ExtractOptions_String[2].def }; ExtractOptions_String[2].def,
ExtractOptions_String[3].def,
ExtractOptions_String[4].def,
ExtractOptions_String[5].def,
ExtractOptions_String[6].def,
ExtractOptions_String[7].def,
ExtractOptions_String[8].def };
if(iView < 0) if(iView < 0)
iView = v ? v->Index : 0; iView = v ? v->Index : 0;
...@@ -218,37 +244,61 @@ Post_View *GMSH_ExtractPlugin::execute(Post_View * v) ...@@ -218,37 +244,61 @@ Post_View *GMSH_ExtractPlugin::execute(Post_View * v)
Post_View *v2 = BeginView(1); Post_View *v2 = BeginView(1);
// points // points
extract(expr, v1->SP, v1->NbSP, v2->SP, &v2->NbSP, v2->VP, &v2->NbVP, v1->NbTimeStep, 1, 1); extract(expr, v1->SP, v1->NbSP, v2->SP, &v2->NbSP, v2->VP, &v2->NbVP, v2->TP, &v2->NbTP,
extract(expr, v1->VP, v1->NbVP, v2->SP, &v2->NbSP, v2->VP, &v2->NbVP, v1->NbTimeStep, 1, 3); v1->NbTimeStep, 1, 1);
extract(expr, v1->TP, v1->NbTP, v2->SP, &v2->NbSP, v2->VP, &v2->NbVP, v1->NbTimeStep, 1, 9); extract(expr, v1->VP, v1->NbVP, v2->SP, &v2->NbSP, v2->VP, &v2->NbVP, v2->TP, &v2->NbTP,
v1->NbTimeStep, 1, 3);
extract(expr, v1->TP, v1->NbTP, v2->SP, &v2->NbSP, v2->VP, &v2->NbVP, v2->TP, &v2->NbTP,
v1->NbTimeStep, 1, 9);
// lines // lines
extract(expr, v1->SL, v1->NbSL, v2->SL, &v2->NbSL, v2->VL, &v2->NbVL, v1->NbTimeStep, 2, 1); extract(expr, v1->SL, v1->NbSL, v2->SL, &v2->NbSL, v2->VL, &v2->NbVL, v2->TL, &v2->NbTL,
extract(expr, v1->VL, v1->NbVL, v2->SL, &v2->NbSL, v2->VL, &v2->NbVL, v1->NbTimeStep, 2, 3); v1->NbTimeStep, 2, 1);
extract(expr, v1->TL, v1->NbTL, v2->SL, &v2->NbSL, v2->VL, &v2->NbVL, v1->NbTimeStep, 2, 9); extract(expr, v1->VL, v1->NbVL, v2->SL, &v2->NbSL, v2->VL, &v2->NbVL, v2->TL, &v2->NbTL,
v1->NbTimeStep, 2, 3);
extract(expr, v1->TL, v1->NbTL, v2->SL, &v2->NbSL, v2->VL, &v2->NbVL, v2->TL, &v2->NbTL,
v1->NbTimeStep, 2, 9);
// triangles // triangles
extract(expr, v1->ST, v1->NbST, v2->ST, &v2->NbST, v2->VT, &v2->NbVT, v1->NbTimeStep, 3, 1); extract(expr, v1->ST, v1->NbST, v2->ST, &v2->NbST, v2->VT, &v2->NbVT, v2->TT, &v2->NbTT,
extract(expr, v1->VT, v1->NbVT, v2->ST, &v2->NbST, v2->VT, &v2->NbVT, v1->NbTimeStep, 3, 3); v1->NbTimeStep, 3, 1);
extract(expr, v1->TT, v1->NbTT, v2->ST, &v2->NbST, v2->VT, &v2->NbVT, v1->NbTimeStep, 3, 9); extract(expr, v1->VT, v1->NbVT, v2->ST, &v2->NbST, v2->VT, &v2->NbVT, v2->TT, &v2->NbTT,
v1->NbTimeStep, 3, 3);
extract(expr, v1->TT, v1->NbTT, v2->ST, &v2->NbST, v2->VT, &v2->NbVT, v2->TT, &v2->NbTT,
v1->NbTimeStep, 3, 9);
// quadrangles // quadrangles
extract(expr, v1->SQ, v1->NbSQ, v2->SQ, &v2->NbSQ, v2->VQ, &v2->NbVQ, v1->NbTimeStep, 4, 1); extract(expr, v1->SQ, v1->NbSQ, v2->SQ, &v2->NbSQ, v2->VQ, &v2->NbVQ, v2->TQ, &v2->NbTQ,
extract(expr, v1->VQ, v1->NbVQ, v2->SQ, &v2->NbSQ, v2->VQ, &v2->NbVQ, v1->NbTimeStep, 4, 3); v1->NbTimeStep, 4, 1);
extract(expr, v1->TQ, v1->NbTQ, v2->SQ, &v2->NbSQ, v2->VQ, &v2->NbVQ, v1->NbTimeStep, 4, 9); extract(expr, v1->VQ, v1->NbVQ, v2->SQ, &v2->NbSQ, v2->VQ, &v2->NbVQ, v2->TQ, &v2->NbTQ,
v1->NbTimeStep, 4, 3);
extract(expr, v1->TQ, v1->NbTQ, v2->SQ, &v2->NbSQ, v2->VQ, &v2->NbVQ, v2->TQ, &v2->NbTQ,
v1->NbTimeStep, 4, 9);
// tets // tets
extract(expr, v1->SS, v1->NbSS, v2->SS, &v2->NbSS, v2->VS, &v2->NbVS, v1->NbTimeStep, 4, 1); extract(expr, v1->SS, v1->NbSS, v2->SS, &v2->NbSS, v2->VS, &v2->NbVS, v2->TS, &v2->NbTS,
extract(expr, v1->VS, v1->NbVS, v2->SS, &v2->NbSS, v2->VS, &v2->NbVS, v1->NbTimeStep, 4, 3); v1->NbTimeStep, 4, 1);
extract(expr, v1->TS, v1->NbTS, v2->SS, &v2->NbSS, v2->VS, &v2->NbVS, v1->NbTimeStep, 4, 9); extract(expr, v1->VS, v1->NbVS, v2->SS, &v2->NbSS, v2->VS, &v2->NbVS, v2->TS, &v2->NbTS,
v1->NbTimeStep, 4, 3);
extract(expr, v1->TS, v1->NbTS, v2->SS, &v2->NbSS, v2->VS, &v2->NbVS, v2->TS, &v2->NbTS,
v1->NbTimeStep, 4, 9);
// hexas // hexas
extract(expr, v1->SH, v1->NbSH, v2->SH, &v2->NbSH, v2->VH, &v2->NbVH, v1->NbTimeStep, 8, 1); extract(expr, v1->SH, v1->NbSH, v2->SH, &v2->NbSH, v2->VH, &v2->NbVH, v2->TH, &v2->NbTH,
extract(expr, v1->VH, v1->NbVH, v2->SH, &v2->NbSH, v2->VH, &v2->NbVH, v1->NbTimeStep, 8, 3); v1->NbTimeStep, 8, 1);
extract(expr, v1->TH, v1->NbTH, v2->SH, &v2->NbSH, v2->VH, &v2->NbVH, v1->NbTimeStep, 8, 9); extract(expr, v1->VH, v1->NbVH, v2->SH, &v2->NbSH, v2->VH, &v2->NbVH, v2->TH, &v2->NbTH,
v1->NbTimeStep, 8, 3);
extract(expr, v1->TH, v1->NbTH, v2->SH, &v2->NbSH, v2->VH, &v2->NbVH, v2->TH, &v2->NbTH,
v1->NbTimeStep, 8, 9);
// prisms // prisms
extract(expr, v1->SI, v1->NbSI, v2->SI, &v2->NbSI, v2->VI, &v2->NbVI, v1->NbTimeStep, 6, 1); extract(expr, v1->SI, v1->NbSI, v2->SI, &v2->NbSI, v2->VI, &v2->NbVI, v2->TI, &v2->NbTI,
extract(expr, v1->VI, v1->NbVI, v2->SI, &v2->NbSI, v2->VI, &v2->NbVI, v1->NbTimeStep, 6, 3); v1->NbTimeStep, 6, 1);
extract(expr, v1->TI, v1->NbTI, v2->SI, &v2->NbSI, v2->VI, &v2->NbVI, v1->NbTimeStep, 6, 9); extract(expr, v1->VI, v1->NbVI, v2->SI, &v2->NbSI, v2->VI, &v2->NbVI, v2->TI, &v2->NbTI,
v1->NbTimeStep, 6, 3);
extract(expr, v1->TI, v1->NbTI, v2->SI, &v2->NbSI, v2->VI, &v2->NbVI, v2->TI, &v2->NbTI,
v1->NbTimeStep, 6, 9);
// pyramids // pyramids
extract(expr, v1->SY, v1->NbSY, v2->SY, &v2->NbSY, v2->VY, &v2->NbVY, v1->NbTimeStep, 5, 1); extract(expr, v1->SY, v1->NbSY, v2->SY, &v2->NbSY, v2->VY, &v2->NbVY, v2->TY, &v2->NbTY,
extract(expr, v1->VY, v1->NbVY, v2->SY, &v2->NbSY, v2->VY, &v2->NbVY, v1->NbTimeStep, 5, 3); v1->NbTimeStep, 5, 1);
extract(expr, v1->TY, v1->NbTY, v2->SY, &v2->NbSY, v2->VY, &v2->NbVY, v1->NbTimeStep, 5, 9); extract(expr, v1->VY, v1->NbVY, v2->SY, &v2->NbSY, v2->VY, &v2->NbVY, v2->TY, &v2->NbTY,
v1->NbTimeStep, 5, 3);
extract(expr, v1->TY, v1->NbTY, v2->SY, &v2->NbSY, v2->VY, &v2->NbVY, v2->TY, &v2->NbTY,
v1->NbTimeStep, 5, 9);
// copy time data // copy time data
for(int i = 0; i < List_Nbr(v1->Time); i++) for(int i = 0; i < List_Nbr(v1->Time); i++)
......
$Id: VERSIONS,v 1.312 2005-03-03 15:07:29 geuzaine Exp $ $Id: VERSIONS,v 1.313 2005-03-03 22:06:06 geuzaine Exp $
New since 1.59: added support for discrete curves; new Window menu on New since 1.59: added support for discrete curves; new Window menu on
Mac OS X; generalized all octree-based plugins (CutGrid, StreamLines, Mac OS X; generalized all octree-based plugins (CutGrid, StreamLines,
Probe, etc.) to handle all element types (and not only scalar and Probe, etc.) to handle all element types (and not only scalar and
vector triangles+tetrahedra); fixed various small bugs. vector triangles+tetrahedra); generalized Plugin(Evaluate) and
Plugin(Extract); fixed various small bugs.
New in 1.59: added support for discrete (triangulated) surfaces, New in 1.59: added support for discrete (triangulated) surfaces,
either in STL format or with the new "Discrete Surface" command; added either in STL format or with the new "Discrete Surface" command; added
......
...@@ -376,19 +376,22 @@ Default value: @code{-1} ...@@ -376,19 +376,22 @@ Default value: @code{-1}
@item Plugin(Extract) @item Plugin(Extract)
Plugin(Extract) extracts a combination of Plugin(Extract) extracts a combination of
components from the view `iView'. If components from the view `iView'. If only
`Expression1' or `Expression2' is empty, the `Expression0' is given (and `Expression1',
plugin creates a scalar view using ..., `Expression8' are all empty), the plugin
`Expression0'; otherwise the plugin creates creates a scalar view. If `Expression0',
a vector view. In addition to the usual `Expression1' and/or `Expression2' are given
mathematical functions (Exp, Log, Sqrt, Sin, (and `Expression3', ..., `Expression8' are all
Cos, Fabs, etc.) and operators (+, -, *, /, ^), empty) the plugin creates a vector view.
the expressions can contain the symbols v0, Otherwise the plugin creates a tensor view.
v1, v2, ..., vn, which represent the n In addition to the usual mathematical functions
components of the field, and the symbols x, y (Exp, Log, Sqrt, Sin, Cos, Fabs, etc.) and
and z, which represent the three spatial operators (+, -, *, /, ^), all expressions
coordinates. If `iView' < 0, the plugin is can contain the symbols v0, v1, v2, ..., vn,
run on the current view. which represent the n components of the field,
and the symbols x, y and z, which represent
the three spatial coordinates. If `iView' < 0,
the plugin is run on the current view.
Plugin(Extract) creates one new view. Plugin(Extract) creates one new view.
...@@ -400,6 +403,18 @@ Default value: @code{"v0"} ...@@ -400,6 +403,18 @@ Default value: @code{"v0"}
Default value: @code{""} Default value: @code{""}
@item Expression2 @item Expression2
Default value: @code{""} Default value: @code{""}
@item Expression3
Default value: @code{""}
@item Expression4
Default value: @code{""}
@item Expression5
Default value: @code{""}
@item Expression6
Default value: @code{""}
@item Expression7
Default value: @code{""}
@item Expression8
Default value: @code{""}
@end table @end table
Numeric options: Numeric options:
@table @code @table @code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment