svMultiPhysics
Loading...
Searching...
No Matches
ActiveStress.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef ACTIVE_STRESS_H
5#define ACTIVE_STRESS_H
6
7#include "Array.h"
8#include "Parameters.h"
9#include "Vector.h"
10#include "consts.h"
11#include "factory.h"
12
13#include "CmMod.h"
14
15#include <memory>
16
17/**
18 * @brief Return whether a certain equation type can be solved with active
19 * stress.
20 */
21bool supports_active_stress(const consts::EquationType eq_type);
22
23/**
24 * @brief Abstract active stress class.
25 *
26 * This class provides an interface for defining active stress models, i.e.
27 * models that, in the context of structural mechanics of muscular tissue,
28 * compute an active tension representing the contribution of muscular
29 * contraction to the constitiutive law.
30 *
31 * The class assumes that the active tension can be expressed as
32 * @f[
33 * \Tact = \Tact(t, \calcium, \fiberstretch, \fiberstretchrate,
34 * \astressstate),
35 * @f]
36 * where @f$\calcium@f$ is the intracellular calcium concentration,
37 * @f$\fiberstretch@f$ is the fiber stretch, @f$\fiberstretchrate@f$ is the
38 * fiber stretch rate, and @f$\astressstate@f$ is a vector of internal state
39 * variables, representing the state of contraction.
40 *
41 * The expression assumed above implies that the active tension is a local
42 * function of the variables it depends on, that is the active tension at a
43 * given point only depends on the value of other variables at that same point.
44 * Accordingly, this class works nodally, by evaluating the active tension at
45 * every mesh node and storing it in a vector, whose values can be accessed
46 * through @ref ActiveStress::get_tension_fibers.
47 *
48 * ### Directional distribution of active stress
49 *
50 * In muscular mechanics models, active stress normally acts only along the
51 * direction of fibers @f$\fiberdirection@f$, reflecting the fact that
52 * contractile units are aligned with fibers. However, one might want to account
53 * for fiber dispersion, i.e. the fact that fibers are not perfectly and
54 * regularly aligned, but rather have a certain distribution of orientations
55 * centered around the principal direction @f$\fiberdirection@f$.
56 *
57 * This can be surrogated by defining the active stress tensor as
58 * @f[
59 * S_\text{act} = \Tact \left(
60 * \eta_f \fiberdirection \otimes \fiberdirection +
61 * \eta_s \sheetdirection \otimes \sheetdirection +
62 * \eta_n \sheetnormaldirection \otimes \sheetnormaldirection
63 * \right),
64 * @f]
65 * where @f$\sheetdirection@f$ and @f$\sheetnormaldirection@f$ are the sheet and
66 * sheet-normal directions, respectively, and @f$\eta_f@f$, @f$\eta_s@f$, and
67 * @f$\eta_n@f$ are coefficients that define the distribution the active tension
68 * along the three principal directions. The coefficients must be such that
69 * @f$\eta_f + \eta_s + \eta_n = 1@f$.
70 *
71 * This class stores the values of @f$\eta_f@f$, @f$\eta_s@f$ and @f$\eta_n@f$,
72 * and provides the functions @ref ActiveStress::get_tension_fibers,
73 * @ref ActiveStress::get_tension_sheets and @ref
74 * ActiveStress::get_tension_sheet_normals to access @f$\eta_f \Tact@f$,
75 * @f$\eta_s \Tact@f$ and @f$\eta_n \Tact@f$, respectively.
76 *
77 * ### Implementing concrete active stress models
78 *
79 * To implement a new active stress model, the following steps need to be taken:
80 *
81 * 1. Create a new class derived from @ref ActiveStress.
82 * 2. Override the methods @ref init_local, @ref advance_time_step_local and
83 * @ref compute_active_tension_local, defining the initial condition,
84 * time evolution and active tension computation, respectively, for a single
85 * node.
86 * 3. Create a new class derived from @ref ActiveStressModelParameters to store
87 * the parameters specific to the new active stress model.
88 * 4. Override the methods @ref get_parameters,
89 * @ref read_model_specific_parameters and
90 * @ref distribute_model_specific_parameters to manage the parameters of the
91 * new active stress model.
92 * 5. Register the new class into the active stress model factory by using the
93 * macro @ref REGISTER_ACTIVE_STRESS_MODEL. The macro should be called in a
94 * `.cpp` file, not in a header file.
95 *
96 * Notice that if the model is expressed in terms of a system of ODEs, it can
97 * be implemented by deriving from @ref ActiveStressODE, which already addresses
98 * some of the points above.
99 */
101public:
102 /**
103 * @brief Constructor.
104 *
105 * @param n_states_ Number of state variables for this model.
106 * @param needs_fiber_stretch Whether this model uses the fiber stretch
107 * passed to @ref advance_time_step. This flag can be used to determine
108 * whether fiber stretch computation can be skipped for efficiency.
109 * @param needs_fiber_stretch_rate Whether this model uses the fiber stretch
110 * rate passed to @ref advance_time_step. This flag can be used to determine
111 * whether fiber stretch rate computation can be skipped for efficiency.
112 */
117
118 /**
119 * @brief Virtual destructor.
120 */
121 virtual ~ActiveStress() = default;
122
123 /**
124 * @brief Construct an instance of model parameters for this model.
125 */
126 virtual std::unique_ptr<ActiveStressModelParameters>
127 get_parameters() const = 0;
128
129 /**
130 * @brief Read model parameters from a parameter object.
131 */
132 void read_parameters(const ActiveStressParameters &params);
133
134 /**
135 * @brief Distribute model parameters to all parallel processes.
136 */
137 void distribute_parameters(const CmMod &cm_mod, const cmType &cm);
138
139 /**
140 * @brief Get the tension along fibers @f$\eta_f \Tact@f$ at a given point.
141 */
142 double get_tension_fibers(const int idx) const {
143 return eta_f * active_tension[idx];
144 }
145
146 /**
147 * @brief Get the tension along sheets @f$\eta_s \Tact@f$ at a given point.
148 */
149 double get_tension_sheets(const int idx) const {
150 return eta_s * active_tension[idx];
151 }
152
153 /**
154 * @brief Get the tension along sheet normals @f$\eta_n \Tact@f$ at a given
155 * point.
156 */
157 double get_tension_sheet_normals(const int idx) const {
158 return eta_n * active_tension[idx];
159 }
160
161 /**
162 * @brief Initialize the model.
163 *
164 * Allocates the internal state vector and initializes it with the model's
165 * initial conditions.
166 *
167 * @param[in] tnNo Total number of mesh nodes for the current rank.
168 */
169 virtual void init(const unsigned int tnNo);
170
171 /**
172 * @brief Advance in time.
173 *
174 * @param[in] t Current time (i.e. the time instant being advanced to).
175 * @param[in] dt Time step size.
176 * @param[in] calcium Calcium concentration at every node.
177 * @param[in] fiber_stretch Fiber stretch at every node. This is usually
178 * computed with post::fib_stretch.
179 * @param[in] fiber_stretch_rate Fiber stretch rate at every node. This is
180 * usually computed with post::fib_stretch_rate.
181 */
182 virtual void advance_time_step(const double t, const double dt,
183 const Vector<double> &calcium,
184 const Vector<double> &fiber_stretch,
185 const Vector<double> &fiber_stretch_rate);
186
187 /// Number of state variables for this model.
188 const unsigned int n_states;
189
190 /**
191 * @brief Whether this model uses the fiber stretch passed to
192 * @ref advance_time_step. This flag can be used to determine whether fiber
193 * stretch computation can be skipped for efficiency.
194 */
196
197 /**
198 * @brief Whether this model uses the fiber stretch rate passed to
199 * @ref advance_time_step. This flag can be used to determine whether fiber
200 * stretch rate computation can be skipped for efficiency.
201 */
203
204protected:
205 /**
206 * @brief Backing store for @ref needs_fiber_stretch.
207 */
209
210 /**
211 * @brief Backing store for @ref needs_fiber_stretch_rate.
212 */
214
215 /**
216 * @brief Read model parameters from a parameter object.
217 *
218 * This method needs to be overridden by derived classes to read the
219 * parameters specific to the concrete model they implement.
220 */
221 virtual void
223
224 /**
225 * @brief Distribute model parameters to all parallel processes.
226 *
227 * This method needs to be overridden by derived classes to distribute the
228 * parameters specific to the concrete model they implement to all parallel
229 * processes.
230 */
231 virtual void distribute_model_specific_parameters(const CmMod &cm_mod,
232 const cmType &cm) = 0;
233
234 /**
235 * @brief Initialize the state vector for a single node.
236 *
237 * @param[out] state State vector for a single node, to be initialized by
238 * this function.
239 */
240 virtual void init_local(Vector<double> &state) const = 0;
241
242 /**
243 * @brief Advance in time for a single node.
244 *
245 * @param[in] t Current time (i.e. the time instant being advanced to).
246 * @param[in] dt Time step size.
247 * @param[in] calcium Calcium concentration at the current node.
248 * @param[in] fiber_stretch Fiber stretch at the current node.
249 * @param[in] fiber_stretch_rate Fiber stretch rate at the current node.
250 * @param[in,out] state State vector for a single node, to be updated by
251 * this function.
252 */
253 virtual void advance_time_step_local(const double t, const double dt,
254 const double calcium,
255 const double fiber_stretch,
256 const double fiber_stretch_rate,
257 Vector<double> &state) const = 0;
258
259 /**
260 * @brief Compute the active tension for a single node.
261 *
262 * @param[in] state State vector for a single node.
263 * @param[in] fiber_stretch Fiber stretch at the current node.
264 */
265 virtual double
267 const double fiber_stretch) const = 0;
268
269 /// Current time. Updated whenever calling @ref advance_time_step.
270 double time;
271
272 /// State variables for the model.
273 Array<double> states;
274
275 /// Active tension at every node.
277
278 /// Active tension coefficient along the fiber direction.
279 double eta_f;
280
281 /// Active tension coefficient along the sheet direction.
282 double eta_s;
283
284 /// Active tension coefficient along the sheet-normal direction.
285 double eta_n;
286};
287
288/**
289 * @brief Alias for the active stress model factory.
290 *
291 * See the documentation for @ref Factory for more details on how this works.
292 */
294
295/**
296 * @brief Macro to register an active stress model in the factory.
297 */
298#define REGISTER_ACTIVE_STRESS_MODEL(name, type) \
299 REGISTER_IN_FACTORY(ActiveStress, type, name)
300
301#endif
Abstract active stress class.
Definition ActiveStress.h:100
virtual void init_local(Vector< double > &state) const =0
Initialize the state vector for a single node.
double get_tension_sheet_normals(const int idx) const
Get the tension along sheet normals at a given point.
Definition ActiveStress.h:157
double eta_n
Active tension coefficient along the sheet-normal direction.
Definition ActiveStress.h:285
double time
Current time. Updated whenever calling advance_time_step.
Definition ActiveStress.h:270
virtual void advance_time_step_local(const double t, const double dt, const double calcium, const double fiber_stretch, const double fiber_stretch_rate, Vector< double > &state) const =0
Advance in time for a single node.
bool needs_fiber_stretch_
Backing store for needs_fiber_stretch.
Definition ActiveStress.h:208
virtual double compute_active_tension_local(const Vector< double > &state, const double fiber_stretch) const =0
Compute the active tension for a single node.
virtual void advance_time_step(const double t, const double dt, const Vector< double > &calcium, const Vector< double > &fiber_stretch, const Vector< double > &fiber_stretch_rate)
Advance in time.
Definition ActiveStress.cpp:45
virtual void read_model_specific_parameters(const ActiveStressModelParameters &params)=0
Read model parameters from a parameter object.
double eta_f
Active tension coefficient along the fiber direction.
Definition ActiveStress.h:279
bool needs_fiber_stretch_rate_
Backing store for needs_fiber_stretch_rate.
Definition ActiveStress.h:213
Vector< double > active_tension
Active tension at every node.
Definition ActiveStress.h:276
void read_parameters(const ActiveStressParameters &params)
Read model parameters from a parameter object.
Definition ActiveStress.cpp:12
double get_tension_fibers(const int idx) const
Get the tension along fibers at a given point.
Definition ActiveStress.h:142
Array< double > states
State variables for the model.
Definition ActiveStress.h:273
double eta_s
Active tension coefficient along the sheet direction.
Definition ActiveStress.h:282
const unsigned int n_states
Number of state variables for this model.
Definition ActiveStress.h:188
void distribute_parameters(const CmMod &cm_mod, const cmType &cm)
Distribute model parameters to all parallel processes.
Definition ActiveStress.cpp:21
bool needs_fiber_stretch_rate() const
Whether this model uses the fiber stretch rate passed to advance_time_step. This flag can be used to ...
Definition ActiveStress.h:202
virtual ~ActiveStress()=default
Virtual destructor.
virtual std::unique_ptr< ActiveStressModelParameters > get_parameters() const =0
Construct an instance of model parameters for this model.
bool needs_fiber_stretch() const
Whether this model uses the fiber stretch passed to advance_time_step. This flag can be used to deter...
Definition ActiveStress.h:195
virtual void distribute_model_specific_parameters(const CmMod &cm_mod, const cmType &cm)=0
Distribute model parameters to all parallel processes.
virtual void init(const unsigned int tnNo)
Initialize the model.
Definition ActiveStress.cpp:30
double get_tension_sheets(const int idx) const
Get the tension along sheets at a given point.
Definition ActiveStress.h:149
ActiveStress(const unsigned int n_states_, const bool needs_fiber_stretch, const bool needs_fiber_stretch_rate)
Constructor.
Definition ActiveStress.h:113
Parameters for a generic active stress model.
Definition Parameters.h:1444
Parameters for active stress models.
Definition Parameters.h:1534
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:36
Abstract self-registering factory.
Definition factory.h:30
The Vector template class is used for storing int and double data.
Definition Vector.h:26
The cmType class stores data and defines methods used for mpi communication.
Definition CmMod.h:56