BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Segment.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef CL_SEGMENT_HPP
13#define CL_SEGMENT_HPP
14
15#include "typedefs.hpp"
16#include "cl_Cell.hpp"
17#include "cl_Element.hpp"
18
19namespace belfem
20{
21 namespace mesh
22 {
23 class Segment : public Vertex
24 {
25 // wrapped 1D element
26 Element * mElement;
27
28 Edge * mEdge = nullptr ;
29
30 public:
31
32 // bring parent edge(uint) overloads into scope
33 using Vertex::edge;
34
35 Segment( Element * aElement );
36
37 ~Segment() override;
38
39 id_t
40 id() const;
41
43 type() const;
44
45 uint
46 number_of_nodes() const override;
47
48 Node *
49 node( const uint aIndex ) override;
50
51 const Node *
52 node( const uint aIndex ) const override ;
53
54 Edge *
55 edge();
56
57 const Edge *
58 edge() const ;
59
60 void
61 insert_edge( Edge * aEdge );
62
63 void
64 clear_edge();
65
66 int
67 edge_direction() const ;
68
69//------------------------------------------------------------------------------
70
74 Element *
75 element();
76
77//------------------------------------------------------------------------------
78
82 Element *
83 element( const uint aIndex ) override;
84
85//------------------------------------------------------------------------------
86
90 const Element *
91 element( const uint aIndex ) const override ;
92
93//------------------------------------------------------------------------------
94
95 size_t
96 memory() const;
97
98//------------------------------------------------------------------------------
99 };
100
101 inline id_t
103 {
104 return mElement->id();
105 }
106
107//------------------------------------------------------------------------------
108
109 inline ElementType
111 {
112 return mElement->type();
113 }
114
115//------------------------------------------------------------------------------
116
117 inline uint
119 {
120 return mElement->number_of_nodes();
121 }
122
123//------------------------------------------------------------------------------
124
125 inline Node *
126 Segment::node( const uint aIndex )
127 {
128 return mElement->node( aIndex );
129 }
130
131 inline const Node *
132 Segment::node( const uint aIndex ) const
133 {
134 return mElement->node( aIndex );
135 }
136
137//------------------------------------------------------------------------------
138
139 inline Element *
141 {
142 return mElement;
143 }
144
145 inline Edge *
147 {
148 BELFEM_ASSERT( mEdge != nullptr, "Edge has not been assigned to segment %lu", ( long unsigned int ) mElement->id() );
149 return mEdge;
150 }
151
152 inline const Edge *
154 {
155 BELFEM_ASSERT( mEdge != nullptr, "Edge hast not been assigned to segment %lu", ( long unsigned int ) mElement->id() );
156 return mEdge;
157 }
158
159 inline void
161 {
162 mEdge = aEdge;
163 }
164
166 {
167 mEdge = nullptr;
168 }
169
170 inline int Segment::edge_direction() const
171 {
172 BELFEM_ASSERT( mEdge != nullptr, "Edge hast not been assigned to segment %lu", ( long unsigned int ) mElement->id() );
173 return mEdge->node( 0 )->id() == mElement->node( 0 )->id() ? 1 : -1;
174 }
175
176 inline size_t Segment::memory() const
177 {
178 return sizeof( Segment )
179 + this->number_of_vertices() * sizeof( Vertex * );
180 }
181//------------------------------------------------------------------------------
182 }
183}
184
185#endif //CL_SEGMENT_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
uint number_of_vertices() const
Definition cl_Graph_Vertex.hpp:321
Special Edge class for NEDELEC-Type elements.
Definition cl_Edge.hpp:30
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_Node.hpp:30
ElementType type() const
Definition cl_Segment.hpp:110
void insert_edge(Edge *aEdge)
Definition cl_Segment.hpp:160
Edge * edge()
Definition cl_Segment.hpp:146
Segment(Element *aElement)
Definition cl_Segment.cpp:18
void clear_edge()
Definition cl_Segment.hpp:165
Node * node(const uint aIndex) override
Definition cl_Segment.hpp:126
size_t memory() const
Definition cl_Segment.hpp:176
id_t id() const
Definition cl_Segment.hpp:102
int edge_direction() const
Definition cl_Segment.hpp:170
Element * element()
expose the element pointer
Definition cl_Segment.hpp:140
uint number_of_nodes() const override
Definition cl_Segment.hpp:118
Node * node(const uint aIndex) override
Definition cl_Vertex.hpp:349
Edge * edge(const uint aIndex) override
Definition cl_Vertex.hpp:377
Vertex()
Definition cl_Vertex.cpp:24
Definition cl_EF_EdgeFunction.hpp:17
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