[Gmsh] Reading/writing POS files from C++

Christophe Geuzaine cgeuzaine at uliege.be
Thu Sep 19 19:49:35 CEST 2019



> On 31 Aug 2019, at 11:23, walter steffe <walter.steffe at alice.it> wrote:
> 
> Hello
> 
> I have started to add the adaptive meshing to my EmCAD code.
> I would like to compute mesh size in an executable and use it in a different executable. 
> So I need a way to export/import the view data related with the mesh size.
> 
> 1) To compute and write the view data I have tried the following code:
> 
>  GModel *gm= ....
> 
>  std::map<std::size_t, double> sf_ele;
>  computeSizeField(mesh, sf_ele);  // computeSizeField is similar to that one in demo/adapt_mesh.cpp
>  std::vector<std::size_t> keys;
>  std::vector<std::vector<double> > values;
>  getKeysValues(sf_ele, keys, values);
>  PViewDataGModel *d=new PViewDataGModel(type);
>  d->addData(gm, keys, values, 0, 0, 0, -1);
>  PView *view = new PView(d,-1);
> 
>  std::string posFileName="xxxx.pos"
>  d->writePOS(posFileName,false,true,false);
> 
> 
> 
> The written file need to be parsed because 
>   "bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed, bool append)"
> do not accepts parsed=false.
> 
> Same situation using "bool PView::write(const std::string &fileName, int format, bool append)"
> 
> 
> 2) To read the pos file I have tried:
> 
>   int status = PView::readPOS(posFileName);
> 
> But the function "bool PView::readPOS(const std::string &fileName, int fileIndex)" 
> can only read a formatted POS file (not a file to be parsed)
> 
> 
> 
> May you please indicate a proper way to write/read PView data using the same format ?

The natural format depends on the underlying type of view: if it's mesh-based (your case), save it as MSH.

(The parsed format reader is coded directly in the lex/yacc parser)

Christophe

> 
> Thanks
> Walter 
> 
> 
> 
> 
> 
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine






More information about the gmsh mailing list