OGS
HeatConductionProcess.cpp
Go to the documentation of this file.
1 
11 #include "HeatConductionProcess.h"
12 
13 #include <cassert>
14 
20 
21 namespace ProcessLib
22 {
23 namespace HeatConduction
24 {
26  std::string name,
27  MeshLib::Mesh& mesh,
28  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
29  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
30  unsigned const integration_order,
31  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
32  process_variables,
33  HeatConductionProcessData&& process_data,
34  SecondaryVariableCollection&& secondary_variables)
35  : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
36  integration_order, std::move(process_variables),
37  std::move(secondary_variables)),
38  _process_data(std::move(process_data))
39 {
40  _heat_flux = MeshLib::getOrCreateMeshProperty<double>(
41  mesh, "HeatFlowRate", MeshLib::MeshItemType::Node, 1);
42 }
43 
45  NumLib::LocalToGlobalIndexMap const& dof_table,
46  MeshLib::Mesh const& mesh,
47  unsigned const integration_order)
48 {
49  int const mesh_space_dimension = _process_data.mesh_space_dimension;
50 
51  ProcessLib::createLocalAssemblers<LocalAssemblerData>(
52  mesh_space_dimension, mesh.getElements(), dof_table, _local_assemblers,
53  NumLib::IntegrationOrder{integration_order}, mesh.isAxiallySymmetric(),
55 
57  "heat_flux",
59  mesh_space_dimension, getExtrapolator(), _local_assemblers,
61 }
62 
64  const double t, double const dt, std::vector<GlobalVector*> const& x,
65  std::vector<GlobalVector*> const& xdot, int const process_id,
67 {
68  DBUG("Assemble HeatConductionProcess.");
69 
70  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
71 
72  std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
73  dof_table = {std::ref(*_local_to_global_index_map)};
74  // Call global assembler for each local assembly item.
77  pv.getActiveElementIDs(), dof_table, t, dt, x, xdot, process_id, M, K,
78  b);
79 
83 
84  auto const residuum = computeResiduum(*x[0], *xdot[0], M, K, b);
85  transformVariableFromGlobalVector(residuum, 0 /*variable id*/,
87  std::negate<double>());
88 }
89 
91  const double t, double const dt, std::vector<GlobalVector*> const& x,
92  std::vector<GlobalVector*> const& xdot, int const process_id,
94 {
95  DBUG("AssembleWithJacobian HeatConductionProcess.");
96 
97  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
98 
99  std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
100  dof_table = {std::ref(*_local_to_global_index_map)};
101  // Call global assembler for each local assembly item.
104  _local_assemblers, pv.getActiveElementIDs(), dof_table, t, dt, x, xdot,
105  process_id, M, K, b, Jac);
106 
107  transformVariableFromGlobalVector(b, 0 /*variable id*/,
109  std::negate<double>());
110 }
111 
113  double const t, double const dt, std::vector<GlobalVector*> const& x,
114  GlobalVector const& x_dot, int const process_id)
115 {
116  DBUG("Compute heat flux for HeatConductionProcess.");
117 
118  std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
119  dof_tables.reserve(x.size());
120  std::generate_n(std::back_inserter(dof_tables), x.size(),
121  [&]() { return _local_to_global_index_map.get(); });
122 
123  ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
126  _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, dt, x,
127  x_dot, process_id);
128 }
129 
130 } // namespace HeatConduction
131 } // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:29
Global vector based on Eigen vector.
Definition: EigenVector.h:28
bool isAxiallySymmetric() const
Definition: Mesh.h:131
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:103
virtual std::vector< double > const & getIntPtHeatFlux(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
void assembleConcreteProcess(const double t, double const, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
HeatConductionProcess(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, HeatConductionProcessData &&process_data, SecondaryVariableCollection &&secondary_variables)
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_dot, int const process_id) override
std::vector< std::unique_ptr< HeatConductionLocalAssemblerInterface > > _local_assemblers
MeshLib::PropertyVector< double > * _heat_flux
void assembleWithJacobianConcreteProcess(const double t, double const, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) override
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_dot, int const process_id)
std::vector< std::size_t > const & getActiveElementIDs() const
NumLib::Extrapolator & getExtrapolator() const
Definition: Process.h:184
SecondaryVariableCollection _secondary_variables
Definition: Process.h:335
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
Definition: Process.h:148
VectorMatrixAssembler _global_assembler
Definition: Process.h:337
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Definition: Process.h:333
Handles configuration of several secondary variables from the project file.
void addSecondaryVariable(std::string const &internal_name, SecondaryVariableFunctions &&fcts)
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< std::reference_wrapper< NumLib::LocalToGlobalIndexMap >> const &dof_tables, const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac)
void assemble(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< std::reference_wrapper< NumLib::LocalToGlobalIndexMap >> const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b)
void finalizeVectorAssembly(VEC_T &)
General function to finalize the vector assembly.
static const double t
bool finalizeMatrixAssembly(MAT_T &)
void transformVariableFromGlobalVector(GlobalVector const &input_vector, int const variable_id, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, MeshLib::PropertyVector< double > &output_vector, Functor mapFunction)
Definition: DOFTableUtil.h:59
GlobalVector computeResiduum(GlobalVector const &x, GlobalVector const &xdot, GlobalMatrix const &M, GlobalMatrix const &K, GlobalVector const &b)
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
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)