diff --git a/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp b/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..29de544b866b0f4f7a7628ec09786a25f616c97f --- /dev/null +++ b/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp @@ -0,0 +1,75 @@ +/** + * \copyright + * Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + * \file CreateConstitutiveRelation.cpp + * Created on July 10, 2018, 12:09 PM + */ + +#include "CreateConstitutiveRelation.h" +#include "CreateEhlers.h" +#include "CreateLinearElasticIsotropic.h" +#include "CreateLubby2.h" + +#include "MechanicsBase.h" + +#include "BaseLib/ConfigTree.h" +#include "BaseLib/Error.h" + +#include "ProcessLib/Parameter/Parameter.h" + +namespace MaterialLib +{ +namespace Solids +{ +template <int DisplacementDim> +std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>> +createConstitutiveRelation( + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config) +{ + auto const constitutive_relation_config = + //! \ogs_file_param{material__solid__constitutive_relation} + config.getConfigSubtree("constitutive_relation"); + + auto const type = + //! \ogs_file_param{material__solid__constitutive_relation__type} + constitutive_relation_config.peekConfigParameter<std::string>("type"); + + if (type == "Ehlers") + { + return MaterialLib::Solids::Ehlers::createEhlers<DisplacementDim>( + parameters, constitutive_relation_config); + } + else if (type == "LinearElasticIsotropic") + { + return MaterialLib::Solids::createLinearElasticIsotropic< + DisplacementDim>(parameters, constitutive_relation_config); + } + else if (type == "Lubby2") + { + return MaterialLib::Solids::Lubby2::createLubby2<DisplacementDim>( + parameters, constitutive_relation_config); + } + else + { + OGS_FATAL( + "Cannot construct constitutive relation of given type \'%s\'.", + type.c_str()); + } +} + +template std::unique_ptr<MaterialLib::Solids::MechanicsBase<2>> +createConstitutiveRelation<2>( + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); + +template std::unique_ptr<MaterialLib::Solids::MechanicsBase<3>> +createConstitutiveRelation<3>( + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); +} +} diff --git a/MaterialLib/SolidModels/CreateConstitutiveRelation.h b/MaterialLib/SolidModels/CreateConstitutiveRelation.h new file mode 100644 index 0000000000000000000000000000000000000000..15c43ebf81a20513d59894b0c8be6b0a036049b6 --- /dev/null +++ b/MaterialLib/SolidModels/CreateConstitutiveRelation.h @@ -0,0 +1,50 @@ +/** + * \copyright + * Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + * \file CreateConstitutiveRelation.h + * Created on July 10, 2018, 12:09 PM + */ + +#pragma once + +#include <memory> +#include <vector> + +namespace BaseLib +{ +class ConfigTree; +} + +namespace ProcessLib +{ +struct ParameterBase; +} + +namespace MaterialLib +{ +namespace Solids +{ +template <int DisplacementDim> +struct MechanicsBase; + +template <int DisplacementDim> +std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>> +createConstitutiveRelation( + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); + +extern template std::unique_ptr<MaterialLib::Solids::MechanicsBase<2>> +createConstitutiveRelation<2>( + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); + +extern template std::unique_ptr<MaterialLib::Solids::MechanicsBase<3>> +createConstitutiveRelation<3>( + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); +} +} diff --git a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp index 61782e91cc3a90717f19fa5da681e41dee02bc0a..4914d6fce61003187e7b618e43e4ed74b5bbd158 100644 --- a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -11,8 +11,10 @@ #include <cassert> -#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" +#include "MaterialLib/SolidModels/MechanicsBase.h" +#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "ProcessLib/Output/CreateSecondaryVariables.h" +#include "ProcessLib/Utils/ProcessUtils.h" #include "HydroMechanicsProcess.h" #include "HydroMechanicsProcessData.h" @@ -100,29 +102,9 @@ std::unique_ptr<Process> createHydroMechanicsProcess( } // Constitutive relation. - // read type; - auto const constitutive_relation_config = - //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__constitutive_relation} - config.getConfigSubtree("constitutive_relation"); - - auto const type = - //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS__constitutive_relation__type} - constitutive_relation_config.peekConfigParameter<std::string>("type"); - - std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>> - material = nullptr; - if (type == "LinearElasticIsotropic") - { - material = - MaterialLib::Solids::createLinearElasticIsotropic<DisplacementDim>( - parameters, constitutive_relation_config); - } - else - { - OGS_FATAL( - "Cannot construct constitutive relation of given type \'%s\'.", - type.c_str()); - } + auto material = + MaterialLib::Solids::createConstitutiveRelation<DisplacementDim>( + parameters, config); // Intrinsic permeability auto& intrinsic_permeability = findParameter<double>( diff --git a/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp index 44a21ff9b3e481b3a9d52c2fc173ce8e48d8c64e..5a8552fb5177c29132a0c66a5d615db28206bdbe 100644 --- a/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -14,7 +14,7 @@ #include "MaterialLib/FractureModels/CreateCohesiveZoneModeI.h" #include "MaterialLib/FractureModels/CreateLinearElasticIsotropic.h" #include "MaterialLib/FractureModels/CreateMohrCoulomb.h" -#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" +#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "ProcessLib/Output/CreateSecondaryVariables.h" #include "ProcessLib/Utils/ProcessUtils.h" // required for findParameter @@ -125,28 +125,9 @@ std::unique_ptr<Process> createHydroMechanicsProcess( // Constitutive relation. - // read type; - auto const constitutive_relation_config = - //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS_WITH_LIE__constitutive_relation} - config.getConfigSubtree("constitutive_relation"); - - auto const type = - //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS_WITH_LIE__constitutive_relation__type} - constitutive_relation_config.peekConfigParameter<std::string>("type"); - - std::unique_ptr<MaterialLib::Solids::MechanicsBase<GlobalDim>> material = - nullptr; - if (type == "LinearElasticIsotropic") - { - material = MaterialLib::Solids::createLinearElasticIsotropic<GlobalDim>( - parameters, constitutive_relation_config); - } - else - { - OGS_FATAL( - "Cannot construct constitutive relation of given type \'%s\'.", - type.c_str()); - } + auto material = + MaterialLib::Solids::createConstitutiveRelation<GlobalDim>( + parameters, config); // Intrinsic permeability auto& intrinsic_permeability = findParameter<double>( diff --git a/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp b/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp index 9038979f191a1a1a36c09551d5c871c986930339..b834695aca4de61eb4f74431dd8c51fcdfb81463 100644 --- a/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp +++ b/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp @@ -14,7 +14,7 @@ #include "MaterialLib/FractureModels/CreateCohesiveZoneModeI.h" #include "MaterialLib/FractureModels/CreateLinearElasticIsotropic.h" #include "MaterialLib/FractureModels/CreateMohrCoulomb.h" -#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" +#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "ProcessLib/Output/CreateSecondaryVariables.h" #include "ProcessLib/Utils/ProcessUtils.h" // required for findParameter @@ -99,29 +99,9 @@ std::unique_ptr<Process> createSmallDeformationProcess( process_variables.push_back(std::move(per_process_variables)); // Constitutive relation. - // read type; - auto const constitutive_relation_config = - //! \ogs_file_param{prj__processes__process__SMALL_DEFORMATION_WITH_LIE__constitutive_relation} - config.getConfigSubtree("constitutive_relation"); - - auto const type = - //! \ogs_file_param{prj__processes__process__SMALL_DEFORMATION_WITH_LIE__constitutive_relation__type} - constitutive_relation_config.peekConfigParameter<std::string>("type"); - - std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>> - material = nullptr; - if (type == "LinearElasticIsotropic") - { - material = - MaterialLib::Solids::createLinearElasticIsotropic<DisplacementDim>( - parameters, constitutive_relation_config); - } - else - { - OGS_FATAL( - "Cannot construct constitutive relation of given type \'%s\'.", - type.c_str()); - } + auto material = + MaterialLib::Solids::createConstitutiveRelation<DisplacementDim>( + parameters, config); // Fracture constitutive relation. // read type; diff --git a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp index 0df0542d83eeee8e96ef7f1a30631d2a8369ef91..ca1ee9024aba05f118b75ed5b3afb62f6ec2c533 100644 --- a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp +++ b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp @@ -11,10 +11,9 @@ #include <cassert> -#include "MaterialLib/SolidModels/CreateEhlers.h" -#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" -#include "MaterialLib/SolidModels/CreateLubby2.h" +#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "ProcessLib/Output/CreateSecondaryVariables.h" +#include "ProcessLib/Utils/ProcessUtils.h" #include "SmallDeformationProcess.h" #include "SmallDeformationProcessData.h" @@ -66,39 +65,9 @@ createSmallDeformationProcess( process_variables.push_back(std::move(per_process_variables)); // Constitutive relation. - // read type; - auto const constitutive_relation_config = - //! \ogs_file_param{prj__processes__process__SMALL_DEFORMATION__constitutive_relation} - config.getConfigSubtree("constitutive_relation"); - - auto const type = - //! \ogs_file_param{prj__processes__process__SMALL_DEFORMATION__constitutive_relation__type} - constitutive_relation_config.peekConfigParameter<std::string>("type"); - - std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>> - material = nullptr; - if (type == "Ehlers") - { - material = MaterialLib::Solids::Ehlers::createEhlers<DisplacementDim>( - parameters, constitutive_relation_config); - } - else if (type == "LinearElasticIsotropic") - { - material = - MaterialLib::Solids::createLinearElasticIsotropic<DisplacementDim>( - parameters, constitutive_relation_config); - } - else if (type == "Lubby2") - { - material = MaterialLib::Solids::Lubby2::createLubby2<DisplacementDim>( - parameters, constitutive_relation_config); - } - else - { - OGS_FATAL( - "Cannot construct constitutive relation of given type \'%s\'.", - type.c_str()); - } + auto material = + MaterialLib::Solids::createConstitutiveRelation<DisplacementDim>( + parameters, config); // Solid density auto& solid_density = findParameter<double>( diff --git a/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp b/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp index e8994170c3b507c1e5c43fbfd4618d8b8bc5c89a..e57ed7bf8cc78562db7ea3a9c01a68fc6952bd08 100644 --- a/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp +++ b/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp @@ -11,10 +11,10 @@ #include <cassert> -#include "MaterialLib/SolidModels/CreateEhlers.h" -#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" -#include "MaterialLib/SolidModels/CreateLubby2.h" +#include "MaterialLib/SolidModels/MechanicsBase.h" +#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "ProcessLib/Output/CreateSecondaryVariables.h" +#include "ProcessLib/Utils/ProcessUtils.h" #include "ThermoMechanicsProcess.h" #include "ThermoMechanicsProcessData.h" @@ -101,39 +101,9 @@ std::unique_ptr<Process> createThermoMechanicsProcess( } // Constitutive relation. - // read type; - auto const constitutive_relation_config = - //! \ogs_file_param{prj__processes__process__THERMO_MECHANICS__constitutive_relation} - config.getConfigSubtree("constitutive_relation"); - - auto const type = - //! \ogs_file_param{prj__processes__process__THERMO_MECHANICS__constitutive_relation__type} - constitutive_relation_config.peekConfigParameter<std::string>("type"); - - std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>> - material = nullptr; - if (type == "Ehlers") - { - material = MaterialLib::Solids::Ehlers::createEhlers<DisplacementDim>( - parameters, constitutive_relation_config); - } - else if (type == "LinearElasticIsotropic") - { - material = - MaterialLib::Solids::createLinearElasticIsotropic<DisplacementDim>( - parameters, constitutive_relation_config); - } - else if (type == "Lubby2") - { - material = MaterialLib::Solids::Lubby2::createLubby2<DisplacementDim>( - parameters, constitutive_relation_config); - } - else - { - OGS_FATAL( - "Cannot construct constitutive relation of given type \'%s\'.", - type.c_str()); - } + auto material = + MaterialLib::Solids::createConstitutiveRelation<DisplacementDim>( + parameters, config); // Reference solid density auto& reference_solid_density = findParameter<double>(