[Gmsh] adaptive meshing: using PView

Max Orok morok at mevex.com
Sun Nov 17 19:06:12 CET 2019


Hi Walter,

My first impression is that it looks like you might indeed be setting the
mesh field value using the mesh coordinates.

It's a little difficult to debug without an actual runnable program or the
pos file that shows everything is OK.
Would you mind sharing your program and pos file?

Sincerely,
Max

On Sun, Nov 17, 2019 at 4:49 AM walter steffe <walter.steffe at alice.it>
wrote:

>
> Hello everyone, I am still experimenting with adaptive meshing and I
> wanted to set a background field based on a PView.
> I have build the view and related background field with the following code:
>
>
>  //sf_ele, and getKeysValues are the same as in
> gmsh-4.4.1-source/demos/api/adapt_mesh.cpp
>   getKeysValues(sf_ele, keys, values);
>
>
>   int viewTag = gmsh::view::add("mesh size");
>
>   const std::vector<double> listdata;
>   int nelem=keys.size();
>   for(int i=0; i<nelem ; i++){
>     int etag=keys[i];
>     for(int j=0; j<mesh.elements()[etag]->nodesNum(); j++)
> listdata.push_back(mesh.elements()[etag]->nodes()[j]->x());
>     for(int j=0; j<mesh.elements()[etag]->nodesNum(); j++)
> listdata.push_back(mesh.elements()[etag]->nodes()[j]->y());
>     for(int j=0; j<mesh.elements()[etag]->nodesNum(); j++)
> listdata.push_back(mesh.elements()[etag]->nodes()[j]->z());
>     listdata.insert(listdata.end(),values[i].begin(),values[i].end());
>   }
>   gmsh::view::addListData(viewTag, "SS", nelem, listdata);
>
>
>   // just to check the data:
>   gmsh::view::write(viewTag, "data.pos");
>   // It seems OK
>
>   ...
>
>   GModel *gm0=new GModel();
>   #importing of OCC geometry ...
>
>   ...
>
>
>   FieldManager *fields = gm->getFields();
>   int fieldTag=1;
>   Field *size_f=fields->newField(fieldTag, "PostView");
>   size_f->options["ViewTag"]->numericalValue(viewTag);
>   fields->setBackgroundFieldId(fieldTag);
>
>
>   gm->mesh(1);
>   gm->mesh(2);
>   gm->mesh(3);
>
>
>   The problem is that the field computed in BGM_MeshSize is WRONG.
>
>   Following lines are taken from BackgroundMeshTools.cpp:
>
>   double BGM_MeshSize(GEntity *ge, double U, double V, double X, double Y,
>                     double Z)
> {
>   ....
>   // lc from fields
>   double l4 = MAX_LC;
>   if(ge){
>     FieldManager *fields = ge->model()->getFields();
>     if(fields->getBackgroundField() > 0) {
>       Field *f = fields->get(fields->getBackgroundField());
>       if(f) l4 = (*f)(X, Y, Z, ge);
>     }
>   }
>
>   ..
> }
>
>
>   I have debugged the code going inside of that computation and I have
> found that, quite often, it happens that
>   the value returned by (*f)(X, Y, Z, ge) coincides with the coordinate
> (x,y,or z) of a vertex used in the view data.
>
>   This could be produced by a wrong ordering of data passed to
> gmsh::view::addListData.
>   But the data file printed by gmsh::view::write(viewTag, "data.pos")
> seems good and the values are not exchanged with
>   the coordinates.
>
>   So I do not understand where is the problem. May you please give me a
> hint ?
>
>
>   Thanks in advance,
>   Walter Steffè
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh
>


-- 
Max Orok
Contractor
www.mevex.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20191117/34061063/attachment.html>


More information about the gmsh mailing list