OGS
SmallDeformationProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
19#include "ProcessLib/Process.h"
24#include "SmallDeformationFEM.h"
25
26namespace ProcessLib
27{
28namespace SmallDeformation
29{
30template <int DisplacementDim>
32 std::string name,
33 MeshLib::Mesh& mesh,
34 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
35 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
36 unsigned const integration_order,
37 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
38 process_variables,
40 SecondaryVariableCollection&& secondary_variables)
41 : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
42 integration_order, std::move(process_variables),
43 std::move(secondary_variables)),
44 _process_data(std::move(process_data))
45{
46 _nodal_forces = MeshLib::getOrCreateMeshProperty<double>(
47 mesh, "NodalForces", MeshLib::MeshItemType::Node, DisplacementDim);
48
49 _material_forces = MeshLib::getOrCreateMeshProperty<double>(
50 mesh, "MaterialForces", MeshLib::MeshItemType::Node, DisplacementDim);
51
52 _process_data.principal_stress_vector[0] =
53 MeshLib::getOrCreateMeshProperty<double>(
54 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_1",
56
57 _process_data.principal_stress_vector[1] =
58 MeshLib::getOrCreateMeshProperty<double>(
59 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_2",
61
62 _process_data.principal_stress_vector[2] =
63 MeshLib::getOrCreateMeshProperty<double>(
64 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_3",
66
67 _process_data.principal_stress_values =
68 MeshLib::getOrCreateMeshProperty<double>(
69 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_values",
71
74 DisplacementDim>::getReflectionDataForOutput(),
75 _integration_point_writer, integration_order,
77}
78
79template <int DisplacementDim>
81{
82 return false;
83}
84
85template <int DisplacementDim>
87 NumLib::LocalToGlobalIndexMap const& dof_table,
88 MeshLib::Mesh const& mesh,
89 unsigned const integration_order)
90{
92 DisplacementDim, SmallDeformationLocalAssembler>(
93 mesh.getElements(), dof_table, _local_assemblers,
94 NumLib::IntegrationOrder{integration_order}, mesh.isAxiallySymmetric(),
95 _process_data);
96
97 auto add_secondary_variable = [&](std::string const& name,
98 int const num_components,
99 auto get_ip_values_function)
100 {
101 _secondary_variables.addSecondaryVariable(
102 name,
103 makeExtrapolator(num_components, getExtrapolator(),
104 _local_assemblers,
105 std::move(get_ip_values_function)));
106 };
107
108 ProcessLib::Reflection::addReflectedSecondaryVariables<DisplacementDim>(
110 DisplacementDim>::getReflectionDataForOutput(),
111 _secondary_variables, getExtrapolator(), _local_assemblers);
112
113 //
114 // enable output of internal variables defined by material models
115 //
117 LocalAssemblerInterface>(_process_data.solid_materials,
118 add_secondary_variable);
119
122 _process_data.solid_materials, _local_assemblers,
123 _integration_point_writer, integration_order);
124
125 setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(),
126 _local_assemblers);
127
128 // Initialize local assemblers after all variables have been set.
130 &LocalAssemblerInterface::initialize, _local_assemblers,
131 *_local_to_global_index_map);
132}
133
134template <int DisplacementDim>
136 double const t, double const dt, std::vector<GlobalVector*> const& x,
137 std::vector<GlobalVector*> const& x_prev, int const process_id,
139{
140 DBUG("Assemble SmallDeformationProcess.");
141
142 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
143 _local_to_global_index_map.get()};
144 // Call global assembler for each local assembly item.
146 _global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
147 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
148 &b);
149
150 _global_output(t, process_id, M, K, b);
151}
152
153template <int DisplacementDim>
156 double const t, double const dt, std::vector<GlobalVector*> const& x,
157 std::vector<GlobalVector*> const& x_prev, int const process_id,
158 GlobalVector& b, GlobalMatrix& Jac)
159{
160 DBUG("AssembleWithJacobian SmallDeformationProcess.");
161
162 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
163 _local_to_global_index_map.get()};
164 // Call global assembler for each local assembly item.
167 _local_assemblers, getActiveElementIDs(), dof_table, t, dt, x, x_prev,
168 process_id, &b, &Jac);
169
170 transformVariableFromGlobalVector(b, 0, *_local_to_global_index_map,
171 *_nodal_forces, std::negate<double>());
172
173 _global_output(t, process_id, b, Jac);
174}
175
176template <int DisplacementDim>
178 std::vector<GlobalVector*> const& x,
179 std::vector<GlobalVector*> const& x_prev, double const t, double const dt,
180 int const process_id)
181{
182 DBUG("PostTimestep SmallDeformationProcess.");
183 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
184 dof_tables.reserve(x.size());
185 std::generate_n(std::back_inserter(dof_tables), x.size(),
186 [&]() { return _local_to_global_index_map.get(); });
187
189 &LocalAssemblerInterface::postTimestep, _local_assemblers,
190 getActiveElementIDs(), dof_tables, x, x_prev, t, dt, process_id);
191
192 std::unique_ptr<GlobalVector> material_forces;
194 material_forces, _local_assemblers, *_local_to_global_index_map,
195 *x[process_id]);
196
197 material_forces->copyValues(*_material_forces);
198}
199
200template <int DisplacementDim>
202 double const t, double const dt, std::vector<GlobalVector*> const& x,
203 GlobalVector const& x_prev, int const process_id)
204{
205 DBUG("Compute the secondary variables for SmallDeformationProcess.");
206 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
207 dof_tables.reserve(x.size());
208 std::generate_n(std::back_inserter(dof_tables), x.size(),
209 [&]() { return _local_to_global_index_map.get(); });
210
213 getActiveElementIDs(), dof_tables, t, dt, x, x_prev, process_id);
214
215 computeCellAverages<DisplacementDim>(cell_average_data_, _local_assemblers);
216}
217template class SmallDeformationProcess<2>;
218template class SmallDeformationProcess<3>;
219
220} // namespace SmallDeformation
221} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Global vector based on Eigen vector.
Definition EigenVector.h:25
bool isAxiallySymmetric() const
Definition Mesh.h:137
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
Properties & getProperties()
Definition Mesh.h:134
virtual void postTimestep(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id)
virtual void computeSecondaryVariable(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id)
virtual void initialize(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > _integration_point_writer
Definition Process.h:390
Handles configuration of several secondary variables from the project file.
SmallDeformationProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, SmallDeformationProcessData< DisplacementDim > &&process_data, SecondaryVariableCollection &&secondary_variables)
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id) override
void assembleConcreteProcess(double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
void assembleWithJacobianConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalVector &b, GlobalMatrix &Jac) override
SmallDeformationProcessData< DisplacementDim > _process_data
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id) override
std::vector< std::unique_ptr< LocalAssemblerInterface > > _local_assemblers
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
void assemble(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix *M, GlobalMatrix *K, GlobalVector *b)
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalVector *b, GlobalMatrix *Jac)
void solidMaterialInternalVariablesToIntegrationPointWriter(std::map< int, std::unique_ptr< SolidMaterial > > const &solid_materials, std::vector< std::unique_ptr< LocalAssemblerInterface > > const &local_assemblers, std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > &integration_point_writer, int const integration_order)
void solidMaterialInternalToSecondaryVariables(std::map< int, std::unique_ptr< SolidMaterial > > const &solid_materials, AddSecondaryVariableCallback const &add_secondary_variable)
void addReflectedIntegrationPointWriters(ReflData const &reflection_data, std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > &integration_point_writers, unsigned const integration_order, std::vector< std::unique_ptr< LocAsmIF > > const &local_assemblers)
void createLocalAssemblers(std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface > > &local_assemblers, ProviderOrOrder const &provider_or_order, ExtraCtorArgs &&... extra_ctor_args)
void writeMaterialForces(std::unique_ptr< GlobalVector > &material_forces, std::vector< std::unique_ptr< LocalAssemblerInterface > > const &local_assemblers, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, GlobalVector const &x)
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
void setIPDataInitialConditions(std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > const &_integration_point_writer, MeshLib::Properties const &mesh_properties, LocalAssemblersVector &local_assemblers)
static void executeSelectedMemberOnDereferenced(Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeSelectedMemberDereferenced(Object &object, Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)