MoCSI API Reference
Loading...
Searching...
No Matches
GenericBoundaryCondition.h
Go to the documentation of this file.
1#ifndef GENERIC_BOUNDARY_CONDITION_H
2#define GENERIC_BOUNDARY_CONDITION_H
3
4#include <memory>
5#include <string>
6#include <utility>
7#include <valarray>
8#include <vector>
9
10#include "SimulationClassBase.h"
11
16template <typename T>
18{
19 protected:
21 std::vector<int> m_boundary_points;
22 std::vector<std::vector<int>> m_connected_points;
23 std::vector<std::vector<std::reference_wrapper<T>>> m_capacitance_matrix_elements{};
24 std::vector<std::vector<std::reference_wrapper<T>>> m_stiffness_matrix_elements{};
25 std::vector<std::reference_wrapper<T>> m_forcing_vector_elements{};
28
29 public:
30 virtual void writeBoundaryCondition() = 0;
33 std::valarray<T>& forcing_vector);
34
36 std::vector<std::vector<int>> connected_points, int facet_nr,
37 std::string face_prefix);
38 virtual ~GenericBoundaryCondition() = default;
39};
40
51template <typename T>
53 SimulationClassBase<T>* sim, std::vector<int> boundary_points,
54 std::vector<std::vector<int>> connected_points, int facet_nr, std::string face_prefix)
55 : m_sim{sim},
56 m_boundary_points{std::move(boundary_points)},
57 m_connected_points{std::move(connected_points)},
58 m_facet_number{facet_nr},
59 m_face_indicator_prefix{std::move(face_prefix)}
60{
61}
62
69template <typename T>
72 std::valarray<T>& forcing_vector)
73{
74 for (int i{0}; i < m_boundary_points.size(); i++)
75 {
76 std::vector<std::reference_wrapper<T>> temp_cap_mat{};
77 std::vector<std::reference_wrapper<T>> temp_stiff_mat{};
78 for (int j{0}; j < m_connected_points[i].size(); j++)
79 {
80 temp_cap_mat.emplace_back(
81 capacitance_matrix(m_boundary_points[i], m_connected_points[i][j]));
82 temp_stiff_mat.emplace_back(
83 stiffness_matrix(m_boundary_points[i], m_connected_points[i][j]));
84 }
85 this->m_capacitance_matrix_elements.emplace_back(temp_cap_mat);
86 this->m_stiffness_matrix_elements.emplace_back(temp_stiff_mat);
87 this->m_forcing_vector_elements.emplace_back(forcing_vector[m_boundary_points[i]]);
88 }
89}
90
91#endif
Error class to throw when a module chain has circular or missing dependencies. Inherits from std::exc...
Definition ChainManager.h:28
Boundary condition abstract base class for the finite element method. All boundary condition implemen...
Definition GenericBoundaryCondition.h:18
virtual void getReferenceToElements(GenericMatrix< T > &capacitance_matrix, GenericMatrix< T > &stiffness_matrix, std::valarray< T > &forcing_vector)
Sets up a referrence_wrapper vector to the elements within the matrix object. This adds a bit of pre-...
Definition GenericBoundaryCondition.h:70
std::vector< std::vector< std::reference_wrapper< T > > > m_stiffness_matrix_elements
Definition GenericBoundaryCondition.h:24
virtual ~GenericBoundaryCondition()=default
std::vector< std::reference_wrapper< T > > m_forcing_vector_elements
Definition GenericBoundaryCondition.h:25
GenericBoundaryCondition(SimulationClassBase< T > *sim, std::vector< int > boundary_points, std::vector< std::vector< int > > connected_points, int facet_nr, std::string face_prefix)
Constructor for a GenericElement object. Sets all parameters that are known at creation.
Definition GenericBoundaryCondition.h:52
int m_facet_number
Definition GenericBoundaryCondition.h:26
std::vector< std::vector< std::reference_wrapper< T > > > m_capacitance_matrix_elements
Definition GenericBoundaryCondition.h:23
std::vector< int > m_boundary_points
Definition GenericBoundaryCondition.h:21
std::vector< std::vector< int > > m_connected_points
Definition GenericBoundaryCondition.h:22
std::string m_face_indicator_prefix
Definition GenericBoundaryCondition.h:27
SimulationClassBase< T > * m_sim
Definition GenericBoundaryCondition.h:20
virtual void writeBoundaryCondition()=0