diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h index 7f4d723cdc1..c740726f178 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h @@ -1046,7 +1046,7 @@ template 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) { diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h index 1c2073039ea..f51448a48f9 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h @@ -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; diff --git a/ProcessLib/HydroMechanics/LocalAssemblerInterface.h b/ProcessLib/HydroMechanics/LocalAssemblerInterface.h index d564adb30b3..619b8739e98 100644 --- a/ProcessLib/HydroMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/HydroMechanics/LocalAssemblerInterface.h @@ -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 getSigma() const = 0; diff --git a/ProcessLib/LargeDeformation/LocalAssemblerInterface.h b/ProcessLib/LargeDeformation/LocalAssemblerInterface.h index a01d8bee9cb..44c38134098 100644 --- a/ProcessLib/LargeDeformation/LocalAssemblerInterface.h +++ b/ProcessLib/LargeDeformation/LocalAssemblerInterface.h @@ -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) { @@ -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_, @@ -99,7 +98,7 @@ struct LargeDeformationLocalAssemblerInterface WARN( "Could not find variable {:s} in solid material model's " "internal variables.", - variable_name); + name); return 0; } diff --git a/ProcessLib/Reflection/ReflectionSetIPData.h b/ProcessLib/Reflection/ReflectionSetIPData.h index 2ce68bd6647..5b3ee832635 100644 --- a/ProcessLib/Reflection/ReflectionSetIPData.h +++ b/ProcessLib/Reflection/ReflectionSetIPData.h @@ -72,7 +72,7 @@ void setIPData(double const* values, // Returns true if IP have been set, false otherwise. template -bool setIPDataIfNameMatches(std::string const& name, double const* values, +bool setIPDataIfNameMatches(std::string_view const name, double const* values, std::vector& ip_data_vector, Accessor_CurrentLevelFromIPData const& accessor, ReflectionData const& refl_data) @@ -112,7 +112,7 @@ bool setIPDataIfNameMatches(std::string const& name, double const* values, template bool reflectSetIPData( - std::string const& name, double const* values, + std::string_view const name, double const* values, std::vector& ip_data_vector, Accessor_CurrentLevelFromIPData const& accessor, std::tuple...> const& refl_data, @@ -128,7 +128,7 @@ bool reflectSetIPData( template bool reflectSetIPData( - std::string const& name, double const* values, + std::string_view const name, double const* values, std::vector& ip_data_vector, Accessor_CurrentLevelFromIPData const& accessor, std::tuple...> const& refl_data) @@ -149,7 +149,7 @@ bool reflectSetIPData( * \return The number of integration points. */ template -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& ip_data_vector) { detail::reflectSetIPData( diff --git a/ProcessLib/RichardsMechanics/LocalAssemblerInterface.h b/ProcessLib/RichardsMechanics/LocalAssemblerInterface.h index b7071b7ca0d..15b57eaafcd 100644 --- a/ProcessLib/RichardsMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/RichardsMechanics/LocalAssemblerInterface.h @@ -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 getSigma() const = 0; diff --git a/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h b/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h index 2cd2acbc576..44570845cfe 100644 --- a/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h +++ b/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h @@ -195,7 +195,7 @@ template 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) { @@ -250,19 +250,18 @@ std::size_t RichardsMechanicsLocalAssembler< } if (name.starts_with("material_state_variable_")) { - std::string const variable_name = name.substr(24, name.size() - 24); + 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); @@ -270,7 +269,7 @@ std::size_t RichardsMechanicsLocalAssembler< ERR("Could not find variable {:s} in solid material model's internal " "variables.", - variable_name); + name); } return 0; } diff --git a/ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h b/ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h index 72f22347367..20dd1a72505 100644 --- a/ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h +++ b/ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h @@ -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; diff --git a/ProcessLib/SmallDeformation/LocalAssemblerInterface.h b/ProcessLib/SmallDeformation/LocalAssemblerInterface.h index 2889e61e1c4..47283639c14 100644 --- a/ProcessLib/SmallDeformation/LocalAssemblerInterface.h +++ b/ProcessLib/SmallDeformation/LocalAssemblerInterface.h @@ -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) { @@ -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_, @@ -102,7 +101,7 @@ struct SmallDeformationLocalAssemblerInterface WARN( "Could not find variable {:s} in solid material model's " "internal variables.", - variable_name); + name); return 0; } diff --git a/ProcessLib/SmallDeformationNonlocal/LocalAssemblerInterface.h b/ProcessLib/SmallDeformationNonlocal/LocalAssemblerInterface.h index bb5c9b59d52..fc83d2146ce 100644 --- a/ProcessLib/SmallDeformationNonlocal/LocalAssemblerInterface.h +++ b/ProcessLib/SmallDeformationNonlocal/LocalAssemblerInterface.h @@ -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( diff --git a/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h b/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h index 3985af716c8..0aaac192d69 100644 --- a/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h +++ b/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h @@ -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 { diff --git a/ProcessLib/TH2M/LocalAssemblerInterface.h b/ProcessLib/TH2M/LocalAssemblerInterface.h index f05ad6995ac..dd1a8759dfc 100644 --- a/ProcessLib/TH2M/LocalAssemblerInterface.h +++ b/ProcessLib/TH2M/LocalAssemblerInterface.h @@ -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 name, double const* values, int const integration_order) = 0; virtual std::vector getSigma() const = 0; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 29b09ffa57a..f470f0769f6 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -852,7 +852,7 @@ template std::size_t TH2MLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, - DisplacementDim>::setIPDataInitialConditions(std::string const& name, + DisplacementDim>::setIPDataInitialConditions(std::string_view name, double const* values, int const integration_order) { @@ -897,19 +897,19 @@ std::size_t TH2MLocalAssembler< } if (name.starts_with("material_state_variable_")) { - std::string const variable_name = name.substr(24, name.size() - 24); + name.remove_prefix(24); + DBUG("Setting material state variable '{:s}'", name); // 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); @@ -918,7 +918,7 @@ std::size_t TH2MLocalAssembler< WARN( "Could not find variable {:s} in solid material model's " "internal variables.", - variable_name); + name); } return 0; } diff --git a/ProcessLib/TH2M/TH2MFEM.h b/ProcessLib/TH2M/TH2MFEM.h index 5d788b93063..1741af2100c 100644 --- a/ProcessLib/TH2M/TH2MFEM.h +++ b/ProcessLib/TH2M/TH2MFEM.h @@ -93,7 +93,7 @@ class TH2MLocalAssembler : public LocalAssemblerInterface private: /// \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; diff --git a/ProcessLib/ThermoHydroMechanics/LocalAssemblerInterface.h b/ProcessLib/ThermoHydroMechanics/LocalAssemblerInterface.h index 9828b2dde0c..f2c2e72af4c 100644 --- a/ProcessLib/ThermoHydroMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/ThermoHydroMechanics/LocalAssemblerInterface.h @@ -21,7 +21,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 getSigma() const = 0; diff --git a/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM-impl.h b/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM-impl.h index 9d91ed0ca9e..95b4219a304 100644 --- a/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM-impl.h +++ b/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM-impl.h @@ -106,7 +106,7 @@ template std::size_t ThermoHydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, - DisplacementDim>::setIPDataInitialConditions(std::string const& name, + DisplacementDim>::setIPDataInitialConditions(std::string_view const name, double const* values, int const integration_order) { diff --git a/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM.h b/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM.h index 8a2404f3538..8a8e4935f7c 100644 --- a/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM.h +++ b/ProcessLib/ThermoHydroMechanics/ThermoHydroMechanicsFEM.h @@ -89,7 +89,7 @@ class ThermoHydroMechanicsLocalAssembler : public LocalAssemblerInterface /// 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; diff --git a/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h b/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h index 2bc3f337206..44b6ef21fb8 100644 --- a/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/ThermoMechanics/LocalAssemblerInterface.h @@ -26,7 +26,7 @@ struct ThermoMechanicsLocalAssemblerInterface 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 getSigma() const = 0; diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h index 61187376a9a..f9e4f067363 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h @@ -81,7 +81,7 @@ ThermoMechanicsLocalAssembler:: template std::size_t ThermoMechanicsLocalAssembler:: - setIPDataInitialConditions(std::string const& name, + setIPDataInitialConditions(std::string_view const name, double const* values, int const integration_order) { diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h index 6b9fe3d72de..73f7bd1af86 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h @@ -163,7 +163,7 @@ class ThermoMechanicsLocalAssembler /// 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; diff --git a/ProcessLib/ThermoRichardsFlow/LocalAssemblerInterface.h b/ProcessLib/ThermoRichardsFlow/LocalAssemblerInterface.h index f48c4591f08..ead9919112a 100644 --- a/ProcessLib/ThermoRichardsFlow/LocalAssemblerInterface.h +++ b/ProcessLib/ThermoRichardsFlow/LocalAssemblerInterface.h @@ -22,7 +22,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 const& getIntPtDarcyVelocity( diff --git a/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM-impl.h b/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM-impl.h index a7b71707fe0..337c827d16a 100644 --- a/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM-impl.h +++ b/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM-impl.h @@ -80,7 +80,7 @@ ThermoRichardsFlowLocalAssembler:: template std::size_t ThermoRichardsFlowLocalAssembler:: - setIPDataInitialConditions(std::string const& name, + setIPDataInitialConditions(std::string_view const name, double const* values, int const integration_order) { diff --git a/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM.h b/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM.h index b6b30386618..eda5e27a4a9 100644 --- a/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM.h +++ b/ProcessLib/ThermoRichardsFlow/ThermoRichardsFlowFEM.h @@ -59,7 +59,7 @@ class ThermoRichardsFlowLocalAssembler : public LocalAssemblerInterface /// \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; diff --git a/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h b/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h index eefa35b0911..c4ab79d2235 100644 --- a/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h +++ b/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h @@ -54,7 +54,7 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface, } } - std::size_t setIPDataInitialConditions(std::string const& name, + std::size_t setIPDataInitialConditions(std::string_view name, double const* values, int const integration_order) { @@ -83,17 +83,16 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface, // reflectWithName function also supports only a single return value. 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_, diff --git a/ProcessLib/Utils/SetIPDataInitialConditions.h b/ProcessLib/Utils/SetIPDataInitialConditions.h index 766d3a5a40b..0c813f65380 100644 --- a/ProcessLib/Utils/SetIPDataInitialConditions.h +++ b/ProcessLib/Utils/SetIPDataInitialConditions.h @@ -10,6 +10,8 @@ #pragma once +#include + #include "BaseLib/Error.h" #include "MeshLib/Properties.h" #include "MeshLib/Utils/IntegrationPointWriter.h" @@ -17,7 +19,7 @@ namespace ProcessLib { /// Removes the suffix '_ip' from the passed field name. -inline std::string removeIPFieldDataNameSuffix(std::string const& name) +inline std::string_view removeIPFieldDataNameSuffix(std::string_view const name) { if (!name.ends_with("_ip")) { @@ -27,7 +29,7 @@ inline std::string removeIPFieldDataNameSuffix(std::string const& name) name); } - return name.substr(0, name.size() - 3); + return {name.data(), name.size() - 3}; } template @@ -71,7 +73,7 @@ void setIPDataInitialConditions( INFO("Setting initial integration point data for '{}'", name); - auto const& name_transformed = removeIPFieldDataNameSuffix(name); + auto const name_transformed = removeIPFieldDataNameSuffix(name); // Now we have a properly named vtk's field data array and the // corresponding meta data.