OGS
CreateWellboreSimulatorProcess.cpp
Go to the documentation of this file.
1
12
17#include "ParameterLib/Utils.h"
20#include "ReservoirProperties.h"
21#include "WellboreGeometry.h"
25
26namespace ProcessLib
27{
28namespace WellboreSimulator
29{
31 MeshLib::Mesh const& mesh,
33{
34 std::array<MaterialPropertyLib::PropertyType, 0> const
35 required_property_medium{};
36
37 std::array<MaterialPropertyLib::PropertyType, 0> const
38 required_property_solid_phase{};
39
40 std::array const required_property_liquid_phase = {
47
48 std::array const required_property_gas_phase = {
53
55 mesh, media_map, required_property_medium,
56 required_property_solid_phase, required_property_liquid_phase,
57 required_property_gas_phase);
58}
59
60std::unique_ptr<Process> createWellboreSimulatorProcess(
61 std::string name,
62 MeshLib::Mesh& mesh,
63 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
64 std::vector<ProcessVariable> const& variables,
65 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
66 unsigned const integration_order,
67 BaseLib::ConfigTree const& config,
68 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
69{
71 config.checkConfigParameter("type", "WELLBORE_SIMULATOR");
72
73 DBUG("Create WellboreSimulatorProcess.");
74
75 // Process variable.
76
78 auto const pv_config = config.getConfigSubtree("process_variables");
79
80 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
81 process_variables;
82
83 auto collected_process_variables = findProcessVariables(
84 variables, pv_config,
85 {
86 "pressure",
88 "velocity",
90 "specific_enthalpy"});
91
92 process_variables.push_back(std::move(collected_process_variables));
93
94 // Specific body force parameter.
95 Eigen::VectorXd specific_body_force;
96 std::vector<double> const b =
98 config.getConfigParameter<std::vector<double>>("specific_body_force");
99 assert(!b.empty() && b.size() < 4);
100 if (b.size() < mesh.getDimension())
101 {
102 OGS_FATAL(
103 "specific body force (gravity vector) has %d components, mesh "
104 "dimension is %d",
105 b.size(), mesh.getDimension());
106 }
107 bool const has_gravity = MathLib::toVector(b).norm() > 0;
108 if (has_gravity)
109 {
110 specific_body_force.resize(b.size());
111 std::copy_n(b.data(), b.size(), specific_body_force.data());
112 }
113
114 WellboreGeometry const wellbore_geometry =
116 createWellboreGeometry(config.getConfigSubtree("wellbore"), parameters);
117
118 auto const& well_ref_pressure = ParameterLib::findParameter<double>(
119 config,
121 "wellbore_ref_pressure", parameters, 1, &mesh);
122 DBUG("Use '{:s}' as wellbore_ref_pressure parameter.",
123 well_ref_pressure.name);
124
125 auto const& well_ref_enthalpy = ParameterLib::findParameter<double>(
126 config,
128 "wellbore_ref_enthalpy", parameters, 1, &mesh);
129 DBUG("Use '{:s}' as wellbore_ref_enthalpy parameter.",
130 well_ref_enthalpy.name);
131
132 auto const heat_exchange_with_formation =
134 config.getConfigParameter<bool>("heat_exchange_with_formation", false);
135
136 ReservoirProperties const reservoir_properties = createReservoirProperties(
138 config.getConfigSubtree("reservoir_properties"), parameters);
139
140 auto const& productivity_index = ParameterLib::findParameter<double>(
141 config,
143 "productivity_index", parameters, 1, &mesh);
144 DBUG("Use '{:s}' as productivity_index parameter.",
145 productivity_index.name);
146
147 auto media_map =
149
150 DBUG("Check the media properties of WellboreSimulator process ...");
151 checkMPLProperties(mesh, media_map);
152 DBUG("Media properties verified.");
153
154 WellboreSimulatorProcessData process_data{std::move(media_map),
155 specific_body_force,
156 std::move(wellbore_geometry),
157 well_ref_pressure,
158 well_ref_enthalpy,
159 std::move(reservoir_properties),
160 productivity_index,
161 heat_exchange_with_formation,
162 has_gravity};
163
164 SecondaryVariableCollection secondary_variables;
165
166 ProcessLib::createSecondaryVariables(config, secondary_variables);
167
168 return std::make_unique<WellboreSimulatorProcess>(
169 std::move(name), mesh, std::move(jacobian_assembler), parameters,
170 integration_order, std::move(process_variables),
171 std::move(process_data), std::move(secondary_variables));
172}
173
174} // namespace WellboreSimulator
175} // 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
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
Handles configuration of several secondary variables from the project file.
void checkMaterialSpatialDistributionMap(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map, ContainerMedium const &required_properties_medium, ContainerSolid const &required_properties_solid_phase, ContainerLiquid const &required_properties_liquid_phase, ContainerGas const &required_properties_gas_phase)
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
std::unique_ptr< Process > createWellboreSimulatorProcess(std::string 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)
ReservoirProperties createReservoirProperties(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
WellboreGeometry createWellboreGeometry(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
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)
Definition of readMeshFromFile function.