OGS
CreateWellboreSimulatorProcess.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
10#include "ParameterLib/Utils.h"
13#include "ReservoirProperties.h"
14#include "WellboreGeometry.h"
18
19namespace ProcessLib
20{
22{
24 MeshLib::Mesh const& mesh,
26{
27 std::array<MaterialPropertyLib::PropertyType, 0> const
28 required_property_medium{};
29
30 std::array<MaterialPropertyLib::PropertyType, 0> const
31 required_property_solid_phase{};
32
33 std::array const required_property_liquid_phase = {
40
41 std::array const required_property_gas_phase = {
46
48 mesh, media_map, required_property_medium,
49 required_property_solid_phase, required_property_liquid_phase,
50 required_property_gas_phase);
51}
52
53std::unique_ptr<Process> createWellboreSimulatorProcess(
54 std::string name,
55 MeshLib::Mesh& mesh,
56 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
57 std::vector<ProcessVariable> const& variables,
58 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
59 unsigned const integration_order,
60 BaseLib::ConfigTree const& config,
61 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
62{
64 config.checkConfigParameter("type", "WELLBORE_SIMULATOR");
65
66 DBUG("Create WellboreSimulatorProcess.");
67
68 // Process variable.
69
71 auto const pv_config = config.getConfigSubtree("process_variables");
72
73 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
74 process_variables;
75
76 auto collected_process_variables = findProcessVariables(
77 variables, pv_config,
78 {
79 "pressure",
81 "velocity",
83 "specific_enthalpy"});
84
85 process_variables.push_back(std::move(collected_process_variables));
86
87 // Specific body force parameter.
88 Eigen::VectorXd specific_body_force;
89 std::vector<double> const b =
91 config.getConfigParameter<std::vector<double>>("specific_body_force");
92 assert(!b.empty() && b.size() < 4);
93 if (b.size() < mesh.getDimension())
94 {
96 "specific body force (gravity vector) has %d components, mesh "
97 "dimension is %d",
98 b.size(), mesh.getDimension());
99 }
100 bool const has_gravity = MathLib::toVector(b).norm() > 0;
101 if (has_gravity)
102 {
103 specific_body_force.resize(b.size());
104 std::copy_n(b.data(), b.size(), specific_body_force.data());
105 }
106
107 WellboreGeometry const wellbore_geometry =
109 createWellboreGeometry(config.getConfigSubtree("wellbore"), parameters);
110
111 auto const& well_ref_pressure = ParameterLib::findParameter<double>(
112 config,
114 "wellbore_ref_pressure", parameters, 1, &mesh);
115 DBUG("Use '{:s}' as wellbore_ref_pressure parameter.",
116 well_ref_pressure.name);
117
118 auto const& well_ref_enthalpy = ParameterLib::findParameter<double>(
119 config,
121 "wellbore_ref_enthalpy", parameters, 1, &mesh);
122 DBUG("Use '{:s}' as wellbore_ref_enthalpy parameter.",
123 well_ref_enthalpy.name);
124
125 auto const heat_exchange_with_formation =
127 config.getConfigParameter<bool>("heat_exchange_with_formation", false);
128
129 ReservoirProperties const reservoir_properties = createReservoirProperties(
131 config.getConfigSubtree("reservoir_properties"), parameters);
132
133 auto const& productivity_index = ParameterLib::findParameter<double>(
134 config,
136 "productivity_index", parameters, 1, &mesh);
137 DBUG("Use '{:s}' as productivity_index parameter.",
138 productivity_index.name);
139
140 auto media_map =
142
143 DBUG("Check the media properties of WellboreSimulator process ...");
144 checkMPLProperties(mesh, media_map);
145 DBUG("Media properties verified.");
146
147 WellboreSimulatorProcessData process_data{std::move(media_map),
148 specific_body_force,
149 std::move(wellbore_geometry),
150 well_ref_pressure,
151 well_ref_enthalpy,
152 std::move(reservoir_properties),
153 productivity_index,
154 heat_exchange_with_formation,
155 has_gravity};
156
157 SecondaryVariableCollection secondary_variables;
158
159 ProcessLib::createSecondaryVariables(config, secondary_variables);
160
161 return std::make_unique<WellboreSimulatorProcess>(
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}
166
167} // namespace WellboreSimulator
168} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
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:79
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)
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)