OGS
LargeDeformationProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
16#include "LargeDeformationFEM.h"
22#include "ProcessLib/Process.h"
26
27namespace ProcessLib
28{
29namespace LargeDeformation
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
50 _process_data.principal_stress_vector[0] =
52 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_1",
54
55 _process_data.principal_stress_vector[1] =
57 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_2",
59
60 _process_data.principal_stress_vector[2] =
62 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_vector_3",
64
65 _process_data.principal_stress_values =
67 const_cast<MeshLib::Mesh&>(mesh), "principal_stress_values",
69
72 DisplacementDim>::getReflectionDataForOutput(),
73 _integration_point_writer, integration_order,
75}
76
77template <int DisplacementDim>
79{
80 return false;
81}
82
83template <int DisplacementDim>
85 NumLib::LocalToGlobalIndexMap const& dof_table,
86 MeshLib::Mesh const& mesh,
87 unsigned const integration_order)
88{
90 DisplacementDim, LargeDeformationLocalAssembler>(
91 mesh.getElements(), dof_table, _local_assemblers,
92 NumLib::IntegrationOrder{integration_order}, mesh.isAxiallySymmetric(),
93 _process_data);
94
95 auto add_secondary_variable = [&](std::string const& name,
96 int const num_components,
97 auto get_ip_values_function)
98 {
99 _secondary_variables.addSecondaryVariable(
100 name,
101 makeExtrapolator(num_components, getExtrapolator(),
102 _local_assemblers,
103 std::move(get_ip_values_function)));
104 };
105
108 DisplacementDim>::getReflectionDataForOutput(),
109 _secondary_variables, getExtrapolator(), _local_assemblers);
110
111 //
112 // enable output of internal variables defined by material models
113 //
115 LocalAssemblerInterface>(_process_data.solid_materials,
116 add_secondary_variable);
117
120 _process_data.solid_materials, _local_assemblers,
121 _integration_point_writer, integration_order);
122
123 setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(),
124 _local_assemblers);
125
126 // Initialize local assemblers after all variables have been set.
128 &LocalAssemblerInterface::initialize, _local_assemblers,
129 *_local_to_global_index_map);
130}
131
132template <int DisplacementDim>
134 double const t, double const dt, std::vector<GlobalVector*> const& x,
135 std::vector<GlobalVector*> const& x_prev, int const process_id,
137{
138 DBUG("Assemble LargeDeformationProcess.");
139
140 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
141 _local_to_global_index_map.get()};
142 // Call global assembler for each local assembly item.
144 _global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
145 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
146 &b);
147
148 _global_output(t, process_id, M, K, b);
149}
150
151template <int DisplacementDim>
154 double const t, double const dt, std::vector<GlobalVector*> const& x,
155 std::vector<GlobalVector*> const& x_prev, int const process_id,
156 GlobalVector& b, GlobalMatrix& Jac)
157{
158 DBUG("AssembleWithJacobian LargeDeformationProcess.");
159
160 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
161 _local_to_global_index_map.get()};
162 // Call global assembler for each local assembly item.
165 _local_assemblers, getActiveElementIDs(), dof_table, t, dt, x, x_prev,
166 process_id, &b, &Jac);
167
168 transformVariableFromGlobalVector(b, 0, *_local_to_global_index_map,
169 *_nodal_forces, std::negate<double>());
170
171 _global_output(t, process_id, b, Jac);
172}
173
174template <int DisplacementDim>
176 std::vector<GlobalVector*> const& x,
177 std::vector<GlobalVector*> const& x_prev, double const t, double const dt,
178 int const process_id)
179{
180 DBUG("PostTimestep LargeDeformationProcess.");
181 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
182 dof_tables.reserve(x.size());
183 std::generate_n(std::back_inserter(dof_tables), x.size(),
184 [&]() { return _local_to_global_index_map.get(); });
185
187 &LocalAssemblerInterface::postTimestep, _local_assemblers,
188 getActiveElementIDs(), dof_tables, x, x_prev, t, dt, process_id);
189}
190
191template <int DisplacementDim>
193 double const t, double const dt, std::vector<GlobalVector*> const& x,
194 GlobalVector const& x_prev, int const process_id)
195{
196 DBUG("Compute the secondary variables for LargeDeformationProcess.");
197 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
198 dof_tables.reserve(x.size());
199 std::generate_n(std::back_inserter(dof_tables), x.size(),
200 [&]() { return _local_to_global_index_map.get(); });
201
204 getActiveElementIDs(), dof_tables, t, dt, x, x_prev, process_id);
205
206 computeCellAverages<DisplacementDim>(cell_average_data_, _local_assemblers);
207}
208template class LargeDeformationProcess<2>;
209template class LargeDeformationProcess<3>;
210
211} // namespace LargeDeformation
212} // 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
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 postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id) override
LargeDeformationProcess(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, LargeDeformationProcessData< DisplacementDim > &&process_data, SecondaryVariableCollection &&secondary_variables)
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
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
std::vector< std::unique_ptr< LocalAssemblerInterface > > _local_assemblers
LargeDeformationProcessData< 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
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.
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::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 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 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 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)