BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_CurveFactory.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_CURVEFACTORY_HPP
13#define CL_CURVEFACTORY_HPP
14
15#include "typedefs.hpp"
16#include "cl_Cell.hpp"
17#include "cl_Curve.hpp"
18#include "cl_Mesh.hpp"
19#include "cl_Segment.hpp"
20#include "cl_SideSet.hpp"
21
22namespace belfem
23{
24 namespace mesh
25 {
27 {
28 const proc_t mCommRank ;
29 Mesh * mMesh ;
30 id_t mMaxElementID ;
31 id_t mMaxCurveID ;
32
33 struct ProtoCurve
34 {
35 Cell< Node * > mNodes ;
36 Cell< Edge * > mEdges ;
37 };
38
39//------------------------------------------------------------------------------
40 public:
41//------------------------------------------------------------------------------
42
43 CurveFactory( Mesh * aMesh ) ;
44
45 ~CurveFactory() = default ;
46
47 /*
48 * This function just checks if two sidesets intersect
49 */
50 bool
51 intersection_exists( const id_t aSideSetA, const id_t aSideSetB ) ;
52
53 /*
54 * This function creates a curve from an intersection between
55 * two surfaces. The intersection must be continuous.
56 */
57 Curve *
58 intersect( const id_t aSideSetA, const id_t aSideSetB, id_t aID ) ;
59
60 /*
61 * This function creates a curve from a 1D sideset
62 */
63 Curve *
64 from_2d_sidesets( const Vector< id_t > & aSideSets, id_t aID ) ;
65
67 thin_shell_side_curves( const Vector< id_t > & aThinShellSideSets, const Vector< id_t > & aDomainBoundaries );
68
69 id_t &
71
72 void
73 collect_nodes( Curve * aCurve );
74
75 void
76 compute_coordinates( Curve * aCurve );
77
78 /*
79 * The three sorters below are one pipeline and must be called in
80 * this order: sort_end_nodes, orient_segments, sort_segments.
81 * On entry to sort_end_nodes, every node of aEndNodes carries its
82 * own slot of that cell as index() and is unflagged, and every
83 * segment of the curve carries its own slot of the segment cell
84 * as index() and is unflagged. sort_end_nodes leaves the visited
85 * nodes flagged, and its "not one connected chain" refusal also
86 * fires on a chain whose node flags were dirty on entry.
87 * sort_end_nodes gives every end node its walk index 0 ... n-1
88 * and sets the closed flag; orient_segments directs each segment
89 * along the walk, so that on a closed curve the segment joining
90 * the last node to the first runs n-1 -> 0; sort_segments then
91 * orders the segments by the walk index of their node 0.
92 */
93 void
94 sort_end_nodes( Curve * aCurve, Matrix< index_t > & aAdjacency, Cell< Node * > & aEndNodes );
95
96 void
97 orient_segments( const bool aClosed, Cell< Node * > & aEndNodes, Cell< Segment * > & aSegments );
98
99 void
100 sort_segments( Cell< Segment * > & aSegments );
101
102//------------------------------------------------------------------------------
103 private:
104//------------------------------------------------------------------------------
105
106 void
107 collect_end_nodes_from_intersection(
108 SideSet * aSidesetA,
109 SideSet * aSideSetB,
110 Cell< Node * > & aEndNodes );
111
124 void
125 create_pairs_from_facets(
126 const Cell< Facet * > & aFacets,
127 Cell< Node * > & aEndNodes,
128 const bool aQuadratic,
129 Cell< std::pair< Node *, Node * > > & aPairs,
130 Cell< Node * > & aMidNodes,
131 const Cell< Facet * > * aSharedWith = nullptr );
132
138 Node *
139 midnode_of_facet_edge(
140 Facet * aFacet,
141 const Node * aA,
142 const Node * aB,
143 Cell< Node * > & aWork );
144
145 void
146 create_segments( Curve * aCurve, Cell< std::pair< Node *, Node * > > & aPairs, Cell< Node * > & aMidNodes );
147
148 Node *
149 next( const Matrix< index_t > & aAdjacency, Cell< Segment * > & aSegments, const Node * aNode );
150
151
152 void
153 collect_nodes( const Vector< id_t > & aSideSets, Cell< Node * > & aNodes );
154
155 void
156 create_edges_on_sidesets(
157 const Vector< id_t > & aSideSets ,
158 Cell< Node * > & aNodes,
159 Cell< Edge * > & aEdges,
160 Map< key_t, Edge * > & aMap );
161
162 void
163 connect_facets_to_edges(
164 const Vector< id_t > & aSideSets,
165 const key_t aNumNodes,
166 Cell< Edge * > & aEdges,
167 Map< key_t, Edge * > & aMap );
168
169 void
170 select_edges(
171 const Vector< id_t > & aThinShellSideSets,
172 const Vector< id_t > & aDomainBoundaries,
173 Cell< Edge * > & aAllEdges,
174 Cell< Edge * > & aSelectedEdges );
175
176 void
177 select_node_subset( Cell< Edge * > & aEdges, Cell< Node * > & aNodes );
178
179 void
180 connect_edges_to_nodes( Cell< Edge * > & aEdges, Cell< Node * > & aNodes );
181
182 index_t
183 identify_subchains( Cell< Node * > & aNodes );
184
185 void
186 create_protocurves( Cell< Node * > & aNodes, Cell< Edge * > & aEdges, Cell< ProtoCurve * > & aProtoCurves );
187
188
189
190 };
191
192 inline id_t &
194 {
195 return mMaxElementID ;
196 }
197
198 }
199}
200
201#endif //CL_CURVEFACTORY_HPP
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
Hash map (unordered key-value).
Definition cl_Map.hpp:75
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
void compute_coordinates(Curve *aCurve)
Definition cl_CurveFactory.cpp:1390
void collect_nodes(Curve *aCurve)
Definition cl_CurveFactory.cpp:1306
Cell< Curve * > thin_shell_side_curves(const Vector< id_t > &aThinShellSideSets, const Vector< id_t > &aDomainBoundaries)
Definition cl_CurveFactory.cpp:77
Curve * intersect(const id_t aSideSetA, const id_t aSideSetB, id_t aID)
Definition cl_CurveFactory.cpp:599
void orient_segments(const bool aClosed, Cell< Node * > &aEndNodes, Cell< Segment * > &aSegments)
Definition cl_CurveFactory.cpp:1201
Curve * from_2d_sidesets(const Vector< id_t > &aSideSets, id_t aID)
Definition cl_CurveFactory.cpp:664
id_t & max_segment_id()
Definition cl_CurveFactory.hpp:193
void sort_end_nodes(Curve *aCurve, Matrix< index_t > &aAdjacency, Cell< Node * > &aEndNodes)
Definition cl_CurveFactory.cpp:1033
void sort_segments(Cell< Segment * > &aSegments)
Definition cl_CurveFactory.cpp:1229
bool intersection_exists(const id_t aSideSetA, const id_t aSideSetB)
Definition cl_CurveFactory.cpp:47
CurveFactory(Mesh *aMesh)
Definition cl_CurveFactory.cpp:35
Definition cl_Curve.hpp:27
Definition cl_Facet.hpp:24
Definition cl_Node.hpp:30
Definition cl_SideSet.hpp:29
Definition cl_EF_EdgeFunction.hpp:24
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int id_t
Definition typedefs.hpp:41
int proc_t
Definition commtypes.hpp:29
long long unsigned int key_t
Definition typedefs.hpp:43
uint32_t index_t
Definition typedefs.hpp:52