diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h index a58161a5b47..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) { @@ -1060,7 +1060,7 @@ std::size_t HydroMechanicsLocalAssembler< _element.getID()); } - if (name == "sigma_ip") + if (name == "sigma") { if (_process_data.initial_stress != nullptr) { @@ -1075,13 +1075,13 @@ std::size_t HydroMechanicsLocalAssembler< values, _ip_data, &IpData::sigma_eff); } - if (name == "epsilon_ip") + if (name == "epsilon") { return ProcessLib::setIntegrationPointKelvinVectorData( 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); 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/LargeDeformationProcess.cpp b/ProcessLib/LargeDeformation/LargeDeformationProcess.cpp index c1abe5156c3..02a03237ac8 100644 --- a/ProcessLib/LargeDeformation/LargeDeformationProcess.cpp +++ b/ProcessLib/LargeDeformation/LargeDeformationProcess.cpp @@ -119,9 +119,8 @@ void LargeDeformationProcess::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( 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 3c081fc93e9..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) { @@ -209,7 +209,7 @@ std::size_t RichardsMechanicsLocalAssembler< _element.getID()); } - if (name == "sigma_ip") + if (name == "sigma") { if (_process_data.initial_stress != nullptr) { @@ -223,46 +223,45 @@ 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( values, _ip_data, &IpData::sigma_sw); } - if (name == "epsilon_ip") + if (name == "epsilon") { return ProcessLib::setIntegrationPointKelvinVectorData( 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); @@ -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/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp index e90f3a85051..d6f2bfbe259 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp +++ b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp @@ -121,9 +121,8 @@ void SmallDeformationProcess::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( 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 a52d93f6262..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 { @@ -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); diff --git a/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalProcess.cpp b/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalProcess.cpp index 2e7dacd7524..f9a0638c053 100644 --- a/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalProcess.cpp +++ b/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalProcess.cpp @@ -14,6 +14,7 @@ #include "MeshLib/Utils/IntegrationPointWriter.h" #include "MeshLib/Utils/getOrCreateMeshProperty.h" +#include "ProcessLib/Utils/SetIPDataInitialConditions.h" // Reusing local assembler creation code. #include "ProcessLib/SmallDeformation/CreateLocalAssemblers.h" @@ -118,57 +119,14 @@ void SmallDeformationNonlocalProcess:: &LocalAssemblerInterface::nonlocal, _local_assemblers, _local_assemblers); - // Set initial conditions for integration point data. + setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(), + _local_assemblers); + + // Set initial conditions for integration point from cell mesh properties. for (auto const& ip_writer : _integration_point_writer) { auto const& name = ip_writer->name(); - // First check the field data, which is used for restart. - if (mesh.getProperties().existsPropertyVector(name)) - { - auto const& mesh_property = - *mesh.getProperties().template getPropertyVector(name); - - // The mesh property must be defined on integration points. - if (mesh_property.getMeshItemType() != - MeshLib::MeshItemType::IntegrationPoint) - { - continue; - } - - auto const ip_meta_data = - getIntegrationPointMetaData(mesh.getProperties(), name); - - // Check the number of components. - if (ip_meta_data.n_components != - mesh_property.getNumberOfGlobalComponents()) - { - OGS_FATAL( - "Different number of components in meta data ({:d}) than " - "in the integration point field data for '{:s}': {:d}.", - ip_meta_data.n_components, name, - mesh_property.getNumberOfGlobalComponents()); - } - - // Now we have a properly named vtk's field data array and the - // corresponding meta data. - std::size_t position = 0; - for (auto& local_asm : _local_assemblers) - { - std::size_t const integration_points_read = - local_asm->setIPDataInitialConditions( - name, &mesh_property[position], - ip_meta_data.integration_order); - if (integration_points_read == 0) - { - OGS_FATAL( - "No integration points read in the integration point " - "initial conditions set function."); - } - position += integration_points_read * ip_meta_data.n_components; - } - } - else if (mesh.getProperties().existsPropertyVector(name + - "_ic")) + if (mesh.getProperties().existsPropertyVector(name + "_ic")) { // Try to find cell data with '_ic' suffix auto const& mesh_property = *mesh.getProperties().template getPropertyVector(name + @@ -178,6 +136,18 @@ void SmallDeformationNonlocalProcess:: continue; } + // Disallow setting ip-data from both, the e.g. sigma_ip and + // sigma_ip_ic fields simultaneously. + if (mesh.getProperties().existsPropertyVector( + name, MeshLib::MeshItemType::IntegrationPoint, + mesh_property.getNumberOfGlobalComponents())) + { + OGS_FATAL( + "Both, the field-data ({:s}) and cell-data ({:s}) " + "properties are available in the mesh for integration " + "point initialization, but only one can be used.", + name, name + "_ic"); + } // Now we have a vtk's cell data array containing the initial // conditions for the corresponding integration point writer. 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 9dcabc5d0a1..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) { @@ -866,7 +866,7 @@ std::size_t TH2MLocalAssembler< _element.getID()); } - if (name == "sigma_ip") + if (name == "sigma") { if (_process_data.initial_stress != nullptr) { @@ -880,36 +880,36 @@ std::size_t TH2MLocalAssembler< values, _ip_data, &IpData::sigma_eff); } - if (name == "saturation_ip") + if (name == "saturation") { return ProcessLib::setIntegrationPointScalarData(values, _ip_data, &IpData::s_L); } - if (name == "swelling_stress_ip") + if (name == "swelling_stress") { return ProcessLib::setIntegrationPointKelvinVectorData( values, _ip_data, &IpData::sigma_sw); } - if (name == "epsilon_ip") + if (name == "epsilon") { return ProcessLib::setIntegrationPointKelvinVectorData( 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); + 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 a7b84efd8b4..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) { @@ -120,7 +120,7 @@ std::size_t ThermoHydroMechanicsLocalAssembler< _element.getID()); } - if (name == "sigma_ip") + if (name == "sigma") { if (_process_data.initial_stress != nullptr) { @@ -134,7 +134,7 @@ std::size_t ThermoHydroMechanicsLocalAssembler< return ProcessLib::setIntegrationPointKelvinVectorData( values, _ip_data, &IpData::sigma_eff); } - if (name == "epsilon_ip") + if (name == "epsilon") { return ProcessLib::setIntegrationPointKelvinVectorData( values, _ip_data, &IpData::eps); 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 61da2353a35..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) { @@ -95,15 +95,15 @@ std::size_t ThermoMechanicsLocalAssembler:: _element.getID()); } - if (name == "sigma_ip") + if (name == "sigma") { return setSigma(values); } - if (name == "epsilon_ip") + if (name == "epsilon") { return setEpsilon(values); } - if (name == "epsilon_m_ip") + if (name == "epsilon_m") { return setEpsilonMechanical(values); } 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 f2c61895f9b..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) { @@ -94,12 +94,12 @@ std::size_t ThermoRichardsFlowLocalAssembler:: _element.getID()); } - 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); 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/ThermoRichardsMechanics/ThermoRichardsMechanicsProcess.cpp b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsProcess.cpp index 1b3c453ac6c..ed52b421283 100644 --- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsProcess.cpp +++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsProcess.cpp @@ -187,9 +187,8 @@ void ThermoRichardsMechanicsProcess:: const_cast(mesh), "temperature_interpolated", MeshLib::MeshItemType::Node, 1); - 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(&LocalAssemblerIF::initialize, diff --git a/ProcessLib/Utils/SetIPDataInitialConditions.h b/ProcessLib/Utils/SetIPDataInitialConditions.h index c6188389811..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 @@ -35,8 +37,7 @@ void setIPDataInitialConditions( std::vector> const& _integration_point_writer, MeshLib::Properties const& mesh_properties, - LocalAssemblersVector& local_assemblers, - bool const remove_name_suffix = false) + LocalAssemblersVector& local_assemblers) { for (auto const& ip_writer : _integration_point_writer) { @@ -72,8 +73,7 @@ void setIPDataInitialConditions( INFO("Setting initial integration point data for '{}'", name); - auto const& name_transformed = - remove_name_suffix ? removeIPFieldDataNameSuffix(name) : name; + auto const name_transformed = removeIPFieldDataNameSuffix(name); // Now we have a properly named vtk's field data array and the // corresponding meta data.