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

adding partition and saveInterpMat option to PVIewData::writeMSH

parent cb538422
No related branches found
No related tags found
No related merge requests found
...@@ -270,7 +270,8 @@ class PViewData { ...@@ -270,7 +270,8 @@ class PViewData {
virtual bool writePOS(const std::string &fileName, bool binary=false, virtual bool writePOS(const std::string &fileName, bool binary=false,
bool parsed=true, bool append=false); bool parsed=true, bool append=false);
virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false, virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false,
bool savemesh=true, bool multipleView=false); bool savemesh=true, bool multipleView=false,
int partitionNum=0, bool saveInterpolationMatrices=true);
virtual bool writeMED(const std::string &fileName); virtual bool writeMED(const std::string &fileName);
virtual bool toVector(std::vector<std::vector<double> > &vec); virtual bool toVector(std::vector<std::vector<double> > &vec);
virtual bool fromVector(const std::vector<std::vector<double> > &vec); virtual bool fromVector(const std::vector<std::vector<double> > &vec);
......
...@@ -250,7 +250,8 @@ class PViewDataGModel : public PViewData { ...@@ -250,7 +250,8 @@ class PViewDataGModel : public PViewData {
double time, int partition, int numComp, int numNodes, double time, int partition, int numComp, int numNodes,
const std::string &interpolationScheme); const std::string &interpolationScheme);
virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false, virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false,
bool savemesh=true, bool multipleView=false); bool savemesh=true, bool multipleView=false,
int partitionNum=0, bool saveInterpolationMatrices=true);
bool readMED(const std::string &fileName, int fileIndex); bool readMED(const std::string &fileName, int fileIndex);
bool writeMED(const std::string &fileName); bool writeMED(const std::string &fileName);
}; };
......
...@@ -133,7 +133,8 @@ bool PViewDataGModel::readMSH(const std::string &viewName, const std::string &fi ...@@ -133,7 +133,8 @@ bool PViewDataGModel::readMSH(const std::string &viewName, const std::string &fi
} }
bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool binary, bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool binary,
bool savemesh, bool multipleView) bool savemesh, bool multipleView, int partitionNum,
bool saveInterpolationMatrices)
{ {
if(_steps.empty()) return true; if(_steps.empty()) return true;
...@@ -181,7 +182,7 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool ...@@ -181,7 +182,7 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool
} }
} }
if(haveInterpolationMatrices()){ if(saveInterpolationMatrices && haveInterpolationMatrices()){
fprintf(fp, "$InterpolationScheme\n"); fprintf(fp, "$InterpolationScheme\n");
fprintf(fp, "\"INTERPOLATION_SCHEME\"\n"); fprintf(fp, "\"INTERPOLATION_SCHEME\"\n");
fprintf(fp, "%d\n", (int)_interpolation.size()); fprintf(fp, "%d\n", (int)_interpolation.size());
...@@ -212,6 +213,9 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool ...@@ -212,6 +213,9 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool
fprintf(fp, "$NodeData\n"); fprintf(fp, "$NodeData\n");
fprintf(fp, "1\n\"%s\"\n", getName().c_str()); fprintf(fp, "1\n\"%s\"\n", getName().c_str());
fprintf(fp, "1\n%.16g\n", _steps[step]->getTime()); fprintf(fp, "1\n%.16g\n", _steps[step]->getTime());
if(partitionNum)
fprintf(fp, "4\n%d\n%d\n%d\n%d\n", step, numComp, numEnt, partitionNum);
else
fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numEnt); fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numEnt);
for(int i = 0; i < _steps[step]->getNumData(); i++){ for(int i = 0; i < _steps[step]->getNumData(); i++){
if(_steps[step]->getData(i)){ if(_steps[step]->getData(i)){
...@@ -242,12 +246,15 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool ...@@ -242,12 +246,15 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool
fprintf(fp, "$ElementNodeData\n"); fprintf(fp, "$ElementNodeData\n");
else else
fprintf(fp, "$ElementData\n"); fprintf(fp, "$ElementData\n");
if(haveInterpolationMatrices()) if(saveInterpolationMatrices && haveInterpolationMatrices())
fprintf(fp, "2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n", getName().c_str()); fprintf(fp, "2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n", getName().c_str());
else else
fprintf(fp, "1\n\"%s\"\n", getName().c_str()); fprintf(fp, "1\n\"%s\"\n", getName().c_str());
fprintf(fp, "1\n%.16g\n", _steps[step]->getTime()); fprintf(fp, "1\n%.16g\n", _steps[step]->getTime());
if(partitionNum)
fprintf(fp, "4\n%d\n%d\n%d\n%d\n", step, numComp, numEnt, partitionNum);
else
fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numEnt); fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numEnt);
for(int i = 0; i < _steps[step]->getNumData(); i++){ for(int i = 0; i < _steps[step]->getNumData(); i++){
if(_steps[step]->getData(i)){ if(_steps[step]->getData(i)){
......
...@@ -179,7 +179,8 @@ bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed, ...@@ -179,7 +179,8 @@ bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed,
} }
bool PViewData::writeMSH(const std::string &fileName, double version, bool binary, bool PViewData::writeMSH(const std::string &fileName, double version, bool binary,
bool savemesh, bool multipleView) bool savemesh, bool multipleView, int partitionNum,
bool saveInterpolationMatrices)
{ {
Msg::Error("MSH export not implemented for this view type"); Msg::Error("MSH export not implemented for this view type");
return false; return false;
......
...@@ -127,7 +127,8 @@ class PViewDataList : public PViewData { ...@@ -127,7 +127,8 @@ class PViewDataList : public PViewData {
bool writePOS(const std::string &fileName, bool binary=false, bool parsed=true, bool writePOS(const std::string &fileName, bool binary=false, bool parsed=true,
bool append=false); bool append=false);
virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false, virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false,
bool savemesh=true, bool multipleView=false); bool savemesh=true, bool multipleView=false,
int partitionNum=0, bool saveInterpolationMatrices=true);
virtual void importLists(int N[24], std::vector<double> *V[24]); virtual void importLists(int N[24], std::vector<double> *V[24]);
virtual void getListPointers(int N[24], std::vector<double> *V[24]); virtual void getListPointers(int N[24], std::vector<double> *V[24]);
}; };
......
...@@ -527,7 +527,8 @@ static void createElements(std::vector<double> &list, int nbelm, int nbnod, ...@@ -527,7 +527,8 @@ static void createElements(std::vector<double> &list, int nbelm, int nbnod,
} }
bool PViewDataList::writeMSH(const std::string &fileName, double version, bool binary, bool PViewDataList::writeMSH(const std::string &fileName, double version, bool binary,
bool savemesh, bool multipleView) bool savemesh, bool multipleView,
int partitionNum, bool saveInterpolationMatrices)
{ {
if(_adaptive){ if(_adaptive){
Msg::Warning("Writing adapted dataset (will only export current time step)"); Msg::Warning("Writing adapted dataset (will only export current time step)");
...@@ -588,7 +589,7 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, bool b ...@@ -588,7 +589,7 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, bool b
} }
fprintf(fp, "$EndElements\n"); fprintf(fp, "$EndElements\n");
if(haveInterpolationMatrices()){ if(saveInterpolationMatrices && haveInterpolationMatrices()){
fprintf(fp, "$InterpolationScheme\n"); fprintf(fp, "$InterpolationScheme\n");
fprintf(fp, "\"INTERPOLATION_SCHEME\"\n"); fprintf(fp, "\"INTERPOLATION_SCHEME\"\n");
fprintf(fp, "%d\n", (int)_interpolation.size()); fprintf(fp, "%d\n", (int)_interpolation.size());
...@@ -612,11 +613,15 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, bool b ...@@ -612,11 +613,15 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, bool b
for(int ts = 0; ts < NbTimeStep; ts++){ for(int ts = 0; ts < NbTimeStep; ts++){
fprintf(fp, "$ElementNodeData\n"); fprintf(fp, "$ElementNodeData\n");
if(haveInterpolationMatrices()) if(saveInterpolationMatrices && haveInterpolationMatrices())
fprintf(fp, "2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n", getName().c_str()); fprintf(fp, "2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n", getName().c_str());
else else
fprintf(fp, "1\n\"%s\"\n", getName().c_str()); fprintf(fp, "1\n\"%s\"\n", getName().c_str());
fprintf(fp, "1\n%.16g\n", getTime(ts)); fprintf(fp, "1\n%.16g\n", getTime(ts));
if(partitionNum)
fprintf(fp, "4\n%d\n%d\n%d\n%d\n", ts, numComponents, (int)elements.size(),
partitionNum);
else
fprintf(fp, "3\n%d\n%d\n%d\n", ts, numComponents, (int)elements.size()); fprintf(fp, "3\n%d\n%d\n%d\n", ts, numComponents, (int)elements.size());
num = 0; num = 0;
for(int i = 0; i < 24; i++){ for(int i = 0; i < 24; i++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment