OGS
SmallDeformationLocalAssemblerMatrix-impl.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <Eigen/Core>
14#include <valarray>
15#include <vector>
16
28#include "SecondaryData.h"
31
32namespace ProcessLib
33{
34namespace LIE
35{
36namespace SmallDeformation
37{
38template <typename ShapeFunction, int DisplacementDim>
41 MeshLib::Element const& e,
42 std::size_t const /*local_matrix_size*/,
43 NumLib::GenericIntegrationMethod const& integration_method,
44 bool const is_axially_symmetric,
46 : _process_data(process_data),
47 _integration_method(integration_method),
48 _element(e),
49 _is_axially_symmetric(is_axially_symmetric)
50{
51 unsigned const n_integration_points =
53
54 _ip_data.reserve(n_integration_points);
55 _secondary_data.N.resize(n_integration_points);
56
57 auto const shape_matrices =
59 DisplacementDim>(e, is_axially_symmetric,
61
63 _process_data.solid_materials, _process_data.material_ids, e.getID());
64
65 for (unsigned ip = 0; ip < n_integration_points; ip++)
66 {
67 _ip_data.emplace_back(solid_material);
68 auto& ip_data = _ip_data[ip];
69 auto const& sm = shape_matrices[ip];
70 ip_data.N = sm.N;
71 ip_data.dNdx = sm.dNdx;
72 ip_data.integration_weight =
74 sm.integralMeasure * sm.detJ;
75
76 // Initialize current time step values
77 static const int kelvin_vector_size =
79 ip_data._sigma.setZero(kelvin_vector_size);
80 ip_data._eps.setZero(kelvin_vector_size);
81
82 // Previous time step values are not initialized and are set later.
83 ip_data._sigma_prev.resize(kelvin_vector_size);
84 ip_data._eps_prev.resize(kelvin_vector_size);
85
86 ip_data._C.resize(kelvin_vector_size, kelvin_vector_size);
87
88 _secondary_data.N[ip] = sm.N;
89 }
90}
91
92template <typename ShapeFunction, int DisplacementDim>
94 assembleWithJacobian(double const t, double const dt,
95 std::vector<double> const& local_x,
96 std::vector<double> const& /*local_x_prev*/,
97 std::vector<double>& local_b_data,
98 std::vector<double>& local_Jac_data)
99{
100 assert(_element.getDimension() == DisplacementDim);
101
102 auto const local_matrix_size = local_x.size();
103
104 auto local_Jac = MathLib::createZeroedMatrix<StiffnessMatrixType>(
105 local_Jac_data, local_matrix_size, local_matrix_size);
106
107 auto local_b = MathLib::createZeroedVector<NodalDisplacementVectorType>(
108 local_b_data, local_matrix_size);
109
110 unsigned const n_integration_points =
111 _integration_method.getNumberOfPoints();
112
113 MPL::VariableArray variables;
114 MPL::VariableArray variables_prev;
116 x_position.setElementID(_element.getID());
117
118 for (unsigned ip = 0; ip < n_integration_points; ip++)
119 {
120 x_position.setIntegrationPoint(ip);
121 auto const& w = _ip_data[ip].integration_weight;
122
123 auto const& N = _ip_data[ip].N;
124 auto const& dNdx = _ip_data[ip].dNdx;
125 auto const x_coord =
126 NumLib::interpolateXCoordinate<ShapeFunction, ShapeMatricesType>(
127 _element, N);
128 auto const B =
129 LinearBMatrix::computeBMatrix<DisplacementDim,
130 ShapeFunction::NPOINTS,
132 dNdx, N, x_coord, _is_axially_symmetric);
133
134 auto const& eps_prev = _ip_data[ip]._eps_prev;
135 auto const& sigma_prev = _ip_data[ip]._sigma_prev;
136
137 auto& eps = _ip_data[ip]._eps;
138 auto& sigma = _ip_data[ip]._sigma;
139 auto& state = _ip_data[ip]._material_state_variables;
140
141 eps.noalias() =
142 B * Eigen::Map<typename BMatricesType::NodalForceVectorType const>(
143 local_x.data(), ShapeFunction::NPOINTS * DisplacementDim);
144
145 variables.mechanical_strain
147 eps);
148 variables_prev.stress
150 sigma_prev);
151 variables_prev.mechanical_strain
153 eps_prev);
154 variables_prev.temperature = _process_data._reference_temperature;
155
156 auto&& solution = _ip_data[ip]._solid_material.integrateStress(
157 variables_prev, variables, t, x_position, dt, *state);
158
159 if (!solution)
160 {
161 OGS_FATAL("Computation of local constitutive relation failed.");
162 }
163
165 std::tie(sigma, state, C) = std::move(*solution);
166
167 local_b.noalias() -= B.transpose() * sigma * w;
168 local_Jac.noalias() += B.transpose() * C * B * w;
169 }
170}
171
172template <typename ShapeFunction, int DisplacementDim>
175 double const /*t*/, Eigen::VectorXd const& /*local_x*/)
176{
177 // Compute average value per element
179 KV sigma_avg = KV::Zero();
180 auto const e_id = _element.getID();
181
182 unsigned const n_integration_points =
183 _integration_method.getNumberOfPoints();
184 for (unsigned ip = 0; ip < n_integration_points; ip++)
185 {
186 sigma_avg += _ip_data[ip]._sigma;
187 }
188 sigma_avg /= n_integration_points;
189
190 Eigen::Map<KV>(
191 &(*_process_data.element_stresses)[e_id * KV::RowsAtCompileTime]) =
193}
194
195template <typename ShapeFunction, int DisplacementDim>
196std::vector<double> const&
199 const double /*t*/,
200 std::vector<GlobalVector*> const& /*x*/,
201 std::vector<NumLib::LocalToGlobalIndexMap const*> const& /*dof_table*/,
202 std::vector<double>& cache) const
203{
204 return ProcessLib::getIntegrationPointKelvinVectorData<DisplacementDim>(
205 _ip_data, &IntegrationPointDataType::_sigma, cache);
206}
207template <typename ShapeFunction, int DisplacementDim>
208std::vector<double> const&
211 const double /*t*/,
212 std::vector<GlobalVector*> const& /*x*/,
213 std::vector<NumLib::LocalToGlobalIndexMap const*> const& /*dof_table*/,
214 std::vector<double>& cache) const
215{
216 return ProcessLib::getIntegrationPointKelvinVectorData<DisplacementDim>(
217 _ip_data, &IntegrationPointDataType::_eps, cache);
218}
219
220} // namespace SmallDeformation
221} // namespace LIE
222} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
double getWeight() const
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:89
MathLib::WeightedPoint const & getWeightedPoint(unsigned const igp) const
void setElementID(std::size_t element_id)
void setIntegrationPoint(unsigned integration_point)
MatrixType< _kelvin_vector_size, _number_of_dof > BMatrixType
void computeSecondaryVariableConcreteWithVector(double const t, Eigen::VectorXd const &local_x) override
std::vector< IntegrationPointDataType, Eigen::aligned_allocator< IntegrationPointDataType > > _ip_data
std::vector< double > const & getIntPtSigma(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
void assembleWithJacobian(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data) override
std::vector< double > const & getIntPtEpsilon(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const override
SmallDeformationLocalAssemblerMatrix(SmallDeformationLocalAssemblerMatrix const &)=delete
auto & selectSolidConstitutiveRelation(SolidMaterialsMap const &constitutive_relations, MeshLib::PropertyVector< int > const *const material_ids, std::size_t const element_id)
Eigen::Matrix< double, 4, 1 > kelvinVectorToSymmetricTensor(Eigen::Matrix< double, 4, 1, Eigen::ColMajor, 4, 1 > const &v)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), 1, Eigen::ColMajor > KelvinVectorType
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), kelvin_vector_dimensions(DisplacementDim), Eigen::RowMajor > KelvinMatrixType
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > initShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, IntegrationMethod const &integration_method)
BMatrixType computeBMatrix(DNDX_Type const &dNdx, N_Type const &N, const double radius, const bool is_axially_symmetric)
Fills a B-matrix based on given shape function dN/dx values.
std::vector< ShapeMatrixType, Eigen::aligned_allocator< ShapeMatrixType > > N