[Gmsh] Problems with Evaluate-plugin

Christophe Geuzaine cag32 at case.edu
Thu Apr 20 14:41:43 CEST 2006


Thomas Jung wrote:
> Hello,
> 
> I am trying to sum up vector fields from different time steps using the 
> Evaluate - plugin. However, apparently I am misunderstanding something.
> 
> 
> I try this: 
> 
> -----------------------------------------
> 
> The file 
> 
> Include "InduktionTest9_Fl.pos";
> 
> View[0].RangeType=3;
> 
> Plugin(Extract).iView=0;
> Plugin(Extract).TimeStep=1;
> Plugin(Extract).Expression0="v0";
> Plugin(Extract).Expression1="v1";
> Plugin(Extract).Expression2="v2";
> Plugin(Extract).Run;
> 
> // fine, View[1] contains the expected field from timestep 1 from View[0]
> // now trying to add values from timestep 2 to field in View[1]
> 
> Plugin(Evaluate).iView=1;
> Plugin(Evaluate).ExternalView=0;
> Plugin(Evaluate).ExternalTimeStep=2;
> Plugin(Evaluate).Component=-1;
> Plugin(Evaluate).Expression="v+w";
> Plugin(Evaluate).Run;
> 
> // gives wrong results (some random-looking vectors)
> 
> -----------------------------------------------------------------------------------
> 
> I have tried a lot of things, but without success.
> 
> Thanks for any hint !
> 


Hi Thomas - indeed, there is an indexing bug in the plugin when the 
external view and the current view don't have the same number of time 
steps. Here is a patch to fix it:


diff -u -r1.25 Evaluate.cpp
--- Plugin/Evaluate.cpp 15 Feb 2006 04:47:35 -0000      1.25
+++ Plugin/Evaluate.cpp 20 Apr 2006 12:31:56 -0000
@@ -171,7 +171,8 @@
    v1->Changed = 1;

    int nb = List_Nbr(list1) / nbElm1;
-  for(int i = 0; i < List_Nbr(list1); i += nb) {
+  int nb2 = nbElm2 ? List_Nbr(list2) / nbElm2 : 0;
+  for(int i = 0, i2 = 0; i < List_Nbr(list1); i += nb, i2 += nb2) {
      double *x = (double *)List_Pointer_Fast(list1, i);
      double *y = (double *)List_Pointer_Fast(list1, i + nbNod);
      double *z = (double *)List_Pointer_Fast(list1, i + 2 * nbNod);
@@ -201,7 +202,7 @@
        }
        else{
         val2 = (double *)List_Pointer_Fast(list2,
-                                          i + 3 * nbNod +
+                                          i2 + 3 * nbNod +
                                            nbNod * nbComp * timeStep2 + 
nbComp * j);
         for(int k = 0; k < nbComp; k++) w[k] = val2[k];
        }


The patch will appear in tomorrow's cvs snapshot.

Thanks for the bug report!

Cheers,

Christophe




> Thomas Jung
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh


-- 
Christophe Geuzaine
Assistant Professor, Case Western Reserve University, Mathematics
http://www.case.edu/artsci/math/geuzaine