OGS
CreateStokesFlowProcess.cpp
Go to the documentation of this file.
1
12
13#include "BaseLib/ConfigTree.h"
17#include "StokesFlowProcess.h"
18
19namespace ProcessLib
20{
21namespace StokesFlow
22{
23namespace
24{
25void checkMPLProperties(
26 MeshLib::Mesh const& mesh,
28 bool const use_stokes_brinkman_form)
29{
30 std::array const required_properties_liquid_phase = {
32
33 std::array const required_properties_medium = {
35
36 for (auto const element_id : mesh.getElements() | MeshLib::views::ids)
37 {
38 auto const& medium = *media_map.getMedium(element_id);
39
40 if (use_stokes_brinkman_form)
41 {
42 checkRequiredProperties(medium, required_properties_medium);
43 }
44
45 // check if liquid phase definition and the corresponding properties
46 // exist
47 auto const& liquid_phase = medium.phase("AqueousLiquid");
48 checkRequiredProperties(liquid_phase, required_properties_liquid_phase);
49 }
50}
51} // namespace
52
53template <int GlobalDim>
54std::unique_ptr<Process> createStokesFlowProcess(
55 std::string const& name,
56 MeshLib::Mesh& mesh,
57 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
58 std::vector<ProcessVariable> const& variables,
59 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
60 unsigned const integration_order,
61 BaseLib::ConfigTree const& config,
62 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
63{
65 config.checkConfigParameter("type", "StokesFlow");
66
67 DBUG("Create StokesFlowProcess.");
68
69 auto const coupling_scheme =
71 config.getConfigParameter<std::string>("coupling_scheme",
72 "monolithic_scheme");
73 const bool use_monolithic_scheme = (coupling_scheme != "staggered");
74
76
78 auto const pv_config = config.getConfigSubtree("process_variables");
79
80 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
81 process_variables;
82
84 auto const collected_process_variables = findProcessVariables(
85 variables, pv_config,
86 {
87 "liquid_velocity",
89 "pressure"});
90
91 // Check number of components for each process variable
92 auto const variable_v = collected_process_variables[0];
93 if (variable_v.get().getNumberOfGlobalComponents() != GlobalDim)
94 {
96 "Number of components of the process variable '{:s}' is different "
97 "from the global dimension: got {:d}, expected {:d}",
98 variable_v.get().getName(),
99 variable_v.get().getNumberOfGlobalComponents(),
100 GlobalDim);
101 }
102
103 auto const variable_p = collected_process_variables[1];
104 if (variable_p.get().getNumberOfGlobalComponents() != 1)
105 {
106 OGS_FATAL(
107 "Pressure process variable '{:s}' is not a scalar variable but has "
108 "{:d} components.",
109 variable_p.get().getName(),
110 variable_p.get().getNumberOfGlobalComponents());
111 }
112
113 // Allocate the collected process variables into a two-dimensional vector,
114 // depending on what coupling scheme is adopted
115 if (use_monolithic_scheme) // monolithic scheme.
116 {
117 process_variables.push_back(std::move(collected_process_variables));
118 }
119 else // staggered scheme.
120 {
121 OGS_FATAL(
122 "The staggered coupling scheme for StokesFlowProcess is not "
123 "implemented.");
124 }
125
127 // Specific body force
128 Eigen::VectorXd specific_body_force = Eigen::VectorXd::Zero(GlobalDim);
129 auto const b =
131 config.getConfigParameter<std::vector<double>>("specific_body_force");
132 if (b.size() != GlobalDim)
133 {
134 OGS_FATAL(
135 "The size of the specific body force vector does not match the "
136 "global dimension. Vector size is {:d}, global "
137 "dimension is {:d}",
138 b.size(), GlobalDim);
139 }
140 std::copy_n(b.data(), b.size(), specific_body_force.data());
141
142 bool const use_stokes_brinkman_form =
144 config.getConfigParameter<bool>("use_stokes_brinkman_form", false);
145
146 auto media_map =
148
149 DBUG("Check the media properties of StokesFlow process ...");
150 checkMPLProperties(mesh, media_map, use_stokes_brinkman_form);
151 DBUG("Media properties verified.");
152
153 StokesFlowProcessData process_data{std::move(media_map),
154 std::move(specific_body_force),
155 use_stokes_brinkman_form};
156
157 SecondaryVariableCollection secondary_variables;
158
159 ProcessLib::createSecondaryVariables(config, secondary_variables);
160
161 return std::make_unique<StokesFlowProcess<GlobalDim>>(
162 std::move(name), mesh, std::move(jacobian_assembler), parameters,
163 integration_order, std::move(process_variables),
164 std::move(process_data), std::move(secondary_variables),
165 use_monolithic_scheme);
166}
167
168template std::unique_ptr<Process> createStokesFlowProcess<2>(
169 std::string const& name,
170 MeshLib::Mesh& mesh,
171 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
172 std::vector<ProcessVariable> const& variables,
173 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
174 unsigned const integration_order,
175 BaseLib::ConfigTree const& config,
176 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
177
178} // namespace StokesFlow
179} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
Phase const & phase(std::size_t index) const
Definition Medium.cpp:33
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
Handles configuration of several secondary variables from the project file.
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:225
std::unique_ptr< Process > createStokesFlowProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createStokesFlowProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)