Skip to content
Snippets Groups Projects
Commit 8c789710 authored by Tom Fischer's avatar Tom Fischer
Browse files

added (1) FEMElemType to elements as template parameter, (2) method...

added (1) FEMElemType to elements as template parameter, (2) method getFEMType() and (3) an enum for FEM element types
parent 9bb17731
No related branches found
No related tags found
No related merge requests found
Showing
with 219 additions and 162 deletions
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace MeshLib { namespace MeshLib {
typedef TemplateEdge<2> Edge; typedef TemplateEdge<2,FEMElemType::EDGE2> Edge;
} }
......
...@@ -113,9 +113,17 @@ public: ...@@ -113,9 +113,17 @@ public:
*/ */
unsigned getNodeIndex(unsigned i) const; unsigned getNodeIndex(unsigned i) const;
/// Get the type of the mesh element (as a MshElemType-enum). /**
* Get the type of the mesh element in geometric context (as a MshElemType-enum).
*/
virtual MshElemType::type getGeoType() const = 0; virtual MshElemType::type getGeoType() const = 0;
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const = 0;
/// Get the value for this element. /// Get the value for this element.
unsigned getValue() const { return _value; }; unsigned getValue() const { return _value; };
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "TemplateHex.h" #include "TemplateHex.h"
namespace MeshLib { namespace MeshLib {
typedef TemplateHex<8> Hex; typedef TemplateHex<8, FEMElemType::HEX8> Hex;
} }
#endif /* HEX_H_ */ #endif /* HEX_H_ */
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace MeshLib { namespace MeshLib {
typedef TemplatePrism<6> Prism; typedef TemplatePrism<6, FEMElemType::PRISM6> Prism;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace MeshLib { namespace MeshLib {
typedef TemplatePyramid<5> Pyramid; typedef TemplatePyramid<5,FEMElemType::PYRAMID5> Pyramid;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace MeshLib { namespace MeshLib {
typedef TemplateQuad<4> Quad; typedef TemplateQuad<4,FEMElemType::QUAD4> Quad;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <limits> #include <limits>
#include "MshEnums.h"
#include "Element.h" #include "Element.h"
#include "Node.h" #include "Node.h"
...@@ -29,7 +30,7 @@ namespace MeshLib { ...@@ -29,7 +30,7 @@ namespace MeshLib {
* 0--------1 * 0--------1
* @endcode * @endcode
*/ */
template <unsigned NNODES> template<unsigned NNODES, FEMElemType::type FEMEDGETYPE>
class TemplateEdge : public Element class TemplateEdge : public Element
{ {
public: public:
...@@ -37,7 +38,7 @@ public: ...@@ -37,7 +38,7 @@ public:
TemplateEdge(Node* nodes[NNODES], unsigned value = 0); TemplateEdge(Node* nodes[NNODES], unsigned value = 0);
/// Copy constructor /// Copy constructor
TemplateEdge(const TemplateEdge<NNODES> &edge); TemplateEdge(const TemplateEdge &edge);
/// Destructor /// Destructor
virtual ~TemplateEdge(); virtual ~TemplateEdge();
...@@ -84,6 +85,12 @@ public: ...@@ -84,6 +85,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::EDGE; } virtual MshElemType::type getGeoType() const { return MshElemType::EDGE; }
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const { return FEMEDGETYPE; }
/// Returns true if these two indices form an edge and false otherwise /// Returns true if these two indices form an edge and false otherwise
bool isEdge(unsigned idx1, unsigned idx2) const bool isEdge(unsigned idx1, unsigned idx2) const
{ {
...@@ -94,7 +101,7 @@ public: ...@@ -94,7 +101,7 @@ public:
virtual Element* clone() const virtual Element* clone() const
{ {
return new TemplateEdge<NNODES>(*this); return new TemplateEdge<NNODES,FEMEDGETYPE>(*this);
} }
/** /**
......
...@@ -11,16 +11,16 @@ ...@@ -11,16 +11,16 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMEDGETYPE>
TemplateEdge<NNODES>::TemplateEdge(Node* nodes[NNODES], unsigned value) : TemplateEdge<NNODES,FEMEDGETYPE>::TemplateEdge(Node* nodes[NNODES], unsigned value) :
Element(value) Element(value)
{ {
_nodes = nodes; _nodes = nodes;
this->_length = this->computeVolume(); this->_length = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMEDGETYPE>
TemplateEdge<NNODES>::TemplateEdge(const TemplateEdge<NNODES> &edge) : TemplateEdge<NNODES,FEMEDGETYPE>::TemplateEdge(const TemplateEdge<NNODES,FEMEDGETYPE> &edge) :
Element(edge.getValue()) Element(edge.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -29,8 +29,8 @@ TemplateEdge<NNODES>::TemplateEdge(const TemplateEdge<NNODES> &edge) : ...@@ -29,8 +29,8 @@ TemplateEdge<NNODES>::TemplateEdge(const TemplateEdge<NNODES> &edge) :
_length = edge.getLength(); _length = edge.getLength();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMEDGETYPE>
TemplateEdge<NNODES>::~TemplateEdge() TemplateEdge<NNODES,FEMEDGETYPE>::~TemplateEdge()
{} {}
} // namespace MeshLib } // namespace MeshLib
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#ifndef TEMPLATEHEX_H_ #ifndef TEMPLATEHEX_H_
#define TEMPLATEHEX_H_ #define TEMPLATEHEX_H_
#include "MshEnums.h"
#include "Cell.h" #include "Cell.h"
namespace MeshLib { namespace MeshLib {
...@@ -42,15 +43,15 @@ namespace MeshLib { ...@@ -42,15 +43,15 @@ namespace MeshLib {
* *
* @endcode * @endcode
*/ */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
class TemplateHex : public Cell class TemplateHex : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes. /// Constructor with an array of mesh nodes.
TemplateHex(Node* nodes[8], unsigned value = 0); TemplateHex(Node* nodes[NNODES], unsigned value = 0);
/// Copy constructor /// Copy constructor
TemplateHex(const TemplateHex<NNODES> &hex); TemplateHex(const TemplateHex &hex);
/// Destructor /// Destructor
virtual ~TemplateHex(); virtual ~TemplateHex();
...@@ -82,6 +83,12 @@ public: ...@@ -82,6 +83,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::HEXAHEDRON; } virtual MshElemType::type getGeoType() const { return MshElemType::HEXAHEDRON; }
/**
* Method returns the FEM type of the element.
* @return
*/
virtual FEMElemType::type getFEMType() const { return FEMHEXTYPE; }
/// Returns true if these two indices form an edge and false otherwise /// Returns true if these two indices form an edge and false otherwise
bool isEdge(unsigned i, unsigned j) const; bool isEdge(unsigned i, unsigned j) const;
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
const unsigned TemplateHex<NNODES>::_face_nodes[6][4] = const unsigned TemplateHex<NNODES,FEMHEXTYPE>::_face_nodes[6][4] =
{ {
{0, 3, 2, 1}, // Face 0 {0, 3, 2, 1}, // Face 0
{0, 1, 5, 4}, // Face 1 {0, 1, 5, 4}, // Face 1
...@@ -29,8 +29,8 @@ const unsigned TemplateHex<NNODES>::_face_nodes[6][4] = ...@@ -29,8 +29,8 @@ const unsigned TemplateHex<NNODES>::_face_nodes[6][4] =
{4, 5, 6, 7} // Face 5 {4, 5, 6, 7} // Face 5
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
const unsigned TemplateHex<NNODES>::_edge_nodes[12][2] = const unsigned TemplateHex<NNODES,FEMHEXTYPE>::_edge_nodes[12][2] =
{ {
{0, 1}, // Edge 0 {0, 1}, // Edge 0
{1, 2}, // Edge 1 {1, 2}, // Edge 1
...@@ -46,8 +46,8 @@ const unsigned TemplateHex<NNODES>::_edge_nodes[12][2] = ...@@ -46,8 +46,8 @@ const unsigned TemplateHex<NNODES>::_edge_nodes[12][2] =
{4, 7} // Edge 11 {4, 7} // Edge 11
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
TemplateHex<NNODES>::TemplateHex(Node* nodes[8], unsigned value) TemplateHex<NNODES,FEMHEXTYPE>::TemplateHex(Node* nodes[8], unsigned value)
: Cell(value) : Cell(value)
{ {
_nodes = nodes; _nodes = nodes;
...@@ -59,8 +59,8 @@ TemplateHex<NNODES>::TemplateHex(Node* nodes[8], unsigned value) ...@@ -59,8 +59,8 @@ TemplateHex<NNODES>::TemplateHex(Node* nodes[8], unsigned value)
this->_volume = this->computeVolume(); this->_volume = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
TemplateHex<NNODES>::TemplateHex(const TemplateHex<NNODES> &hex) TemplateHex<NNODES,FEMHEXTYPE>::TemplateHex(const TemplateHex<NNODES,FEMHEXTYPE> &hex)
: Cell(hex.getValue()) : Cell(hex.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -74,13 +74,13 @@ TemplateHex<NNODES>::TemplateHex(const TemplateHex<NNODES> &hex) ...@@ -74,13 +74,13 @@ TemplateHex<NNODES>::TemplateHex(const TemplateHex<NNODES> &hex)
_volume = hex.getVolume(); _volume = hex.getVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
TemplateHex<NNODES>::~TemplateHex() TemplateHex<NNODES,FEMHEXTYPE>::~TemplateHex()
{ {
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
double TemplateHex<NNODES>::computeVolume() double TemplateHex<NNODES,FEMHEXTYPE>::computeVolume()
{ {
return MathLib::calcTetrahedronVolume(_nodes[4]->getCoords(), _nodes[7]->getCoords(), _nodes[5]->getCoords(), _nodes[0]->getCoords()) return MathLib::calcTetrahedronVolume(_nodes[4]->getCoords(), _nodes[7]->getCoords(), _nodes[5]->getCoords(), _nodes[0]->getCoords())
+ MathLib::calcTetrahedronVolume(_nodes[5]->getCoords(), _nodes[3]->getCoords(), _nodes[1]->getCoords(), _nodes[0]->getCoords()) + MathLib::calcTetrahedronVolume(_nodes[5]->getCoords(), _nodes[3]->getCoords(), _nodes[1]->getCoords(), _nodes[0]->getCoords())
...@@ -90,8 +90,8 @@ double TemplateHex<NNODES>::computeVolume() ...@@ -90,8 +90,8 @@ double TemplateHex<NNODES>::computeVolume()
+ MathLib::calcTetrahedronVolume(_nodes[3]->getCoords(), _nodes[7]->getCoords(), _nodes[5]->getCoords(), _nodes[2]->getCoords()); + MathLib::calcTetrahedronVolume(_nodes[3]->getCoords(), _nodes[7]->getCoords(), _nodes[5]->getCoords(), _nodes[2]->getCoords());
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
const Element* TemplateHex<NNODES>::getFace(unsigned i) const const Element* TemplateHex<NNODES,FEMHEXTYPE>::getFace(unsigned i) const
{ {
if (i<this->getNFaces()) if (i<this->getNFaces())
{ {
...@@ -105,8 +105,8 @@ const Element* TemplateHex<NNODES>::getFace(unsigned i) const ...@@ -105,8 +105,8 @@ const Element* TemplateHex<NNODES>::getFace(unsigned i) const
return NULL; return NULL;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
bool TemplateHex<NNODES>::isEdge(unsigned idx1, unsigned idx2) const bool TemplateHex<NNODES,FEMHEXTYPE>::isEdge(unsigned idx1, unsigned idx2) const
{ {
for (unsigned i(0); i<12; i++) for (unsigned i(0); i<12; i++)
{ {
...@@ -116,14 +116,14 @@ bool TemplateHex<NNODES>::isEdge(unsigned idx1, unsigned idx2) const ...@@ -116,14 +116,14 @@ bool TemplateHex<NNODES>::isEdge(unsigned idx1, unsigned idx2) const
return false; return false;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
Element* TemplateHex<NNODES>::clone() const Element* TemplateHex<NNODES,FEMHEXTYPE>::clone() const
{ {
return new TemplateHex<NNODES>(*this); return new TemplateHex<NNODES,FEMHEXTYPE>(*this);
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
unsigned TemplateHex<NNODES>::identifyFace(Node* nodes[3]) const unsigned TemplateHex<NNODES,FEMHEXTYPE>::identifyFace(Node* nodes[3]) const
{ {
for (unsigned i=0; i<6; i++) for (unsigned i=0; i<6; i++)
{ {
...@@ -138,8 +138,8 @@ unsigned TemplateHex<NNODES>::identifyFace(Node* nodes[3]) const ...@@ -138,8 +138,8 @@ unsigned TemplateHex<NNODES>::identifyFace(Node* nodes[3]) const
return std::numeric_limits<unsigned>::max(); return std::numeric_limits<unsigned>::max();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMHEXTYPE>
Element* TemplateHex<NNODES>::reviseElement() const Element* TemplateHex<NNODES,FEMHEXTYPE>::reviseElement() const
{ {
std::vector<size_t> collapsed_edges; std::vector<size_t> collapsed_edges;
for (size_t edge(0); edge<getNEdges(); edge++) { for (size_t edge(0); edge<getNEdges(); edge++) {
...@@ -149,7 +149,7 @@ Element* TemplateHex<NNODES>::reviseElement() const ...@@ -149,7 +149,7 @@ Element* TemplateHex<NNODES>::reviseElement() const
} }
if (collapsed_edges.size() == 1) { if (collapsed_edges.size() == 1) {
std::cerr << "[TemplateHex<NNODES>::reviseElement()] collapsing of one edge in hexahedron not handled" << std::endl; std::cerr << "[TemplateHex<NNODES,FEMHEXTYPE>::reviseElement()] collapsing of one edge in hexahedron not handled" << std::endl;
return NULL; return NULL;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#ifndef TEMPLATEPRISM_H_ #ifndef TEMPLATEPRISM_H_
#define TEMPLATEPRISM_H_ #define TEMPLATEPRISM_H_
#include "MshEnums.h"
#include "Cell.h" #include "Cell.h"
namespace MeshLib { namespace MeshLib {
...@@ -40,7 +41,7 @@ namespace MeshLib { ...@@ -40,7 +41,7 @@ namespace MeshLib {
* *
* @endcode * @endcode
*/ */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
class TemplatePrism : public Cell class TemplatePrism : public Cell
{ {
public: public:
...@@ -48,7 +49,7 @@ public: ...@@ -48,7 +49,7 @@ public:
TemplatePrism(Node* nodes[6], unsigned value = 0); TemplatePrism(Node* nodes[6], unsigned value = 0);
/// Copy constructor /// Copy constructor
TemplatePrism(const TemplatePrism<NNODES> &prism); TemplatePrism(const TemplatePrism &prism);
/// Destructor /// Destructor
virtual ~TemplatePrism(); virtual ~TemplatePrism();
...@@ -80,6 +81,12 @@ public: ...@@ -80,6 +81,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::PRISM; } virtual MshElemType::type getGeoType() const { return MshElemType::PRISM; }
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const { return FEMPRISMTYPE; };
/// Returns true if these two indeces form an edge and false otherwise /// Returns true if these two indeces form an edge and false otherwise
bool isEdge(unsigned i, unsigned j) const; bool isEdge(unsigned i, unsigned j) const;
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
const unsigned TemplatePrism<NNODES>::_face_nodes[5][4] = const unsigned TemplatePrism<NNODES,FEMPRISMTYPE>::_face_nodes[5][4] =
{ {
{0, 2, 1, 99}, // Face 0 {0, 2, 1, 99}, // Face 0
{0, 1, 4, 3}, // Face 1 {0, 1, 4, 3}, // Face 1
...@@ -29,8 +29,8 @@ const unsigned TemplatePrism<NNODES>::_face_nodes[5][4] = ...@@ -29,8 +29,8 @@ const unsigned TemplatePrism<NNODES>::_face_nodes[5][4] =
{3, 4, 5, 99} // Face 4 {3, 4, 5, 99} // Face 4
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
const unsigned TemplatePrism<NNODES>::_edge_nodes[9][2] = const unsigned TemplatePrism<NNODES,FEMPRISMTYPE>::_edge_nodes[9][2] =
{ {
{0, 1}, // Edge 0 {0, 1}, // Edge 0
{1, 2}, // Edge 1 {1, 2}, // Edge 1
...@@ -43,11 +43,11 @@ const unsigned TemplatePrism<NNODES>::_edge_nodes[9][2] = ...@@ -43,11 +43,11 @@ const unsigned TemplatePrism<NNODES>::_edge_nodes[9][2] =
{3, 5} // Edge 8 {3, 5} // Edge 8
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
const unsigned TemplatePrism<NNODES>::_n_face_nodes[5] = { 3, 4, 4, 4, 3 }; const unsigned TemplatePrism<NNODES,FEMPRISMTYPE>::_n_face_nodes[5] = { 3, 4, 4, 4, 3 };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
TemplatePrism<NNODES>::TemplatePrism(Node* nodes[6], unsigned value) TemplatePrism<NNODES,FEMPRISMTYPE>::TemplatePrism(Node* nodes[6], unsigned value)
: Cell(value) : Cell(value)
{ {
_nodes = nodes; _nodes = nodes;
...@@ -57,8 +57,8 @@ TemplatePrism<NNODES>::TemplatePrism(Node* nodes[6], unsigned value) ...@@ -57,8 +57,8 @@ TemplatePrism<NNODES>::TemplatePrism(Node* nodes[6], unsigned value)
this->_volume = this->computeVolume(); this->_volume = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
TemplatePrism<NNODES>::TemplatePrism(const TemplatePrism<NNODES> &prism) TemplatePrism<NNODES,FEMPRISMTYPE>::TemplatePrism(const TemplatePrism<NNODES,FEMPRISMTYPE> &prism)
: Cell(prism.getValue()) : Cell(prism.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -72,21 +72,21 @@ TemplatePrism<NNODES>::TemplatePrism(const TemplatePrism<NNODES> &prism) ...@@ -72,21 +72,21 @@ TemplatePrism<NNODES>::TemplatePrism(const TemplatePrism<NNODES> &prism)
_volume = prism.getVolume(); _volume = prism.getVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
TemplatePrism<NNODES>::~TemplatePrism() TemplatePrism<NNODES,FEMPRISMTYPE>::~TemplatePrism()
{ {
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
double TemplatePrism<NNODES>::computeVolume() double TemplatePrism<NNODES,FEMPRISMTYPE>::computeVolume()
{ {
return MathLib::calcTetrahedronVolume(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords(), _nodes[3]->getCoords()) return MathLib::calcTetrahedronVolume(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords(), _nodes[3]->getCoords())
+ MathLib::calcTetrahedronVolume(_nodes[1]->getCoords(), _nodes[4]->getCoords(), _nodes[2]->getCoords(), _nodes[3]->getCoords()) + MathLib::calcTetrahedronVolume(_nodes[1]->getCoords(), _nodes[4]->getCoords(), _nodes[2]->getCoords(), _nodes[3]->getCoords())
+ MathLib::calcTetrahedronVolume(_nodes[2]->getCoords(), _nodes[4]->getCoords(), _nodes[5]->getCoords(), _nodes[3]->getCoords()); + MathLib::calcTetrahedronVolume(_nodes[2]->getCoords(), _nodes[4]->getCoords(), _nodes[5]->getCoords(), _nodes[3]->getCoords());
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
const Element* TemplatePrism<NNODES>::getFace(unsigned i) const const Element* TemplatePrism<NNODES,FEMPRISMTYPE>::getFace(unsigned i) const
{ {
if (i<this->getNFaces()) if (i<this->getNFaces())
{ {
...@@ -104,8 +104,8 @@ const Element* TemplatePrism<NNODES>::getFace(unsigned i) const ...@@ -104,8 +104,8 @@ const Element* TemplatePrism<NNODES>::getFace(unsigned i) const
return NULL; return NULL;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
unsigned TemplatePrism<NNODES>::getNFaceNodes(unsigned i) const unsigned TemplatePrism<NNODES,FEMPRISMTYPE>::getNFaceNodes(unsigned i) const
{ {
if (i<5) if (i<5)
return _n_face_nodes[i]; return _n_face_nodes[i];
...@@ -113,8 +113,8 @@ unsigned TemplatePrism<NNODES>::getNFaceNodes(unsigned i) const ...@@ -113,8 +113,8 @@ unsigned TemplatePrism<NNODES>::getNFaceNodes(unsigned i) const
return 0; return 0;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
bool TemplatePrism<NNODES>::isEdge(unsigned idx1, unsigned idx2) const bool TemplatePrism<NNODES,FEMPRISMTYPE>::isEdge(unsigned idx1, unsigned idx2) const
{ {
for (unsigned i(0); i<9; i++) for (unsigned i(0); i<9; i++)
{ {
...@@ -124,14 +124,14 @@ bool TemplatePrism<NNODES>::isEdge(unsigned idx1, unsigned idx2) const ...@@ -124,14 +124,14 @@ bool TemplatePrism<NNODES>::isEdge(unsigned idx1, unsigned idx2) const
return false; return false;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
Element* TemplatePrism<NNODES>::clone() const Element* TemplatePrism<NNODES,FEMPRISMTYPE>::clone() const
{ {
return new TemplatePrism<NNODES>(*this); return new TemplatePrism<NNODES,FEMPRISMTYPE>(*this);
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
unsigned TemplatePrism<NNODES>::identifyFace(Node* nodes[3]) const unsigned TemplatePrism<NNODES,FEMPRISMTYPE>::identifyFace(Node* nodes[3]) const
{ {
for (unsigned i=0; i<5; i++) for (unsigned i=0; i<5; i++)
{ {
...@@ -146,8 +146,8 @@ unsigned TemplatePrism<NNODES>::identifyFace(Node* nodes[3]) const ...@@ -146,8 +146,8 @@ unsigned TemplatePrism<NNODES>::identifyFace(Node* nodes[3]) const
return std::numeric_limits<unsigned>::max(); return std::numeric_limits<unsigned>::max();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPRISMTYPE>
Element* TemplatePrism<NNODES>::reviseElement() const Element* TemplatePrism<NNODES,FEMPRISMTYPE>::reviseElement() const
{ {
// try to create Pyramid // try to create Pyramid
if (_nodes[_edge_nodes[3][0]] == _nodes[_edge_nodes[3][1]]) { if (_nodes[_edge_nodes[3][0]] == _nodes[_edge_nodes[3][1]]) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#ifndef TEMPLATEPYRAMID_H_ #ifndef TEMPLATEPYRAMID_H_
#define TEMPLATEPYRAMID_H_ #define TEMPLATEPYRAMID_H_
#include "MshEnums.h"
#include "Cell.h" #include "Cell.h"
namespace MeshLib { namespace MeshLib {
...@@ -38,7 +39,7 @@ namespace MeshLib { ...@@ -38,7 +39,7 @@ namespace MeshLib {
* 0 * 0
* @endcode * @endcode
*/ */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
class TemplatePyramid : public Cell class TemplatePyramid : public Cell
{ {
public: public:
...@@ -46,7 +47,7 @@ public: ...@@ -46,7 +47,7 @@ public:
TemplatePyramid(Node* nodes[NNODES], unsigned value = 0); TemplatePyramid(Node* nodes[NNODES], unsigned value = 0);
/// Copy constructor /// Copy constructor
TemplatePyramid(const TemplatePyramid<NNODES> &pyramid); TemplatePyramid(const TemplatePyramid &pyramid);
/// Destructor /// Destructor
virtual ~TemplatePyramid(); virtual ~TemplatePyramid();
...@@ -78,6 +79,12 @@ public: ...@@ -78,6 +79,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::PYRAMID; } virtual MshElemType::type getGeoType() const { return MshElemType::PYRAMID; }
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const { return FEMPYRAMIDTYPE; }
/// Returns true if these two indeces form an edge and false otherwise /// Returns true if these two indeces form an edge and false otherwise
bool isEdge(unsigned i, unsigned j) const; bool isEdge(unsigned i, unsigned j) const;
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
const unsigned TemplatePyramid<NNODES>::_face_nodes[5][4] = const unsigned TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::_face_nodes[5][4] =
{ {
{0, 1, 4, 99}, // Face 0 {0, 1, 4, 99}, // Face 0
{1, 2, 4, 99}, // Face 1 {1, 2, 4, 99}, // Face 1
...@@ -29,8 +29,8 @@ const unsigned TemplatePyramid<NNODES>::_face_nodes[5][4] = ...@@ -29,8 +29,8 @@ const unsigned TemplatePyramid<NNODES>::_face_nodes[5][4] =
{0, 3, 2, 1} // Face 4 {0, 3, 2, 1} // Face 4
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
const unsigned TemplatePyramid<NNODES>::_edge_nodes[8][2] = const unsigned TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::_edge_nodes[8][2] =
{ {
{0, 1}, // Edge 0 {0, 1}, // Edge 0
{1, 2}, // Edge 1 {1, 2}, // Edge 1
...@@ -42,11 +42,11 @@ const unsigned TemplatePyramid<NNODES>::_edge_nodes[8][2] = ...@@ -42,11 +42,11 @@ const unsigned TemplatePyramid<NNODES>::_edge_nodes[8][2] =
{3, 4} // Edge 7 {3, 4} // Edge 7
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
const unsigned TemplatePyramid<NNODES>::_n_face_nodes[5] = { 3, 3, 3, 3, 4 }; const unsigned TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::_n_face_nodes[5] = { 3, 3, 3, 3, 4 };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
TemplatePyramid<NNODES>::TemplatePyramid(Node* nodes[NNODES], unsigned value) TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::TemplatePyramid(Node* nodes[NNODES], unsigned value)
: Cell(value) : Cell(value)
{ {
_nodes = nodes; _nodes = nodes;
...@@ -58,8 +58,8 @@ TemplatePyramid<NNODES>::TemplatePyramid(Node* nodes[NNODES], unsigned value) ...@@ -58,8 +58,8 @@ TemplatePyramid<NNODES>::TemplatePyramid(Node* nodes[NNODES], unsigned value)
this->_volume = this->computeVolume(); this->_volume = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
TemplatePyramid<NNODES>::TemplatePyramid(const TemplatePyramid<NNODES> &pyramid) TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::TemplatePyramid(const TemplatePyramid<NNODES,FEMPYRAMIDTYPE> &pyramid)
: Cell(pyramid.getValue()) : Cell(pyramid.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -75,20 +75,20 @@ TemplatePyramid<NNODES>::TemplatePyramid(const TemplatePyramid<NNODES> &pyramid) ...@@ -75,20 +75,20 @@ TemplatePyramid<NNODES>::TemplatePyramid(const TemplatePyramid<NNODES> &pyramid)
_volume = pyramid.getVolume(); _volume = pyramid.getVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
TemplatePyramid<NNODES>::~TemplatePyramid() TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::~TemplatePyramid()
{ {
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
double TemplatePyramid<NNODES>::computeVolume() double TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::computeVolume()
{ {
return MathLib::calcTetrahedronVolume(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords(), _nodes[4]->getCoords()) return MathLib::calcTetrahedronVolume(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords(), _nodes[4]->getCoords())
+ MathLib::calcTetrahedronVolume(_nodes[2]->getCoords(), _nodes[3]->getCoords(), _nodes[0]->getCoords(), _nodes[4]->getCoords()); + MathLib::calcTetrahedronVolume(_nodes[2]->getCoords(), _nodes[3]->getCoords(), _nodes[0]->getCoords(), _nodes[4]->getCoords());
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
const Element* TemplatePyramid<NNODES>::getFace(unsigned i) const const Element* TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::getFace(unsigned i) const
{ {
if (i<this->getNFaces()) if (i<this->getNFaces())
{ {
...@@ -106,8 +106,8 @@ const Element* TemplatePyramid<NNODES>::getFace(unsigned i) const ...@@ -106,8 +106,8 @@ const Element* TemplatePyramid<NNODES>::getFace(unsigned i) const
return NULL; return NULL;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
unsigned TemplatePyramid<NNODES>::getNFaceNodes(unsigned i) const unsigned TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::getNFaceNodes(unsigned i) const
{ {
if (i<5) if (i<5)
return _n_face_nodes[i]; return _n_face_nodes[i];
...@@ -115,8 +115,8 @@ unsigned TemplatePyramid<NNODES>::getNFaceNodes(unsigned i) const ...@@ -115,8 +115,8 @@ unsigned TemplatePyramid<NNODES>::getNFaceNodes(unsigned i) const
return 0; return 0;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
bool TemplatePyramid<NNODES>::isEdge(unsigned idx1, unsigned idx2) const bool TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::isEdge(unsigned idx1, unsigned idx2) const
{ {
for (unsigned i(0); i<8; i++) for (unsigned i(0); i<8; i++)
{ {
...@@ -126,14 +126,14 @@ bool TemplatePyramid<NNODES>::isEdge(unsigned idx1, unsigned idx2) const ...@@ -126,14 +126,14 @@ bool TemplatePyramid<NNODES>::isEdge(unsigned idx1, unsigned idx2) const
return false; return false;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
Element* TemplatePyramid<NNODES>::clone() const Element* TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::clone() const
{ {
return new TemplatePyramid<NNODES>(*this); return new TemplatePyramid<NNODES,FEMPYRAMIDTYPE>(*this);
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
unsigned TemplatePyramid<NNODES>::identifyFace(Node* nodes[3]) const unsigned TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::identifyFace(Node* nodes[3]) const
{ {
for (unsigned i=0; i<5; i++) for (unsigned i=0; i<5; i++)
{ {
...@@ -148,8 +148,8 @@ unsigned TemplatePyramid<NNODES>::identifyFace(Node* nodes[3]) const ...@@ -148,8 +148,8 @@ unsigned TemplatePyramid<NNODES>::identifyFace(Node* nodes[3]) const
return std::numeric_limits<unsigned>::max(); return std::numeric_limits<unsigned>::max();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMPYRAMIDTYPE>
Element* TemplatePyramid<NNODES>::reviseElement() const Element* TemplatePyramid<NNODES,FEMPYRAMIDTYPE>::reviseElement() const
{ {
// try to create tetrahedron // try to create tetrahedron
if (_nodes[_edge_nodes[0][0]] == _nodes[_edge_nodes[0][1]] if (_nodes[_edge_nodes[0][0]] == _nodes[_edge_nodes[0][1]]
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* http://www.opengeosys.org/project/license * http://www.opengeosys.org/project/license
* *
* *
* \file Quad.h * \file TemplateQuad.h
* *
* Created on 2012-05-02 by Karsten Rink * Created on 2012-05-02 by Karsten Rink
*/ */
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#ifndef TEMPLATEQUAD_H_ #ifndef TEMPLATEQUAD_H_
#define TEMPLATEQUAD_H_ #define TEMPLATEQUAD_H_
#include "MshEnums.h"
#include "Face.h" #include "Face.h"
namespace MeshLib { namespace MeshLib {
...@@ -32,7 +33,7 @@ namespace MeshLib { ...@@ -32,7 +33,7 @@ namespace MeshLib {
* 0 * 0
* @endcode * @endcode
*/ */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
class TemplateQuad : public Face class TemplateQuad : public Face
{ {
public: public:
...@@ -63,6 +64,12 @@ public: ...@@ -63,6 +64,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::QUAD; } virtual MshElemType::type getGeoType() const { return MshElemType::QUAD; }
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const { return FEMQUADTYPE; }
/// Returns true if these two indeces form an edge and false otherwise /// Returns true if these two indeces form an edge and false otherwise
bool isEdge(unsigned i, unsigned j) const; bool isEdge(unsigned i, unsigned j) const;
...@@ -98,8 +105,8 @@ protected: ...@@ -98,8 +105,8 @@ protected:
}; /* class */ }; /* class */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
const unsigned TemplateQuad<NNODES>::_edge_nodes[4][2] = const unsigned TemplateQuad<NNODES, FEMQUADTYPE>::_edge_nodes[4][2] =
{ {
{0, 1}, // Edge 0 {0, 1}, // Edge 0
{1, 2}, // Edge 1 {1, 2}, // Edge 1
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
TemplateQuad<NNODES>::TemplateQuad(Node* nodes[NNODES], unsigned value) TemplateQuad<NNODES,FEMQUADTYPE>::TemplateQuad(Node* nodes[NNODES], unsigned value)
: Face(value) : Face(value)
{ {
_nodes = nodes; _nodes = nodes;
...@@ -30,8 +30,8 @@ TemplateQuad<NNODES>::TemplateQuad(Node* nodes[NNODES], unsigned value) ...@@ -30,8 +30,8 @@ TemplateQuad<NNODES>::TemplateQuad(Node* nodes[NNODES], unsigned value)
this->_area = this->computeVolume(); this->_area = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
TemplateQuad<NNODES>::TemplateQuad(const TemplateQuad<NNODES> &quad) TemplateQuad<NNODES,FEMQUADTYPE>::TemplateQuad(const TemplateQuad<NNODES,FEMQUADTYPE> &quad)
: Face(quad.getValue()) : Face(quad.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -47,20 +47,20 @@ TemplateQuad<NNODES>::TemplateQuad(const TemplateQuad<NNODES> &quad) ...@@ -47,20 +47,20 @@ TemplateQuad<NNODES>::TemplateQuad(const TemplateQuad<NNODES> &quad)
_area = quad.getArea(); _area = quad.getArea();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
TemplateQuad<NNODES>::~TemplateQuad() TemplateQuad<NNODES,FEMQUADTYPE>::~TemplateQuad()
{ {
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
double TemplateQuad<NNODES>::computeVolume() double TemplateQuad<NNODES,FEMQUADTYPE>::computeVolume()
{ {
return MathLib::calcTriangleArea(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords()) return MathLib::calcTriangleArea(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords())
+ MathLib::calcTriangleArea(_nodes[2]->getCoords(), _nodes[3]->getCoords(), _nodes[0]->getCoords()); + MathLib::calcTriangleArea(_nodes[2]->getCoords(), _nodes[3]->getCoords(), _nodes[0]->getCoords());
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
bool TemplateQuad<NNODES>::isEdge(unsigned idx1, unsigned idx2) const bool TemplateQuad<NNODES,FEMQUADTYPE>::isEdge(unsigned idx1, unsigned idx2) const
{ {
for (unsigned i(0); i<4; i++) for (unsigned i(0); i<4; i++)
{ {
...@@ -70,14 +70,14 @@ bool TemplateQuad<NNODES>::isEdge(unsigned idx1, unsigned idx2) const ...@@ -70,14 +70,14 @@ bool TemplateQuad<NNODES>::isEdge(unsigned idx1, unsigned idx2) const
return false; return false;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
Element* TemplateQuad<NNODES>::clone() const Element* TemplateQuad<NNODES,FEMQUADTYPE>::clone() const
{ {
return new TemplateQuad(*this); return new TemplateQuad(*this);
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
unsigned TemplateQuad<NNODES>::identifyFace(Node* nodes[3]) const unsigned TemplateQuad<NNODES,FEMQUADTYPE>::identifyFace(Node* nodes[3]) const
{ {
for (unsigned i=0; i<4; i++) for (unsigned i=0; i<4; i++)
{ {
...@@ -92,8 +92,8 @@ unsigned TemplateQuad<NNODES>::identifyFace(Node* nodes[3]) const ...@@ -92,8 +92,8 @@ unsigned TemplateQuad<NNODES>::identifyFace(Node* nodes[3]) const
return std::numeric_limits<unsigned>::max(); return std::numeric_limits<unsigned>::max();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMQUADTYPE>
Element* TemplateQuad<NNODES>::reviseElement() const Element* TemplateQuad<NNODES,FEMQUADTYPE>::reviseElement() const
{ {
if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) { if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) {
MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; MeshLib::Node** tri_nodes = new MeshLib::Node*[3];
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#ifndef TEMPLATETET_H_ #ifndef TEMPLATETET_H_
#define TEMPLATETET_H_ #define TEMPLATETET_H_
#include "MshEnums.h"
#include "Cell.h" #include "Cell.h"
namespace MeshLib { namespace MeshLib {
...@@ -37,7 +38,7 @@ namespace MeshLib { ...@@ -37,7 +38,7 @@ namespace MeshLib {
* *
* @endcode * @endcode
*/ */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
class TemplateTet : public Cell class TemplateTet : public Cell
{ {
public: public:
...@@ -45,7 +46,7 @@ public: ...@@ -45,7 +46,7 @@ public:
TemplateTet(Node* nodes[NNODES], unsigned value = 0); TemplateTet(Node* nodes[NNODES], unsigned value = 0);
/// Copy constructor /// Copy constructor
TemplateTet(const TemplateTet<NNODES> &tet); TemplateTet(const TemplateTet &tet);
/// Destructor /// Destructor
virtual ~TemplateTet(); virtual ~TemplateTet();
...@@ -77,6 +78,12 @@ public: ...@@ -77,6 +78,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::TETRAHEDRON; } virtual MshElemType::type getGeoType() const { return MshElemType::TETRAHEDRON; }
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const { return FEMTETTYPE; }
/// Returns true if these two indeces form an edge and false otherwise /// Returns true if these two indeces form an edge and false otherwise
bool isEdge(unsigned i, unsigned j) const; bool isEdge(unsigned i, unsigned j) const;
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
const unsigned TemplateTet<NNODES>::_face_nodes[4][3] = const unsigned TemplateTet<NNODES,FEMTETTYPE>::_face_nodes[4][3] =
{ {
{0, 2, 1}, // Face 0 {0, 2, 1}, // Face 0
{0, 1, 3}, // Face 1 {0, 1, 3}, // Face 1
...@@ -26,8 +26,8 @@ const unsigned TemplateTet<NNODES>::_face_nodes[4][3] = ...@@ -26,8 +26,8 @@ const unsigned TemplateTet<NNODES>::_face_nodes[4][3] =
{2, 0, 3} // Face 3 {2, 0, 3} // Face 3
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
const unsigned TemplateTet<NNODES>::_edge_nodes[6][2] = const unsigned TemplateTet<NNODES,FEMTETTYPE>::_edge_nodes[6][2] =
{ {
{0, 1}, // Edge 0 {0, 1}, // Edge 0
{1, 2}, // Edge 1 {1, 2}, // Edge 1
...@@ -37,8 +37,8 @@ const unsigned TemplateTet<NNODES>::_edge_nodes[6][2] = ...@@ -37,8 +37,8 @@ const unsigned TemplateTet<NNODES>::_edge_nodes[6][2] =
{2, 3} // Edge 5 {2, 3} // Edge 5
}; };
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
TemplateTet<NNODES>::TemplateTet(Node* nodes[NNODES], unsigned value) TemplateTet<NNODES,FEMTETTYPE>::TemplateTet(Node* nodes[NNODES], unsigned value)
: Cell(value) : Cell(value)
{ {
_nodes = nodes; _nodes = nodes;
...@@ -50,8 +50,8 @@ TemplateTet<NNODES>::TemplateTet(Node* nodes[NNODES], unsigned value) ...@@ -50,8 +50,8 @@ TemplateTet<NNODES>::TemplateTet(Node* nodes[NNODES], unsigned value)
this->_volume = this->computeVolume(); this->_volume = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
TemplateTet<NNODES>::TemplateTet(const TemplateTet<NNODES> &tet) TemplateTet<NNODES,FEMTETTYPE>::TemplateTet(const TemplateTet<NNODES,FEMTETTYPE> &tet)
: Cell(tet.getValue()) : Cell(tet.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -68,19 +68,19 @@ TemplateTet<NNODES>::TemplateTet(const TemplateTet<NNODES> &tet) ...@@ -68,19 +68,19 @@ TemplateTet<NNODES>::TemplateTet(const TemplateTet<NNODES> &tet)
_volume = tet.getVolume(); _volume = tet.getVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
TemplateTet<NNODES>::~TemplateTet() TemplateTet<NNODES,FEMTETTYPE>::~TemplateTet()
{ {
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
double TemplateTet<NNODES>::computeVolume() double TemplateTet<NNODES,FEMTETTYPE>::computeVolume()
{ {
return MathLib::calcTetrahedronVolume(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords(), _nodes[3]->getCoords()); return MathLib::calcTetrahedronVolume(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords(), _nodes[3]->getCoords());
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
const Element* TemplateTet<NNODES>::getFace(unsigned i) const const Element* TemplateTet<NNODES,FEMTETTYPE>::getFace(unsigned i) const
{ {
if (i<this->getNFaces()) if (i<this->getNFaces())
{ {
...@@ -94,8 +94,8 @@ const Element* TemplateTet<NNODES>::getFace(unsigned i) const ...@@ -94,8 +94,8 @@ const Element* TemplateTet<NNODES>::getFace(unsigned i) const
return NULL; return NULL;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
bool TemplateTet<NNODES>::isEdge(unsigned idx1, unsigned idx2) const bool TemplateTet<NNODES,FEMTETTYPE>::isEdge(unsigned idx1, unsigned idx2) const
{ {
for (unsigned i(0); i<6; i++) for (unsigned i(0); i<6; i++)
{ {
...@@ -105,14 +105,14 @@ bool TemplateTet<NNODES>::isEdge(unsigned idx1, unsigned idx2) const ...@@ -105,14 +105,14 @@ bool TemplateTet<NNODES>::isEdge(unsigned idx1, unsigned idx2) const
return false; return false;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
Element* TemplateTet<NNODES>::clone() const Element* TemplateTet<NNODES,FEMTETTYPE>::clone() const
{ {
return new TemplateTet<NNODES>(*this); return new TemplateTet<NNODES,FEMTETTYPE>(*this);
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
unsigned TemplateTet<NNODES>::identifyFace(Node* nodes[3]) const unsigned TemplateTet<NNODES,FEMTETTYPE>::identifyFace(Node* nodes[3]) const
{ {
for (unsigned i=0; i<4; i++) for (unsigned i=0; i<4; i++)
{ {
...@@ -127,8 +127,8 @@ unsigned TemplateTet<NNODES>::identifyFace(Node* nodes[3]) const ...@@ -127,8 +127,8 @@ unsigned TemplateTet<NNODES>::identifyFace(Node* nodes[3]) const
return std::numeric_limits<unsigned>::max(); return std::numeric_limits<unsigned>::max();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTETTYPE>
Element* TemplateTet<NNODES>::reviseElement() const Element* TemplateTet<NNODES,FEMTETTYPE>::reviseElement() const
{ {
if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) { if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) {
MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; MeshLib::Node** tri_nodes = new MeshLib::Node*[3];
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Edge.h" #include "Edge.h"
#include "Node.h" #include "Node.h"
#include "Face.h" #include "Face.h"
#include "MshEnums.h"
#include "MathTools.h" #include "MathTools.h"
...@@ -39,7 +40,7 @@ namespace MeshLib { ...@@ -39,7 +40,7 @@ namespace MeshLib {
* *
* @endcode * @endcode
*/ */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
class TemplateTri : public Face class TemplateTri : public Face
{ {
public: public:
...@@ -47,7 +48,7 @@ public: ...@@ -47,7 +48,7 @@ public:
TemplateTri(Node* nodes[NNODES], unsigned value = 0); TemplateTri(Node* nodes[NNODES], unsigned value = 0);
/// Copy constructor /// Copy constructor
TemplateTri(const TemplateTri<NNODES> &tri); TemplateTri(const TemplateTri &tri);
/// Destructor /// Destructor
virtual ~TemplateTri(); virtual ~TemplateTri();
...@@ -70,6 +71,12 @@ public: ...@@ -70,6 +71,12 @@ public:
*/ */
virtual MshElemType::type getGeoType() const { return MshElemType::TRIANGLE; } virtual MshElemType::type getGeoType() const { return MshElemType::TRIANGLE; }
/**
* Get the type of the element in context of the finite element method.
* @return a value of the enum FEMElemType::type
*/
virtual FEMElemType::type getFEMType() const { return FEMTRITYPE; }
/// Returns true if these two indices form an edge and false otherwise /// Returns true if these two indices form an edge and false otherwise
bool isEdge(unsigned idx1, unsigned idx2) const; bool isEdge(unsigned idx1, unsigned idx2) const;
...@@ -79,7 +86,7 @@ public: ...@@ -79,7 +86,7 @@ public:
*/ */
virtual Element* clone() const virtual Element* clone() const
{ {
return new TemplateTri<NNODES>(*this); return new TemplateTri<NNODES,FEMTRITYPE>(*this);
} }
...@@ -113,8 +120,8 @@ protected: ...@@ -113,8 +120,8 @@ protected:
static const unsigned _edge_nodes[3][2]; static const unsigned _edge_nodes[3][2];
}; /* class */ }; /* class */
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
const unsigned TemplateTri<NNODES>::_edge_nodes[3][2] = { const unsigned TemplateTri<NNODES,FEMTRITYPE>::_edge_nodes[3][2] = {
{0, 1}, // Edge 0 {0, 1}, // Edge 0
{1, 2}, // Edge 1 {1, 2}, // Edge 1
{0, 2} // Edge 2 {0, 2} // Edge 2
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
namespace MeshLib { namespace MeshLib {
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
TemplateTri<NNODES>::TemplateTri(Node* nodes[NNODES], unsigned value) : TemplateTri<NNODES,FEMTRITYPE>::TemplateTri(Node* nodes[NNODES], unsigned value) :
Face(value) Face(value)
{ {
_nodes = nodes; _nodes = nodes;
...@@ -22,8 +22,8 @@ TemplateTri<NNODES>::TemplateTri(Node* nodes[NNODES], unsigned value) : ...@@ -22,8 +22,8 @@ TemplateTri<NNODES>::TemplateTri(Node* nodes[NNODES], unsigned value) :
this->_area = this->computeVolume(); this->_area = this->computeVolume();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
TemplateTri<NNODES>::TemplateTri(const TemplateTri<NNODES> &tri) : TemplateTri<NNODES,FEMTRITYPE>::TemplateTri(const TemplateTri<NNODES,FEMTRITYPE> &tri) :
Face(tri.getValue()) Face(tri.getValue())
{ {
_nodes = new Node*[NNODES]; _nodes = new Node*[NNODES];
...@@ -40,12 +40,12 @@ TemplateTri<NNODES>::TemplateTri(const TemplateTri<NNODES> &tri) : ...@@ -40,12 +40,12 @@ TemplateTri<NNODES>::TemplateTri(const TemplateTri<NNODES> &tri) :
_area = tri.getArea(); _area = tri.getArea();
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
TemplateTri<NNODES>::~TemplateTri() TemplateTri<NNODES,FEMTRITYPE>::~TemplateTri()
{} {}
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
bool TemplateTri<NNODES>::isEdge(unsigned idx1, unsigned idx2) const bool TemplateTri<NNODES,FEMTRITYPE>::isEdge(unsigned idx1, unsigned idx2) const
{ {
for (unsigned i(0); i<3; i++) for (unsigned i(0); i<3; i++)
{ {
...@@ -55,8 +55,8 @@ bool TemplateTri<NNODES>::isEdge(unsigned idx1, unsigned idx2) const ...@@ -55,8 +55,8 @@ bool TemplateTri<NNODES>::isEdge(unsigned idx1, unsigned idx2) const
return false; return false;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
Element* TemplateTri<NNODES>::reviseElement() const Element* TemplateTri<NNODES,FEMTRITYPE>::reviseElement() const
{ {
// try to create an edge // try to create an edge
if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) { if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) {
...@@ -76,8 +76,8 @@ Element* TemplateTri<NNODES>::reviseElement() const ...@@ -76,8 +76,8 @@ Element* TemplateTri<NNODES>::reviseElement() const
return NULL; return NULL;
} }
template <unsigned NNODES> template <unsigned NNODES, FEMElemType::type FEMTRITYPE>
unsigned TemplateTri<NNODES>::identifyFace(Node* nodes[3]) const unsigned TemplateTri<NNODES,FEMTRITYPE>::identifyFace(Node* nodes[3]) const
{ {
for (unsigned i=0; i<3; i++) for (unsigned i=0; i<3; i++)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment