svZeroDSolver
Loading...
Searching...
No Matches
DOFHandler.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 DofHandler.h
32 * @brief model::DOFHandler source file
33 */
34#ifndef SVZERODSOLVER_MODEL_DOFHANDLER_HPP_
35#define SVZERODSOLVER_MODEL_DOFHANDLER_HPP_
36
37#include <map>
38#include <string>
39#include <vector>
40
41/**
42 * @brief Degree-of-freedom handler.
43 *
44 * This class handles degrees-of-freedom for model variables and
45 * equations. It assigns each element with row and column indices which it
46 * can use to assemble it's local contributions into the global system.
47 */
49 private:
50 int var_counter{0}; ///< Variable counter
51 int eqn_counter{0}; ///< Equation counter
52
53 public:
54 std::vector<std::string>
55 variables; ///< Variable names corresponding to the variable indices
56 std::map<std::string, int>
57 variable_name_map; ///< Map between variable name and index
58 std::vector<std::string>
59 equations; ///< Equation names corresponding to the equation indices
60
61 /**
62 * @brief Get the size of the system
63 *
64 * @return Size of the system
65 */
66 int size() const;
67
68 /**
69 * @brief Get the number of equations
70 *
71 * @return int Number of equations
72 */
73 int get_num_equations() const;
74
75 /**
76 * @brief Get the number of variables
77 *
78 * @return int Number of variables
79 */
80 int get_num_variables() const;
81
82 /**
83 * @brief Register a new variable at the DOFHandler.
84 *
85 * @param name Name of the variable
86 * @return Global index of the variable
87 */
88 int register_variable(const std::string& name);
89
90 /**
91 * @brief Get the index of a variable by its name
92 *
93 * @param name Name of the variable
94 * @return int Name of the variable
95 */
96 int get_variable_index(const std::string& name) const;
97
98 /**
99 * @brief Register a new equation at the DOFHandler
100 *
101 * @param name Name of the equation
102 * @return Global index of the equation
103 */
104 int register_equation(const std::string& name);
105
106 /**
107 * @brief Get the index of a variable
108 *
109 * @param name Name of the variable
110 * @return Index of variable with given name
111 */
112 int get_index(const std::string_view& name) const;
113};
114
115#endif // SVZERODSOLVER_MODEL_DOFHANDLER_HPP_
Degree-of-freedom handler.
Definition DOFHandler.h:48
int register_variable(const std::string &name)
Register a new variable at the DOFHandler.
Definition DOFHandler.cpp:42
int get_index(const std::string_view &name) const
Get the index of a variable.
Definition DOFHandler.cpp:62
int get_num_equations() const
Get the number of equations.
Definition DOFHandler.cpp:38
std::vector< std::string > variables
Variable names corresponding to the variable indices.
Definition DOFHandler.h:55
int get_num_variables() const
Get the number of variables.
Definition DOFHandler.cpp:40
int size() const
Get the size of the system.
Definition DOFHandler.cpp:36
std::vector< std::string > equations
Equation names corresponding to the equation indices.
Definition DOFHandler.h:59
int get_variable_index(const std::string &name) const
Get the index of a variable by its name.
Definition DOFHandler.cpp:48
int register_equation(const std::string &name)
Register a new equation at the DOFHandler.
Definition DOFHandler.cpp:57
std::map< std::string, int > variable_name_map
Map between variable name and index.
Definition DOFHandler.h:57