diff --git a/Common/GmshDefines.h b/Common/GmshDefines.h index 9742f84b15e1f4e75d9c878887f81224fe00d8dc..3b7c867589707f552a6329140ec729e38a5a2e99 100644 --- a/Common/GmshDefines.h +++ b/Common/GmshDefines.h @@ -209,8 +209,9 @@ #define MSH_TRI_SUB 135 #define MSH_TET_SUB 136 #define MSH_TET_16 137 +#define MSH_TRI_MINI 138 -#define MSH_NUM_TYPE 137 +#define MSH_NUM_TYPE 138 // Geometric entities #define ENT_NONE 0 diff --git a/Numeric/BasisFactory.cpp b/Numeric/BasisFactory.cpp index 96f51530117c1f88b6997d54ba73923cf34b87b9..356fdec336895600f244742ec6e725891b9282d4 100644 --- a/Numeric/BasisFactory.cpp +++ b/Numeric/BasisFactory.cpp @@ -5,6 +5,7 @@ #include "GmshDefines.h" #include "GmshMessage.h" +#include "miniBasis.h" #include "polynomialBasis.h" #include "pyramidalBasis.h" #include "pointsGenerators.h" @@ -25,25 +26,29 @@ const nodalBasis* BasisFactory::getNodalBasis(int tag) } // Get the parent type to see which kind of basis // we want to create - int parentType = ElementType::ParentTypeFromTag(tag); nodalBasis* F = NULL; - - switch(parentType) { - case(TYPE_PNT): - case(TYPE_LIN): - case(TYPE_TRI): - case(TYPE_QUA): - case(TYPE_PRI): - case(TYPE_TET): - case(TYPE_HEX): - F = new polynomialBasis(tag); - break; - case(TYPE_PYR): - F = new pyramidalBasis(tag); - break; - default: - Msg::Error("Unknown type of element %d (in BasisFactory)", tag); - return NULL; + if (tag == MSH_TRI_MINI) { + F = new miniBasis(); + } + else { + int parentType = ElementType::ParentTypeFromTag(tag); + switch(parentType) { + case(TYPE_PNT): + case(TYPE_LIN): + case(TYPE_TRI): + case(TYPE_QUA): + case(TYPE_PRI): + case(TYPE_TET): + case(TYPE_HEX): + F = new polynomialBasis(tag); + break; + case(TYPE_PYR): + F = new pyramidalBasis(tag); + break; + default: + Msg::Error("Unknown type of element %d (in BasisFactory)", tag); + return NULL; + } } std::pair<std::map<int, nodalBasis*>::const_iterator, bool> inserted; diff --git a/Numeric/CMakeLists.txt b/Numeric/CMakeLists.txt index d7a0f85162762cad918498d8e384a620a25851f9..6977d241ce9dd39049daa8520bd2c5b991d52323 100644 --- a/Numeric/CMakeLists.txt +++ b/Numeric/CMakeLists.txt @@ -8,6 +8,7 @@ set(SRC fullMatrix.cpp BasisFactory.cpp discreteFrechetDistance.cpp + miniBasis.cpp nodalBasis.cpp polynomialBasis.cpp pyramidalBasis.cpp diff --git a/Numeric/miniBasis.cpp b/Numeric/miniBasis.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b893ebc0c2830ae39f8adbc364061aee015a0462 --- /dev/null +++ b/Numeric/miniBasis.cpp @@ -0,0 +1,37 @@ +#include "miniBasis.h" +#include "BasisFactory.h" +miniBasis::miniBasis() +{ + type = MSH_TRI_MINI; + parentType = TYPE_TRI; + order = 3; + dimension = 2; + numFaces = 3; + serendip = false; + const nodalBasis &p1 = *BasisFactory::getNodalBasis(MSH_TRI_3); + closures = p1.closures; + fullClosures = p1.fullClosures; + for(size_t i = 0; i < fullClosures.size(); ++i) { + fullClosures[i].push_back(3); + } + closureRef = p1.closureRef; + points = p1.points; + points.resize(4, 2); + points(0, 0) = 0.; points(0, 1) = 0.; + points(1, 0) = 1.; points(1, 1) = 0.; + points(2, 0) = 0.; points(2, 1) = 1.; + points(3, 0) = 1./3; points(3, 1) = 1./3; + monomials.resize(6, 2); + monomials(0, 0) = 0.; monomials(0, 1) = 0.; + monomials(1, 0) = 1.; monomials(1, 1) = 0.; + monomials(2, 0) = 0.; monomials(2, 1) = 1.; + monomials(3, 0) = 1.; monomials(3, 1) = 1.; + monomials(4, 0) = 2.; monomials(4, 1) = 1.; + monomials(5, 0) = 1.; monomials(5, 1) = 2.; + coefficients.resize(4, 6); + coefficients.setAll(0.); + coefficients(0, 0) = 1.; coefficients(0, 1) = -1.; coefficients(0, 2) = -1.; + coefficients(1, 1) = 1.; + coefficients(2, 2) = 1.; + coefficients(3, 3) = 1.; coefficients(3, 4) = -1.; coefficients(3, 5) = -1.; +} diff --git a/Numeric/miniBasis.h b/Numeric/miniBasis.h new file mode 100644 index 0000000000000000000000000000000000000000..631980ab31cdc26ee008b173c45d6dd4f87ae961 --- /dev/null +++ b/Numeric/miniBasis.h @@ -0,0 +1,8 @@ +#ifndef _MINI_BASIS_H_ +#define _MINI_BASIS_H_ +#include "polynomialBasis.h" +class miniBasis : public polynomialBasis { // mini is NOT a real nodal basis but in GMSH, only the nodal basis have closure and mini have closure so... + public: + miniBasis(); +}; +#endif diff --git a/Numeric/nodalBasis.h b/Numeric/nodalBasis.h index e35f948e093dbf0619ae76b71862203e1ec6309c..25b855610bed3fc6936c55dd3105fe176f06c29f 100644 --- a/Numeric/nodalBasis.h +++ b/Numeric/nodalBasis.h @@ -15,6 +15,7 @@ class nodalBasis { bool serendip; fullMatrix<double> points; + nodalBasis() {}; nodalBasis(int tag); virtual ~nodalBasis() {} diff --git a/Numeric/polynomialBasis.h b/Numeric/polynomialBasis.h index 3ecc83619a20b23ed6e2a46c61d143be95eaa1e4..ef60d077d9b6f6eb18a08144bab4116487ea3d0d 100644 --- a/Numeric/polynomialBasis.h +++ b/Numeric/polynomialBasis.h @@ -79,6 +79,7 @@ class polynomialBasis : public nodalBasis fullMatrix<double> monomials; fullMatrix<double> coefficients; + polynomialBasis() {}; polynomialBasis(int tag); ~polynomialBasis();