svZeroDSolver
Loading...
Searching...
No Matches
DOFHandler.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 DofHandler.h
5 * @brief model::DOFHandler source file
6 */
7#ifndef SVZERODSOLVER_MODEL_DOFHANDLER_HPP_
8#define SVZERODSOLVER_MODEL_DOFHANDLER_HPP_
9
10#include <map>
11#include <string>
12#include <vector>
13
14/**
15 * @brief Degree-of-freedom handler.
16 *
17 * This class handles degrees-of-freedom for model variables and
18 * equations. It assigns each element with row and column indices which it
19 * can use to assemble it's local contributions into the global system.
20 */
22 private:
23 int var_counter{0}; ///< Variable counter
24 int eqn_counter{0}; ///< Equation counter
25
26 public:
27 std::vector<std::string>
28 variables; ///< Variable names corresponding to the variable indices
29 std::map<std::string, int>
30 variable_name_map; ///< Map between variable name and index
31 std::vector<std::string>
32 equations; ///< Equation names corresponding to the equation indices
33
34 /**
35 * @brief Get the size of the system
36 *
37 * @return Size of the system
38 */
39 int size() const;
40
41 /**
42 * @brief Get the number of equations
43 *
44 * @return int Number of equations
45 */
46 int get_num_equations() const;
47
48 /**
49 * @brief Get the number of variables
50 *
51 * @return int Number of variables
52 */
53 int get_num_variables() const;
54
55 /**
56 * @brief Register a new variable at the DOFHandler.
57 *
58 * @param name Name of the variable
59 * @return Global index of the variable
60 */
61 int register_variable(const std::string& name);
62
63 /**
64 * @brief Get the index of a variable by its name
65 *
66 * @param name Name of the variable
67 * @return int Name of the variable
68 */
69 int get_variable_index(const std::string& name) const;
70
71 /**
72 * @brief Register a new equation at the DOFHandler
73 *
74 * @param name Name of the equation
75 * @return Global index of the equation
76 */
77 int register_equation(const std::string& name);
78
79 /**
80 * @brief Get the index of a variable
81 *
82 * @param name Name of the variable
83 * @return Index of variable with given name
84 */
85 int get_index(const std::string_view& name) const;
86};
87
88#endif // SVZERODSOLVER_MODEL_DOFHANDLER_HPP_
Degree-of-freedom handler.
Definition DOFHandler.h:21
int register_variable(const std::string &name)
Register a new variable at the DOFHandler.
Definition DOFHandler.cpp:14
int get_index(const std::string_view &name) const
Get the index of a variable.
Definition DOFHandler.cpp:34
int get_num_equations() const
Get the number of equations.
Definition DOFHandler.cpp:10
std::vector< std::string > variables
Variable names corresponding to the variable indices.
Definition DOFHandler.h:28
int get_num_variables() const
Get the number of variables.
Definition DOFHandler.cpp:12
int size() const
Get the size of the system.
Definition DOFHandler.cpp:8
std::vector< std::string > equations
Equation names corresponding to the equation indices.
Definition DOFHandler.h:32
int get_variable_index(const std::string &name) const
Get the index of a variable by its name.
Definition DOFHandler.cpp:20
int register_equation(const std::string &name)
Register a new equation at the DOFHandler.
Definition DOFHandler.cpp:29
std::map< std::string, int > variable_name_map
Map between variable name and index.
Definition DOFHandler.h:30