Skip to content

Commit

Permalink
Merge branch 'rm-constitutive-setting' into 'master'
Browse files Browse the repository at this point in the history
Refactoring assembly of RichardsMechanics

See merge request ogs/ogs!5008
  • Loading branch information
endJunction committed May 31, 2024
2 parents fe59f0d + 2fe391a commit f547d40
Show file tree
Hide file tree
Showing 15 changed files with 688 additions and 157 deletions.
1 change: 1 addition & 0 deletions ProcessLib/RichardsMechanics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
get_source_files(SOURCES)
append_source_files(SOURCES ConstitutiveRelations)

ogs_add_library(RichardsMechanics ${SOURCES})
target_link_libraries(RichardsMechanics PUBLIC ProcessLib PRIVATE ParameterLib)
Expand Down
76 changes: 76 additions & 0 deletions ProcessLib/RichardsMechanics/ConstitutiveRelations/Base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "BaseLib/StrongType.h"
#include "MaterialLib/MPL/Medium.h"
#include "MathLib/KelvinVector.h"
#include "ParameterLib/SpatialPosition.h"
#include "ProcessLib/ConstitutiveRelations/Base.h"
#include "ProcessLib/Reflection/ReflectionData.h"

namespace ProcessLib::RichardsMechanics
{

using namespace ProcessLib::ConstitutiveRelations;
namespace KV = MathLib::KelvinVector;

template <int DisplacementDim>
using KelvinVector = KV::KelvinVectorType<DisplacementDim>;

template <int DisplacementDim>
using KelvinMatrix = KV::KelvinMatrixType<DisplacementDim>;

template <int DisplacementDim>
using GlobalDimVector = Eigen::Vector<double, DisplacementDim>;

template <int DisplacementDim>
using GlobalDimMatrix =
Eigen::Matrix<double, DisplacementDim, DisplacementDim, Eigen::RowMajor>;

/// Used to set a D dimensional vector to all not-a-number.
template <int D>
constexpr GlobalDimVector<D> DVnan()
{
return GlobalDimVector<D>::Constant(nan);
}

/// Used to set a D x D matrix to all not-a-number.
template <int D>
constexpr GlobalDimMatrix<D> DMnan()
{
return GlobalDimMatrix<D>::Constant(nan);
}

struct MediaData
{
explicit MediaData(MaterialPropertyLib::Medium const& medium)
: medium{medium},
liquid{medium.phase("AqueousLiquid")},
solid{medium.phase("Solid")}
{
}

MaterialPropertyLib::Medium const& medium;
MaterialPropertyLib::Phase const& liquid;
MaterialPropertyLib::Phase const& solid;
};

using TemperatureData = BaseLib::StrongType<double, struct TemperatureDataTag>;

template <int DisplacementDim>
struct CapillaryPressureData
{
double p_cap;
double p_cap_prev;
Eigen::Vector<double, DisplacementDim> grad_p_cap;
};
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "Density.h"
#include "LiquidDensity.h"
#include "ProcessLib/ConstitutiveRelations/Base.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Biot.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/LiquidViscosity.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/PermeabilityData.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Porosity.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/Saturation.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SolidCompressibilityData.h"
#include "SaturationSecantDerivative.h"
#include "StiffnessTensor.h"

namespace ProcessLib::RichardsMechanics
{
// TODO directly declare these type aliases in Traits.h
/// Data whose state must be tracked by the TRM process.
template <int DisplacementDim>
using StatefulData = std::tuple<>;

template <int DisplacementDim>
using StatefulDataPrev = ProcessLib::ConstitutiveRelations::PrevStateOf<
StatefulData<DisplacementDim>>;

/// Data that is needed for output purposes, but not directly for the assembly.
template <int DisplacementDim>
using OutputData = std::tuple<>;

/// Data that is needed for the equation system assembly.
template <int DisplacementDim>
using ConstitutiveData = std::tuple<
// TODO (CL) check if all that data should stay here
StiffnessTensor<DisplacementDim>,
ProcessLib::ThermoRichardsMechanics::PorosityData, Density, LiquidDensity,
ProcessLib::ThermoRichardsMechanics::BiotData,
ProcessLib::ThermoRichardsMechanics::SaturationDataDeriv,
ProcessLib::ThermoRichardsMechanics::LiquidViscosityData,
ProcessLib::ThermoRichardsMechanics::SolidCompressibilityData,
ProcessLib::ThermoRichardsMechanics::BishopsData,
PrevState<ProcessLib::ThermoRichardsMechanics::BishopsData>,
ProcessLib::ThermoRichardsMechanics::PermeabilityData<DisplacementDim>,
SaturationSecantDerivative>;

/// Data that stores intermediate values, which are not needed outside the
/// constitutive setting.
template <int DisplacementDim>
using ConstitutiveTempData = std::tuple<>;
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "MaterialLib/SolidModels/MechanicsBase.h"
#include "ProcessLib/Graph/ConstructModels.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/SpecificBodyForceData.h"

namespace ProcessLib::RichardsMechanics
{
/// Constitutive models used for assembly.
template <int DisplacementDim>
using ConstitutiveModels = std::tuple<>;

template <int DisplacementDim, typename TRMProcessData>
ConstitutiveModels<DisplacementDim> createConstitutiveModels(
TRMProcessData const& process_data,
MaterialLib::Solids::MechanicsBase<DisplacementDim> const& solid_material)
{
return ProcessLib::Graph::constructModels<
ConstitutiveModels<DisplacementDim>>(
ProcessLib::ThermoRichardsMechanics::SpecificBodyForceData<
DisplacementDim>{process_data.specific_body_force},
solid_material);
}
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "ConstitutiveSetting.h"

namespace ProcessLib::RichardsMechanics
{
template <int DisplacementDim>
void ConstitutiveSetting<DisplacementDim>::eval(
ConstitutiveModels<DisplacementDim>& /*models*/, double const /*t*/,
double const /*dt*/, ParameterLib::SpatialPosition const& /*x_position*/,
MaterialPropertyLib::Medium const& /*medium*/,
TemperatureData const /*T_data*/,
CapillaryPressureData<DisplacementDim> const& /*p_cap_data*/,
KelvinVector<DisplacementDim> const& /*eps_arg*/,
StatefulData<DisplacementDim>& /*state*/,
StatefulDataPrev<DisplacementDim> const& /*prev_state*/,
ProcessLib::ThermoRichardsMechanics::MaterialStateData<DisplacementDim>&
/*mat_state*/,
ConstitutiveTempData<DisplacementDim>& /*tmp*/,
OutputData<DisplacementDim>& /*out*/,
ConstitutiveData<DisplacementDim>& /*cd*/) const
{
}

template struct ConstitutiveSetting<2>;
template struct ConstitutiveSetting<3>;
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "Base.h"
#include "ConstitutiveData.h"
#include "ConstitutiveModels.h"
#include "ProcessLib/ThermoRichardsMechanics/ConstitutiveCommon/MaterialState.h"

namespace ProcessLib::RichardsMechanics
{
template <int DisplacementDim>
struct ConstitutiveSetting
{
/// Evaluate the constitutive setting.
void eval(
ConstitutiveModels<DisplacementDim>& models, double const t,
double const dt, ParameterLib::SpatialPosition const& x_position,
MaterialPropertyLib::Medium const& medium, TemperatureData const T_data,
CapillaryPressureData<DisplacementDim> const& p_cap_data,
KelvinVector<DisplacementDim> const& eps_arg,
StatefulData<DisplacementDim>& state,
StatefulDataPrev<DisplacementDim> const& prev_state,
ProcessLib::ThermoRichardsMechanics::MaterialStateData<DisplacementDim>&
mat_state,
ConstitutiveTempData<DisplacementDim>& tmp,
OutputData<DisplacementDim>& out,
ConstitutiveData<DisplacementDim>& cd) const;
};

extern template struct ConstitutiveSetting<2>;
extern template struct ConstitutiveSetting<3>;
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "CreateConstitutiveSetting.h"

#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h"

namespace ProcessLib::RichardsMechanics
{
template <int DisplacementDim>
std::map<int,
std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>>>
CreateConstitutiveSetting<DisplacementDim>::createSolidConstitutiveRelations(
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
std::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
BaseLib::ConfigTree const& config)
{
return MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
parameters, local_coordinate_system, config);
}

template struct CreateConstitutiveSetting<2>;
template struct CreateConstitutiveSetting<3>;
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 <map>

#include "MaterialLib/SolidModels/MechanicsBase.h"
#include "ParameterLib/Parameter.h"

namespace ProcessLib::RichardsMechanics
{
template <int DisplacementDim>
struct CreateConstitutiveSetting
{
static std::map<
int,
std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>>>
createSolidConstitutiveRelations(
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
parameters,
std::optional<ParameterLib::CoordinateSystem> const&
local_coordinate_system,
BaseLib::ConfigTree const& config);
};
} // namespace ProcessLib::RichardsMechanics
19 changes: 19 additions & 0 deletions ProcessLib/RichardsMechanics/ConstitutiveRelations/Density.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "BaseLib/StrongType.h"

namespace ProcessLib::RichardsMechanics
{
// effective density of both the solid and fluid phases
using Density = BaseLib::StrongType<double, struct DensityTag>;
} // namespace ProcessLib::RichardsMechanics
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "BaseLib/StrongType.h"

namespace ProcessLib::RichardsMechanics
{
using EffectivePorePressure =
BaseLib::StrongType<double, struct EffectivePorePressureTag>;
} // namespace ProcessLib::RichardsMechanics
18 changes: 18 additions & 0 deletions ProcessLib/RichardsMechanics/ConstitutiveRelations/LiquidDensity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2024, 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 "BaseLib/StrongType.h"

namespace ProcessLib::RichardsMechanics
{
using LiquidDensity = BaseLib::StrongType<double, struct LiquidDensityTag>;
} // namespace ProcessLib::RichardsMechanics
Loading

0 comments on commit f547d40

Please sign in to comment.