OGS
LiquidFlowProcess.cpp
Go to the documentation of this file.
1
13#include "LiquidFlowProcess.h"
14
15#include <cassert>
16
23
24namespace ProcessLib
25{
26namespace LiquidFlow
27{
29 std::string name,
30 MeshLib::Mesh& mesh,
31 std::unique_ptr<AbstractJacobianAssembler>&& jacobian_assembler,
32 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
33 unsigned const integration_order,
34 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
35 process_variables,
36 LiquidFlowData&& process_data,
37 SecondaryVariableCollection&& secondary_variables,
38 std::unique_ptr<ProcessLib::SurfaceFluxData>&& surfaceflux)
39 : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
40 integration_order, std::move(process_variables),
41 std::move(secondary_variables)),
42 _process_data(std::move(process_data)),
43 _surfaceflux(std::move(surfaceflux))
44{
45 DBUG("Create Liquid flow process.");
46
47 _hydraulic_flow = MeshLib::getOrCreateMeshProperty<double>(
48 mesh, "VolumetricFlowRate", MeshLib::MeshItemType::Node, 1);
49}
50
52 NumLib::LocalToGlobalIndexMap const& dof_table,
53 MeshLib::Mesh const& mesh,
54 unsigned const integration_order)
55{
56 int const mesh_space_dimension = _process_data.mesh_space_dimension;
57 ProcessLib::createLocalAssemblers<LiquidFlowLocalAssembler>(
58 mesh_space_dimension, mesh.getElements(), dof_table, _local_assemblers,
59 mesh.isAxiallySymmetric(), integration_order, _process_data);
60
62 "darcy_velocity",
64 mesh_space_dimension, getExtrapolator(), _local_assemblers,
66}
67
69 const double t, double const dt, std::vector<GlobalVector*> const& x,
70 std::vector<GlobalVector*> const& xdot, int const process_id,
72{
73 DBUG("Assemble LiquidFlowProcess.");
74
75 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
76 dof_table = {std::ref(*_local_to_global_index_map)};
77
78 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
79
80 // Call global assembler for each local assembly item.
83 pv.getActiveElementIDs(), dof_table, t, dt, x, xdot, process_id, M, K,
84 b);
85
89
90 auto const residuum = computeResiduum(*x[0], *xdot[0], M, K, b);
91 transformVariableFromGlobalVector(residuum, 0 /*variable id*/,
93 *_hydraulic_flow, std::negate<double>());
94}
95
97 const double t, double const dt, std::vector<GlobalVector*> const& x,
98 std::vector<GlobalVector*> const& xdot, int const process_id,
100{
101 DBUG("AssembleWithJacobian LiquidFlowProcess.");
102
103 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
104 dof_table = {std::ref(*_local_to_global_index_map)};
105 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
106
107 // Call global assembler for each local assembly item.
110 _local_assemblers, pv.getActiveElementIDs(), dof_table, t, dt, x, xdot,
111 process_id, M, K, b, Jac);
112}
113
115 double const t, double const dt, std::vector<GlobalVector*> const& x,
116 GlobalVector const& x_dot, int const process_id)
117{
118 DBUG("Compute the velocity for LiquidFlowProcess.");
119 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
120 dof_tables.reserve(x.size());
121 std::generate_n(std::back_inserter(dof_tables), x.size(),
122 [&]() { return _local_to_global_index_map.get(); });
123
124 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
127 _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, dt, x,
128 x_dot, process_id);
129}
130
132 std::size_t const element_id,
133 MathLib::Point3d const& p,
134 double const t,
135 std::vector<GlobalVector*> const& x) const
136{
137 // fetch local_x from primary variable
138 std::vector<GlobalIndexType> indices_cache;
139 auto const r_c_indices = NumLib::getRowColumnIndices(
140 element_id, *_local_to_global_index_map, indices_cache);
141 constexpr int process_id = 0; // monolithic scheme.
142 std::vector<double> local_x(x[process_id]->get(r_c_indices.rows));
143
144 return _local_assemblers[element_id]->getFlux(p, t, local_x);
145}
146
147// this is almost a copy of the implementation in the GroundwaterFlow
149 std::vector<GlobalVector*> const& x,
150 const double t,
151 const double /*dt*/,
152 int const process_id)
153{
154 if (!_surfaceflux) // computing the surfaceflux is optional
155 {
156 return;
157 }
158
159 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
160 _surfaceflux->integrate(x, t, *this, process_id, _integration_order, _mesh,
162}
163
164} // namespace LiquidFlow
165} // namespace ProcessLib
void DBUG(char const *fmt, Args const &... 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 & getIntPtDarcyVelocity(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
Eigen::Vector3d getFlux(std::size_t const element_id, MathLib::Point3d const &p, double const t, std::vector< GlobalVector * > const &x) const override
void assembleWithJacobianConcreteProcess(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) override
std::vector< std::unique_ptr< LiquidFlowLocalAssemblerInterface > > _local_assemblers
void assembleConcreteProcess(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) override
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_dot, int const process_id) override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
std::unique_ptr< ProcessLib::SurfaceFluxData > _surfaceflux
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, const double t, const double dt, int const process_id) override
LiquidFlowProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< 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, LiquidFlowData &&process_data, SecondaryVariableCollection &&secondary_variables, std::unique_ptr< ProcessLib::SurfaceFluxData > &&surfaceflux)
MeshLib::PropertyVector< double > * _hydraulic_flow
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
MeshLib::Mesh & _mesh
Definition: Process.h:328
SecondaryVariableCollection _secondary_variables
Definition: Process.h:333
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
Definition: Process.h:146
VectorMatrixAssembler _global_assembler
Definition: Process.h:335
unsigned const _integration_order
Definition: Process.h:346
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Definition: Process.h:331
NumLib::Extrapolator & getExtrapolator() const
Definition: Process.h:182
Handles configuration of several secondary variables from the project file.
void addSecondaryVariable(std::string const &internal_name, SecondaryVariableFunctions &&fcts)
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 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 finalizeVectorAssembly(VEC_T &)
General function to finalize the vector assembly.
static const double t
bool finalizeMatrixAssembly(MAT_T &)
NumLib::LocalToGlobalIndexMap::RowColumnIndices getRowColumnIndices(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< GlobalIndexType > &indices)
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)