diff --git a/Geo/GModelIO_MSH.cpp b/Geo/GModelIO_MSH.cpp index 3e949fd2fb63b20c1bc0a7acac77a77777dccb85..00127caa3b62fe2e5c636163c98fd1e79a1fe50d 100644 --- a/Geo/GModelIO_MSH.cpp +++ b/Geo/GModelIO_MSH.cpp @@ -55,7 +55,7 @@ int GModel::readMSH(const std::string &name) } char str[256] = ""; - double version = 2.2; + double version = 0.; bool binary = false, swap = false, postpro = false; int minVertex = 0; std::map<int, std::vector<int> > entities[4]; diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index 02a359fb22c7f0b2ae0cdeae6d7af0eb59f173bc..eb8341bab3e9c7e37b7534b9e4156edfc0dc15fc 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -710,42 +710,45 @@ double MElement::integrateFlux(double val[], int face, int pOrder, int order) return result; } -void MElement::_fillInfoMSH(std::vector<int> &info, int elementary, - std::vector<short> *ghosts) -{ - info.clear(); - info.push_back(0); - info.push_back(elementary); - if(_partition) - info.push_back(_partition); - if(ghosts) - info.insert(info.end(), ghosts->begin(), ghosts->end()); - info[0] = info.size() - 1; - std::vector<int> verts; - getVerticesIdForMSH(verts); - info.insert(info.end(), verts.begin(), verts.end()); -} - void MElement::writeMSH(FILE *fp, bool binary, int elementary, std::vector<short> *ghosts) { + int num = getNum(); int type = getTypeForMSH(); if(!type) return; - std::vector<int> info; - _fillInfoMSH(info, elementary, ghosts); - // if necessary, change the ordering of the vertices to get positive volume setVolumePositive(); + std::vector<int> info; + info.push_back(0); + info.push_back(elementary); + if(getParent()) + info.push_back(getParent()->getNum()); + if(getPartition()){ + if(ghosts){ + info.push_back(1 + ghosts->size()); + info.push_back(getPartition()); + info.insert(info.end(), ghosts->begin(), ghosts->end()); + } + else{ + info.push_back(1); + info.push_back(getPartition()); + } + } + info[0] = info.size() - 1; + std::vector<int> verts; + getVerticesIdForMSH(verts); + info.insert(info.end(), verts.begin(), verts.end()); + if(!binary){ - fprintf(fp, "%d %d", _num, type); + fprintf(fp, "%d %d", num, type); for(unsigned int i = 0; i < info.size(); i++) fprintf(fp, " %d", info[i]); fprintf(fp, "\n"); } else{ - fwrite(&_num, sizeof(int), 1, fp); + fwrite(&num, sizeof(int), 1, fp); fwrite(&type, sizeof(int), 1, fp); fwrite(&info[0], sizeof(int), info.size(), fp); } @@ -1225,10 +1228,10 @@ int MElement::getInfoMSH(const int typeMSH, const char **const name) case MSH_PYR_13 : if(name) *name = "Pyramid 13"; return 5 + 8; case MSH_PYR_14 : if(name) *name = "Pyramid 14"; return 5 + 8 + 1; case MSH_POLYH_ : if(name) *name = "Polyhedron"; return 0; - case MSH_PNT_SUB: if(name) *name = "Point Xfem"; return 1; - case MSH_LIN_SUB: if(name) *name = "Line Xfem"; return 2; - case MSH_TRI_SUB: if(name) *name = "Triangle Xfem"; return 3; - case MSH_TET_SUB: if(name) *name = "Tetrahedron Xfem";return 4; + case MSH_PNT_SUB : if(name) *name = "Point Xfem"; return 1; + case MSH_LIN_SUB : if(name) *name = "Line Xfem"; return 2; + case MSH_TRI_SUB : if(name) *name = "Triangle Xfem"; return 3; + case MSH_TET_SUB : if(name) *name = "Tetrahedron Xfem"; return 4; default: Msg::Error("Unknown type of element %d", typeMSH); if(name) *name = "Unknown"; diff --git a/Geo/MElement.h b/Geo/MElement.h index d1d33ad50cecffefe80033c02250379275b0c1e1..7630b6664d4e0a5a298284b15e630c8fd94abcbf 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -40,10 +40,6 @@ class MElement int faceIndex=-1); void _getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, double *x, double *y, double *z, SVector3 *n); - // fill the vector of integers that will be written after the element number - // and type in writeMSH - virtual void _fillInfoMSH(std::vector<int> &info, int elementary=1, - std::vector<short> *ghosts=0); public : MElement(int num=0, int part=0); virtual ~MElement(){} diff --git a/Geo/MSubElement.cpp b/Geo/MSubElement.cpp index 6dcdf8d79a6ba344dc9cbb179d0623ce0c68168d..7640a3eb068d80bb52e076eafe1390e9b805e0d9 100644 --- a/Geo/MSubElement.cpp +++ b/Geo/MSubElement.cpp @@ -16,22 +16,6 @@ MSubTetrahedron::~MSubTetrahedron() delete _orig; } -void MSubTetrahedron::_fillInfoMSH(std::vector<int> &info, int elementary, - std::vector<short> *ghosts) -{ - info.clear(); - info.push_back(0); - info.push_back(getParent()->getNum()); - if(getPartition()) - info.push_back(getPartition()); - if(ghosts) - info.insert(info.end(), ghosts->begin(), ghosts->end()); - info[0] = info.size() - 1; - std::vector<int> verts; - getVerticesIdForMSH(verts); - info.insert(info.end(), verts.begin(), verts.end()); -} - const polynomialBasis* MSubTetrahedron::getFunctionSpace(int order) const { if(_orig) return _orig->getFunctionSpace(order); @@ -130,22 +114,6 @@ MSubTriangle::~MSubTriangle() delete _orig; } -void MSubTriangle::_fillInfoMSH(std::vector<int> &info, int elementary, - std::vector<short> *ghosts) -{ - info.clear(); - info.push_back(0); - info.push_back(getParent()->getNum()); - if(getPartition()) - info.push_back(getPartition()); - if(ghosts) - info.insert(info.end(), ghosts->begin(), ghosts->end()); - info[0] = info.size() - 1; - std::vector<int> verts; - getVerticesIdForMSH(verts); - info.insert(info.end(), verts.begin(), verts.end()); -} - const polynomialBasis* MSubTriangle::getFunctionSpace(int order) const { if(_orig) return _orig->getFunctionSpace(order); @@ -241,22 +209,6 @@ MSubLine::~MSubLine() delete _orig; } -void MSubLine::_fillInfoMSH(std::vector<int> &info, int elementary, - std::vector<short> *ghosts) -{ - info.clear(); - info.push_back(0); - info.push_back(getParent()->getNum()); - if(getPartition()) - info.push_back(getPartition()); - if(ghosts) - info.insert(info.end(), ghosts->begin(), ghosts->end()); - info[0] = info.size() - 1; - std::vector<int> verts; - getVerticesIdForMSH(verts); - info.insert(info.end(), verts.begin(), verts.end()); -} - const polynomialBasis* MSubLine::getFunctionSpace(int order) const { if(_orig) return _orig->getFunctionSpace(order); @@ -347,22 +299,6 @@ MSubPoint::~MSubPoint() delete _orig; } -void MSubPoint::_fillInfoMSH(std::vector<int> &info, int elementary, - std::vector<short> *ghosts) -{ - info.clear(); - info.push_back(0); - info.push_back(getParent()->getNum()); - if(getPartition()) - info.push_back(getPartition()); - if(ghosts) - info.insert(info.end(), ghosts->begin(), ghosts->end()); - info[0] = info.size() - 1; - std::vector<int> verts; - getVerticesIdForMSH(verts); - info.insert(info.end(), verts.begin(), verts.end()); -} - const polynomialBasis* MSubPoint::getFunctionSpace(int order) const { if(_orig) return _orig->getFunctionSpace(order); diff --git a/Geo/MSubElement.h b/Geo/MSubElement.h index 563686b404ccda9de29e429f92bee180406741fb..4f241d1facb678e4976873714dc7c45b58566f5a 100644 --- a/Geo/MSubElement.h +++ b/Geo/MSubElement.h @@ -24,8 +24,6 @@ class MSubTetrahedron : public MTetrahedron MElement* _orig; std::vector<MElement*> _parents; IntPt *_intpt; - virtual void _fillInfoMSH(std::vector<int> &info, int elementary=1, - std::vector<short> *ghosts=0); public: MSubTetrahedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num=0, int part=0, bool owner=false, MElement* orig=NULL) @@ -61,8 +59,6 @@ class MSubTriangle : public MTriangle MElement* _orig; std::vector<MElement*> _parents; IntPt *_intpt; - virtual void _fillInfoMSH(std::vector<int> &info, int elementary=1, - std::vector<short> *ghosts=0); public: MSubTriangle(MVertex *v0, MVertex *v1, MVertex *v2, int num=0, int part=0, bool owner=false, MElement* orig=NULL) @@ -97,8 +93,6 @@ class MSubLine : public MLine MElement* _orig; std::vector<MElement*> _parents; IntPt *_intpt; - virtual void _fillInfoMSH(std::vector<int> &info, int elementary=1, - std::vector<short> *ghosts=0); public: MSubLine(MVertex *v0, MVertex *v1, int num=0, int part=0, bool owner=false, MElement* orig=NULL) : MLine(v0, v1, num, part), _owner(owner), _orig(orig), _intpt(0) {} @@ -132,8 +126,6 @@ class MSubPoint : public MPoint MElement* _orig; std::vector<MElement*> _parents; IntPt *_intpt; - virtual void _fillInfoMSH(std::vector<int> &info, int elementary=1, - std::vector<short> *ghosts=0); public: MSubPoint(MVertex *v0, int num=0, int part=0, bool owner=false, MElement* orig=NULL) : MPoint(v0, num, part), _owner(owner), _orig(orig), _intpt(0) {}