svZeroDSolver
Loading...
Searching...
No Matches
ResistiveJunction.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 ResistiveJunction.h
32 * @brief model::ResistiveJunction source file
33 */
34#ifndef SVZERODSOLVER_MODEL_RESISTIVEJUNCTION_HPP_
35#define SVZERODSOLVER_MODEL_RESISTIVEJUNCTION_HPP_
36
37#include "Block.h"
38#include "SparseSystem.h"
39
40/**
41 * @brief ResistiveJunction
42 *
43 * Models a junction with arbitrary resistive inlets and outlets. Across all
44 * inlets and outlets of the junction, mass is conserved.
45 *
46 * \f[
47 * \begin{circuitikz}
48 * \draw [-latex] (0.25,1.4) node[left] {$Q_{in,1}$} -- (0.85,1.1);
49 * \draw [-latex] (0.25,-1.4) node[left] {$Q_{in,1}$} -- (0.85,-1.1);
50 * \draw (1,1.0) node[anchor=south]{$P_{in,1}$} to [R, , l=$R_{in,1}$, *-*]
51 * (3.0,0) node[anchor=north] {$P_{C}$}; \draw (1,-1.0)
52 * node[anchor=north]{$P_{in, 2}$} to [R, , l=$R_{in,2}$, *-*] (3.0,0); \draw
53 * (3,0) node[anchor=south]{} to [R, l=$R_{out,1}$, -*] (5,1.0); \draw
54 (4.3,1.1)
55 * node[anchor=south] {$P_{out,1}$}; \draw (3,0) node[anchor=south]{} to [R,
56 * l=$R_{out,2}$, -*] (5,-1.0); \draw (4.3,-1.1) node[anchor=north]
57 * {$P_{out,2}$}; \draw [-latex] (5.15,1.1) -- (5.75,1.4) node[right]
58 * {$Q_{out,1}$}; \draw [-latex] (5.15,-1.1) -- (5.75,-1.4) node[right]
59 * {$Q_{out,2}$}; \end{circuitikz}
60 * \f]
61 *
62 * ### Governing equations
63 *
64 * \f[
65 * \sum_{i}^{n_{inlets}} Q_{in, i}=\sum_{j}^{n_{outlets}} Q_{out, j}
66 * \f]
67 *
68 * \f[
69 * P_{in,i}-P_{C}=R_{in,i} \cdot Q_{in,i}\quad \forall i\in n_{inlets}
70 * \f]
71 * \f[
72 * P_{C}-P_{out,j}=R_{out,j} \cdot Q_{out,j}\quad \forall j\in n_{outlets}
73 * \f]
74 *
75 * ### Local contributions
76 *
77 * \f[
78 * \mathbf{y}^{e}=\left[\begin{array}{lllllllllll}P_{in, 1}^{e} & Q_{in, 1}^{e}
79 * & \dots & P_{in, i}^{e} & Q_{in, i}^{e} & P_{out, 1}^{e} & Q_{out, 1}^{e} &
80 * \dots & P_{out, i}^{e} & Q_{out, i}^{e} & P_{C}\end{array}\right] \f]
81 *
82 * Mass conservation
83 *
84 * \f[
85 * \mathbf{F}^{e}_1 = \left[\begin{array}{lllllllllll}0 & 1 & 0 & 1 & \dots & 0
86 * & -1 & 0 & -1 & \dots & 0\end{array}\right] \f]
87 *
88 * \f[ \mathbf{F}^{e}_{2,...,n} = \left[\begin{array}{lllll}\dots &
89 * \underbrace{1}_{P_{in,i}} & \underbrace{-R_{in,i}}_{Q_{in,i}} & \dots &
90 * \underbrace{-1}_{P_{C}}\end{array}\right] \quad \mathrm{with} \quad \forall
91 * i\in n_{inlets} \f]
92 *
93 * \f[ \mathbf{F}^{e}_{2,...,n} = \left[\begin{array}{lllll}\dots &
94 * \underbrace{-1}_{P_{out,j}} & \underbrace{-R_{out,j}}_{Q_{out,j}} & \dots &
95 * \underbrace{1}_{P_{C}}\end{array}\right] \quad \mathrm{with} \quad \forall
96 * j\in n_{oulets} \f]
97 *
98 * ### Parameters
99 *
100 * Parameter sequence for constructing this block
101 *
102 * * `i` Poiseuille resistance for inner blood vessel `i`
103 *
104 * ### Internal variables
105 *
106 * Names of internal variables in this block's output:
107 *
108 * * `pressure_c`: Pressure at the center of the junction
109 *
110 */
111class ResistiveJunction : public Block {
112 public:
113 /**
114 * @brief Construct a new ResistiveJunction object
115 *
116 * @param id Global ID of the block
117 * @param model The model to which the block belongs
118 */
120 : Block(id, model, BlockType::resistive_junction, BlockClass::junction,
121 {{"R", InputParameter()}}) {}
122
123 /**
124 * @brief Set up the degrees of freedom (DOF) of the block
125 *
126 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
127 * number of equations and the number of internal variables of the
128 * element.
129 *
130 * @param dofhandler Degree-of-freedom handler to register variables and
131 * equations at
132 */
133 void setup_dofs(DOFHandler &dofhandler);
134
135 /**
136 * @brief Update the constant contributions of the element in a sparse system
137 *
138 * @param system System to update contributions at
139 * @param parameters Parameters of the model
140 */
141 void update_constant(SparseSystem &system, std::vector<double> &parameters);
142
143 /**
144 * @brief Number of triplets of element
145 *
146 * Number of triplets that the element contributes to the global system
147 * (relevant for sparse memory reservation)
148 */
150
151 private:
152 int num_inlets;
153 int num_outlets;
154};
155
156#endif // SVZERODSOLVER_MODEL_RESISTIVEJUNCTION_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
Degree-of-freedom handler.
Definition DOFHandler.h:48
Model of 0D elements.
Definition Model.h:75
ResistiveJunction.
Definition ResistiveJunction.h:111
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ResistiveJunction.cpp:33
ResistiveJunction(int id, Model *model)
Construct a new ResistiveJunction object.
Definition ResistiveJunction.h:119
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ResistiveJunction.cpp:42
TripletsContributions num_triplets
Number of triplets of element.
Definition ResistiveJunction.h:149
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