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

*** empty log message ***

parent 2cf7cee4
No related branches found
No related tags found
No related merge requests found
...@@ -245,52 +245,94 @@ int GModel::readMSH(const std::string &name) ...@@ -245,52 +245,94 @@ int GModel::readMSH(const std::string &name)
int n[30]; int n[30];
for(int j = 0; j < numVertices; j++) fscanf(fp, "%d", &n[j]); for(int j = 0; j < numVertices; j++) fscanf(fp, "%d", &n[j]);
int dim = 0; int dim = 0;
std::map<int, MVertex*> &v(vertices);
switch (type) { switch (type) {
case PNT: case PNT:
points[elementary].push_back(vertices[n[0]]); points[elementary].push_back(v[n[0]]);
dim = 0; dim = 0;
break; break;
case LGN1: case LGN1:
elements[0][elementary].push_back elements[0][elementary].push_back
(new MLine(vertices[n[0]], vertices[n[1]], num, partition)); (new MLine(v[n[0]], v[n[1]], num, partition));
dim = 1;
break;
case LGN2:
elements[0][elementary].push_back
(new MLine2(v[n[0]], v[n[1]], v[n[2]], num, partition));
dim = 1; dim = 1;
break; break;
case TRI1: case TRI1:
elements[1][elementary].push_back elements[1][elementary].push_back
(new MTriangle(vertices[n[0]], vertices[n[1]], vertices[n[2]], (new MTriangle(v[n[0]], v[n[1]], v[n[2]], num, partition));
dim = 2;
break;
case TRI2:
elements[1][elementary].push_back
(new MTriangle2(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
num, partition)); num, partition));
dim = 2; dim = 2;
break; break;
case QUA1: case QUA1:
elements[2][elementary].push_back elements[2][elementary].push_back
(new MQuadrangle(vertices[n[0]], vertices[n[1]], vertices[n[2]], (new MQuadrangle(v[n[0]], v[n[1]], v[n[2]], v[n[3]], num, partition));
vertices[n[3]], num, partition)); dim = 2;
break;
case QUA2:
elements[2][elementary].push_back
(new MQuadrangle2(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
v[n[6]], v[n[7]], v[n[8]], num, partition));
dim = 2; dim = 2;
break; break;
case TET1: case TET1:
elements[3][elementary].push_back elements[3][elementary].push_back
(new MTetrahedron(vertices[n[0]], vertices[n[1]], vertices[n[2]], (new MTetrahedron(v[n[0]], v[n[1]], v[n[2]], v[n[3]], num, partition));
vertices[n[3]], num, partition)); dim = 3;
break;
case TET2:
elements[3][elementary].push_back
(new MTetrahedron2(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
v[n[6]], v[n[7]], v[n[8]], v[n[9]], num, partition));
dim = 3; dim = 3;
break; break;
case HEX1: case HEX1:
elements[4][elementary].push_back elements[4][elementary].push_back
(new MHexahedron(vertices[n[0]], vertices[n[1]], vertices[n[2]], (new MHexahedron(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
vertices[n[3]], vertices[n[4]], vertices[n[5]], v[n[6]], v[n[7]], num, partition));
vertices[n[6]], vertices[n[7]], num, partition)); dim = 3;
break;
case HEX2:
elements[4][elementary].push_back
(new MHexahedron2(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
v[n[6]], v[n[7]], v[n[8]], v[n[9]], v[n[10]], v[n[11]],
v[n[12]], v[n[13]], v[n[14]], v[n[15]], v[n[16]], v[n[17]],
v[n[18]], v[n[19]], v[n[20]], v[n[21]], v[n[22]], v[n[23]],
v[n[24]], v[n[25]], v[n[26]], num, partition));
dim = 3; dim = 3;
break; break;
case PRI1: case PRI1:
elements[5][elementary].push_back elements[5][elementary].push_back
(new MPrism(vertices[n[0]], vertices[n[1]], vertices[n[2]], (new MPrism(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
vertices[n[3]], vertices[n[4]], vertices[n[5]], num, partition));
dim = 3;
break;
case PRI2:
elements[5][elementary].push_back
(new MPrism2(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
v[n[6]], v[n[7]], v[n[8]], v[n[9]], v[n[10]], v[n[11]],
v[n[12]], v[n[13]], v[n[14]], v[n[15]], v[n[16]], v[n[17]],
num, partition)); num, partition));
dim = 3; dim = 3;
break; break;
case PYR1: case PYR1:
elements[6][elementary].push_back elements[6][elementary].push_back
(new MPyramid(vertices[n[0]], vertices[n[1]], vertices[n[2]], (new MPyramid(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], num, partition));
vertices[n[3]], vertices[n[4]], num, partition)); dim = 3;
break;
case PYR2:
elements[6][elementary].push_back
(new MPyramid2(v[n[0]], v[n[1]], v[n[2]], v[n[3]], v[n[4]], v[n[5]],
v[n[6]], v[n[7]], v[n[8]], v[n[9]], v[n[10]], v[n[11]],
v[n[12]], v[n[13]], num, partition));
dim = 3; dim = 3;
break; break;
default: default:
...@@ -298,10 +340,9 @@ int GModel::readMSH(const std::string &name) ...@@ -298,10 +340,9 @@ int GModel::readMSH(const std::string &name)
break; break;
} }
if(physical){ if(physical && (!physicals[dim].count(elementary) ||
if(!physicals[dim].count(elementary) || !physicals[dim][elementary].count(physical)) !physicals[dim][elementary].count(physical)))
physicals[dim][elementary][physical] = "unnamed"; physicals[dim][elementary][physical] = "unnamed";
}
if(partition) meshPartitions.insert(partition); if(partition) meshPartitions.insert(partition);
...@@ -761,17 +802,11 @@ int GModel::writeUNV(const std::string &name, double scalingFactor) ...@@ -761,17 +802,11 @@ int GModel::writeUNV(const std::string &name, double scalingFactor)
return 0; return 0;
} }
// IDEAS records
const int NODES=2411, ELEMENTS=2412, GROUPOFNODES=790;
// IDEAS elements
const int BEAM=21, THINSHLL=91, QUAD=94, SOLIDFEM=111, WEDGE=112, BRICK=115;
//const int BEAM2=24, THINSHLL2=92, QUAD2=95/*?*/, SOLIDFEM2=118;
renumberMeshVertices(); renumberMeshVertices();
// IDEAS NODES record
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
fprintf(fp, "%6d\n", NODES); fprintf(fp, "%6d\n", 2411);
for(viter it = firstVertex(); it != lastVertex(); ++it) for(viter it = firstVertex(); it != lastVertex(); ++it)
for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++)
(*it)->mesh_vertices[i]->writeUNV(fp, scalingFactor); (*it)->mesh_vertices[i]->writeUNV(fp, scalingFactor);
...@@ -786,25 +821,26 @@ int GModel::writeUNV(const std::string &name, double scalingFactor) ...@@ -786,25 +821,26 @@ int GModel::writeUNV(const std::string &name, double scalingFactor)
(*it)->mesh_vertices[i]->writeUNV(fp, scalingFactor); (*it)->mesh_vertices[i]->writeUNV(fp, scalingFactor);
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
// IDEAS ELEMENTS record
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
fprintf(fp, "%6d\n", ELEMENTS); fprintf(fp, "%6d\n", 2412);
for(eiter it = firstEdge(); it != lastEdge(); ++it){ for(eiter it = firstEdge(); it != lastEdge(); ++it){
for(unsigned int i = 0; i < (*it)->lines.size(); i++) for(unsigned int i = 0; i < (*it)->lines.size(); i++)
(*it)->lines[i]->writeUNV(fp, BEAM, (*it)->tag()); (*it)->lines[i]->writeUNV(fp, (*it)->tag());
} }
for(fiter it = firstFace(); it != lastFace(); ++it){ for(fiter it = firstFace(); it != lastFace(); ++it){
for(unsigned int i = 0; i < (*it)->triangles.size(); i++) for(unsigned int i = 0; i < (*it)->triangles.size(); i++)
(*it)->triangles[i]->writeUNV(fp, THINSHLL, (*it)->tag()); (*it)->triangles[i]->writeUNV(fp, (*it)->tag());
for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++)
(*it)->quadrangles[i]->writeUNV(fp, QUAD, (*it)->tag()); (*it)->quadrangles[i]->writeUNV(fp, (*it)->tag());
} }
for(riter it = firstRegion(); it != lastRegion(); ++it){ for(riter it = firstRegion(); it != lastRegion(); ++it){
for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++)
(*it)->tetrahedra[i]->writeUNV(fp, SOLIDFEM, (*it)->tag()); (*it)->tetrahedra[i]->writeUNV(fp, (*it)->tag());
for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++)
(*it)->hexahedra[i]->writeUNV(fp, BRICK, (*it)->tag()); (*it)->hexahedra[i]->writeUNV(fp, (*it)->tag());
for(unsigned int i = 0; i < (*it)->prisms.size(); i++) for(unsigned int i = 0; i < (*it)->prisms.size(); i++)
(*it)->prisms[i]->writeUNV(fp, WEDGE, (*it)->tag()); (*it)->prisms[i]->writeUNV(fp, (*it)->tag());
} }
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
...@@ -815,8 +851,9 @@ int GModel::writeUNV(const std::string &name, double scalingFactor) ...@@ -815,8 +851,9 @@ int GModel::writeUNV(const std::string &name, double scalingFactor)
std::map<int, std::vector<GEntity*> >::const_iterator it = physicals[dim].begin(); std::map<int, std::vector<GEntity*> >::const_iterator it = physicals[dim].begin();
std::map<int, std::vector<GEntity*> >::const_iterator ite = physicals[dim].end(); std::map<int, std::vector<GEntity*> >::const_iterator ite = physicals[dim].end();
for(; it != ite; ++it){ for(; it != ite; ++it){
// IDEAS GROUPOFNODES record
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
fprintf(fp, "%6d\n", GROUPOFNODES); fprintf(fp, "%6d\n", 790);
fprintf(fp, "%10d%10d\n", it->first, 1); fprintf(fp, "%10d%10d\n", it->first, 1);
fprintf(fp, "LOAD SET %2d\n", 1); fprintf(fp, "LOAD SET %2d\n", 1);
std::set<int> nodes; std::set<int> nodes;
......
...@@ -90,13 +90,13 @@ void MElement::cog(double &x, double &y, double &z) ...@@ -90,13 +90,13 @@ void MElement::cog(double &x, double &y, double &z)
void MElement::writeMSH(FILE *fp, double version, int num, int elementary, void MElement::writeMSH(FILE *fp, double version, int num, int elementary,
int physical) int physical)
{ {
int n = getNumVertices();
int type = getTypeForMSH();
// if necessary, change the ordering of the vertices to get positive // if necessary, change the ordering of the vertices to get positive
// volume // volume
setVolumePositive(); setVolumePositive();
int n = getNumVertices();
int type = getTypeForMSH();
fprintf(fp, "%d %d", num ? num : _num, type); fprintf(fp, "%d %d", num ? num : _num, type);
if(version < 2.0) if(version < 2.0)
fprintf(fp, " %d %d %d", physical, elementary, n); fprintf(fp, " %d %d %d", physical, elementary, n);
...@@ -200,13 +200,15 @@ void MElement::writeVRML(FILE *fp) ...@@ -200,13 +200,15 @@ void MElement::writeVRML(FILE *fp)
fprintf(fp, "-1,\n"); fprintf(fp, "-1,\n");
} }
void MElement::writeUNV(FILE *fp, int type, int elementary) void MElement::writeUNV(FILE *fp, int elementary)
{ {
// if necessary, change the ordering of the vertices to get positive // if necessary, change the ordering of the vertices to get positive
// volume // volume
setVolumePositive(); setVolumePositive();
int n = getNumVertices(); int n = getNumVertices();
int type = getTypeForUNV();
fprintf(fp, "%10d%10d%10d%10d%10d%10d\n", fprintf(fp, "%10d%10d%10d%10d%10d%10d\n",
_num, type, elementary, elementary, 7, n); _num, type, elementary, elementary, 7, n);
if(type == 21 || type == 24) // BEAM or BEAM2 if(type == 21 || type == 24) // BEAM or BEAM2
......
...@@ -44,6 +44,9 @@ class MElement ...@@ -44,6 +44,9 @@ class MElement
// returns the tag of the element // returns the tag of the element
virtual int getNum(){ return _num; } virtual int getNum(){ return _num; }
// returns the polynomial order the element
virtual int getPolynomialOrder(){ return 1; }
// returns the partition to which the element belongs // returns the partition to which the element belongs
virtual int getPartition(){ return _partition; } virtual int getPartition(){ return _partition; }
...@@ -108,10 +111,11 @@ class MElement ...@@ -108,10 +111,11 @@ class MElement
int elementary=1); int elementary=1);
virtual void writeSTL(FILE *fp, double scalingFactor=1.0); virtual void writeSTL(FILE *fp, double scalingFactor=1.0);
virtual void writeVRML(FILE *fp); virtual void writeVRML(FILE *fp);
virtual void writeUNV(FILE *fp, int type, int elementary); virtual void writeUNV(FILE *fp, int elementary);
virtual void writeMESH(FILE *fp, int elementary); virtual void writeMESH(FILE *fp, int elementary);
virtual char *getStringForPOS() = 0; virtual char *getStringForPOS() = 0;
virtual int getTypeForMSH() = 0; virtual int getTypeForMSH() = 0;
virtual int getTypeForUNV() = 0;
}; };
class MLine : public MElement { class MLine : public MElement {
...@@ -137,6 +141,7 @@ class MLine : public MElement { ...@@ -137,6 +141,7 @@ class MLine : public MElement {
v[0] = v[1] = v[2] = v[3] = 0; v[0] = v[1] = v[2] = v[3] = 0;
} }
int getTypeForMSH(){ return LGN1; } int getTypeForMSH(){ return LGN1; }
int getTypeForUNV(){ return 21; } // BEAM
char *getStringForPOS(){ return "SL"; } char *getStringForPOS(){ return "SL"; }
}; };
...@@ -150,6 +155,7 @@ class MLine2 : public MLine { ...@@ -150,6 +155,7 @@ class MLine2 : public MLine {
_vs[0] = v2; _vs[0] = v2;
} }
~MLine2(){} ~MLine2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 3; } inline int getNumVertices(){ return 3; }
inline MVertex *getVertex(int num){ return num < 2 ? _v[num] : _vs[num - 2]; } inline MVertex *getVertex(int num){ return num < 2 ? _v[num] : _vs[num - 2]; }
inline int getNumEdgeVertices(){ return 1; } inline int getNumEdgeVertices(){ return 1; }
...@@ -165,6 +171,7 @@ class MLine2 : public MLine { ...@@ -165,6 +171,7 @@ class MLine2 : public MLine {
v[1] = i1 < 2? _v[i1] : _vs[i1 - 2]; v[1] = i1 < 2? _v[i1] : _vs[i1 - 2];
} }
int getTypeForMSH(){ return LGN2; } int getTypeForMSH(){ return LGN2; }
int getTypeForUNV(){ return 24; } // BEAM2
char *getStringForPOS(){ return "SL2"; } char *getStringForPOS(){ return "SL2"; }
}; };
...@@ -192,6 +199,7 @@ class MTriangle : public MElement { ...@@ -192,6 +199,7 @@ class MTriangle : public MElement {
v[0] = _v[0]; v[1] = _v[1]; v[2] = _v[2]; v[3] = 0; v[0] = _v[0]; v[1] = _v[1]; v[2] = _v[2]; v[3] = 0;
} }
int getTypeForMSH(){ return TRI1; } int getTypeForMSH(){ return TRI1; }
int getTypeForUNV(){ return 91; } // THINSHLL
char *getStringForPOS(){ return "ST"; } char *getStringForPOS(){ return "ST"; }
}; };
...@@ -199,14 +207,14 @@ class MTriangle2 : public MTriangle { ...@@ -199,14 +207,14 @@ class MTriangle2 : public MTriangle {
protected: protected:
MVertex *_vs[3]; MVertex *_vs[3];
public : public :
MTriangle2 (MVertex *v0, MVertex *v1, MVertex *v2, MTriangle2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
MVertex *v3, MVertex *v4, MVertex *v5, MVertex *v5, int num=0, int part=0)
int num=0, int part=0)
: MTriangle(v0, v1, v2, num, part) : MTriangle(v0, v1, v2, num, part)
{ {
_vs[0] = v3; _vs[1] = v4; _vs[2] = v5; _vs[0] = v3; _vs[1] = v4; _vs[2] = v5;
} }
~MTriangle2(){} ~MTriangle2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 6; } inline int getNumVertices(){ return 6; }
inline MVertex *getVertex(int num){ return num < 3 ? _v[num] : _vs[num - 3]; } inline MVertex *getVertex(int num){ return num < 3 ? _v[num] : _vs[num - 3]; }
inline int getNumEdgeVertices(){ return 3; } inline int getNumEdgeVertices(){ return 3; }
...@@ -244,6 +252,7 @@ class MTriangle2 : public MTriangle { ...@@ -244,6 +252,7 @@ class MTriangle2 : public MTriangle {
v[2]->x(), v[2]->y(), v[2]->y(), n); v[2]->x(), v[2]->y(), v[2]->y(), n);
} }
int getTypeForMSH(){ return TRI2; } int getTypeForMSH(){ return TRI2; }
int getTypeForUNV(){ return 92; } // THINSHLL2
char *getStringForPOS(){ return "ST2"; } char *getStringForPOS(){ return "ST2"; }
}; };
...@@ -251,8 +260,7 @@ class MQuadrangle : public MElement { ...@@ -251,8 +260,7 @@ class MQuadrangle : public MElement {
protected: protected:
MVertex *_v[4]; MVertex *_v[4];
public : public :
MQuadrangle(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MQuadrangle(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num=0, int part=0)
int num=0, int part=0)
: MElement(num, part) : MElement(num, part)
{ {
_v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3;
...@@ -272,6 +280,7 @@ class MQuadrangle : public MElement { ...@@ -272,6 +280,7 @@ class MQuadrangle : public MElement {
v[0] = _v[0]; v[1] = _v[1]; v[2] = _v[2]; v[3] = _v[3]; v[0] = _v[0]; v[1] = _v[1]; v[2] = _v[2]; v[3] = _v[3];
} }
int getTypeForMSH(){ return QUA1; } int getTypeForMSH(){ return QUA1; }
int getTypeForUNV(){ return 94; } // QUAD
char *getStringForPOS(){ return "SQ"; } char *getStringForPOS(){ return "SQ"; }
}; };
...@@ -279,19 +288,21 @@ class MQuadrangle2 : public MQuadrangle { ...@@ -279,19 +288,21 @@ class MQuadrangle2 : public MQuadrangle {
protected: protected:
MVertex *_vs[5]; MVertex *_vs[5];
public : public :
MQuadrangle2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MQuadrangle2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
MVertex *v4, MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, int num=0, int part=0)
MVertex *v8, int num=0, int part=0)
: MQuadrangle(v0, v1, v2, v3, num, part) : MQuadrangle(v0, v1, v2, v3, num, part)
{ {
_vs[0] = v4; _v[1] = v5; _v[2] = v6; _v[3] = v7; _v[4] = v8; _vs[0] = v4; _v[1] = v5; _v[2] = v6; _v[3] = v7; _v[4] = v8;
} }
~MQuadrangle2(){} ~MQuadrangle2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 9; } inline int getNumVertices(){ return 9; }
inline MVertex *getVertex(int num){ return num < 4 ? _v[num] : _vs[num - 4]; } inline MVertex *getVertex(int num){ return num < 4 ? _v[num] : _vs[num - 4]; }
inline int getNumEdgeVertices(){ return 4; } inline int getNumEdgeVertices(){ return 4; }
inline int getNumFaceVertices(){ return 1; } inline int getNumFaceVertices(){ return 1; }
// TODO: edgeRep, faceRep
int getTypeForMSH(){ return QUA2; } int getTypeForMSH(){ return QUA2; }
int getTypeForUNV(){ return 95; } // ???? QUAD2
char *getStringForPOS(){ return "SQ2"; } char *getStringForPOS(){ return "SQ2"; }
}; };
...@@ -299,8 +310,7 @@ class MTetrahedron : public MElement { ...@@ -299,8 +310,7 @@ class MTetrahedron : public MElement {
protected: protected:
MVertex *_v[4]; MVertex *_v[4];
public : public :
MTetrahedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MTetrahedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num=0, int part=0)
int num=0, int part=0)
: MElement(num, part) : MElement(num, part)
{ {
_v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3;
...@@ -323,6 +333,7 @@ class MTetrahedron : public MElement { ...@@ -323,6 +333,7 @@ class MTetrahedron : public MElement {
v[3] = 0; v[3] = 0;
} }
int getTypeForMSH(){ return TET1; } int getTypeForMSH(){ return TET1; }
int getTypeForUNV(){ return 111; } // SOLIDFEM
char *getStringForPOS(){ return "SS"; } char *getStringForPOS(){ return "SS"; }
virtual double getVolume() virtual double getVolume()
{ {
...@@ -350,24 +361,43 @@ class MTetrahedron : public MElement { ...@@ -350,24 +361,43 @@ class MTetrahedron : public MElement {
virtual double etaShapeMeasure(); virtual double etaShapeMeasure();
}; };
// TODO: for MTetrahedron2 class MTetrahedron2 : public MTetrahedron {
// void setVolumePositive() protected:
// { MVertex *_vs[6];
// if(getVolumeSign() < 0){ public :
// MVertex *tmp; MTetrahedron2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
// tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp; MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9,
// tmp = _vs[1]; _vs[1] = _vs[2]; _vs[2] = temp; int num=0, int part=0)
// tmp = _vs[5]; _vs[5] = _vs[3]; _vs[3] = temp; : MTetrahedron(v0, v1, v2, v3, num, part)
// } {
// } _vs[0] = v4; _vs[1] = v5; _vs[2] = v6; _vs[3] = v7; _vs[4] = v8; _vs[5] = v9;
}
~MTetrahedron2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 10; }
inline MVertex *getVertex(int num){ return num < 4 ? _v[num] : _vs[num - 4]; }
inline int getNumEdgeVertices(){ return 6; }
// TODO: edgeRep, faceRep
int getTypeForMSH(){ return TET2; }
int getTypeForUNV(){ return 118; } // SOLIDFEM2
char *getStringForPOS(){ return "SS2"; }
void setVolumePositive()
{
if(getVolumeSign() < 0){
MVertex *tmp;
tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp;
tmp = _vs[1]; _vs[1] = _vs[2]; _vs[2] = tmp;
tmp = _vs[5]; _vs[5] = _vs[3]; _vs[3] = tmp;
}
}
};
class MHexahedron : public MElement { class MHexahedron : public MElement {
protected: protected:
MVertex *_v[8]; MVertex *_v[8];
public : public :
MHexahedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MHexahedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
MVertex *v4, MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v5, MVertex *v6, MVertex *v7, int num=0, int part=0)
int num=0, int part=0)
: MElement(num, part) : MElement(num, part)
{ {
_v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3;
...@@ -391,6 +421,7 @@ class MHexahedron : public MElement { ...@@ -391,6 +421,7 @@ class MHexahedron : public MElement {
v[3] = _v[quadfaces_hexa[num][3]]; v[3] = _v[quadfaces_hexa[num][3]];
} }
int getTypeForMSH(){ return HEX1; } int getTypeForMSH(){ return HEX1; }
int getTypeForUNV(){ return 115; } // BRICK
char *getStringForPOS(){ return "SH"; } char *getStringForPOS(){ return "SH"; }
virtual int getVolumeSign() virtual int getVolumeSign()
{ {
...@@ -416,28 +447,56 @@ class MHexahedron : public MElement { ...@@ -416,28 +447,56 @@ class MHexahedron : public MElement {
} }
}; };
// TODO: for MHexahedron2 class MHexahedron2 : public MHexahedron {
// void setVolumePositive() protected:
// { MVertex *_vs[19];
// if(getVolumeSign() < 0){ public :
// MVertex *tmp; MHexahedron2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
// tmp = _v[0]; _v[0] = _v[2]; _v[2] = tmp; MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9,
// tmp = _v[4]; _v[4] = _v[6]; _v[6] = tmp; MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14,
// MVertex *old[12]; MVertex *v15, MVertex *v16, MVertex *v17, MVertex *v18, MVertex *v19,
// for(int i = 0; i < 12; i++) old[i] = _vs[i]; MVertex *v20, MVertex *v21, MVertex *v22, MVertex *v23, MVertex *v24,
// _vs[0] = old[3]; _vs[1] = old[5]; _vs[2] = old[6]; MVertex *v25, MVertex *v26, int num=0, int part=0)
// _vs[3] = old[0]; _vs[4] = old[4]; _vs[5] = old[1]; : MHexahedron(v0, v1, v2, v3, v4, v5, v6, v7, num, part)
// _vs[6] = old[2]; _vs[7] = old[7]; _vs[8] = old[10]; {
// _vs[9] = old[11]; _vs[10] = old[8]; _vs[11] = old[9]; _vs[0] = v8; _vs[1] = v9; _vs[2] = v10; _vs[3] = v11; _vs[4] = v12;
// } _vs[5] = v13; _vs[6] = v14; _vs[7] = v15; _vs[8] = v16; _vs[9] = v17;
// } _vs[10] = v18; _vs[11] = v19; _vs[12] = v20; _vs[13] = v21; _vs[14] = v22;
_vs[15] = v23; _vs[16] = v24; _vs[17] = v25; _vs[18] = v26;
}
~MHexahedron2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 27; }
inline MVertex *getVertex(int num){ return num < 8 ? _v[num] : _vs[num - 8]; }
inline int getNumEdgeVertices(){ return 12; }
inline int getNumFaceVertices(){ return 6; }
inline int getNumVolumeVertices(){ return 1; }
// TODO: edgeRep, faceRep
int getTypeForMSH(){ return HEX2; }
int getTypeForUNV(){ return 116; } // ???? BRICK2
char *getStringForPOS(){ return "SH2"; }
void setVolumePositive()
{
if(getVolumeSign() < 0){
MVertex *tmp;
tmp = _v[0]; _v[0] = _v[2]; _v[2] = tmp;
tmp = _v[4]; _v[4] = _v[6]; _v[6] = tmp;
MVertex *old[12];
for(int i = 0; i < 12; i++) old[i] = _vs[i];
_vs[0] = old[3]; _vs[1] = old[5]; _vs[2] = old[6];
_vs[3] = old[0]; _vs[4] = old[4]; _vs[5] = old[1];
_vs[6] = old[2]; _vs[7] = old[7]; _vs[8] = old[10];
_vs[9] = old[11]; _vs[10] = old[8]; _vs[11] = old[9];
}
}
};
class MPrism : public MElement { class MPrism : public MElement {
protected: protected:
MVertex *_v[6]; MVertex *_v[6];
public : public :
MPrism(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MPrism(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
MVertex *v4, MVertex *v5, int num=0, int part=0) MVertex *v5, int num=0, int part=0)
: MElement(num, part) : MElement(num, part)
{ {
_v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3;
...@@ -469,6 +528,7 @@ class MPrism : public MElement { ...@@ -469,6 +528,7 @@ class MPrism : public MElement {
} }
} }
int getTypeForMSH(){ return PRI1; } int getTypeForMSH(){ return PRI1; }
int getTypeForUNV(){ return 112; } // WEDGE
char *getStringForPOS(){ return "SI"; } char *getStringForPOS(){ return "SI"; }
virtual int getVolumeSign() virtual int getVolumeSign()
{ {
...@@ -494,25 +554,49 @@ class MPrism : public MElement { ...@@ -494,25 +554,49 @@ class MPrism : public MElement {
} }
}; };
// TODO: for MPrism2 class MPrism2 : public MPrism {
// void setVolumePositive() protected:
// { MVertex *_vs[12];
// if(getVolumeSign() < 0){ public :
// MVertex *tmp; MPrism2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
// tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp; MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9,
// tmp = _v[3]; _v[3] = _v[4]; _v[4] = tmp; MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13, MVertex *v14,
// tmp = _vs[1]; _vs[1] = _vs[3]; _vs[3] = tmp; MVertex *v15, MVertex *v16, MVertex *v17, int num=0, int part=0)
// tmp = _vs[2]; _vs[2] = _vs[4]; _vs[4] = tmp; : MPrism(v0, v1, v2, v3, v4, v5, num, part)
// tmp = _vs[7]; _vs[7] = _vs[8]; _vs[8] = tmp; {
// } _vs[0] = v6; _vs[1] = v7; _vs[2] = v8; _vs[3] = v9; _vs[4] = v10;
// } _vs[5] = v11; _vs[6] = v12; _vs[7] = v13; _vs[8] = v14; _vs[9] = v15;
_vs[10] = v16; _vs[11] = v17;
}
~MPrism2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 18; }
inline MVertex *getVertex(int num){ return num < 6 ? _v[num] : _vs[num - 6]; }
inline int getNumEdgeVertices(){ return 9; }
inline int getNumFaceVertices(){ return 3; }
// TODO: edgeRep, faceRep
int getTypeForMSH(){ return PRI2; }
int getTypeForUNV(){ return 113; } // ???? WEDGE2
char *getStringForPOS(){ return "SI2"; }
void setVolumePositive()
{
if(getVolumeSign() < 0){
MVertex *tmp;
tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp;
tmp = _v[3]; _v[3] = _v[4]; _v[4] = tmp;
tmp = _vs[1]; _vs[1] = _vs[3]; _vs[3] = tmp;
tmp = _vs[2]; _vs[2] = _vs[4]; _vs[4] = tmp;
tmp = _vs[7]; _vs[7] = _vs[8]; _vs[8] = tmp;
}
}
};
class MPyramid : public MElement { class MPyramid : public MElement {
protected: protected:
MVertex *_v[5]; MVertex *_v[5];
public : public :
MPyramid(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MPyramid(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
MVertex *v4, int num=0, int part=0) int num=0, int part=0)
: MElement(num, part) : MElement(num, part)
{ {
_v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[4] = v4; _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; _v[4] = v4;
...@@ -543,6 +627,7 @@ class MPyramid : public MElement { ...@@ -543,6 +627,7 @@ class MPyramid : public MElement {
} }
} }
int getTypeForMSH(){ return PYR1; } int getTypeForMSH(){ return PYR1; }
int getTypeForUNV(){ throw; }
char *getStringForPOS(){ return "SY"; } char *getStringForPOS(){ return "SY"; }
virtual int getVolumeSign() virtual int getVolumeSign()
{ {
...@@ -567,16 +652,39 @@ class MPyramid : public MElement { ...@@ -567,16 +652,39 @@ class MPyramid : public MElement {
} }
}; };
// TODO: for MPyramid2 class MPyramid2 : public MPyramid {
// void setVolumePositive() protected:
// { MVertex *_vs[9];
// if(getVolumeSign() < 0){ public :
// MVertex *tmp; MPyramid2(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
// tmp = _v[0]; _v[0] = _v[2]; _v[2] = tmp; MVertex *v5, MVertex *v6, MVertex *v7, MVertex *v8, MVertex *v9,
// tmp = _vs[0]; _vs[0] = _vs[3]; _vs[3] = tmp; MVertex *v10, MVertex *v11, MVertex *v12, MVertex *v13,
// tmp = _vs[1]; _vs[1] = _vs[5]; _vs[5] = tmp; int num=0, int part=0)
// tmp = _vs[2]; _vs[2] = _vs[6]; _vs[6] = tmp; : MPyramid(v0, v1, v2, v3, v4, num, part)
// } {
// } _vs[0] = v5; _vs[1] = v6; _vs[2] = v7; _vs[3] = v8; _vs[4] = v9;
_vs[5] = v10; _vs[6] = v11; _vs[7] = v12; _vs[8] = v13;
}
~MPyramid2(){}
inline int getPolynomialOrder(){ return 2; }
inline int getNumVertices(){ return 14; }
inline MVertex *getVertex(int num){ return num < 5 ? _v[num] : _vs[num - 5]; }
inline int getNumEdgeVertices(){ return 8; }
inline int getNumFaceVertices(){ return 1; }
// TODO: edgeRep, faceRep
int getTypeForMSH(){ return PYR2; }
int getTypeForUNV(){ throw; }
char *getStringForPOS(){ return "SY2"; }
void setVolumePositive()
{
if(getVolumeSign() < 0){
MVertex *tmp;
tmp = _v[0]; _v[0] = _v[2]; _v[2] = tmp;
tmp = _vs[0]; _vs[0] = _vs[3]; _vs[3] = tmp;
tmp = _vs[1]; _vs[1] = _vs[5]; _vs[5] = tmp;
tmp = _vs[2]; _vs[2] = _vs[6]; _vs[6] = tmp;
}
}
};
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment