diff --git a/MeshLib/Properties-impl.h b/MeshLib/Properties-impl.h index aeb19dec20f21cfbb18718ed70512ba4bb45d6c1..e4a8762b7e96b16411a65c216b61ae00e522c678 100644 --- a/MeshLib/Properties-impl.h +++ b/MeshLib/Properties-impl.h @@ -129,8 +129,9 @@ PropertyVector<T>* Properties::getPropertyVector(std::string const& name) } template <typename T> -PropertyVector<T> const* Properties::getNodalNComponentPropertyVector( - std::string const& name, int const n_components) const +PropertyVector<T> const* Properties::getPropertyVector( + std::string const& name, MeshItemType const item_type, + int const n_components) const { auto const it = _properties.find(name); if (it == _properties.end()) @@ -143,12 +144,12 @@ PropertyVector<T> const* Properties::getNodalNComponentPropertyVector( { OGS_FATAL("Could not cast property '%s' to given type.", name.c_str()); } - if (property->getMeshItemType() != MeshItemType::Node) + if (property->getMeshItemType() != item_type) { OGS_FATAL( - "Only nodal fields are supported for non-uniform fields. Field " - "`%s' is not nodal.", - name.c_str()); + "The PropertyVector '%s' has a different type than requested. A " + "`%s' field is requested.", + name.c_str(), toString(item_type)); } if (property->getNumberOfComponents() != n_components) { diff --git a/MeshLib/Properties.h b/MeshLib/Properties.h index 88d8d43ca3fe4a3d336b2bf313662a07e41d9c04..220889273ce304535c789317a54ffc5c6ab45ab5 100644 --- a/MeshLib/Properties.h +++ b/MeshLib/Properties.h @@ -99,8 +99,9 @@ public: /// number_of_components or aborts calling OGS_FATAL if no such property /// vector exists. template <typename T> - PropertyVector<T> const* getNodalNComponentPropertyVector( - std::string const& name, int n_components) const; + PropertyVector<T> const* getPropertyVector(std::string const& name, + MeshItemType const item_type, + int const n_components) const; void removePropertyVector(std::string const& name); diff --git a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp index 667dc4f706d6e5c703d19f7acabe7fabb35f605f..5e6829484fb859fc49690c95de82ee8ba5e65ce0 100644 --- a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp @@ -36,51 +36,42 @@ createNonuniformVariableDependentNeumannBoundaryCondition( auto const constant_name = //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__constant_name} config.getConfigParameter<std::string>("constant_name"); - auto const* const constant = - boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( - constant_name, 1); + auto const& constant = + *boundary_mesh.getProperties().getPropertyVector<double>( + constant_name, MeshLib::MeshItemType::Node, 1); auto const coefficient_current_variable_name = //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__coefficient_current_variable_name} config.getConfigParameter<std::string>( "coefficient_current_variable_name"); - auto const* const coefficient_current_variable = - boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( - coefficient_current_variable_name, 1); + auto const& coefficient_current_variable = + *boundary_mesh.getProperties().getPropertyVector<double>( + coefficient_current_variable_name, MeshLib::MeshItemType::Node, 1); auto const coefficient_other_variable_name = //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__coefficient_other_variable_name} config.getConfigParameter<std::string>( "coefficient_other_variable_name"); - auto const* const coefficient_other_variable = - boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( - coefficient_other_variable_name, 1); + auto const& coefficient_other_variable = + *boundary_mesh.getProperties().getPropertyVector<double>( + coefficient_other_variable_name, MeshLib::MeshItemType::Node, 1); auto const coefficient_mixed_variables_name = //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__coefficient_mixed_variables_name} config.getConfigParameter<std::string>( "coefficient_mixed_variables_name"); - auto const* const coefficient_mixed_variables = - boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( - coefficient_mixed_variables_name, 1); + auto const& coefficient_mixed_variables = + *boundary_mesh.getProperties().getPropertyVector<double>( + coefficient_mixed_variables_name, MeshLib::MeshItemType::Node, 1); std::string const mapping_to_bulk_nodes_property = "bulk_node_ids"; - auto const* const mapping_to_bulk_nodes = - boundary_mesh.getProperties().getPropertyVector<std::size_t>( - mapping_to_bulk_nodes_property); - - if (!(mapping_to_bulk_nodes && mapping_to_bulk_nodes->getMeshItemType() == - MeshLib::MeshItemType::Node) && - mapping_to_bulk_nodes->getNumberOfComponents() == 1) - { - OGS_FATAL("Field `%s' is not set up properly.", - mapping_to_bulk_nodes_property.c_str()); - } + boundary_mesh.getProperties().getPropertyVector<std::size_t>( + mapping_to_bulk_nodes_property, MeshLib::MeshItemType::Node, 1); std::vector<MeshLib::Node*> const& bc_nodes = boundary_mesh.getNodes(); MeshLib::MeshSubset bc_mesh_subset(boundary_mesh, bc_nodes); - auto const* const dof_table_boundary_other_variable = - dof_table.deriveBoundaryConstrainedMap( + auto const& dof_table_boundary_other_variable = + *dof_table.deriveBoundaryConstrainedMap( (variable_id + 1) % 2, {component_id}, std::move(bc_mesh_subset)); // In case of partitioned mesh the boundary could be empty, i.e. there is no @@ -103,9 +94,8 @@ createNonuniformVariableDependentNeumannBoundaryCondition( integration_order, shapefunction_order, dof_table, variable_id, component_id, bulk_mesh.getDimension(), boundary_mesh, NonuniformVariableDependentNeumannBoundaryConditionData{ - *constant, *coefficient_current_variable, - *coefficient_other_variable, *coefficient_mixed_variables, - *dof_table_boundary_other_variable}); + constant, coefficient_current_variable, coefficient_other_variable, + coefficient_mixed_variables, dof_table_boundary_other_variable}); } } // namespace ProcessLib