BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_TimestepMatrices.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, through
4 * 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 BELFEM_CL_FEM_TIMESTEPMATRICES_HPP
13#define BELFEM_CL_FEM_TIMESTEPMATRICES_HPP
14
15#include "typedefs.hpp"
16#include "cl_Vector.hpp"
17#include "cl_Matrix.hpp"
18#include "cl_Bitset.hpp"
19
20namespace belfem
21{
22 namespace fem
23 {
31 enum class MatrixFlag : index_t
32 {
33 M = 0,
34 D = 1,
35 K = 2,
36 F = 3,
40 dFdX = 7
41 };
42
71 {
72 //--------------------------------------------------------------
73 // Physics matrices (populated by IWG) - all DENSE, n_e × n_e
74 //--------------------------------------------------------------
75
80
81 // Contracted derivatives: (dX_ik/dx_j) * v_k for some vector v
82 // These are dense n_e × n_e matrices, computed by IWG
83 Matrix< real > mdMdX_times_x;
84 Matrix< real > mdMdX_times_h;
85 Matrix< real > mdKdX_times_x;
86 Matrix< real > mdFdX;
87
88 //--------------------------------------------------------------
89 // Assembled element system (computed by time-stepping scheme)
90 //--------------------------------------------------------------
91
93 Matrix< real > mdJdx;
94
95 //--------------------------------------------------------------
96 // Flags
97 //--------------------------------------------------------------
98
99 Bitset< 8 > mFlags;
100
101 public:
102
103 //--------------------------------------------------------------
104 // Constructor / Destructor
105 //--------------------------------------------------------------
106
107 TimestepMatrices() = default;
108 ~TimestepMatrices() = default;
109
114 void
115 initialize( const index_t aNumDofs );
116
117 void
118 reset();
119
120 //--------------------------------------------------------------
121 // Flag management
122 //--------------------------------------------------------------
123
127 void
129 {
130 mFlags.reset();
131 }
132
136 void
137 set_flag( const MatrixFlag aFlag )
138 {
139 mFlags.set( static_cast< index_t >( aFlag ) );
140 }
141
145 bool
146 has_flag( const MatrixFlag aFlag ) const
147 {
148 return mFlags.test( static_cast< index_t >( aFlag ) );
149 }
150
154 const Bitset< 8 > &
155 flags() const
156 {
157 return mFlags;
158 }
159
160 //--------------------------------------------------------------
161 // Const accessors
162 //--------------------------------------------------------------
163
164 const Matrix< real > & M() const { return mM; }
165 const Matrix< real > & D() const { return mD; }
166 const Matrix< real > & K() const { return mK; }
167 const Vector< real > & f() const { return mF; }
168
169 const Matrix< real > & dMdx_times_x() const { return mdMdX_times_x; }
170 const Matrix< real > & dMdx_times_h() const { return mdMdX_times_h; }
171 const Matrix< real > & dKdx_times_x() const { return mdKdX_times_x; }
172 const Matrix< real > & dfdx() const { return mdFdX; }
173
174 const Matrix< real > & J() const { return mJ; }
175 const Matrix< real > & dJdx() const { return mdJdx; }
176
177 //--------------------------------------------------------------
178 // Non-const accessors (for IWG to fill)
179 //--------------------------------------------------------------
180
181 Matrix< real > & M() { return mM; }
182 Matrix< real > & D() { return mD; }
183 Matrix< real > & K() { return mK; }
184 Vector< real > & f() { return mF; }
185
186 Matrix< real > & dMdx_times_x() { return mdMdX_times_x; }
187 Matrix< real > & dMdx_times_h() { return mdMdX_times_h; }
188 Matrix< real > & dKdx_times_x() { return mdKdX_times_x; }
189 Matrix< real > & dfdx() { return mdFdX; }
190
191 //--------------------------------------------------------------
192 // Assembly methods
193 //--------------------------------------------------------------
194
195 void
196 assemble_J( const real adt );
197
205 void
206 assemble_dJdx( const real adt, const real aAlpha = 1.0 );
207
208
209 };
210
211 } // namespace fem
212} // namespace belfem
213
214#endif // BELFEM_CL_FEM_TIMESTEPMATRICES_HPP
void reset()
Definition cl_TimestepMatrices.cpp:63
const Matrix< real > & dMdx_times_x() const
Definition cl_TimestepMatrices.hpp:169
const Matrix< real > & dMdx_times_h() const
Definition cl_TimestepMatrices.hpp:170
bool has_flag(const MatrixFlag aFlag) const
Check if a matrix has been populated.
Definition cl_TimestepMatrices.hpp:146
const Matrix< real > & J() const
Definition cl_TimestepMatrices.hpp:174
const Matrix< real > & dKdx_times_x() const
Definition cl_TimestepMatrices.hpp:171
const Bitset< 8 > & flags() const
Direct access to flags bitset.
Definition cl_TimestepMatrices.hpp:155
void reset_flags()
Clear all flags ( unused; the IWG sets its flags once in the constructor ).
Definition cl_TimestepMatrices.hpp:128
Matrix< real > & D()
Definition cl_TimestepMatrices.hpp:182
Matrix< real > & dKdx_times_x()
Definition cl_TimestepMatrices.hpp:188
Matrix< real > & M()
Definition cl_TimestepMatrices.hpp:181
void initialize(const index_t aNumDofs)
Initialize all matrices to given size.
Definition cl_TimestepMatrices.cpp:15
const Matrix< real > & dJdx() const
Definition cl_TimestepMatrices.hpp:175
Vector< real > & f()
Definition cl_TimestepMatrices.hpp:184
const Matrix< real > & D() const
Definition cl_TimestepMatrices.hpp:165
const Matrix< real > & M() const
Definition cl_TimestepMatrices.hpp:164
Matrix< real > & dMdx_times_x()
Definition cl_TimestepMatrices.hpp:186
void set_flag(const MatrixFlag aFlag)
Set a flag after populating corresponding matrix.
Definition cl_TimestepMatrices.hpp:137
Matrix< real > & K()
Definition cl_TimestepMatrices.hpp:183
const Matrix< real > & K() const
Definition cl_TimestepMatrices.hpp:166
Matrix< real > & dfdx()
Definition cl_TimestepMatrices.hpp:189
Matrix< real > & dMdx_times_h()
Definition cl_TimestepMatrices.hpp:187
void assemble_J(const real adt)
Definition cl_TimestepMatrices.cpp:112
const Matrix< real > & dfdx() const
Definition cl_TimestepMatrices.hpp:172
void assemble_dJdx(const real adt, const real aAlpha=1.0)
Assemble the Newton correction dJ/dx.
Definition cl_TimestepMatrices.cpp:131
const Vector< real > & f() const
Definition cl_TimestepMatrices.hpp:167
Definition cl_IFB_LINE3.hpp:21
MatrixFlag
Flags indicating which matrices/vectors have been set by the IWG.
Definition cl_TimestepMatrices.hpp:32
@ dKdX_times_x
Contracted stiffness derivative.
Definition cl_TimestepMatrices.hpp:39
@ dFdX
Force vector Jacobian df_i/dx_j.
Definition cl_TimestepMatrices.hpp:40
@ M
Mass matrix.
Definition cl_TimestepMatrices.hpp:33
@ dMdX_times_h
Contracted mass derivative with history: (dM_ik/dx_j) * h_k.
Definition cl_TimestepMatrices.hpp:38
@ K
Stiffness matrix.
Definition cl_TimestepMatrices.hpp:35
@ dMdX_times_x
Contracted mass derivative: (dM_ik/dx_j) * x_k.
Definition cl_TimestepMatrices.hpp:37
@ D
Damping matrix (reserved for second-order).
Definition cl_TimestepMatrices.hpp:34
USER GUIDES:
Definition cl_Capacitor.cpp:16
uint32_t index_t
Definition typedefs.hpp:52
double real
Definition typedefs.hpp:36