13 #include <Eigen/Eigen>
34 namespace SmallDeformation
36 template <
typename ShapeFunction,
typename IntegrationMethod,
38 SmallDeformationLocalAssemblerMatrix<ShapeFunction, IntegrationMethod,
40 SmallDeformationLocalAssemblerMatrix(
43 bool const is_axially_symmetric,
44 unsigned const integration_order,
46 : _process_data(process_data),
47 _integration_method(integration_order),
49 _is_axially_symmetric(is_axially_symmetric)
51 unsigned const n_integration_points =
54 _ip_data.reserve(n_integration_points);
57 auto const shape_matrices =
59 DisplacementDim>(e, is_axially_symmetric,
65 for (
unsigned ip = 0; ip < n_integration_points; ip++)
67 _ip_data.emplace_back(solid_material);
69 auto const& sm = shape_matrices[ip];
71 ip_data.dNdx = sm.dNdx;
72 ip_data.integration_weight =
74 sm.integralMeasure * sm.detJ;
77 static const int kelvin_vector_size =
79 ip_data._sigma.setZero(kelvin_vector_size);
80 ip_data._eps.setZero(kelvin_vector_size);
83 ip_data._sigma_prev.resize(kelvin_vector_size);
84 ip_data._eps_prev.resize(kelvin_vector_size);
86 ip_data._C.resize(kelvin_vector_size, kelvin_vector_size);
92 template <
typename ShapeFunction,
typename IntegrationMethod,
96 assembleWithJacobian(
double const t,
double const dt,
97 std::vector<double>
const& local_x,
98 std::vector<double>
const& ,
99 const double ,
const double ,
100 std::vector<double>& ,
101 std::vector<double>& ,
102 std::vector<double>& local_b_data,
103 std::vector<double>& local_Jac_data)
105 assert(_element.getDimension() == DisplacementDim);
107 auto const local_matrix_size = local_x.size();
109 auto local_Jac = MathLib::createZeroedMatrix<StiffnessMatrixType>(
110 local_Jac_data, local_matrix_size, local_matrix_size);
112 auto local_b = MathLib::createZeroedVector<NodalDisplacementVectorType>(
113 local_b_data, local_matrix_size);
115 unsigned const n_integration_points =
116 _integration_method.getNumberOfPoints();
123 for (
unsigned ip = 0; ip < n_integration_points; ip++)
126 auto const& w = _ip_data[ip].integration_weight;
128 auto const& N = _ip_data[ip].N;
129 auto const& dNdx = _ip_data[ip].dNdx;
131 NumLib::interpolateXCoordinate<ShapeFunction, ShapeMatricesType>(
135 ShapeFunction::NPOINTS,
137 dNdx, N, x_coord, _is_axially_symmetric);
139 auto const& eps_prev = _ip_data[ip]._eps_prev;
140 auto const& sigma_prev = _ip_data[ip]._sigma_prev;
142 auto& eps = _ip_data[ip]._eps;
143 auto& sigma = _ip_data[ip]._sigma;
144 auto& state = _ip_data[ip]._material_state_variables;
147 B * Eigen::Map<typename BMatricesType::NodalForceVectorType const>(
148 local_x.data(), ShapeFunction::NPOINTS * DisplacementDim);
150 variables[
static_cast<int>(
158 variables_prev[
static_cast<int>(
162 variables_prev[
static_cast<int>(
164 .emplace<double>(_process_data._reference_temperature);
166 auto&& solution = _ip_data[ip]._solid_material.integrateStress(
167 variables_prev, variables, t, x_position, dt, *state);
171 OGS_FATAL(
"Computation of local constitutive relation failed.");
175 std::tie(sigma, state, C) = std::move(*solution);
177 local_b.noalias() -= B.transpose() * sigma * w;
178 local_Jac.noalias() += B.transpose() * C * B * w;
182 template <
typename ShapeFunction,
typename IntegrationMethod,
186 computeSecondaryVariableConcreteWithVector(
187 double const , Eigen::VectorXd
const& )
190 const int n = DisplacementDim == 2 ? 4 : 6;
191 Eigen::VectorXd ele_stress = Eigen::VectorXd::Zero(n);
192 Eigen::VectorXd ele_strain = Eigen::VectorXd::Zero(n);
194 unsigned const n_integration_points =
195 _integration_method.getNumberOfPoints();
196 for (
unsigned ip = 0; ip < n_integration_points; ip++)
198 auto& ip_data = _ip_data[ip];
200 ele_stress += ip_data._sigma;
201 ele_strain += ip_data._eps;
203 ele_stress /= n_integration_points;
204 ele_strain /= n_integration_points;
206 (*_process_data._mesh_prop_stress_xx)[_element.getID()] = ele_stress[0];
207 (*_process_data._mesh_prop_stress_yy)[_element.getID()] = ele_stress[1];
208 (*_process_data._mesh_prop_stress_zz)[_element.getID()] = ele_stress[2];
209 (*_process_data._mesh_prop_stress_xy)[_element.getID()] = ele_stress[3];
210 if (DisplacementDim == 3)
212 (*_process_data._mesh_prop_stress_yz)[_element.getID()] = ele_stress[4];
213 (*_process_data._mesh_prop_stress_xz)[_element.getID()] = ele_stress[5];
216 (*_process_data._mesh_prop_strain_xx)[_element.getID()] = ele_strain[0];
217 (*_process_data._mesh_prop_strain_yy)[_element.getID()] = ele_strain[1];
218 (*_process_data._mesh_prop_strain_zz)[_element.getID()] = ele_strain[2];
219 (*_process_data._mesh_prop_strain_xy)[_element.getID()] = ele_strain[3];
220 if (DisplacementDim == 3)
222 (*_process_data._mesh_prop_strain_yz)[_element.getID()] = ele_strain[4];
223 (*_process_data._mesh_prop_strain_xz)[_element.getID()] = ele_strain[5];
virtual std::size_t getID() const final
Returns the ID of the element.
void setElementID(std::size_t element_id)
void setIntegrationPoint(unsigned integration_point)
MatrixType< _kelvin_vector_size, _number_of_dof > BMatrixType
MechanicsBase< DisplacementDim > & selectSolidConstitutiveRelation(std::map< int, std::unique_ptr< MechanicsBase< DisplacementDim >>> const &constitutive_relations, MeshLib::PropertyVector< int > const *const material_ids, std::size_t const element_id)
std::array< VariableType, static_cast< int >(Variable::number_of_variables)> VariableArray
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), 1, Eigen::ColMajor > KelvinVectorType
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
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