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;
191 edge(
const uint aIndex )
const override;
205 face(
const uint aIndex )
const override;
219 void flag_nodes(
const uint8_t aIndex=0 )
override;
311 print()
const override ;
353 allocate_node_container();
361 reset_node_container();
369 throw_facet_error(
const uint aFacetIndex );
377 throw_edge_error(
const uint aEdgeIndex );
384 template< u
int N, u
int C, u
int E, u
int T, u
int F >
386 ElementTemplate< N, C, E, T, F >::allocate_node_container()
388 mNodes =
new Node * [ N ];
390 for (
uint k = 0; k < N; ++k )
392 mNodes[ k ] =
nullptr;
399 template< u
int N, u
int C, u
int E, u
int T, u
int F >
404 BELFEM_ASSERT( ! mHaveEdges,
"Edge container for element %lu has already been allocated",
405 (
long unsigned int ) this->
id() );
407 mEdges =
new Edge * [
E ];
409 for (
uint k = 0; k <
E; ++k )
411 mEdges[ k ] =
nullptr;
419 template< u
int N, u
int C, u
int E, u
int T, u
int F >
424 BELFEM_ASSERT( ! mHaveFaces,
"Face container for element %lu has already been allocated",
425 (
long unsigned int ) this->
id() );
427 mFaces =
new Face * [ F ];
429 for (
uint k = 0; k < F ; ++k )
431 mFaces[ k ] =
nullptr;
439 template< u
int N, u
int C, u
int E, u
int T, u
int F >
443 this->allocate_node_container();
453 template< u
int N, u
int C, u
int E, u
int T, u
int F >
458 this->reset_node_container();
463 template< u
int N, u
int C, u
int E, u
int T, u
int F >
467 BELFEM_ERROR(
false,
"type() function not implemented for ElementTemplate< %u, %u, %u, %u, %u > with id %lu",
473 (
long unsigned int ) this->
id() );
480 template< u
int N, u
int C, u
int E, u
int T, u
int F >
489 template< u
int N, u
int C, u
int E, u
int T, u
int F >
498 template< u
int N, u
int C, u
int E, u
int T, u
int F >
507 template< u
int N, u
int C, u
int E, u
int T, u
int F >
517 template< u
int N, u
int C, u
int E, u
int T, u
int F >
526 template< u
int N, u
int C, u
int E, u
int T, u
int F >
532 + N *
sizeof(
Node * );
536 tMem +=
E *
sizeof(
Edge * );
540 tMem += F *
sizeof(
Face * );
548 template< u
int N, u
int C, u
int E, u
int T, u
int F >
550 ElementTemplate< N, C, E, T, F >::reset_node_container()
556 template< u
int N, u
int C, u
int E, u
int T, u
int F >
570 template< u
int N, u
int C, u
int E, u
int T, u
int F >
584 template< u
int N, u
int C, u
int E, u
int T, u
int F >
590 "Tried to write node into index %u of %u node element %lu",
591 (
unsigned int ) aIndex,
593 (
long unsigned int ) this->
id() );
595 mNodes[ aIndex ] = aNode;
600 template< u
int N, u
int C, u
int E, u
int T, u
int F >
606 "Tried acces node %u of %u node element %lu",
607 (
unsigned int ) aIndex,
609 (
long unsigned int ) this->
id() );
611 return mNodes[ aIndex ];
616 template< u
int N, u
int C, u
int E, u
int T, u
int F >
622 "Tried acces node %u of %u node element %lu",
623 (
unsigned int ) aIndex,
625 (
long unsigned int ) this->
id() );
627 return mNodes[ aIndex ];
633 template< u
int N, u
int C, u
int E, u
int T, u
int F >
642 template< u
int N, u
int C, u
int E, u
int T, u
int F >
651 template< u
int N, u
int C, u
int E, u
int T, u
int F >
657 "Tried to write edge into index %u of %u element %lu",
658 (
unsigned int ) aIndex,
660 (
long unsigned int ) this->
id() );
662 mEdges[ aIndex ] = aEdge;
667 template< u
int N, u
int C, u
int E, u
int T, u
int F >
673 "Tried to write face into index %u of %u element %lu",
674 (
unsigned int ) aIndex,
676 (
long unsigned int ) this->
id() );
678 mFaces[ aIndex ] = aFace;
683 template< u
int N, u
int C, u
int E, u
int T, u
int F >
688 BELFEM_ASSERT( mHaveEdges,
"Edges for element %lu on block %lu have not been allocated",
689 (
long unsigned int ) this->
id(),
690 (
long unsigned int ) this->
block_id() );
694 "Tried to access edge %u of %u node element %lu",
695 (
unsigned int ) aIndex,
697 (
long unsigned int ) this->
id() );
699 return mEdges[ aIndex ];
704 template< u
int N, u
int C, u
int E, u
int T, u
int F >
709 BELFEM_ASSERT( mHaveEdges,
"Edges for element %lu have not been allocated",
710 (
long unsigned int ) this->
id() );
714 "Tried to access edge %u of %u node element %lu",
715 (
unsigned int ) aIndex,
717 (
long unsigned int ) this->
id() );
719 return mEdges[ aIndex ];
724 template< u
int N, u
int C, u
int E, u
int T, u
int F >
729 BELFEM_ASSERT( mHaveFaces,
"Faces for element %lu ( block %lu ) have not been allocated",
730 (
long unsigned int ) this->
id(),
731 (
long unsigned int ) this->
block_id() );
735 "Tried to access face %u of %u node element %lu",
736 (
unsigned int ) aIndex,
738 (
long unsigned int ) this->
id() );
740 return mFaces[ aIndex ];
745 template< u
int N, u
int C, u
int E, u
int T, u
int F >
750 BELFEM_ASSERT( mHaveFaces,
"Edges for element %lu have not been allocated",
751 (
long unsigned int ) this->
id() );
755 "Tried to access face %u of %u node element %lu",
756 (
unsigned int ) aIndex,
758 (
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 >
769 for(
uint k=0; k<N; ++k )
771 mNodes[ k ]->unflag( aIndex );
777 template< u
int N, u
int C, u
int E, u
int T, u
int F >
781 for(
uint k=0; k<N; ++k )
783 mNodes[ k ]->flag( aIndex );
789 template< u
int N, u
int C, u
int E, u
int T, u
int F >
793 for(
uint k=0; k<C; ++k )
795 mNodes[ k ]->flag( aIndex );
801 template< u
int N, u
int C, u
int E, u
int T, u
int F >
805 for(
uint k=0; k<C; ++k )
807 mNodes[ k ]->unflag( aIndex );
813 template< u
int N, u
int C, u
int E, u
int T, u
int F >
819 for (
uint k = 0; k <
E; ++k )
821 mEdges[ k ]->unflag();
828 template< u
int N, u
int C, u
int E, u
int T, u
int F >
834 for (
uint k = 0; k <
E; ++k )
843 template< u
int N, u
int C, u
int E, u
int T, u
int F >
849 for (
uint k = 0; k < F; ++k )
851 mFaces[ k ]->unflag();
858 template< u
int N, u
int C, u
int E, u
int T, u
int F >
864 for (
uint k = 0; k < F; ++k )
873 template< u
int N, u
int C, u
int E, u
int T, u
int F >
878 "Function get_nodes_of_facet() not implemented for element %lu",
880 (
long unsigned int ) this->
id() );
884 template< u
int N, u
int C, u
int E, u
int T, u
int F >
889 "Function get_corner_nodes_of_facet() not implemented for element %lu",
890 (
long unsigned int ) this->
id() );
895 template< u
int N, u
int C, u
int E, u
int T, u
int F >
900 "invalid call of base class function get_edges_of_facet() from element %lu",
901 (
long unsigned int ) this->
id() );
907 template< u
int N, u
int C, u
int E, u
int T, u
int F >
917 template< u
int N, u
int C, u
int E, u
int T, u
int F >
919 ElementTemplate< N, C, E, T, F >::throw_facet_error(
const uint aFacetIndex )
922 "invalid facet index %u for element %lu ( must be < %u )",
923 (
unsigned int ) aFacetIndex,
924 (
long unsigned int ) this->
id(),
925 (
unsigned int ) T );
930 template< u
int N, u
int C, u
int E, u
int T, u
int F >
934 BELFEM_ASSERT( mHaveEdges,
"edges have not been allocated for element %lu",
935 (
long unsigned int ) this->
id() );
938 "invalid edge index %u for element %lu ( must be < %u )",
939 (
unsigned int ) aEdgeIndex,
940 (
long unsigned int ) this->
id(),
941 (
unsigned int )
E );
945 mEdgeOrientations.set( aEdgeIndex );
949 mEdgeOrientations.reset( aEdgeIndex );
955 template< u
int N, u
int C, u
int E, u
int T, u
int F >
959 BELFEM_ERROR(
false,
"no dimension implemented for this element" );
965 template< u
int N, u
int C, u
int E, u
int T, u
int F >
969 BELFEM_ASSERT( mHaveEdges,
"edges have not been allocated for element %lu",
970 (
long unsigned int ) this->
id() );
973 "invalid edge index %u for element %lu ( must be < %u )",
974 (
unsigned int ) aEdgeIndex,
975 (
long unsigned int ) this->
id(),
976 (
unsigned int )
E );
978 return mEdgeOrientations.test( aEdgeIndex );
983 template< u
int N, u
int C, u
int E, u
int T, u
int F >
985 ElementTemplate< N, C, E, T, F >::throw_edge_error(
const uint aEdgeIndex )
988 "invalid edge index %u for element %lu ( must be < %u )",
989 (
unsigned int ) aEdgeIndex,
990 (
long unsigned int ) this->
id(),
991 (
unsigned int ) E );
996 template <u
int N, u
int C, u
int E, u
int T, u
int F>
1004 template< u
int N, u
int C, u
int E, u
int T, u
int F >
1008 std::cout <<
"Element " << this->
id() <<
" of type " <<
1011 <<
" Nodes : " << std::endl ;
1013 for(
uint k=0; k<N; ++k )
1015 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
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
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:909
size_t memory() const override
Definition cl_ElementTemplate.hpp:528
void get_nodes_of_facet(const uint aFacetIndex, Cell< Node * > &aNodes) override
Definition cl_ElementTemplate.hpp:875
void flag_faces() override
flag all faces of this element
Definition cl_ElementTemplate.hpp:860
void allocate_edge_container() override
Initialize the edge container.
Definition cl_ElementTemplate.hpp:401
void unflag_nodes(const uint8_t aIndex=0) override
unflag all nodes of this element
Definition cl_ElementTemplate.hpp:767
uint number_of_faces() const override
how faces can this element have
Definition cl_ElementTemplate.hpp:509
bool is_thinshell() const override
Definition cl_ElementTemplate.hpp:997
void unflag_faces() override
unflag all faces of this element
Definition cl_ElementTemplate.hpp:845
void flag_edges() override
flag all edges of this element
Definition cl_ElementTemplate.hpp:830
void flag_corner_nodes(const uint8_t aIndex=0) override
flag all corner nodes of this element
Definition cl_ElementTemplate.hpp:791
void print() const override
display some debug information
Definition cl_ElementTemplate.hpp:1006
uint number_of_edges() const override
how many edges this element has
Definition cl_ElementTemplate.hpp:519
void get_corner_nodes_of_facet(const uint aFacetIndex, Cell< Node * > &aNodes) override
Definition cl_ElementTemplate.hpp:886
void unflag_corner_nodes(const uint8_t aIndex=0) override
unflag all corner nodes of this element
Definition cl_ElementTemplate.hpp:803
Face * face(const uint aIndex) override
return the face pointer
Definition cl_ElementTemplate.hpp:726
void insert_edge(Edge *aEdge, const uint aIndex) override
Stores the pointer without taking ownership: the mesh owns the nodes, edges and faces,...
Definition cl_ElementTemplate.hpp:653
void reset_face_container() override
Delete the face container.
Definition cl_ElementTemplate.hpp:558
void flag_nodes(const uint8_t aIndex=0) override
flag all nodes of this element
Definition cl_ElementTemplate.hpp:779
void set_edge_direction(const uint aEdgeIndex, const bool aIsPlus) override
Definition cl_ElementTemplate.hpp:932
uint number_of_corner_nodes() const override
how many corner nodes does this element have ( for linear interpolation )
Definition cl_ElementTemplate.hpp:491
void reset_edge_container() override
Delete the edge container.
Definition cl_ElementTemplate.hpp:572
bool has_faces() const override
tells if the face container has been allocated
Definition cl_ElementTemplate.hpp:644
uint dimension() const override
Definition cl_ElementTemplate.hpp:957
Node * node(const uint aIndex) override
return the node pointer
Definition cl_ElementTemplate.hpp:602
void insert_face(Face *aFace, const uint aIndex) override
insert a face to a position in the member array
Definition cl_ElementTemplate.hpp:669
ElementType type() const override
return the type of the element
Definition cl_ElementTemplate.hpp:465
void unflag_edges() override
unflag all edges of this element
Definition cl_ElementTemplate.hpp:815
ElementTemplate(const id_t &aID)
Definition cl_ElementTemplate.hpp:440
bool has_edges() const override
tells if the edge container has been allocated
Definition cl_ElementTemplate.hpp:635
void get_edges_of_facet(const uint aFacetIndex, Cell< Edge * > &aEdges) override
Definition cl_ElementTemplate.hpp:897
void allocate_face_container() override
Initialize the face container.
Definition cl_ElementTemplate.hpp:421
uint number_of_facets() const override
how facets can this element have
Definition cl_ElementTemplate.hpp:500
~ElementTemplate() override
Definition cl_ElementTemplate.hpp:454
void insert_node(Node *aNode, const uint aIndex) override
insert a node to a position in the member array
Definition cl_ElementTemplate.hpp:586
Edge * edge(const uint aIndex) override
return the edge pointer
Definition cl_ElementTemplate.hpp:685
uint number_of_nodes() const override
how many nodes does this element have
Definition cl_ElementTemplate.hpp:482
bool edge_direction(const uint aEdgeIndex) const override
Definition cl_ElementTemplate.hpp:967
Definition cl_Face.hpp:29
Definition cl_Node.hpp:30
Definition cl_EF_EdgeFunction.hpp:24
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:79