Skip to content
Snippets Groups Projects
Commit 5331a938 authored by Amaury Johnen's avatar Amaury Johnen
Browse files

fix serendipity element

parent 6af628b3
Branches
Tags
No related merge requests found
...@@ -484,22 +484,19 @@ class MHexahedronN : public MHexahedron { ...@@ -484,22 +484,19 @@ class MHexahedronN : public MHexahedron {
virtual const MVertex *getVertex(int num) const { return num < 8 ? _v[num] : _vs[num - 8]; } virtual const MVertex *getVertex(int num) const { return num < 8 ? _v[num] : _vs[num - 8]; }
virtual int getNumEdgeVertices() const { return 12 * (_order - 1); } virtual int getNumEdgeVertices() const { return 12 * (_order - 1); }
virtual int getNumFaceVertices() const { return 6 * (_order - 1)*(_order - 1); } virtual int getNumFaceVertices() const
{
if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
return 0;
else
return 6 * (_order - 1)*(_order - 1);
}
virtual int getNumVolumeVertices() const virtual int getNumVolumeVertices() const
{ {
switch(getTypeForMSH()){ if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
case MSH_HEX_27 :
case MSH_HEX_64 :
case MSH_HEX_125 :
case MSH_HEX_216 :
case MSH_HEX_343 :
case MSH_HEX_512 :
case MSH_HEX_729 :
case MSH_HEX_1000 :
return (_order - 1) * (_order - 1) * (_order - 1);
default:
return 0; return 0;
} else
return (_order - 1) * (_order - 1) * (_order - 1);
} }
virtual int getNumEdgesRep(); virtual int getNumEdgesRep();
virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n); virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n);
......
...@@ -411,8 +411,20 @@ class MPrismN : public MPrism { ...@@ -411,8 +411,20 @@ class MPrismN : public MPrism {
virtual MVertex *getVertex(int num){ return num < 6 ? _v[num] : _vs[num-6]; } virtual MVertex *getVertex(int num){ return num < 6 ? _v[num] : _vs[num-6]; }
virtual const MVertex *getVertex(int num) const{ return num < 6 ? _v[num] : _vs[num-6]; } virtual const MVertex *getVertex(int num) const{ return num < 6 ? _v[num] : _vs[num-6]; }
virtual int getNumEdgeVertices() const { return 9*(_order-1); } virtual int getNumEdgeVertices() const { return 9*(_order-1); }
virtual int getNumFaceVertices() const { int n = _order-1; return n*((n-1)+3*n); } virtual int getNumFaceVertices() const
virtual int getNumVolumeVertices() const { int n = _order-1; return _vs.size()-n*(9+(n-1)+3*n); } {
if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
return 0;
else
int n = _order-1; return (n-1 + 3*n) * n;
}
virtual int getNumVolumeVertices() const
{
if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
return 0;
else
int n = _order-1; return n * (n * (n+1) / 2);
}
virtual int getNumEdgesRep(); virtual int getNumEdgesRep();
virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n); virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n);
virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
...@@ -433,35 +445,35 @@ class MPrismN : public MPrism { ...@@ -433,35 +445,35 @@ class MPrismN : public MPrism {
return MSH_PRI_6; return MSH_PRI_6;
case 2: case 2:
if (_vs.size() == 12) return MSH_PRI_18; if (_vs.size() == 12) return MSH_PRI_18;
else if (_vs.size() == 9) return MSH_PRI_15; if (_vs.size() == 9) return MSH_PRI_15;
break; break;
case 3: case 3:
if (_vs.size() == 34) return MSH_PRI_40; if (_vs.size() == 34) return MSH_PRI_40;
else if (_vs.size() == 18) return MSH_PRI_24; if (_vs.size() == 18) return MSH_PRI_24;
break; break;
case 4: case 4:
if (_vs.size() == 69) return MSH_PRI_75; if (_vs.size() == 69) return MSH_PRI_75;
else if (_vs.size() == 27) return MSH_PRI_33; if (_vs.size() == 27) return MSH_PRI_33;
break; break;
case 5: case 5:
if (_vs.size() == 120) return MSH_PRI_126; if (_vs.size() == 120) return MSH_PRI_126;
else if (_vs.size() == 36) return MSH_PRI_42; if (_vs.size() == 36) return MSH_PRI_42;
break; break;
case 6: case 6:
if (_vs.size() == 190) return MSH_PRI_196; if (_vs.size() == 190) return MSH_PRI_196;
else if (_vs.size() == 45) return MSH_PRI_51; if (_vs.size() == 45) return MSH_PRI_51;
break; break;
case 7: case 7:
if (_vs.size() == 282) return MSH_PRI_288; if (_vs.size() == 282) return MSH_PRI_288;
else if (_vs.size() == 54) return MSH_PRI_60; if (_vs.size() == 54) return MSH_PRI_60;
break; break;
case 8: case 8:
if (_vs.size() == 399) return MSH_PRI_405; if (_vs.size() == 399) return MSH_PRI_405;
else if (_vs.size() == 63) return MSH_PRI_69; if (_vs.size() == 63) return MSH_PRI_69;
break; break;
case 9: case 9:
if (_vs.size() == 544) return MSH_PRI_550; if (_vs.size() == 544) return MSH_PRI_550;
else if (_vs.size() == 72) return MSH_PRI_78; if (_vs.size() == 72) return MSH_PRI_78;
break; break;
} }
Msg::Error("No tag matches a p%d prism with %d vertices", _order, 6+_vs.size()); Msg::Error("No tag matches a p%d prism with %d vertices", _order, 6+_vs.size());
......
...@@ -251,7 +251,10 @@ class MPyramidN : public MPyramid { ...@@ -251,7 +251,10 @@ class MPyramidN : public MPyramid {
virtual int getNumEdgeVertices() const { return 8 * (_order - 1); } virtual int getNumEdgeVertices() const { return 8 * (_order - 1); }
virtual int getNumFaceVertices() const virtual int getNumFaceVertices() const
{ {
return (_order-1)*(_order-1) + 4 * ((_order - 1) * (_order - 2)) / 2; if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
return 0;
else
return (_order-1)*(_order-1) + 4 * ((_order - 1) * (_order - 2)) / 2;
} }
virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
{ {
...@@ -279,16 +282,10 @@ class MPyramidN : public MPyramid { ...@@ -279,16 +282,10 @@ class MPyramidN : public MPyramid {
} }
virtual int getNumVolumeVertices() const virtual int getNumVolumeVertices() const
{ {
switch(getTypeForMSH()){ if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
case MSH_PYR_30 : return 1; return 0;
case MSH_PYR_55 : return 5; else
case MSH_PYR_91 : return 14; return (_order-2) * ((_order-2)+1) * (2*(_order-2)+1) / 6;
case MSH_PYR_140 : return 30;
case MSH_PYR_204 : return 55;
case MSH_PYR_285 : return 91;
case MSH_PYR_385 : return 140;
default : return 0;
}
} }
virtual int getTypeForMSH() const virtual int getTypeForMSH() const
{ {
......
...@@ -375,10 +375,10 @@ class MQuadrangleN : public MQuadrangle { ...@@ -375,10 +375,10 @@ class MQuadrangleN : public MQuadrangle {
virtual const MVertex *getVertex(int num) const{ return num < 4 ? _v[num] : _vs[num - 4]; } virtual const MVertex *getVertex(int num) const{ return num < 4 ? _v[num] : _vs[num - 4]; }
virtual int getNumFaceVertices() const virtual int getNumFaceVertices() const
{ {
if(_order > 1 && (int)_vs.size() + 4 == (_order + 1) * (_order + 1)) if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
return (_order - 1) * (_order - 1);
else
return 0; return 0;
else
return (_order - 1) * (_order - 1);
} }
virtual int getNumEdgeVertices() const { return 4 * (_order - 1); } virtual int getNumEdgeVertices() const { return 4 * (_order - 1); }
virtual int getNumEdgesRep(); virtual int getNumEdgesRep();
......
...@@ -334,7 +334,10 @@ class MTetrahedronN : public MTetrahedron { ...@@ -334,7 +334,10 @@ class MTetrahedronN : public MTetrahedron {
virtual int getNumEdgeVertices() const { return 6 * (_order - 1); } virtual int getNumEdgeVertices() const { return 6 * (_order - 1); }
virtual int getNumFaceVertices() const virtual int getNumFaceVertices() const
{ {
return 4 * ((_order - 1) * (_order - 2)) / 2; if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
return 0;
else
return 4 * ((_order - 1) * (_order - 2)) / 2;
} }
virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
{ {
...@@ -370,16 +373,10 @@ class MTetrahedronN : public MTetrahedron { ...@@ -370,16 +373,10 @@ class MTetrahedronN : public MTetrahedron {
} }
virtual int getNumVolumeVertices() const virtual int getNumVolumeVertices() const
{ {
switch(getTypeForMSH()){ if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
case MSH_TET_35 : return 1; return 0;
case MSH_TET_56 : return 4; else
case MSH_TET_84 : return 10; return ((_order - 1) * (_order - 2) * (_order - 3)) / 6;
case MSH_TET_120 : return 20;
case MSH_TET_165 : return 35;
case MSH_TET_220 : return 56;
case MSH_TET_286 : return 84;
default : return 0;
}
} }
virtual int getTypeForMSH() const virtual int getTypeForMSH() const
{ {
......
...@@ -279,23 +279,10 @@ class MTriangleN : public MTriangle { ...@@ -279,23 +279,10 @@ class MTriangleN : public MTriangle {
virtual const MVertex *getVertex(int num) const { return num < 3 ? _v[num] : _vs[num - 3]; } virtual const MVertex *getVertex(int num) const { return num < 3 ? _v[num] : _vs[num - 3]; }
virtual int getNumFaceVertices() const virtual int getNumFaceVertices() const
{ {
if(_order == 3 && _vs.size() == 6) return 0; if (ElementType::SerendipityFromTag(getTypeForMSH()) > 0)
if(_order == 3 && _vs.size() == 7) return 1; return 0;
if(_order == 4 && _vs.size() == 9) return 0; else
if(_order == 4 && _vs.size() == 12) return 3; return (_order - 1) * (_order - 2) / 2;
if(_order == 5 && _vs.size() == 12) return 0;
if(_order == 5 && _vs.size() == 18) return 6;
if(_order == 6 && _vs.size() == 25) return 10;
if(_order == 7 && _vs.size() == 33) return 12;
if(_order == 8 && _vs.size() == 42) return 15;
if(_order == 9 && _vs.size() == 52) return 21;
if(_order == 10 && _vs.size() == 63) return 28;
if(_order == 6 && _vs.size() == 15) return 0;
if(_order == 7 && _vs.size() == 18) return 0;
if(_order == 8 && _vs.size() == 21) return 0;
if(_order == 9 && _vs.size() == 24) return 0;
if(_order == 10 && _vs.size() == 27) return 0;
return 0;
} }
virtual void xyz2uvw(double xyz[3], double uvw[3]) const { MElement::xyz2uvw(xyz, uvw); } virtual void xyz2uvw(double xyz[3], double uvw[3]) const { MElement::xyz2uvw(xyz, uvw); }
virtual int getNumEdgeVertices() const { return 3 * (_order - 1); } virtual int getNumEdgeVertices() const { return 3 * (_order - 1); }
......
...@@ -322,6 +322,9 @@ int ElementType::DimensionFromTag(int tag) ...@@ -322,6 +322,9 @@ int ElementType::DimensionFromTag(int tag)
} }
} }
// Gives > 0 if element tag is in Serendipity Family.
// Gives < 2 if element tag is in 'Normal' Family.
// 1 is for element that is either Serendipity or not !
int ElementType::SerendipityFromTag(int tag) int ElementType::SerendipityFromTag(int tag)
{ {
switch (tag) { switch (tag) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment