CreateHydroMechanicsProcess.cpp 11.1 KB
Newer Older
1
/**
2
 * \file
3
 * \copyright
4
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
5
6
7
8
9
10
11
12
13
14
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "CreateHydroMechanicsProcess.h"

#include <cassert>

Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
15
16
#include "HydroMechanicsProcess.h"
#include "HydroMechanicsProcessData.h"
FZill's avatar
FZill committed
17
18
#include "MaterialLib/MPL/CreateMaterialSpatialDistributionMap.h"
#include "MaterialLib/MPL/MaterialSpatialDistributionMap.h"
19
#include "MaterialLib/MPL/Medium.h"
20
#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h"
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
21
#include "MaterialLib/SolidModels/MechanicsBase.h"
22
#include "MeshLib/Utils/Is2DMeshOnRotatedVerticalPlane.h"
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
23
#include "ParameterLib/Utils.h"
24
#include "ProcessLib/Output/CreateSecondaryVariables.h"
25
#include "ProcessLib/Utils/ProcessUtils.h"
26
27
28
29
30
31
32

namespace ProcessLib
{
namespace HydroMechanics
{
template <int DisplacementDim>
std::unique_ptr<Process> createHydroMechanicsProcess(
FZill's avatar
FZill committed
33
    std::string name, MeshLib::Mesh& mesh,
34
35
    std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
    std::vector<ProcessVariable> const& variables,
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
36
    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
37
    std::optional<ParameterLib::CoordinateSystem> const&
38
        local_coordinate_system,
FZill's avatar
FZill committed
39
    unsigned const integration_order, BaseLib::ConfigTree const& config,
40
    std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
41
{
42
    //! \ogs_file_param{prj__processes__process__type}
43
44
45
    config.checkConfigParameter("type", "HYDRO_MECHANICS");
    DBUG("Create HydroMechanicsProcess.");

46
47
48
49
50
51
52
53
54
55
56
57
    if (DisplacementDim == 2)
    {
        if (mesh.isAxiallySymmetric() &&
            MeshLib::is2DMeshOnRotatedVerticalPlane(mesh))
        {
            OGS_FATAL(
                "Mesh {:s} is on a plane rotated around the vertical axis. The "
                "axisymmetric problem can not use such mesh.",
                mesh.getName());
        }
    }

Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
58
    auto const coupling_scheme =
59
60
61
        //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__coupling_scheme}
        config.getConfigParameterOptional<std::string>("coupling_scheme");
    const bool use_monolithic_scheme =
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
62
        !(coupling_scheme && (*coupling_scheme == "staggered"));
63

64
65
66
    auto coupling_scheme_parameter_optional =
        //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__coupling_scheme_parameter}
        config.getConfigParameterOptional<double>("coupling_scheme_parameter");
67
    double coupling_scheme_parameter = std::numeric_limits<double>::quiet_NaN();
68

69
    if (use_monolithic_scheme)
70
    {
71
        if (coupling_scheme_parameter_optional)
72
73
74
75
76
        {
            WARN(
                "Monolithic scheme ignores coupling scheme parameter set in "
                "project file.");
        }
77
78
79
80
    }
    else
    {
        if (coupling_scheme_parameter_optional)
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
        {
            coupling_scheme_parameter =
                coupling_scheme_parameter_optional.value();
            // optimum not a-priori known, but within certain interval [Storvik
            // & Nordbotten]
            double const csp_min = 1.0 / 6.0;
            double const csp_max = 1.0;
            if (coupling_scheme_parameter < csp_min ||
                coupling_scheme_parameter > csp_max)
            {
                WARN(
                    "Value of coupling scheme parameter = {:g} is out of "
                    "reasonable range ({:g}, {:g}).",
                    coupling_scheme_parameter, csp_min, csp_max);
            }
        }
97
98
99
100
        else
        {
            coupling_scheme_parameter = 0.5;  // default value recommended [Mikelic & Wheeler]
        }
101
        DBUG("Using value {:g} for coupling parameter of staggered scheme.",
102
              coupling_scheme_parameter);
103
104
    }

105
    /// \section processvariableshm Process Variables
106
107
108
109

    //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__process_variables}
    auto const pv_config = config.getConfigSubtree("process_variables");

110
111
112
113
    ProcessVariable* variable_p;
    ProcessVariable* variable_u;
    std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
        process_variables;
114
115
116
117

    int const hydraulic_process_id = 0;
    int mechanics_related_process_id = 0;

118
119
    if (use_monolithic_scheme)  // monolithic scheme.
    {
120
        /// Primary process variables as they appear in the global component vector:
121
122
123
        auto per_process_variables = findProcessVariables(
            variables, pv_config,
            {//! \ogs_file_param_special{prj__processes__process__HYDRO_MECHANICS__process_variables__pressure}
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
124
125
126
             "pressure",
             //! \ogs_file_param_special{prj__processes__process__HYDRO_MECHANICS__process_variables__displacement}
             "displacement"});
127
128
129
130
131
132
        variable_p = &per_process_variables[0].get();
        variable_u = &per_process_variables[1].get();
        process_variables.push_back(std::move(per_process_variables));
    }
    else  // staggered scheme.
    {
133
134
        using namespace std::string_literals;
        for (auto const& variable_name : {"pressure"s, "displacement"s})
135
136
        {
            auto per_process_variables =
137
                findProcessVariables(variables, pv_config, {variable_name});
138
139
            process_variables.push_back(std::move(per_process_variables));
        }
140
141
142
        mechanics_related_process_id = 1;
        variable_p = &process_variables[hydraulic_process_id][0].get();
        variable_u = &process_variables[mechanics_related_process_id][0].get();
143
    }
144

Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
145
    DBUG("Associate displacement with process variable '{:s}'.",
146
         variable_u->getName());
147

148
    if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
149
150
    {
        OGS_FATAL(
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
151
152
            "Number of components of the process variable '{:s}' is different "
            "from the displacement dimension: got {:d}, expected {:d}",
153
            variable_u->getName(),
154
            variable_u->getNumberOfGlobalComponents(),
155
156
157
            DisplacementDim);
    }

Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
158
    DBUG("Associate pressure with process variable '{:s}'.",
159
         variable_p->getName());
160
    if (variable_p->getNumberOfGlobalComponents() != 1)
161
162
    {
        OGS_FATAL(
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
163
164
            "Pressure process variable '{:s}' is not a scalar variable but has "
            "{:d} components.",
165
            variable_p->getName(),
166
            variable_p->getNumberOfGlobalComponents());
167
168
    }

169
170
    auto solid_constitutive_relations =
        MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
171
            parameters, local_coordinate_system, config);
172

173
    /// \section parametershm Process Parameters
174
175
176
177
    // Specific body force
    Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
    {
        std::vector<double> const b =
178
            //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__specific_body_force}
179
180
            config.getConfigParameter<std::vector<double>>(
                "specific_body_force");
181
        if (b.size() != DisplacementDim)
wenqing's avatar
wenqing committed
182
        {
183
184
            OGS_FATAL(
                "The size of the specific body force vector does not match the "
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
185
186
                "displacement dimension. Vector size is {:d}, displacement "
                "dimension is {:d}",
187
                b.size(), DisplacementDim);
wenqing's avatar
wenqing committed
188
        }
189
190
191
192

        std::copy_n(b.data(), b.size(), specific_body_force.data());
    }

FZill's avatar
FZill committed
193
194
195
    //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__mass_lumping}
    auto mass_lumping = config.getConfigParameter<bool>("mass_lumping", false);

FZill's avatar
FZill committed
196
197
198
    auto media_map =
        MaterialPropertyLib::createMaterialSpatialDistributionMap(media, mesh);

FZill's avatar
FZill committed
199
    std::array const requiredMediumProperties = {
200
        MaterialPropertyLib::reference_temperature,
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
201
202
203
204
205
        MaterialPropertyLib::permeability, MaterialPropertyLib::porosity,
        MaterialPropertyLib::biot_coefficient};
    std::array const requiredFluidProperties = {MaterialPropertyLib::viscosity,
                                                MaterialPropertyLib::density};
    std::array const requiredSolidProperties = {MaterialPropertyLib::density};
206

207
    for (auto const& element : mesh.getElements())
208
    {
209
210
211
212
        auto const element_id = element->getID();
        media_map->checkElementHasMedium(element_id);
        auto const& medium = *media_map->getMedium(element_id);
        checkRequiredProperties(medium, requiredMediumProperties);
213
        checkRequiredProperties(fluidPhase(medium), requiredFluidProperties);
214
        checkRequiredProperties(medium.phase("Solid"), requiredSolidProperties);
215
    }
216
    DBUG("Media properties verified.");
217

218
219
220
221
222
    // Initial stress conditions
    auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
        //! \ogs_file_param_special{prj__processes__process__HYDRO_MECHANICS__initial_stress}
        config, "initial_stress", parameters,
        // Symmetric tensor size, 4 or 6, not a Kelvin vector.
223
        MathLib::KelvinVector::kelvin_vector_dimensions(DisplacementDim),
224
225
        &mesh);

226
227
228
    const bool use_taylor_hood_elements = variable_p->getShapeFunctionOrder() !=
                                          variable_u->getShapeFunctionOrder();

229
    HydroMechanicsProcessData<DisplacementDim> process_data{
230
231
232
233
234
235
236
        materialIDs(mesh), std::move(media_map),
        std::move(solid_constitutive_relations), initial_stress,
        specific_body_force, mass_lumping,
        coupling_scheme_parameter,  // this parameter gets its specific meaning
                                    // in the process depending on implemented
                                    // coupling scheme
        hydraulic_process_id, mechanics_related_process_id,
237
        use_taylor_hood_elements};
238
239
240

    SecondaryVariableCollection secondary_variables;

241
    ProcessLib::createSecondaryVariables(config, secondary_variables);
242

Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
243
    return std::make_unique<HydroMechanicsProcess<DisplacementDim>>(
244
245
246
        std::move(name), mesh, std::move(jacobian_assembler), parameters,
        integration_order, std::move(process_variables),
        std::move(process_data), std::move(secondary_variables),
247
        use_monolithic_scheme);
248
249
250
}

template std::unique_ptr<Process> createHydroMechanicsProcess<2>(
251
    std::string name,
252
253
254
    MeshLib::Mesh& mesh,
    std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
    std::vector<ProcessVariable> const& variables,
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
255
    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
256
    std::optional<ParameterLib::CoordinateSystem> const&
257
        local_coordinate_system,
258
    unsigned const integration_order,
FZill's avatar
FZill committed
259
    BaseLib::ConfigTree const& config,
260
    std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
261
262

template std::unique_ptr<Process> createHydroMechanicsProcess<3>(
263
    std::string name,
264
265
266
    MeshLib::Mesh& mesh,
    std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
    std::vector<ProcessVariable> const& variables,
Dmitry Yu. Naumov's avatar
Dmitry Yu. Naumov committed
267
    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
268
    std::optional<ParameterLib::CoordinateSystem> const&
269
        local_coordinate_system,
270
    unsigned const integration_order,
FZill's avatar
FZill committed
271
    BaseLib::ConfigTree const& config,
272
    std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
273
274
275

}  // namespace HydroMechanics
}  // namespace ProcessLib