Skip to content
Snippets Groups Projects
Commit 8594d738 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Dmitri Naumov
Browse files

[PL] Extract parsing of initial stress.

Adding a new function for parameter lookup of optional tags.
parent e48ccd60
No related branches found
No related tags found
No related merge requests found
...@@ -142,4 +142,38 @@ Parameter<ParameterDataType>& findParameter( ...@@ -142,4 +142,38 @@ Parameter<ParameterDataType>& findParameter(
return findParameter<ParameterDataType>(name, parameters, num_components, return findParameter<ParameterDataType>(name, parameters, num_components,
mesh); mesh);
} }
/// Find a parameter of specific type for a name given in the process
/// configuration under the optional tag.
/// If the tag is not present, a nullptr will be returned.
/// The parameter must have the specified number of components.
/// In the process config a parameter is referenced by a name. For example it
/// will be looking for a parameter named "K" in the list of parameters
/// when the tag is "hydraulic_conductivity":
/// \code
/// <process>
/// ...
/// <hydraulic_conductivity>K</hydraulic_conductivity>
/// </process>
/// \endcode
/// and return a pointer to that parameter. Additionally it checks for the
/// type of the found parameter.
template <typename ParameterDataType>
Parameter<ParameterDataType>* findOptionalTagParameter(
BaseLib::ConfigTree const& process_config, std::string const& tag,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
int const num_components, MeshLib::Mesh const* const mesh = nullptr)
{
// Find parameter name in process config.
auto const name =
//! \ogs_file_special
process_config.getConfigParameterOptional<std::string>(tag);
if (!name)
{
return nullptr;
}
return &findParameter<ParameterDataType>(*name, parameters, num_components,
mesh);
}
} // namespace ParameterLib } // namespace ParameterLib
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <cassert> #include <cassert>
#include "MaterialLib/SolidModels/CreateConstitutiveRelation.h" #include "MaterialLib/SolidModels/CreateConstitutiveRelation.h"
#include "MathLib/KelvinVector.h"
#include "ParameterLib/Utils.h" #include "ParameterLib/Utils.h"
#include "ProcessLib/Output/CreateSecondaryVariables.h" #include "ProcessLib/Output/CreateSecondaryVariables.h"
#include "ProcessLib/Utils/ProcessUtils.h" #include "ProcessLib/Utils/ProcessUtils.h"
...@@ -104,24 +103,12 @@ std::unique_ptr<Process> createSmallDeformationProcess( ...@@ -104,24 +103,12 @@ std::unique_ptr<Process> createSmallDeformationProcess(
"reference_temperature", std::numeric_limits<double>::quiet_NaN()); "reference_temperature", std::numeric_limits<double>::quiet_NaN());
// Initial stress conditions // Initial stress conditions
ParameterLib::Parameter<double> const* initial_stress = nullptr; auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
auto const initial_stress_parameter_name = //! \ogs_file_param_special{prj__processes__process__SMALL_DEFORMATION__initial_stress}
//! \ogs_file_param{prj__processes__process__SMALL_DEFORMATION__initial_stress} config, "initial_stress", parameters,
config.getConfigParameterOptional<std::string>("initial_stress"); // Symmetric tensor size, 4 or 6, not a Kelvin vector.
if (initial_stress_parameter_name) MathLib::KelvinVector::KelvinVectorDimensions<DisplacementDim>::value,
{ &mesh);
initial_stress = ParameterLib::findParameterOptional<double>(
*initial_stress_parameter_name, parameters,
// Symmetric tensor size, 4 or 6, not a Kelvin vector.
MathLib::KelvinVector::KelvinVectorDimensions<
DisplacementDim>::value,
&mesh);
}
if (initial_stress != nullptr)
{
DBUG("Use '%s' as initial stress parameter.",
initial_stress->name.c_str());
}
SmallDeformationProcessData<DisplacementDim> process_data{ SmallDeformationProcessData<DisplacementDim> process_data{
materialIDs(mesh), std::move(solid_constitutive_relations), materialIDs(mesh), std::move(solid_constitutive_relations),
......
...@@ -168,24 +168,12 @@ std::unique_ptr<Process> createThermoMechanicsProcess( ...@@ -168,24 +168,12 @@ std::unique_ptr<Process> createThermoMechanicsProcess(
} }
// Initial stress conditions // Initial stress conditions
ParameterLib::Parameter<double> const* initial_stress = nullptr; auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
auto const initial_stress_parameter_name = //! \ogs_file_param_special{prj__processes__process__THERMO_MECHANICS__initial_stress}
//! \ogs_file_param{prj__processes__process__THERMO_MECHANICS__initial_stress} config, "initial_stress", parameters,
config.getConfigParameterOptional<std::string>("initial_stress"); // Symmetric tensor size, 4 or 6, not a Kelvin vector.
if (initial_stress_parameter_name) MathLib::KelvinVector::KelvinVectorDimensions<DisplacementDim>::value,
{ &mesh);
initial_stress = ParameterLib::findParameterOptional<double>(
*initial_stress_parameter_name, parameters,
// Symmetric tensor size, 4 or 6, not a Kelvin vector.
MathLib::KelvinVector::KelvinVectorDimensions<
DisplacementDim>::value,
&mesh);
}
if (initial_stress != nullptr)
{
DBUG("Use '%s' as initial stress parameter.",
initial_stress->name.c_str());
}
ThermoMechanicsProcessData<DisplacementDim> process_data{ ThermoMechanicsProcessData<DisplacementDim> process_data{
materialIDs(mesh), materialIDs(mesh),
......
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