BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Chain.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#include <iostream>
13#include "typedefs.hpp"
14#include "assert.hpp"
15#include "cl_Map.hpp"
16#include "cl_OrderedMap.hpp"
17#include "cl_Cell.hpp"
18#include "cl_Vertex.hpp"
19#include "cl_Mesh.hpp"
20
21#ifndef BELFEM_CL_CHAIN_HPP
22#define BELFEM_CL_CHAIN_HPP
23
24namespace belfem
25{
26 namespace mesh
27 {
28//-----------------------------------------------------------------------------
35 class Chain
36 {
37 // Dimensions of the chain
38 int mDim ;
39
40 // Mesh
41 Mesh * mMesh ;
42
43 // Map of the k-simplices coefficients
44 OrderedMap< index_t, int > mSimplicesMap ;
45
46 // Boundary chain of the given chain
47 Chain * mBoundary = nullptr;
48
49 // Coboundary chain of the given chain
50 Chain * mCoboundary = nullptr;
51
52 bool mIsBound = false;
53 bool mIsCobound = false;
54
55//-----------------------------------------------------------------------------
56 public:
57//-----------------------------------------------------------------------------
58
59 Chain( const uint aDim, Mesh * aMesh, const bool aIsBound, const bool aIsCobound ) ;
60
61//-----------------------------------------------------------------------------
62
63 ~Chain();
64
65//-----------------------------------------------------------------------------
66
67 void
68 operator+( Chain * aChain ) ;
69
70//-----------------------------------------------------------------------------
71
72 void
73 operator-( Chain * aChain ) ;
74
75//-----------------------------------------------------------------------------
76
77 void
78 operator*( const int aMult ) ;
79
80//-----------------------------------------------------------------------------
81
82 int
83 operator()( Chain * aChain ) ;
84
85//-----------------------------------------------------------------------------
86
87 void
88 addSimplexToChain(const id_t aID, const int aCoeff ) ;
89
90//-----------------------------------------------------------------------------
91
92 void
93 removeSimplexToChain(const id_t aID) ;
94
95//-----------------------------------------------------------------------------
96
97 void
98 addChainToChain(Chain * aChain, int aCoeff) ;
99
100//-----------------------------------------------------------------------------
101
102 void
103 removeChainFromChain(Chain * aChain) ;
104
105//-----------------------------------------------------------------------------
106
109
110//-----------------------------------------------------------------------------
111
112 int
113 getCoefficient(const id_t aID) ;
114
115//-----------------------------------------------------------------------------
116
117 Chain *
118 getBoundary() ;
119
120//-----------------------------------------------------------------------------
121
122 Chain *
123 getCoboundary() ;
124
125//-----------------------------------------------------------------------------
126
127 void
128 add_simplex_to_boundary(id_t aID, const int aCoeff) ;
129
130//-----------------------------------------------------------------------------
131
132 void
133 add_simplex_to_coboundary(id_t aID, const int aCoeff) ;
134
135//-----------------------------------------------------------------------------
136
137 int
138 getDim() ;
139
140//-----------------------------------------------------------------------------
141
142 void
143 setCoefficient(const id_t aID, const int tCoeff) ;
144
145//-----------------------------------------------------------------------------
146
147 void
148 print() ;
149
150//-----------------------------------------------------------------------------
151
152 };
153
154
155//-----------------------------------------------------------------------------
156
159 {
160 return mSimplicesMap;
161 }
162
163//------------------------------------------------------------------------------
164
165 inline int
167 {
168 auto it = mSimplicesMap.find(aID);
169 if (it != mSimplicesMap.end()) {
170 return it->second;
171 }
172 else {
173 return 0;
174 }
175 }
176
177//------------------------------------------------------------------------------
178
179 inline Chain *
181 {
182 return mBoundary;
183 }
184
185//-----------------------------------------------------------------------------
186
187 inline Chain *
189 {
190 return mCoboundary;
191 }
192
193//-----------------------------------------------------------------------------
194
195 inline void
196 Chain::add_simplex_to_boundary( id_t aID, const int aCoeff )
197 {
198 mBoundary->addSimplexToChain(aID,aCoeff);
199 }
200
201//-----------------------------------------------------------------------------
202
203 inline void
205 {
206 mCoboundary->addSimplexToChain(aID,aCoeff);
207 }
208
209//-----------------------------------------------------------------------------
210
211 inline int
213 {
214 return mDim;
215 }
216
217//-----------------------------------------------------------------------------
218 }
219}
220#endif //BELFEM_CL_CHAIN_HPP
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
auto find(const Key &tKey) const -> decltype(mMap.find(tKey))
Definition cl_OrderedMap.hpp:139
Formal sum of k-simplices (homology).
Definition cl_Chain.hpp:36
int operator()(Chain *aChain)
Definition cl_Chain.cpp:84
int getDim()
Definition cl_Chain.hpp:212
void operator-(Chain *aChain)
Definition cl_Chain.cpp:65
Chain * getBoundary()
Definition cl_Chain.hpp:180
void operator*(const int aMult)
Definition cl_Chain.cpp:73
void setCoefficient(const id_t aID, const int tCoeff)
Definition cl_Chain.cpp:182
Chain * getCoboundary()
Definition cl_Chain.hpp:188
void removeSimplexToChain(const id_t aID)
Definition cl_Chain.cpp:125
void add_simplex_to_boundary(id_t aID, const int aCoeff)
Definition cl_Chain.hpp:196
void operator+(Chain *aChain)
Definition cl_Chain.cpp:57
void addChainToChain(Chain *aChain, int aCoeff)
Definition cl_Chain.cpp:134
void addSimplexToChain(const id_t aID, const int aCoeff)
Definition cl_Chain.cpp:101
OrderedMap< id_t, int > & getSimplicesMap()
Definition cl_Chain.hpp:158
int getCoefficient(const id_t aID)
Definition cl_Chain.hpp:166
void add_simplex_to_coboundary(id_t aID, const int aCoeff)
Definition cl_Chain.hpp:204
void print()
Definition cl_Chain.cpp:197
void removeChainFromChain(Chain *aChain)
Definition cl_Chain.cpp:163
Chain(const uint aDim, Mesh *aMesh, const bool aIsBound, const bool aIsCobound)
Definition cl_Chain.cpp:21
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