OGS
SmallDeformationProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
17#include "NumLib/Exceptions.h"
20#include "ProcessLib/Process.h"
25#include "SmallDeformationFEM.h"
26
27namespace ProcessLib
28{
29namespace SmallDeformation
30{
31template <int DisplacementDim>
33 std::string name,
34 MeshLib::Mesh& mesh,
35 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
36 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
37 unsigned const integration_order,
38 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
39 process_variables,
41 SecondaryVariableCollection&& secondary_variables)
42 : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
43 integration_order, std::move(process_variables),
44 std::move(secondary_variables)),
45 _process_data(std::move(process_data))
46{
48 mesh, "NodalForces", MeshLib::MeshItemType::Node, DisplacementDim);
49
51 mesh, "MaterialForces", MeshLib::MeshItemType::Node, DisplacementDim);
52
53 _process_data.principal_stress_vector[0] =
55 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_1",
57
58 _process_data.principal_stress_vector[1] =
60 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_2",
62
63 _process_data.principal_stress_vector[2] =
65 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_3",
67
68 _process_data.principal_stress_values =
70 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_values",
72
75 DisplacementDim>::getReflectionDataForOutput(),
76 _integration_point_writer, integration_order,
78}
79
80template <int DisplacementDim>
82{
83 return false;
84}
85
86template <int DisplacementDim>
88 NumLib::LocalToGlobalIndexMap const& dof_table,
89 MeshLib::Mesh const& mesh,
90 unsigned const integration_order)
91{
93 DisplacementDim, SmallDeformationLocalAssembler>(
94 mesh.getElements(), dof_table, _local_assemblers,
95 NumLib::IntegrationOrder{integration_order}, mesh.isAxiallySymmetric(),
96 _process_data);
97
98 auto add_secondary_variable = [&](std::string const& name,
99 int const num_components,
100 auto get_ip_values_function)
101 {
102 _secondary_variables.addSecondaryVariable(
103 name,
104 makeExtrapolator(num_components, getExtrapolator(),
105 _local_assemblers,
106 std::move(get_ip_values_function)));
107 };
108
111 DisplacementDim>::getReflectionDataForOutput(),
112 _secondary_variables, getExtrapolator(), _local_assemblers);
113
114 //
115 // enable output of internal variables defined by material models
116 //
118 LocalAssemblerInterface>(_process_data.solid_materials,
119 add_secondary_variable);
120
123 _process_data.solid_materials, _local_assemblers,
124 _integration_point_writer, integration_order);
125
126 setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(),
127 _local_assemblers);
128
129 // Initialize local assemblers after all variables have been set.
131 &LocalAssemblerInterface::initialize, _local_assemblers,
132 *_local_to_global_index_map);
133}
134
135template <int DisplacementDim>
137 double const t, double const dt, std::vector<GlobalVector*> const& x,
138 std::vector<GlobalVector*> const& x_prev, int const process_id,
140{
141 DBUG("Assemble SmallDeformationProcess.");
142
143 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
144 _local_to_global_index_map.get()};
145 // Call global assembler for each local assembly item.
147 _global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
148 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
149 &b);
150
151 _global_output(t, process_id, M, K, b);
152}
153
154template <int DisplacementDim>
157 double const t, double const dt, std::vector<GlobalVector*> const& x,
158 std::vector<GlobalVector*> const& x_prev, int const process_id,
159 GlobalVector& b, GlobalMatrix& Jac)
160{
161 DBUG("AssembleWithJacobian SmallDeformationProcess.");
162
163 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
164 _local_to_global_index_map.get()};
165 // Call global assembler for each local assembly item.
166 try
167 {
170 _local_assemblers, getActiveElementIDs(), dof_table, t, dt, x,
171 x_prev, process_id, &b, &Jac);
172 }
173 catch (NumLib::AssemblyException const&)
174 {
175 transformVariableFromGlobalVector(b, 0, *_local_to_global_index_map,
176 *_nodal_forces,
177 std::negate<double>());
178 throw;
179 }
180 transformVariableFromGlobalVector(b, 0, *_local_to_global_index_map,
181 *_nodal_forces, std::negate<double>());
182
183 _global_output(t, process_id, b, Jac);
184}
185
186template <int DisplacementDim>
188 std::vector<GlobalVector*> const& x,
189 std::vector<GlobalVector*> const& x_prev, double const t, double const dt,
190 int const process_id)
191{
192 DBUG("PostTimestep SmallDeformationProcess.");
193 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
194 dof_tables.reserve(x.size());
195 std::generate_n(std::back_inserter(dof_tables), x.size(),
196 [&]() { return _local_to_global_index_map.get(); });
197
199 &LocalAssemblerInterface::postTimestep, _local_assemblers,
200 getActiveElementIDs(), dof_tables, x, x_prev, t, dt, process_id);
201
202 std::unique_ptr<GlobalVector> material_forces;
204 material_forces, _local_assemblers, *_local_to_global_index_map,
205 *x[process_id]);
206
207 material_forces->copyValues(*_material_forces);
208}
209
210template <int DisplacementDim>
212 double const t, double const dt, std::vector<GlobalVector*> const& x,
213 GlobalVector const& x_prev, int const process_id)
214{
215 DBUG("Compute the secondary variables for SmallDeformationProcess.");
216 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
217 dof_tables.reserve(x.size());
218 std::generate_n(std::back_inserter(dof_tables), x.size(),
219 [&]() { return _local_to_global_index_map.get(); });
220
223 getActiveElementIDs(), dof_tables, t, dt, x, x_prev, process_id);
224
225 computeCellAverages<DisplacementDim>(cell_average_data_, _local_assemblers);
226}
227template class SmallDeformationProcess<2>;
228template class SmallDeformationProcess<3>;
229
230} // namespace SmallDeformation
231} // 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)
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
void solidMaterialInternalVariablesToIntegrationPointWriter(std::map< int, std::shared_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::shared_ptr< SolidMaterial > > const &solid_materials, AddSecondaryVariableCallback const &add_secondary_variable)
void addReflectedSecondaryVariables(ReflData const &reflection_data, SecondaryVariableCollection &secondary_variables, NumLib::Extrapolator &extrapolator, std::vector< std::unique_ptr< LocAsmIF > > const &local_assemblers)
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)
void computeCellAverages(CellAverageData &cell_average_data, std::vector< std::unique_ptr< LAIntf > > const &local_assemblers)
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)