12#ifndef BELFEM_CL_ELEMENT_TEMPLATE_HPP
13#define BELFEM_CL_ELEMENT_TEMPLATE_HPP
36 template< u
int N, u
int C, u
int E, u
int T, u
int F >
49 bool mHaveEdges = false ;
52 bool mHaveFaces = false ;
74 type()
const override;
139 node(
const uint aIndex )
const override;
190 edge(
const uint aIndex )
const override;
204 face(
const uint aIndex )
const override;
218 void flag_nodes(
const uint8_t aIndex=0 )
override;
310 print()
const override ;
352 allocate_node_container();
360 reset_node_container();
368 throw_facet_error(
const uint aFacetIndex );
376 throw_edge_error(
const uint aEdgeIndex );
383 template< u
int N, u
int C, u
int E, u
int T, u
int F >
385 ElementTemplate< N, C, E, T, F >::allocate_node_container()
388 mNodes =
new Node * [ N ];
391 for (
uint k = 0; k < N; ++k )
393 mNodes[ k ] =
nullptr;
400 template< u
int N, u
int C, u
int E, u
int T, u
int F >
405 BELFEM_ASSERT( ! mHaveEdges,
"Edge container for element %lu has already been allocated",
406 (
long unsigned int ) this->
id() );
409 mEdges =
new Edge * [
E ];
412 for (
uint k = 0; k <
E; ++k )
414 mEdges[ k ] =
nullptr;
422 template< u
int N, u
int C, u
int E, u
int T, u
int F >
427 BELFEM_ASSERT( ! mHaveFaces,
"Face container for element %lu has already been allocated",
428 (
long unsigned int ) this->
id() );
431 mFaces =
new Face * [ F ];
434 for (
uint k = 0; k < F ; ++k )
436 mFaces[ k ] =
nullptr;
444 template< u
int N, u
int C, u
int E, u
int T, u
int F >
448 this->allocate_node_container();
458 template< u
int N, u
int C, u
int E, u
int T, u
int F >
463 this->reset_node_container();
468 template< u
int N, u
int C, u
int E, u
int T, u
int F >
472 BELFEM_ERROR(
false,
"type() function not implemented for ElementTemplate< %u, %u, %u, %u, %u > with id %lu",
478 (
long unsigned int ) this->
id() );
485 template< u
int N, u
int C, u
int E, u
int T, u
int F >
494 template< u
int N, u
int C, u
int E, u
int T, u
int F >
503 template< u
int N, u
int C, u
int E, u
int T, u
int F >
512 template< u
int N, u
int C, u
int E, u
int T, u
int F >
522 template< u
int N, u
int C, u
int E, u
int T, u
int F >
531 template< u
int N, u
int C, u
int E, u
int T, u
int F >
537 + N *
sizeof(
Node * );
541 tMem +=
E *
sizeof(
Edge * );
545 tMem += F *
sizeof(
Face * );
553 template< u
int N, u
int C, u
int E, u
int T, u
int F >
555 ElementTemplate< N, C, E, T, F >::reset_node_container()
562 template< u
int N, u
int C, u
int E, u
int T, u
int F >
579 template< u
int N, u
int C, u
int E, u
int T, u
int F >
596 template< u
int N, u
int C, u
int E, u
int T, u
int F >
602 "Tried to write node into index %u of %u node element %lu",
603 (
unsigned int ) aIndex,
605 (
long unsigned int ) this->
id() );
608 mNodes[ aIndex ] = aNode;
613 template< u
int N, u
int C, u
int E, u
int T, u
int F >
619 "Tried acces node %u of %u node element %lu",
620 (
unsigned int ) aIndex,
622 (
long unsigned int ) this->
id() );
625 return mNodes[ aIndex ];
630 template< u
int N, u
int C, u
int E, u
int T, u
int F >
636 "Tried acces node %u of %u node element %lu",
637 (
unsigned int ) aIndex,
639 (
long unsigned int ) this->
id() );
642 return mNodes[ aIndex ];
648 template< u
int N, u
int C, u
int E, u
int T, u
int F >
657 template< u
int N, u
int C, u
int E, u
int T, u
int F >
666 template< u
int N, u
int C, u
int E, u
int T, u
int F >
672 "Tried to write edge into index %u of %u element %lu",
673 (
unsigned int ) aIndex,
675 (
long unsigned int ) this->
id() );
678 mEdges[ aIndex ] = aEdge;
683 template< u
int N, u
int C, u
int E, u
int T, u
int F >
689 "Tried to write face into index %u of %u element %lu",
690 (
unsigned int ) aIndex,
692 (
long unsigned int ) this->
id() );
695 mFaces[ aIndex ] = aFace;
700 template< u
int N, u
int C, u
int E, u
int T, u
int F >
705 BELFEM_ASSERT( mHaveEdges,
"Edges for element %lu on block %lu have not been allocated",
706 (
long unsigned int ) this->
id(),
707 (
long unsigned int ) this->
block_id() );
711 "Tried to access edge %u of %u node element %lu",
712 (
unsigned int ) aIndex,
714 (
long unsigned int ) this->
id() );
717 return mEdges[ aIndex ];
722 template< u
int N, u
int C, u
int E, u
int T, u
int F >
727 BELFEM_ASSERT( mHaveEdges,
"Edges for element %lu have not been allocated",
728 (
long unsigned int ) this->
id() );
732 "Tried to access edge %u of %u node element %lu",
733 (
unsigned int ) aIndex,
735 (
long unsigned int ) this->
id() );
738 return mEdges[ aIndex ];
743 template< u
int N, u
int C, u
int E, u
int T, u
int F >
748 BELFEM_ASSERT( mHaveFaces,
"Faces for element %lu ( block %lu ) have not been allocated",
749 (
long unsigned int ) this->
id(),
750 (
long unsigned int ) this->
block_id() );
754 "Tried to access face %u of %u node element %lu",
755 (
unsigned int ) aIndex,
757 (
long unsigned int ) this->
id() );
760 return mFaces[ aIndex ];
765 template< u
int N, u
int C, u
int E, u
int T, u
int F >
770 BELFEM_ASSERT( mHaveFaces,
"Edges for element %lu have not been allocated",
771 (
long unsigned int ) this->
id() );
775 "Tried to access face %u of %u node element %lu",
776 (
unsigned int ) aIndex,
778 (
long unsigned int ) this->
id() );
781 return mFaces[ aIndex ];
786 template< u
int N, u
int C, u
int E, u
int T, u
int F >
790 for(
uint k=0; k<N; ++k )
792 mNodes[ k ]->unflag( aIndex );
798 template< u
int N, u
int C, u
int E, u
int T, u
int F >
802 for(
uint k=0; k<N; ++k )
804 mNodes[ k ]->flag( aIndex );
810 template< u
int N, u
int C, u
int E, u
int T, u
int F >
814 for(
uint k=0; k<C; ++k )
816 mNodes[ k ]->flag( aIndex );
822 template< u
int N, u
int C, u
int E, u
int T, u
int F >
826 for(
uint k=0; k<C; ++k )
828 mNodes[ k ]->unflag( aIndex );
834 template< u
int N, u
int C, u
int E, u
int T, u
int F >
840 for (
uint k = 0; k <
E; ++k )
842 mEdges[ k ]->unflag();
849 template< u
int N, u
int C, u
int E, u
int T, u
int F >
855 for (
uint k = 0; k <
E; ++k )
864 template< u
int N, u
int C, u
int E, u
int T, u
int F >
870 for (
uint k = 0; k < F; ++k )
872 mFaces[ k ]->unflag();
879 template< u
int N, u
int C, u
int E, u
int T, u
int F >
885 for (
uint k = 0; k < F; ++k )
894 template< u
int N, u
int C, u
int E, u
int T, u
int F >
899 "Function get_nodes_of_facet() not implemented for element %lu",
901 (
long unsigned int ) this->
id() );
905 template< u
int N, u
int C, u
int E, u
int T, u
int F >
910 "Function get_corner_nodes_of_facet() not implemented for element %lu",
911 (
long unsigned int ) this->
id() );
916 template< u
int N, u
int C, u
int E, u
int T, u
int F >
921 "invalid call of base class function get_edges_of_facet() from element %lu",
922 (
long unsigned int ) this->
id() );
928 template< u
int N, u
int C, u
int E, u
int T, u
int F >
938 template< u
int N, u
int C, u
int E, u
int T, u
int F >
940 ElementTemplate< N, C, E, T, F >::throw_facet_error(
const uint aFacetIndex )
943 "invalid facet index %u for element %lu ( must be < %u )",
944 (
unsigned int ) aFacetIndex,
945 (
long unsigned int ) this->
id(),
946 (
unsigned int ) T );
951 template< u
int N, u
int C, u
int E, u
int T, u
int F >
955 BELFEM_ASSERT( mHaveEdges,
"edges have not been allocated for element %lu",
956 (
long unsigned int ) this->
id() );
959 "invalid edge index %u for element %lu ( must be < %u )",
960 (
unsigned int ) aEdgeIndex,
961 (
long unsigned int ) this->
id(),
962 (
unsigned int )
E );
966 mEdgeOrientations.set( aEdgeIndex );
970 mEdgeOrientations.reset( aEdgeIndex );
976 template< u
int N, u
int C, u
int E, u
int T, u
int F >
980 BELFEM_ERROR(
false,
"no dimension implemented for this element" );
986 template< u
int N, u
int C, u
int E, u
int T, u
int F >
990 BELFEM_ASSERT( mHaveEdges,
"edges have not been allocated for element %lu",
991 (
long unsigned int ) this->
id() );
994 "invalid edge index %u for element %lu ( must be < %u )",
995 (
unsigned int ) aEdgeIndex,
996 (
long unsigned int ) this->
id(),
997 (
unsigned int )
E );
999 return mEdgeOrientations.test( aEdgeIndex );
1004 template< u
int N, u
int C, u
int E, u
int T, u
int F >
1006 ElementTemplate< N, C, E, T, F >::throw_edge_error(
const uint aEdgeIndex )
1009 "invalid edge index %u for element %lu ( must be < %u )",
1010 (
unsigned int ) aEdgeIndex,
1011 (
long unsigned int ) this->
id(),
1012 (
unsigned int ) E );
1017 template <u
int N, u
int C, u
int E, u
int T, u
int F>
1025 template< u
int N, u
int C, u
int E, u
int T, u
int F >
1029 std::cout <<
"Element " << this->
id() <<
" of type " <<
1032 <<
" Nodes : " << std::endl ;
1034 for(
uint k=0; k<N; ++k )
1036 std::cout <<
" " << k <<
" " << mNodes[ k ]->id() << std::endl ;
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Compile-time fixed-size bitset.
Definition cl_Bitset.hpp:32
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
id_t id() const
Definition cl_Graph_Vertex.hpp:218
Special Edge class for NEDELEC-Type elements.
Definition cl_Edge.hpp:30
id_t block_id() const
Definition cl_Element.hpp:728
size_t array_memory() const
Definition cl_Element.hpp:826
Element(const id_t aID)
Definition cl_Element.cpp:21
bool mCurvedFlag
flag telling if this element is curved
Definition cl_Element.hpp:41
void get_nodes_of_edge(const uint aEdgeIndex, Cell< Node * > &aNodes) override
Definition cl_ElementTemplate.hpp:930
size_t memory() const override
Definition cl_ElementTemplate.hpp:533
void get_nodes_of_facet(const uint aFacetIndex, Cell< Node * > &aNodes) override
Definition cl_ElementTemplate.hpp:896
void flag_faces() override
flag all faces of this element
Definition cl_ElementTemplate.hpp:881
void allocate_edge_container() override
Initialize the edge container.
Definition cl_ElementTemplate.hpp:402
void unflag_nodes(const uint8_t aIndex=0) override
unflag all nodes of this element
Definition cl_ElementTemplate.hpp:788
uint number_of_faces() const override
how faces can this element have
Definition cl_ElementTemplate.hpp:514
bool is_thinshell() const override
Definition cl_ElementTemplate.hpp:1018
void unflag_faces() override
unflag all faces of this element
Definition cl_ElementTemplate.hpp:866
void flag_edges() override
flag all edges of this element
Definition cl_ElementTemplate.hpp:851
void flag_corner_nodes(const uint8_t aIndex=0) override
flag all corner nodes of this element
Definition cl_ElementTemplate.hpp:812
void print() const override
display some debug information
Definition cl_ElementTemplate.hpp:1027
uint number_of_edges() const override
how many edges this element has
Definition cl_ElementTemplate.hpp:524
void get_corner_nodes_of_facet(const uint aFacetIndex, Cell< Node * > &aNodes) override
Definition cl_ElementTemplate.hpp:907
void unflag_corner_nodes(const uint8_t aIndex=0) override
unflag all corner nodes of this element
Definition cl_ElementTemplate.hpp:824
Face * face(const uint aIndex) override
return the face pointer
Definition cl_ElementTemplate.hpp:745
void insert_edge(Edge *aEdge, const uint aIndex) override
insert an edge to a position in the member array
Definition cl_ElementTemplate.hpp:668
void reset_face_container() override
Delete the face container.
Definition cl_ElementTemplate.hpp:564
void flag_nodes(const uint8_t aIndex=0) override
flag all nodes of this element
Definition cl_ElementTemplate.hpp:800
void set_edge_direction(const uint aEdgeIndex, const bool aIsPlus) override
Definition cl_ElementTemplate.hpp:953
uint number_of_corner_nodes() const override
how many corner nodes does this element have ( for linear interpolation )
Definition cl_ElementTemplate.hpp:496
void reset_edge_container() override
Delete the edge container.
Definition cl_ElementTemplate.hpp:581
bool has_faces() const override
tells if the face container has been allocated
Definition cl_ElementTemplate.hpp:659
uint dimension() const override
Definition cl_ElementTemplate.hpp:978
Node * node(const uint aIndex) override
return the node pointer
Definition cl_ElementTemplate.hpp:615
void insert_face(Face *aFace, const uint aIndex) override
insert a face to a position in the member array
Definition cl_ElementTemplate.hpp:685
ElementType type() const override
return the type of the element
Definition cl_ElementTemplate.hpp:470
void unflag_edges() override
unflag all edges of this element
Definition cl_ElementTemplate.hpp:836
ElementTemplate(const id_t &aID)
Definition cl_ElementTemplate.hpp:445
bool has_edges() const override
tells if the edge container has been allocated
Definition cl_ElementTemplate.hpp:650
void get_edges_of_facet(const uint aFacetIndex, Cell< Edge * > &aEdges) override
Definition cl_ElementTemplate.hpp:918
void allocate_face_container() override
Initialize the face container.
Definition cl_ElementTemplate.hpp:424
uint number_of_facets() const override
how facets can this element have
Definition cl_ElementTemplate.hpp:505
~ElementTemplate() override
Definition cl_ElementTemplate.hpp:459
void insert_node(Node *aNode, const uint aIndex) override
insert a node to a position in the member array
Definition cl_ElementTemplate.hpp:598
Edge * edge(const uint aIndex) override
return the edge pointer
Definition cl_ElementTemplate.hpp:702
uint number_of_nodes() const override
how many nodes does this element have
Definition cl_ElementTemplate.hpp:487
bool edge_direction(const uint aEdgeIndex) const override
Definition cl_ElementTemplate.hpp:988
Definition cl_Face.hpp:29
Definition cl_Node.hpp:30
Definition cl_EF_EdgeFunction.hpp:17
belfem::InterpolationOrder interpolation_order(const enum ElementType aElementType)
Definition meshtools.cpp:210
string to_string(CutAlgorithm aCutAlgorithm)
Definition en_CutAlgorithm.hpp:31
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
ElementType
Element types.
Definition Mesh_Enums.hpp:27
@ UNDEFINED
Definition Mesh_Enums.hpp:64
@ E
Definition cl_Material.hpp:155
@ LINEAR
Definition Mesh_Enums.hpp:87
#define BELFEM_UINT_MAX
Definition typedefs.hpp:80