Skip to content
Snippets Groups Projects
Unverified Commit 09b6a2e1 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by GitHub
Browse files

Merge pull request #2778 from TomFischer/GeneralizedMPLChecker

Using generalized MPL checker in HM and HT processes.
parents 3623ca75 0ceebcc4
No related branches found
No related tags found
No related merge requests found
......@@ -88,4 +88,19 @@ private:
/// special-defaults are allowed as well...
PropertyArray _properties;
};
template <typename Container>
void checkRequiredProperties(Medium const& medium,
Container const& required_properties)
{
for (auto const& p : required_properties)
{
if (!medium.hasProperty(p))
{
OGS_FATAL("The property '%s' is missing in the medium definition.",
property_enum_to_string[p].c_str());
}
}
}
} // namespace MaterialPropertyLib
......@@ -52,20 +52,6 @@ public:
std::string name() const;
template <size_t N>
void checkRequiredProperties(
std::array<PropertyType, N> const& required_properties) const
{
for (auto const& p : required_properties)
{
if (!hasProperty(p))
{
OGS_FATAL("The property '%s' is missing in the %s phase.",
property_enum_to_string[p].c_str(), name().c_str());
}
}
}
private:
std::vector<std::unique_ptr<Component>> const _components;
......@@ -77,4 +63,17 @@ private:
PropertyArray _properties;
};
template <typename Container>
void checkRequiredProperties(Phase const& phase, Container const& required_properties)
{
for (auto const& p : required_properties)
{
if (!phase.hasProperty(p))
{
OGS_FATAL("The property '%s' is missing in the %s phase.",
property_enum_to_string[p].c_str(), phase.name().c_str());
}
}
}
} // namespace MaterialPropertyLib
......@@ -24,6 +24,42 @@ namespace ProcessLib
{
namespace HT
{
void checkMPLProperties(MeshLib::Mesh const& mesh,
HTProcessData const& process_data)
{
DBUG("Check the media properties of HT process ...");
std::array const requiredPropertyMedium = {
MaterialPropertyLib::PropertyType::porosity,
MaterialPropertyLib::PropertyType::permeability};
std::array const requiredPropertyLiquidPhase = {
MaterialPropertyLib::PropertyType::viscosity,
MaterialPropertyLib::PropertyType::density,
MaterialPropertyLib::PropertyType::specific_heat_capacity};
std::array const requiredPropertySolidPhase = {
MaterialPropertyLib::PropertyType::specific_heat_capacity,
MaterialPropertyLib::PropertyType::density,
MaterialPropertyLib::PropertyType::storage};
for (auto const& element : mesh.getElements())
{
auto const element_id = element->getID();
auto const& medium = *process_data.media_map->getMedium(element_id);
MaterialPropertyLib::checkRequiredProperties(
medium, requiredPropertyMedium);
MaterialPropertyLib::checkRequiredProperties(
medium.phase("AqueousLiquid"), requiredPropertyLiquidPhase);
MaterialPropertyLib::checkRequiredProperties(
medium.phase("Solid"), requiredPropertySolidPhase);
}
DBUG("Media properties verified.");
}
HTProcess::HTProcess(
std::string name,
MeshLib::Mesh& mesh,
......@@ -285,72 +321,5 @@ void HTProcess::postTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
pv.getActiveElementIDs());
_surfaceflux->save(t);
}
void checkMPLProperties(MeshLib::Mesh const& mesh,
HTProcessData const& process_data)
{
DBUG("Check the media properties of HT process ...");
std::array const requiredPropertyMedium = {
MaterialPropertyLib::PropertyType::porosity,
MaterialPropertyLib::PropertyType::permeability};
std::array const requiredPropertyLiquidPhase = {
MaterialPropertyLib::PropertyType::viscosity,
MaterialPropertyLib::PropertyType::density,
MaterialPropertyLib::PropertyType::specific_heat_capacity};
std::array const requiredPropertySolidPhase = {
MaterialPropertyLib::PropertyType::specific_heat_capacity,
MaterialPropertyLib::PropertyType::density,
MaterialPropertyLib::PropertyType::storage};
for (auto const& element : mesh.getElements())
{
auto const element_id = element->getID();
// check if a definition of the porous media exists
auto const& medium = *process_data.media_map->getMedium(element_id);
for (auto const property : requiredPropertyMedium)
{
if (!medium.hasProperty(property))
{
OGS_FATAL("The property '%s' is not specified for the medium.",
MaterialPropertyLib::property_enum_to_string[property]
.c_str());
}
}
// check if liquid phase definition and the corresponding properties
// exists
auto const& liquid_phase = medium.phase("AqueousLiquid");
for (auto const property : requiredPropertyLiquidPhase)
{
if (!liquid_phase.hasProperty(property))
{
OGS_FATAL(
"The property '%s' is not specified for the liquid phase.",
MaterialPropertyLib::property_enum_to_string[property]
.c_str());
}
}
// check if solid phase definition and the corresponding properties
// exists
auto const& solid_phase = medium.phase("Solid");
for (auto const property : requiredPropertySolidPhase)
{
if (!solid_phase.hasProperty(property))
{
OGS_FATAL(
"The property '%s' is not specified for the solid phase.",
MaterialPropertyLib::property_enum_to_string[property]
.c_str());
}
}
}
DBUG("Media properties verified.");
}
} // namespace HT
} // namespace ProcessLib
......@@ -135,8 +135,5 @@ private:
const int _hydraulic_process_id;
};
void checkMPLProperties(MeshLib::Mesh const& mesh,
HTProcessData const& process_data);
} // namespace HT
} // namespace ProcessLib
......@@ -156,9 +156,9 @@ std::unique_ptr<Process> createHydroMechanicsProcess(
MaterialPropertyLib::density};
for (auto const& m : media)
{
m.second->phase("Gas").checkRequiredProperties(requiredGasProperties);
m.second->phase("Solid").checkRequiredProperties(
requiredSolidProperties);
checkRequiredProperties(m.second->phase("Gas"), requiredGasProperties);
checkRequiredProperties(m.second->phase("Solid"),
requiredSolidProperties);
}
// Initial stress conditions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment