MoCSI API Reference
Loading...
Searching...
No Matches
OneDimLinearElement.h
Go to the documentation of this file.
1#ifndef ONE_D_LINEAR_ELEMENT
2#define ONE_D_LINEAR_ELEMENT
3
4#include <map>
5#include <memory>
6#include <valarray>
7#include <vector>
8
9#include "GenericElement.h"
10#include "SimulationClassBase.h"
11
15template <typename T>
17{
18 private:
19 T m_area;
20 T m_element_length;
21
22 public:
23 void writeMatrixVectorBlock() override;
24 void writeBoundaryCondition() override;
25
27 std::map<std::string_view, std::vector<int>> all_boundary_points,
28 std::vector<int> nodal_values, SimulationClassBase<T>* sim, int cell_nr,
30 ~OneDimLinearElement() override = default;
31};
32
45template <typename T>
47 bool is_boundary_point, std::map<std::string_view, std::vector<int>> all_boundary_points,
48 std::vector<int> nodal_values, SimulationClassBase<T>* sim, int cell_nr,
51 m_area(this->m_properties.element_area),
52 m_element_length(this->m_properties.element_length)
53{
54}
55
62template <typename T>
64{
66 (this->m_sim->getFieldValue("HeatConductivity", this->m_nodal_values[0])
67 + this->m_sim->getFieldValue("HeatConductivity", this->m_nodal_values[1]))
68 / 2;
69 T heat_capacity = (this->m_sim->getFieldValue("HeatCapacity", this->m_nodal_values[0])
70 + this->m_sim->getFieldValue("HeatCapacity", this->m_nodal_values[1]))
71 / 2;
72 T density = (this->m_sim->getFieldValue("Density", this->m_nodal_values[0])
73 + this->m_sim->getFieldValue("Density", this->m_nodal_values[1]))
74 / 2;
75 T source_terms = (this->m_sim->getFieldValue("HeatSource", this->m_nodal_values[0])
76 + this->m_sim->getFieldValue("HeatSource", this->m_nodal_values[1]))
77 / 2;
78 // T area{ SHAPEMODEL.getArea(this->m_element_nr)};
79
80 // Capacitance matrix entries
81 this->m_capacitance_matrix_elements[0] +=
82 2 * density * heat_capacity * m_area * m_element_length / 6;
83 this->m_capacitance_matrix_elements[1] +=
84 density * heat_capacity * m_area * m_element_length / 6;
85 this->m_capacitance_matrix_elements[2] +=
86 density * heat_capacity * m_area * m_element_length / 6;
87 this->m_capacitance_matrix_elements[3] +=
88 2 * density * heat_capacity * m_area * m_element_length / 6;
89
90 // Stiffness matrix entries
91 this->m_stiffness_matrix_elements[0] += heat_conductivity * m_area / m_element_length;
92 this->m_stiffness_matrix_elements[1] -= heat_conductivity * m_area / m_element_length;
93 this->m_stiffness_matrix_elements[2] -= heat_conductivity * m_area / m_element_length;
94 this->m_stiffness_matrix_elements[3] += heat_conductivity * m_area / m_element_length;
95
96 // Forcing vector entries
97 this->m_forcing_vector_elements[0] += m_area * source_terms * m_element_length / 2;
98 this->m_forcing_vector_elements[1] += m_area * source_terms * m_element_length / 2;
99}
100
105template <typename T>
107{
108 for (auto& [key, boundary_condition] : this->m_boundary_conditions)
109 {
110 writeMatrixVectorBlock(); // The interior entries of the boundary are never changed, so
111 // they need to be calculated
112 boundary_condition->writeBoundaryCondition(); // Then everything reading the boundary
113 // condition is calculated (and overwrites
114 // the previous values if necessary)
115 }
116}
117
118#endif
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:35
Cell/Element abstract base class for the finite element method. All 1D/2D/3D elements should inherit ...
Definition GenericElement.h:32
Concrete Implementation of a 1D linear (line) element for the FEM.
Definition OneDimLinearElement.h:17
void writeMatrixVectorBlock() override
The implementation of the FEM scheme on this element type. Calculates all the values that you get sol...
Definition OneDimLinearElement.h:63
~OneDimLinearElement() override=default
void writeBoundaryCondition() override
The implementation of a boundary cell in the FEM scheme on this element type. If this cell is a bound...
Definition OneDimLinearElement.h:106
OneDimLinearElement(bool is_boundary_point, std::map< std::string_view, std::vector< int > > all_boundary_points, std::vector< int > nodal_values, SimulationClassBase< T > *sim, int cell_nr, ElementProperties< T > props)
Constructor for a OneDimLinearElement object.
Definition OneDimLinearElement.h:46