svZeroDSolver
Loading...
Searching...
No Matches
ClosedLoopRCRBC.h
Go to the documentation of this file.
1// Copyright (c) Stanford University, The Regents of the University of
2// California, and others.
3//
4// All Rights Reserved.
5//
6// See Copyright-SimVascular.txt for additional details.
7//
8// Permission is hereby granted, free of charge, to any person obtaining
9// a copy of this software and associated documentation files (the
10// "Software"), to deal in the Software without restriction, including
11// without limitation the rights to use, copy, modify, merge, publish,
12// distribute, sublicense, and/or sell copies of the Software, and to
13// permit persons to whom the Software is furnished to do so, subject
14// to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included
17// in all copies or substantial portions of the Software.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30/**
31 * @file ClosedLoopRCRbc.h
32 * @brief model::ClosedLoopRCRBC source file
33 */
34#ifndef SVZERODSOLVER_MODEL_CLOSEDLOOPRCRBC_HPP_
35#define SVZERODSOLVER_MODEL_CLOSEDLOOPRCRBC_HPP_
36
37#include "Block.h"
38#include "SparseSystem.h"
39
40/**
41 * @brief Closed-loop RCR boundary condition.
42 *
43 * Models the mechanical behavior of a Windkessel boundary condition that is
44 * connected to other blocks on both sides.
45 *
46 * \f[
47 * \begin{circuitikz} \draw
48 * node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
49 * \draw (1,0) node[anchor=south]{$P_{in}$}
50 * to [R, l=$R_p$, *-] (3,0)
51 * node[anchor=south]{$P_{c}$}
52 * to [R, l=$R_d$, *-*] (5,0)
53 * node[anchor=south]{$P_{out}$}
54 * (3,0) to [C, l=$C$, *-] (3,-1.5)
55 * node[ground]{};
56 * \draw [-latex] (5.2,0) -- (6.0,0) node[right] {$Q_{out}$} ;
57 * \end{circuitikz}
58 * \f]
59 *
60 * ### Governing equations
61 *
62 * \f[
63 * C \frac{d P_c}{dt} + Q_{out} -Q_{in} = 0
64 * \f]
65 *
66 * \f[
67 * P_{in}-P_{c}-R_{p} Q_{in}=0
68 * \f]
69 *
70 * \f[
71 * P_{c} - P_{out} - R_{d} Q_{out}=0
72 * \f]
73 *
74 * ### Local contributions
75 *
76 * \f[
77 * \mathbf{y}^e=\left[\begin{array}{lllll}P_{in} & Q_{in} & P_{out} & Q_{out} &
78 * P_{c}\end{array}\right]^{T} \f]
79 *
80 * \f[
81 * \mathbf{E}^{e}=\left[\begin{array}{ccccc}
82 * 0 & 0 & 0 & 0 & C \\
83 * 0 & 0 & 0 & 0 & 0 \\
84 * 0 & 0 & 0 & 0 & 0 \\
85 * \end{array}\right]
86 * \f]
87 *
88 * \f[
89 * \mathbf{F}^{e}=\left[\begin{array}{ccccc}
90 * 0 & -1 & 1 & 0 & 0 \\
91 * 1 & -R_p & 0 & 0 & -1 \\
92 * 0 & 0 & -1 & -R_d & +1 \\
93 * \end{array}\right]
94 * \f]
95 *
96 * \f[
97 * \mathbf{c}^{e}=\left[\begin{array}{c}
98 * 0 \\
99 * 0 \\
100 * 0
101 * \end{array}\right]
102 * \f]
103 *
104 * ### Parameters
105 *
106 * Parameter sequence for constructing this block
107 *
108 * * `0` Proximal resistance
109 * * `1` Capacitance
110 * * `2` Distal resistance
111 *
112 * ### Internal variables
113 *
114 * Names of internal variables in this block's output:
115 *
116 * * `P_c`: Pressure at the capacitor
117 *
118 */
119class ClosedLoopRCRBC : public Block {
120 public:
121 /**
122 * @brief Construct a new ClosedLoopRCRBC object
123 *
124 * @param id Global ID of the block
125 * @param model The model to which the block belongs
126 */
128 : Block(id, model, BlockType::closed_loop_rcr_bc,
129 BlockClass::boundary_condition,
130 {{"Rp", InputParameter()},
131 {"C", InputParameter()},
132 {"Rd", InputParameter()},
133 {"closed_loop_outlet", InputParameter(true, false, false)}}) {}
134
135 /**
136 * @brief Local IDs of the parameters
137 *
138 */
139 enum ParamId {
140 RP = 0,
141 C = 1,
142 RD = 2,
143 };
144
145 /**
146 * @brief Set up the degrees of freedom (DOF) of the block
147 *
148 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
149 * number of equations and the number of internal variables of the
150 * element.
151 *
152 * @param dofhandler Degree-of-freedom handler to register variables and
153 * equations at
154 */
155 void setup_dofs(DOFHandler &dofhandler);
156
157 /**
158 * @brief Update the constant contributions of the element in a sparse
159 system
160 *
161 * @param system System to update contributions at
162 * @param parameters Parameters of the model
163 */
164 void update_constant(SparseSystem &system, std::vector<double> &parameters);
165
166 /**
167 * @brief Number of triplets of element
168 *
169 * Number of triplets that the element contributes to the global system
170 * (relevant for sparse memory reservation)
171 */
173};
174
175#endif // SVZERODSOLVER_MODEL_CLOSEDLOOPRCRBCBC_HPP_
model::Block source file
BlockType
The types of blocks supported by the solver.
Definition BlockType.h:42
BlockClass
The classes/categories of blocks supported. Some classes require special handling (e....
Definition BlockType.h:64
SparseSystem source file.
Base class for 0D model components.
Definition Block.h:101
const int id
Global ID of the block.
Definition Block.h:103
const Model * model
The model to which the block belongs.
Definition Block.h:104
Closed-loop RCR boundary condition.
Definition ClosedLoopRCRBC.h:119
ClosedLoopRCRBC(int id, Model *model)
Construct a new ClosedLoopRCRBC object.
Definition ClosedLoopRCRBC.h:127
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ClosedLoopRCRBC.cpp:37
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ClosedLoopRCRBC.cpp:33
ParamId
Local IDs of the parameters.
Definition ClosedLoopRCRBC.h:139
TripletsContributions num_triplets
Number of triplets of element.
Definition ClosedLoopRCRBC.h:172
Degree-of-freedom handler.
Definition DOFHandler.h:48
Model of 0D elements.
Definition Model.h:75
Sparse system.
Definition SparseSystem.h:57
Handles the properties of input parameters.
Definition Parameter.h:127
The number of triplets that the element contributes to the global system.
Definition Block.h:52