diff --git a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a7cbf1bea6d9ab2755a21643f74bb368b43c07b --- /dev/null +++ b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp @@ -0,0 +1,120 @@ +/** + * \copyright + * Copyright (c) 2012-2016, 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 "CreateSmallDeformationProcess.h" + +#include <cassert> + +#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" +#include "ProcessLib/Utils/ParseSecondaryVariables.h" + +#include "SmallDeformationProcess.h" +#include "SmallDeformationProcessData.h" + +namespace ProcessLib +{ +namespace SmallDeformation +{ +template <int DisplacementDim> +class SmallDeformationProcess; + +extern template class SmallDeformationProcess<2>; +extern template class SmallDeformationProcess<3>; + +template <int DisplacementDim> +std::unique_ptr<Process> +createSmallDeformationProcess( + MeshLib::Mesh& mesh, + std::vector<ProcessVariable> const& variables, + std::vector<std::unique_ptr<ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config) +{ + //! \ogs_file_param{process__type} + config.checkConfigParameter("type", "SMALL_DEFORMATION"); + DBUG("Create SmallDeformationProcess."); + + // Process variable. + auto process_variables = findProcessVariables( + variables, config, + {//! \ogs_file_param_special{process__SMALL_DEFORMATION__process_variables__process_variable} + "process_variable"}); + + DBUG("Associate displacement with process variable \'%s\'.", + process_variables.back().get().getName().c_str()); + + if (process_variables.back().get().getNumberOfComponents() != + DisplacementDim) + { + OGS_FATAL( + "Number of components of the process variable '%s' is different " + "from the displacement dimension: got %d, expected %d", + process_variables.back().get().getName().c_str(), + process_variables.back().get().getNumberOfComponents(), + DisplacementDim); + } + + // Constitutive relation. + // read type; + auto const constitutive_relation_config = + //! \ogs_file_param{process__SMALL_DEFORMATION__constitutive_relation} + config.getConfigSubtree("constitutive_relation"); + + auto const type = + constitutive_relation_config.peekConfigParameter<std::string>("type"); + + std::unique_ptr<Solids::MechanicsBase<DisplacementDim>> material = nullptr; + if (type == "LinearElasticIsotropic") + { + material = Solids::createLinearElasticIsotropic<DisplacementDim>( + parameters, constitutive_relation_config); + } + else + { + OGS_FATAL( + "Cannot construct constitutive relation of given type \'%s\'.", + type.c_str()); + } + + SmallDeformationProcessData<DisplacementDim> process_data{ + std::move(material)}; + + SecondaryVariableCollection secondary_variables; + + NumLib::NamedFunctionCaller named_function_caller( + {"SmallDeformation_displacement"}); + + ProcessLib::parseSecondaryVariables(config, secondary_variables, + named_function_caller); + + return std::unique_ptr<SmallDeformationProcess<DisplacementDim>>{ + new SmallDeformationProcess<DisplacementDim>{ + mesh, parameters, std::move(process_variables), + std::move(process_data), std::move(secondary_variables), + std::move(named_function_caller)}}; +} + + +template +std::unique_ptr<Process> +createSmallDeformationProcess<2>( + MeshLib::Mesh& mesh, + std::vector<ProcessVariable> const& variables, + std::vector<std::unique_ptr<ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); + +template +std::unique_ptr<Process> +createSmallDeformationProcess<3>( + MeshLib::Mesh& mesh, + std::vector<ProcessVariable> const& variables, + std::vector<std::unique_ptr<ParameterBase>> const& parameters, + BaseLib::ConfigTree const& config); + +} // namespace SmallDeformation +} // namespace ProcessLib diff --git a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.h b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.h index 6fdb423652967cdcf889ee6f2c9599646773f8cf..0f53b6c015030202a7ba71cf91e9643c4e875ce5 100644 --- a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.h +++ b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.h @@ -10,95 +10,21 @@ #ifndef PROCESS_LIB_CREATESMALLDEFORMATIONPROCESS_H_ #define PROCESS_LIB_CREATESMALLDEFORMATIONPROCESS_H_ -#include <cassert> - -#include "MaterialLib/SolidModels/CreateLinearElasticIsotropic.h" -#include "ProcessLib/Utils/ParseSecondaryVariables.h" - -#include "SmallDeformationProcess.h" -#include "SmallDeformationProcessData.h" +#include "ProcessLib/Process.h" namespace ProcessLib { namespace SmallDeformation { -template <int DisplacementDim> -class SmallDeformationProcess; - -extern template class SmallDeformationProcess<2>; -extern template class SmallDeformationProcess<3>; template <int DisplacementDim> -std::unique_ptr<SmallDeformationProcess<DisplacementDim>> +std::unique_ptr<Process> createSmallDeformationProcess( MeshLib::Mesh& mesh, std::vector<ProcessVariable> const& variables, std::vector<std::unique_ptr<ParameterBase>> const& parameters, - BaseLib::ConfigTree const& config) -{ - //! \ogs_file_param{process__type} - config.checkConfigParameter("type", "SMALL_DEFORMATION"); - DBUG("Create SmallDeformationProcess."); - - // Process variable. - auto process_variables = findProcessVariables( - variables, config, - {//! \ogs_file_param_special{process__SMALL_DEFORMATION__process_variables__process_variable} - "process_variable"}); - - DBUG("Associate displacement with process variable \'%s\'.", - process_variables.back().get().getName().c_str()); - - if (process_variables.back().get().getNumberOfComponents() != - DisplacementDim) - { - OGS_FATAL( - "Number of components of the process variable '%s' is different " - "from the displacement dimension: got %d, expected %d", - process_variables.back().get().getName().c_str(), - process_variables.back().get().getNumberOfComponents(), - DisplacementDim); - } - - // Constitutive relation. - // read type; - auto const constitutive_relation_config = - //! \ogs_file_param{process__SMALL_DEFORMATION__constitutive_relation} - config.getConfigSubtree("constitutive_relation"); - - auto const type = - constitutive_relation_config.peekConfigParameter<std::string>("type"); - - std::unique_ptr<Solids::MechanicsBase<DisplacementDim>> material = nullptr; - if (type == "LinearElasticIsotropic") - { - material = Solids::createLinearElasticIsotropic<DisplacementDim>( - parameters, constitutive_relation_config); - } - else - { - OGS_FATAL( - "Cannot construct constitutive relation of given type \'%s\'.", - type.c_str()); - } - - SmallDeformationProcessData<DisplacementDim> process_data{ - std::move(material)}; - - SecondaryVariableCollection secondary_variables; - - NumLib::NamedFunctionCaller named_function_caller( - {"SmallDeformation_displacement"}); - - ProcessLib::parseSecondaryVariables(config, secondary_variables, - named_function_caller); + BaseLib::ConfigTree const& config); - return std::unique_ptr<SmallDeformationProcess<DisplacementDim>>{ - new SmallDeformationProcess<DisplacementDim>{ - mesh, parameters, std::move(process_variables), - std::move(process_data), std::move(secondary_variables), - std::move(named_function_caller)}}; -} } // namespace SmallDeformation } // namespace ProcessLib