Skip to content

Commit

Permalink
Merge branch 'RemoveIpSuffixInSetIpData' into 'master'
Browse files Browse the repository at this point in the history
Always remove "_ip" suffix in setIPDataIinitialConditions

See merge request ogs/ogs!4870
  • Loading branch information
TomFischer committed Jan 18, 2024
2 parents 66213e0 + a88ea31 commit 1a9aaaf
Show file tree
Hide file tree
Showing 29 changed files with 102 additions and 139 deletions.
8 changes: 4 additions & 4 deletions ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
std::size_t HydroMechanicsLocalAssembler<
ShapeFunctionDisplacement, ShapeFunctionPressure,
DisplacementDim>::setIPDataInitialConditions(std::string const& name,
DisplacementDim>::setIPDataInitialConditions(std::string_view const name,
double const* values,
int const integration_order)
{
Expand All @@ -1060,7 +1060,7 @@ std::size_t HydroMechanicsLocalAssembler<
_element.getID());
}

if (name == "sigma_ip")
if (name == "sigma")
{
if (_process_data.initial_stress != nullptr)
{
Expand All @@ -1075,13 +1075,13 @@ std::size_t HydroMechanicsLocalAssembler<
values, _ip_data, &IpData::sigma_eff);
}

if (name == "epsilon_ip")
if (name == "epsilon")
{
return ProcessLib::setIntegrationPointKelvinVectorData<DisplacementDim>(
values, _ip_data, &IpData::eps);
}

if (name == "strain_rate_variable_ip")
if (name == "strain_rate_variable")
{
return ProcessLib::setIntegrationPointScalarData(
values, _ip_data, &IpData::strain_rate_variable);
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/HydroMechanics/HydroMechanicsFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class HydroMechanicsLocalAssembler

/// Returns number of read integration points.
std::size_t setIPDataInitialConditions(
std::string const& name,
std::string_view const name,
double const* values,
int const integration_order) override;

Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/HydroMechanics/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
public NumLib::ExtrapolatableElement
{
virtual std::size_t setIPDataInitialConditions(
std::string const& name, double const* values,
std::string_view const name, double const* values,
int const integration_order) = 0;

virtual std::vector<double> getSigma() const = 0;
Expand Down
3 changes: 1 addition & 2 deletions ProcessLib/LargeDeformation/LargeDeformationProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ void LargeDeformationProcess<DisplacementDim>::initializeConcreteProcess(
_process_data.solid_materials, _local_assemblers,
_integration_point_writer, integration_order);

bool const remove_name_suffix = true;
setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(),
_local_assemblers, remove_name_suffix);
_local_assemblers);

// Initialize local assemblers after all variables have been set.
GlobalExecutor::executeMemberOnDereferenced(
Expand Down
11 changes: 5 additions & 6 deletions ProcessLib/LargeDeformation/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct LargeDeformationLocalAssemblerInterface
output_data_.resize(n_integration_points);
}
/// Returns number of read integration points.
std::size_t setIPDataInitialConditions(std::string const& name,
std::size_t setIPDataInitialConditions(std::string_view name,
double const* values,
int const integration_order)
{
Expand All @@ -77,17 +77,16 @@ struct LargeDeformationLocalAssemblerInterface

if (name.starts_with("material_state_variable_"))
{
std::string const variable_name = name.substr(24, name.size() - 24);
name.remove_prefix(24);

auto const& internal_variables =
solid_material_.getInternalVariables();
if (auto const iv = std::find_if(
begin(internal_variables), end(internal_variables),
[&variable_name](auto const& iv)
{ return iv.name == variable_name; });
[&name](auto const& iv) { return iv.name == name; });
iv != end(internal_variables))
{
DBUG("Setting material state variable '{:s}'", variable_name);
DBUG("Setting material state variable '{:s}'", name);
return ProcessLib::
setIntegrationPointDataMaterialStateVariables(
values, material_states_,
Expand All @@ -99,7 +98,7 @@ struct LargeDeformationLocalAssemblerInterface
WARN(
"Could not find variable {:s} in solid material model's "
"internal variables.",
variable_name);
name);
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/Reflection/ReflectionSetIPData.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void setIPData(double const* values,
// Returns true if IP have been set, false otherwise.
template <int dim, typename IPData, typename Accessor_CurrentLevelFromIPData,
typename Class, typename Accessor>
bool setIPDataIfNameMatches(std::string const& name, double const* values,
bool setIPDataIfNameMatches(std::string_view const name, double const* values,
std::vector<IPData>& ip_data_vector,
Accessor_CurrentLevelFromIPData const& accessor,
ReflectionData<Class, Accessor> const& refl_data)
Expand Down Expand Up @@ -112,7 +112,7 @@ bool setIPDataIfNameMatches(std::string const& name, double const* values,
template <int dim, typename IPData, typename Accessor_CurrentLevelFromIPData,
typename... Classes, typename... Accessors, std::size_t... Idcs>
bool reflectSetIPData(
std::string const& name, double const* values,
std::string_view const name, double const* values,
std::vector<IPData>& ip_data_vector,
Accessor_CurrentLevelFromIPData const& accessor,
std::tuple<ReflectionData<Classes, Accessors>...> const& refl_data,
Expand All @@ -128,7 +128,7 @@ bool reflectSetIPData(
template <int dim, typename IPData, typename Accessor_CurrentLevelFromIPData,
typename... Classes, typename... Accessors>
bool reflectSetIPData(
std::string const& name, double const* values,
std::string_view const name, double const* values,
std::vector<IPData>& ip_data_vector,
Accessor_CurrentLevelFromIPData const& accessor,
std::tuple<ReflectionData<Classes, Accessors>...> const& refl_data)
Expand All @@ -149,7 +149,7 @@ bool reflectSetIPData(
* \return The number of integration points.
*/
template <int dim, typename IPData>
std::size_t reflectSetIPData(std::string const& name, double const* values,
std::size_t reflectSetIPData(std::string_view const name, double const* values,
std::vector<IPData>& ip_data_vector)
{
detail::reflectSetIPData<dim>(
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/RichardsMechanics/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
public NumLib::ExtrapolatableElement
{
virtual std::size_t setIPDataInitialConditions(
std::string const& name, double const* values,
std::string_view const name, double const* values,
int const integration_order) = 0;

virtual std::vector<double> getSigma() const = 0;
Expand Down
29 changes: 14 additions & 15 deletions ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
std::size_t RichardsMechanicsLocalAssembler<
ShapeFunctionDisplacement, ShapeFunctionPressure,
DisplacementDim>::setIPDataInitialConditions(std::string const& name,
DisplacementDim>::setIPDataInitialConditions(std::string_view name,
double const* values,
int const integration_order)
{
Expand All @@ -209,7 +209,7 @@ std::size_t RichardsMechanicsLocalAssembler<
_element.getID());
}

if (name == "sigma_ip")
if (name == "sigma")
{
if (_process_data.initial_stress != nullptr)
{
Expand All @@ -223,54 +223,53 @@ std::size_t RichardsMechanicsLocalAssembler<
values, _ip_data, &IpData::sigma_eff);
}

if (name == "saturation_ip")
if (name == "saturation")
{
return ProcessLib::setIntegrationPointScalarData(values, _ip_data,
&IpData::saturation);
}
if (name == "porosity_ip")
if (name == "porosity")
{
return ProcessLib::setIntegrationPointScalarData(values, _ip_data,
&IpData::porosity);
}
if (name == "transport_porosity_ip")
if (name == "transport_porosity")
{
return ProcessLib::setIntegrationPointScalarData(
values, _ip_data, &IpData::transport_porosity);
}
if (name == "swelling_stress_ip")
if (name == "swelling_stress")
{
return ProcessLib::setIntegrationPointKelvinVectorData<DisplacementDim>(
values, _ip_data, &IpData::sigma_sw);
}
if (name == "epsilon_ip")
if (name == "epsilon")
{
return ProcessLib::setIntegrationPointKelvinVectorData<DisplacementDim>(
values, _ip_data, &IpData::eps);
}
if (name.starts_with("material_state_variable_") && name.ends_with("_ip"))
if (name.starts_with("material_state_variable_"))
{
std::string const variable_name = name.substr(24, name.size() - 24 - 3);
name.remove_prefix(24);

// Using first ip data for solid material. TODO (naumov) move solid
// material into element, store only material state in IPs.
auto const& internal_variables =
_ip_data[0].solid_material.getInternalVariables();
if (auto const iv =
std::find_if(begin(internal_variables), end(internal_variables),
[&variable_name](auto const& iv)
{ return iv.name == variable_name; });
if (auto const iv = std::find_if(
begin(internal_variables), end(internal_variables),
[&name](auto const& iv) { return iv.name == name; });
iv != end(internal_variables))
{
DBUG("Setting material state variable '{:s}'", variable_name);
DBUG("Setting material state variable '{:s}'", name);
return ProcessLib::setIntegrationPointDataMaterialStateVariables(
values, _ip_data, &IpData::material_state_variables,
iv->reference);
}

ERR("Could not find variable {:s} in solid material model's internal "
"variables.",
variable_name);
name);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class RichardsMechanicsLocalAssembler

/// \return the number of read integration points.
std::size_t setIPDataInitialConditions(
std::string const& name,
std::string_view const name,
double const* values,
int const integration_order) override;

Expand Down
11 changes: 5 additions & 6 deletions ProcessLib/SmallDeformation/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct SmallDeformationLocalAssemblerInterface
output_data_.resize(n_integration_points);
}
/// Returns number of read integration points.
std::size_t setIPDataInitialConditions(std::string const& name,
std::size_t setIPDataInitialConditions(std::string_view name,
double const* values,
int const integration_order)
{
Expand All @@ -80,17 +80,16 @@ struct SmallDeformationLocalAssemblerInterface

if (name.starts_with("material_state_variable_"))
{
std::string const variable_name = name.substr(24, name.size() - 24);
name.remove_prefix(24);

auto const& internal_variables =
solid_material_.getInternalVariables();
if (auto const iv = std::find_if(
begin(internal_variables), end(internal_variables),
[&variable_name](auto const& iv)
{ return iv.name == variable_name; });
[&name](auto const& iv) { return iv.name == name; });
iv != end(internal_variables))
{
DBUG("Setting material state variable '{:s}'", variable_name);
DBUG("Setting material state variable '{:s}'", name);
return ProcessLib::
setIntegrationPointDataMaterialStateVariables(
values, material_states_,
Expand All @@ -102,7 +101,7 @@ struct SmallDeformationLocalAssemblerInterface
WARN(
"Could not find variable {:s} in solid material model's "
"internal variables.",
variable_name);
name);
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions ProcessLib/SmallDeformation/SmallDeformationProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
_process_data.solid_materials, _local_assemblers,
_integration_point_writer, integration_order);

bool const remove_name_suffix = true;
setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(),
_local_assemblers, remove_name_suffix);
_local_assemblers);

// Initialize local assemblers after all variables have been set.
GlobalExecutor::executeMemberOnDereferenced(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct SmallDeformationNonlocalLocalAssemblerInterface
public NumLib::ExtrapolatableElement
{
virtual std::size_t setIPDataInitialConditions(
std::string const& name, double const* values,
std::string_view const name, double const* values,
int const integration_order) = 0;

virtual void setIPDataInitialConditionsFromCellData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SmallDeformationNonlocalLocalAssembler
}
}

std::size_t setIPDataInitialConditions(std::string const& name,
std::size_t setIPDataInitialConditions(std::string_view const name,
double const* values,
int const integration_order) override
{
Expand All @@ -160,12 +160,12 @@ class SmallDeformationNonlocalLocalAssembler
_element.getID());
}

if (name == "sigma_ip")
if (name == "sigma")
{
return setSigma(values);
}

if (name == "kappa_d_ip")
if (name == "kappa_d")
{
return ProcessLib::setIntegrationPointScalarData(values, _ip_data,
&IpData::kappa_d);
Expand Down
Loading

0 comments on commit 1a9aaaf

Please sign in to comment.