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