[Gmsh] Reading/writing POS files from C++
walter steffe
walter.steffe at alice.it
Sat Aug 31 11:23:15 CEST 2019
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 ?
Thanks
Walter
More information about the gmsh
mailing list