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

small generalization: we can now interpolate data from abritrary
views (and not only from views having the same data type as the
destination)

I use this to interpolate (combination of) components of a field
in one mesh onto another mesh, for example a set of isosurfaces
from another field. Wicked cool! ;-)
parent c3115af4
Branches
Tags
No related merge requests found
// $Id: Evaluate.cpp,v 1.17 2005-03-02 07:49:41 geuzaine Exp $ // $Id: Evaluate.cpp,v 1.18 2005-03-03 21:31:59 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -93,11 +93,10 @@ void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright, ...@@ -93,11 +93,10 @@ void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright,
"\n" "\n"
"- the symbol w, to retrieve the `Component'-th\n" "- the symbol w, to retrieve the `Component'-th\n"
"component of the field in `ExternalView' at the\n" "component of the field in `ExternalView' at the\n"
"`ExternalTimeStep'-th time step. `ExternalView'\n" "`ExternalTimeStep'-th time step. if `ExternalView'\n"
"and `iView' must be of the same type (scalar,\n" "and `iView' are based on different spatial grids,\n"
"vector or tensor); if `ExternalView' and `iView'\n" "or if their data types are different, `ExternalView'\n"
"are not based on the same spatial grid,\n" "is interpolated onto `iView';\n"
"`ExternalView' is interpolated onto `iView';\n"
"\n" "\n"
"- the symbols w0, w1, w2, ..., w8, to retrieve each\n" "- the symbols w0, w1, w2, ..., w8, to retrieve each\n"
"component of the field in `ExternalView' at the\n" "component of the field in `ExternalView' at the\n"
...@@ -177,28 +176,35 @@ void GMSH_EvaluatePlugin::evaluate(Post_View *v1, List_T *list1, int nbElm1, ...@@ -177,28 +176,35 @@ void GMSH_EvaluatePlugin::evaluate(Post_View *v1, List_T *list1, int nbElm1,
double *y = (double *)List_Pointer_Fast(list1, i + nbNod); double *y = (double *)List_Pointer_Fast(list1, i + nbNod);
double *z = (double *)List_Pointer_Fast(list1, i + 2 * nbNod); double *z = (double *)List_Pointer_Fast(list1, i + 2 * nbNod);
for(int j = 0; j < nbNod; j++) { for(int j = 0; j < nbNod; j++) {
// store data from the main view into v
double v[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.};
double *val1 = (double *)List_Pointer_Fast(list1, double *val1 = (double *)List_Pointer_Fast(list1,
i + 3 * nbNod + i + 3 * nbNod +
nbNod * nbComp * timeStep1 + nbComp * j); nbNod * nbComp * timeStep1 + nbComp * j);
for(int k = 0; k < nbComp; k++) v[k] = val1[k];
// store data from the external view into w
double *val2, tmp[9], sizeElm; double *val2, tmp[9], sizeElm;
double w[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.};
if(_octree){ if(_octree){
val2 = tmp; val2 = tmp;
if(nbComp == 1) if(_octree->searchScalar(x[j], y[j], z[j], val2, timeStep2)){
_octree->searchScalar(x[j], y[j], z[j], val2, timeStep2); w[0] = val2[0];
else if(nbComp == 3) }
_octree->searchVector(x[j], y[j], z[j], val2, &sizeElm, timeStep2); else if(_octree->searchVector(x[j], y[j], z[j], val2, &sizeElm, timeStep2)){
else for(int k = 0; k < 3; k++) w[k] = val2[k];
_octree->searchTensor(x[j], y[j], z[j], val2, timeStep2); }
else if(_octree->searchTensor(x[j], y[j], z[j], val2, timeStep2)){
for(int k = 0; k < 9; k++) w[k] = val2[k];
}
} }
else else{
val2 = (double *)List_Pointer_Fast(list2, val2 = (double *)List_Pointer_Fast(list2,
i + 3 * nbNod + i + 3 * nbNod +
nbNod * nbComp * timeStep2 + nbComp * j); nbNod * nbComp * timeStep2 + nbComp * j);
for(int k = 0; k < nbComp; k++) w[k] = val2[k];
double v[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}; }
for(int k = 0; k < nbComp; k++) v[k] = val1[k];
double w[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.};
for(int k = 0; k < nbComp; k++) w[k] = val2[k];
double time = *(double*)List_Pointer(v1->Time, timeStep1); double time = *(double*)List_Pointer(v1->Time, timeStep1);
double tstep = timeStep1; double tstep = timeStep1;
char *names[] = { "x", "y", "z", "Time", "TimeStep", char *names[] = { "x", "y", "z", "Time", "TimeStep",
......
...@@ -333,11 +333,10 @@ component of the field in `iView' at the ...@@ -333,11 +333,10 @@ component of the field in `iView' at the
- the symbol w, to retrieve the `Component'-th - the symbol w, to retrieve the `Component'-th
component of the field in `ExternalView' at the component of the field in `ExternalView' at the
`ExternalTimeStep'-th time step. `ExternalView' `ExternalTimeStep'-th time step. if `ExternalView'
and `iView' must be of the same type (scalar, and `iView' are based on different spatial grids,
vector or tensor); if `ExternalView' and `iView' or if their data types are different, `ExternalView'
are not based on the same spatial grid, is interpolated onto `iView';
`ExternalView' is interpolated onto `iView';
- the symbols w0, w1, w2, ..., w8, to retrieve each - the symbols w0, w1, w2, ..., w8, to retrieve each
component of the field in `ExternalView' at the component of the field in `ExternalView' at the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment