Commit 32137548 authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov
Browse files

Merge branch 'RM_T' into 'master'

Non-isothermal Richards mechanics (monolithic scheme)

See merge request ogs/ogs!3166
parents 3e021e75 2ab85aa7
......@@ -73,6 +73,11 @@
#ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
#include "ProcessLib/LiquidFlow/CreateLiquidFlowProcess.h"
#endif
#ifdef OGS_BUILD_PROCESS_THERMORICHARDSMECHANICS
#include "ProcessLib/ThermoRichardsMechanics/CreateThermoRichardsMechanicsProcess.h"
#endif
#ifdef OGS_BUILD_PROCESS_PHASEFIELD
#include "ProcessLib/PhaseField/CreatePhaseFieldProcess.h"
#endif
......@@ -987,6 +992,33 @@ void ProjectData::parseProcesses(
}
else
#endif
#ifdef OGS_BUILD_PROCESS_THERMORICHARDSMECHANICS
if (type == "THERMO_RICHARDS_MECHANICS")
{
switch (_mesh_vec[0]->getDimension())
{
case 2:
process = ProcessLib::ThermoRichardsMechanics::
createThermoRichardsMechanicsProcess<2>(
name, *_mesh_vec[0], std::move(jacobian_assembler),
_process_variables, _parameters,
_local_coordinate_system, integration_order,
process_config, _media);
break;
case 3:
process = ProcessLib::ThermoRichardsMechanics::
createThermoRichardsMechanicsProcess<3>(
name, *_mesh_vec[0], std::move(jacobian_assembler),
_process_variables, _parameters,
_local_coordinate_system, integration_order,
process_config, _media);
break;
}
}
else
#endif
#ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
if (type == "TWOPHASE_FLOW_PP")
{
......
\copydoc ProcessLib::ThermoRichardsMechanics::ThermoRichardsMechanicsProcess
The process variables for temperature, pressure and displacement.
If higher order elements (order=2) are chosen for the displacement variable,
the linear elements (order=1) have to be used for the temperature and
the pressure variables. That means to use the Talyor-Hood elements.
If the linear elements (order=1) are used for displacement variable,
they are used for temperature and the pressure variables as well.
Coupling scheme. So far, only the full monolithic scheme is available.
\copydoc ProcessLib::RichardsMechanics::RichardsMechanicsProcessData::initial_stress
A tag for enabling diagonal lumping of the mass matrix of the Richards equation.
\ No newline at end of file
\copydoc ProcessLib::RichardsMechanics::RichardsMechanicsProcessData::specific_body_force
append_source_files(SOURCES)
ogs_add_library(ThermoRichardsMechanics ${SOURCES})
target_link_libraries(ThermoRichardsMechanics PUBLIC ProcessLib PRIVATE ParameterLib)
if(BUILD_TESTING)
include(Tests.cmake)
endif()
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "CreateThermoRichardsMechanicsProcess.h"
#include <cassert>
#include "MaterialLib/MPL/CreateMaterialSpatialDistributionMap.h"
#include "MaterialLib/MPL/MaterialSpatialDistributionMap.h"
#include "MaterialLib/MPL/Medium.h"
#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h"
#include "MaterialLib/SolidModels/MechanicsBase.h"
#include "ParameterLib/Utils.h"
#include "ProcessLib/Output/CreateSecondaryVariables.h"
#include "ProcessLib/Utils/ProcessUtils.h"
#include "ThermoRichardsMechanicsProcess.h"
#include "ThermoRichardsMechanicsProcessData.h"
namespace ProcessLib
{
namespace ThermoRichardsMechanics
{
void checkMPLProperties(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
std::array const required_medium_properties = {
MaterialPropertyLib::porosity, MaterialPropertyLib::biot_coefficient,
MaterialPropertyLib::bishops_effective_stress,
MaterialPropertyLib::relative_permeability,
MaterialPropertyLib::saturation};
std::array const required_liquid_properties = {
MaterialPropertyLib::viscosity, MaterialPropertyLib::density};
std::array const required_solid_properties = {MaterialPropertyLib::density};
// Thermal properties are not checked because they can be phase property or
// meduim property (will be enabled later).
for (auto const& m : media)
{
checkRequiredProperties(*m.second, required_medium_properties);
checkRequiredProperties(m.second->phase("AqueousLiquid"),
required_liquid_properties);
checkRequiredProperties(m.second->phase("Solid"),
required_solid_properties);
}
}
void checkProcessVariableComponents(ProcessVariable const& variable,
const int dim)
{
DBUG("Associate displacement with process variable '{:s}'.",
variable.getName());
if (variable.getNumberOfGlobalComponents() != dim)
{
OGS_FATAL(
"Number of components of the process variable '{:s}' is different "
"from the displacement dimension: got {:d}, expected {:d}",
variable.getName(),
variable.getNumberOfGlobalComponents(),
dim);
}
}
template <int DisplacementDim>
std::unique_ptr<Process> createThermoRichardsMechanicsProcess(
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,
boost::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
unsigned const integration_order,
BaseLib::ConfigTree const& config,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
//! \ogs_file_param{prj__processes__process__type}
config.checkConfigParameter("type", "THERMO_RICHARDS_MECHANICS");
DBUG("Create ThermoRichardsMechanicsProcess.");
auto const staggered_scheme =
//! \ogs_file_param{prj__processes__process__THERMO_RICHARDS_MECHANICS__coupling_scheme}
config.getConfigParameterOptional<std::string>("coupling_scheme");
const bool use_monolithic_scheme =
!(staggered_scheme && (*staggered_scheme == "staggered"));
// Process variable.
//! \ogs_file_param{prj__processes__process__THERMO_RICHARDS_MECHANICS__process_variables}
auto const pv_config = config.getConfigSubtree("process_variables");
ProcessVariable* variable_T;
ProcessVariable* variable_p;
ProcessVariable* variable_u;
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
process_variables;
if (use_monolithic_scheme) // monolithic scheme.
{
auto per_process_variables = findProcessVariables(
variables, pv_config,
{
//! \ogs_file_param_special{prj__processes__process__THERMO_RICHARDS_MECHANICS__process_variables__temperature}
"temperature",
//! \ogs_file_param_special{prj__processes__process__THERMO_RICHARDS_MECHANICS__process_variables__pressure}
"pressure",
//! \ogs_file_param_special{prj__processes__process__THERMO_RICHARDS_MECHANICS__process_variables__displacement}
"displacement"});
variable_T = &per_process_variables[0].get();
variable_p = &per_process_variables[1].get();
variable_u = &per_process_variables[2].get();
process_variables.push_back(std::move(per_process_variables));
}
else // staggered scheme.
{
OGS_FATAL(
"So far, only the monolithic scheme is implemented for "
"THERMO_RICHARDS_MECHANICS");
}
checkProcessVariableComponents(*variable_T, 1);
checkProcessVariableComponents(*variable_p, 1);
checkProcessVariableComponents(*variable_u, DisplacementDim);
auto solid_constitutive_relations =
MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
parameters, local_coordinate_system, config);
// Specific body force
Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
{
std::vector<double> const b =
//! \ogs_file_param{prj__processes__process__THERMO_RICHARDS_MECHANICS__specific_body_force}
config.getConfigParameter<std::vector<double>>(
"specific_body_force");
if (b.size() != DisplacementDim)
{
OGS_FATAL(
"The size of the specific body force vector does not match the "
"displacement dimension. Vector size is {:d}, displacement "
"dimension is {:d}",
b.size(), DisplacementDim);
}
std::copy_n(b.data(), b.size(), specific_body_force.data());
}
auto media_map =
MaterialPropertyLib::createMaterialSpatialDistributionMap(media, mesh);
DBUG(
"Check the media properties of ThermoRichardsMechanics process "
"...");
checkMPLProperties(media);
DBUG("Media properties verified.");
// Initial stress conditions
auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
//! \ogs_file_param_special{prj__processes__process__THERMO_RICHARDS_MECHANICS__initial_stress}
config, "initial_stress", parameters,
// Symmetric tensor size, 4 or 6, not a Kelvin vector.
MathLib::KelvinVector::KelvinVectorDimensions<DisplacementDim>::value,
&mesh);
bool mass_lumping = false;
if (auto const mass_lumping_ptr =
//! \ogs_file_param{prj__processes__process__THERMO_RICHARDS_MECHANICS__mass_lumping}
config.getConfigParameterOptional<bool>("mass_lumping"))
{
DBUG("Using mass lumping for the Richards flow equation.");
mass_lumping = *mass_lumping_ptr;
}
ThermoRichardsMechanicsProcessData<DisplacementDim> process_data{
materialIDs(mesh),
std::move(media_map),
std::move(solid_constitutive_relations),
initial_stress,
specific_body_force,
mass_lumping};
SecondaryVariableCollection secondary_variables;
ProcessLib::createSecondaryVariables(config, secondary_variables);
return std::make_unique<ThermoRichardsMechanicsProcess<DisplacementDim>>(
std::move(name), mesh, std::move(jacobian_assembler), parameters,
integration_order, std::move(process_variables),
std::move(process_data), std::move(secondary_variables),
use_monolithic_scheme);
}
template std::unique_ptr<Process> createThermoRichardsMechanicsProcess<2>(
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,
boost::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
unsigned const integration_order,
BaseLib::ConfigTree const& config,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
template std::unique_ptr<Process> createThermoRichardsMechanicsProcess<3>(
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,
boost::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
unsigned const integration_order,
BaseLib::ConfigTree const& config,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
} // namespace ThermoRichardsMechanics
} // namespace ProcessLib
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include <boost/optional.hpp>
#include <map>
#include <memory>
#include <vector>
namespace BaseLib
{
class ConfigTree;
}
namespace MeshLib
{
class Mesh;
}
namespace MathLib
{
class PiecewiseLinearInterpolation;
}
namespace MaterialPropertyLib
{
class Medium;
}
namespace ParameterLib
{
struct CoordinateSystem;
struct ParameterBase;
} // namespace ParameterLib
namespace ProcessLib
{
class AbstractJacobianAssembler;
class Process;
class ProcessVariable;
} // namespace ProcessLib
namespace ProcessLib
{
namespace ThermoRichardsMechanics
{
template <int DisplacementDim>
std::unique_ptr<Process> createThermoRichardsMechanicsProcess(
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,
boost::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
unsigned const integration_order,
BaseLib::ConfigTree const& config,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
extern template std::unique_ptr<Process>
createThermoRichardsMechanicsProcess<2>(
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,
boost::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
unsigned const integration_order,
BaseLib::ConfigTree const& config,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
extern template std::unique_ptr<Process>
createThermoRichardsMechanicsProcess<3>(
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,
boost::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
unsigned const integration_order,
BaseLib::ConfigTree const& config,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
} // namespace ThermoRichardsMechanics
} // namespace ProcessLib
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include <limits>
#include <memory>
#include "MaterialLib/MPL/VariableType.h"
#include "MaterialLib/SolidModels/LinearElasticIsotropic.h"
#include "MathLib/KelvinVector.h"
#include "MathLib/LinAlg/Eigen/EigenMapTools.h"
namespace ProcessLib
{
namespace ThermoRichardsMechanics
{
template <typename BMatricesType, typename ShapeMatrixTypeDisplacement,
typename ShapeMatricesTypePressure, int DisplacementDim, int NPoints>
struct IntegrationPointData final
{
explicit IntegrationPointData(
MaterialLib::Solids::MechanicsBase<DisplacementDim> const&
solid_material)
: solid_material(solid_material),
material_state_variables(
solid_material.createMaterialStateVariables())
{
// Initialize current time step values
static const int kelvin_vector_size =
MathLib::KelvinVector::KelvinVectorDimensions<
DisplacementDim>::value;
sigma_eff.setZero(kelvin_vector_size);
sigma_sw.setZero(kelvin_vector_size);
eps.setZero(kelvin_vector_size);
eps_m.setZero(kelvin_vector_size);
// Previous time step values are not initialized and are set later.
eps_prev.resize(kelvin_vector_size);
eps_m_prev.resize(kelvin_vector_size);
sigma_eff_prev.resize(kelvin_vector_size);
}
typename ShapeMatrixTypeDisplacement::template MatrixType<
DisplacementDim, NPoints * DisplacementDim>
N_u_op;
typename BMatricesType::KelvinVectorType sigma_eff, sigma_eff_prev;
typename BMatricesType::KelvinVectorType sigma_sw, sigma_sw_prev;
typename BMatricesType::KelvinVectorType eps, eps_prev;
typename BMatricesType::KelvinVectorType eps_m, eps_m_prev;
typename ShapeMatrixTypeDisplacement::NodalRowVectorType N_u;
typename ShapeMatrixTypeDisplacement::GlobalDimNodalMatrixType dNdx_u;
typename ShapeMatricesTypePressure::NodalRowVectorType N_p;
typename ShapeMatricesTypePressure::GlobalDimNodalMatrixType dNdx_p;
typename ShapeMatricesTypePressure::GlobalDimVectorType v_darcy;
double saturation = std::numeric_limits<double>::quiet_NaN();
double saturation_prev = std::numeric_limits<double>::quiet_NaN();
double porosity = std::numeric_limits<double>::quiet_NaN();
double porosity_prev = std::numeric_limits<double>::quiet_NaN();
double transport_porosity = std::numeric_limits<double>::quiet_NaN();
double transport_porosity_prev = std::numeric_limits<double>::quiet_NaN();
double dry_density_solid = std::numeric_limits<double>::quiet_NaN();
double dry_density_pellet_saturated =
std::numeric_limits<double>::quiet_NaN();
double dry_density_pellet_unsaturated =
std::numeric_limits<double>::quiet_NaN();
MaterialLib::Solids::MechanicsBase<DisplacementDim> const& solid_material;
std::unique_ptr<typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables>
material_state_variables;
double integration_weight = std::numeric_limits<double>::quiet_NaN();
void pushBackState()
{
eps_prev = eps;
eps_m_prev = eps_m;
sigma_eff_prev = sigma_eff;
sigma_sw_prev = sigma_sw;
saturation_prev = saturation;
porosity_prev = porosity;
transport_porosity_prev = transport_porosity;
material_state_variables->pushBackState();
}
MathLib::KelvinVector::KelvinMatrixType<DisplacementDim>
computeElasticTangentStiffness(
double const t,
ParameterLib::SpatialPosition const& x_position,
double const dt,
double const temperature)
{
namespace MPL = MaterialPropertyLib;
MPL::VariableArray variable_array;
MPL::VariableArray variable_array_prev;
auto const null_state = solid_material.createMaterialStateVariables();
using KV = MathLib::KelvinVector::KelvinVectorType<DisplacementDim>;
variable_array[static_cast<int>(MPL::Variable::stress)].emplace<KV>(
KV::Zero());
variable_array[static_cast<int>(MPL::Variable::mechanical_strain)]
.emplace<KV>(KV::Zero());
variable_array[static_cast<int>(MPL::Variable::temperature)]
.emplace<double>(temperature);
variable_array_prev[static_cast<int>(MPL::Variable::stress)]
.emplace<KV>(KV::Zero());
variable_array_prev[static_cast<int>(MPL::Variable::mechanical_strain)]
.emplace<KV>(KV::Zero());
variable_array_prev[static_cast<int>(MPL::Variable::temperature)]
.emplace<double>(temperature);
auto&& solution =
solid_material.integrateStress(variable_array_prev, variable_array,
t, x_position, dt, *null_state);
if (!solution)
{
OGS_FATAL("Computation of elastic tangent stiffness failed.");
}
MathLib::KelvinVector::KelvinMatrixType<DisplacementDim> C =
std::move(std::get<2>(*solution));
return C;
}
typename BMatricesType::KelvinMatrixType updateConstitutiveRelation(
MaterialPropertyLib::VariableArray const& variable_array,
double const t,
ParameterLib::SpatialPosition const& x_position,
double const dt,
double const temperature)
{
MaterialPropertyLib::VariableArray variable_array_prev;
variable_array_prev[static_cast<int>(
MaterialPropertyLib::Variable::stress)]
.emplace<MathLib::KelvinVector::KelvinVectorType<DisplacementDim>>(
sigma_eff_prev);
variable_array_prev[static_cast<int>(MaterialPropertyLib::Variable::
mechanical_strain)]
.emplace<MathLib::KelvinVector::KelvinVectorType<DisplacementDim>>(
eps_m_prev);
variable_array_prev[static_cast<int>(
MaterialPropertyLib::Variable::temperature)]
.emplace<double>(temperature);
auto&& solution = solid_material.integrateStress(
variable_array_prev, variable_array, t, x_position, dt,
*material_state_variables);
if (!solution)
{
OGS_FATAL("Computation of local constitutive relation failed.");
}