diff --git a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/c_NonuniformVariableDependentNeumann.md b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/c_NonuniformVariableDependentNeumann.md index fd59f4dee5101f1f743419a2dc432bfb7d8e1451..0848a2f750c6d1cd5337633c1fc9048a595a6f9a 100644 --- a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/c_NonuniformVariableDependentNeumann.md +++ b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/c_NonuniformVariableDependentNeumann.md @@ -1,2 +1,3 @@ Declares a Neumann boundary condition for a two variable process that is non-uniform in space and depending on both variable values on the mesh nodes of the boundary mesh. The flux iconsists of 4 summands: 1) a constant flux, 2) a flux depending on the process variables value at the mesh node, 3) a flux depending on the other variables value at the mesh node and 3) a flux depending on the product of both variables at the mesh node. +If the Newton-Raphson method is applied for the global system, please select the numerical Jacobian calculation. diff --git a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_current_variable_name.md b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_current_variable_name.md index 5cdc5ef69829f063887b19f16a97b8fb8613a35a..1bdf42c51d49c02df3c99f4047873e108daad705 100644 --- a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_current_variable_name.md +++ b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_current_variable_name.md @@ -1,3 +1,3 @@ This specifies a nodal field defined on the surface mesh. -From the nodal field the coefficient values, which are multiplied by the process variable to calculate the current variable dependant flux, which is applied via this Neumann BC, are read. +From the nodal field the coefficient values, which are multiplied by the process variable to calculate the current variable dependent flux, which is applied via this Neumann BC, are read. diff --git a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_mixed_variables_name.md b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_mixed_variables_name.md index eb46298cf4e9f2596bcba6c6a665127173558f73..828ed39873b07c1d2c3937b6adcf80f53a9171fa 100644 --- a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_mixed_variables_name.md +++ b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_mixed_variables_name.md @@ -1,3 +1,3 @@ This specifies a nodal field defined on the surface mesh. -From the nodal field the coefficient values, which are multiplied by the product of both variables to calculate the mixed variable dependant flux, which is applied via this Neumann BC, are read. +From the nodal field the coefficient values, which are multiplied by the product of both variables to calculate the mixed variable dependent flux, which is applied via this Neumann BC, are read. diff --git a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_other_variable_name.md b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_other_variable_name.md index 706341d0275d5100596abab0bcbd8dcbe7d3e748..bb42d4abbe625c5cdcdabf6228c3f853cd8c833e 100644 --- a/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_other_variable_name.md +++ b/Documentation/ProjectFile/prj/process_variables/process_variable/boundary_conditions/boundary_condition/NonuniformVariableDependentNeumann/t_coefficient_other_variable_name.md @@ -1,3 +1,3 @@ This specifies a nodal field defined on the surface mesh. -From the nodal field the coefficient values, which are multiplied by the other variable to calculate the other variable dependant flux, which is applied via this Neumann BC, are read. +From the nodal field the coefficient values, which are multiplied by the other variable to calculate the other variable dependent flux, which is applied via this Neumann BC, are read. diff --git a/MeshLib/Properties-impl.h b/MeshLib/Properties-impl.h index 6af4d52bd12384bcf5019beab0b5862ca7ba8d21..7569c28f2993f5b54af086ccba99cce4d07720ef 100644 --- a/MeshLib/Properties-impl.h +++ b/MeshLib/Properties-impl.h @@ -127,4 +127,28 @@ PropertyVector<T>* Properties::getPropertyVector(std::string const& name) } return dynamic_cast<PropertyVector<T>*>(it->second); } - +template <typename T> +PropertyVector<T> const* Properties::getNodalNComponentPropertyVector( + std::string const& name, unsigned n_components) const +{ + auto it(_properties.find(name)); + if (it == _properties.end()) + { + OGS_FATAL("A property with name `%s' does not exist.", name.c_str()); + } + if (dynamic_cast<PropertyVector<T>*>(it->second)->getMeshItemType() != + MeshItemType::Node) + { + OGS_FATAL( + "Only nodal fields are supported for non-uniform fields. Field " + "`%s' is not nodal.", + name.c_str()); + } + if (dynamic_cast<PropertyVector<T>*>(it->second)->getNumberOfComponents() != + n_components) + { + OGS_FATAL("`%s' does not have the right number of components.", + name.c_str()); + } + return dynamic_cast<PropertyVector<T> const*>(it->second); +} diff --git a/MeshLib/Properties.h b/MeshLib/Properties.h index 1ba2a4f53231eadd2aa42d7bcf5cbb5db4edb6db..3f478177148c490b3ee4c2646789a70bad91b7c9 100644 --- a/MeshLib/Properties.h +++ b/MeshLib/Properties.h @@ -95,6 +95,13 @@ public: template <typename T> PropertyVector<T>* getPropertyVector(std::string const& name); + /// Returns a property vector with given \c name, \c item_type and \c + /// 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, unsigned n_components) const; + void removePropertyVector(std::string const& name); /// Check if a PropertyVector accessible by the name is already diff --git a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp index 3cb3457c945c6ead113c51ebab9a4e03b23b8972..667dc4f706d6e5c703d19f7acabe7fabb35f605f 100644 --- a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp @@ -12,33 +12,6 @@ #include "MeshLib/IO/readMeshFromFile.h" #include "ProcessLib/Utils/ProcessUtils.h" -namespace -{ -MeshLib::PropertyVector<double> const* getAndCheckPropertyVector( - std::string const& name, MeshLib::Mesh const& mesh) -{ - auto const* const property_vector = - mesh.getProperties().getPropertyVector<double>(name); - if (property_vector == nullptr) - { - OGS_FATAL("A property with name `%s' does not exist in `%s'.", - name.c_str(), mesh.getName().c_str()); - } - if (property_vector->getMeshItemType() != MeshLib::MeshItemType::Node) - { - OGS_FATAL( - "Only nodal fields are supported for non-uniform fields. Field " - "`%s' is not nodal.", - name.c_str()); - } - if (property_vector->getNumberOfComponents() != 1) - { - OGS_FATAL("`%s' is not a one-component field.", name.c_str()); - } - return property_vector; -}; -} // namespace - namespace ProcessLib { std::unique_ptr<NonuniformVariableDependentNeumannBoundaryCondition> @@ -63,30 +36,33 @@ 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 = xxx(constant_name); auto const* const constant = - getAndCheckPropertyVector(constant_name, boundary_mesh); + boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( + constant_name, 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 = getAndCheckPropertyVector( - coefficient_current_variable_name, boundary_mesh); + auto const* const coefficient_current_variable = + boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( + coefficient_current_variable_name, 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 = getAndCheckPropertyVector( - coefficient_other_variable_name, boundary_mesh); + auto const* const coefficient_other_variable = + boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( + coefficient_other_variable_name, 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 = getAndCheckPropertyVector( - coefficient_mixed_variables_name, boundary_mesh); + auto const* const coefficient_mixed_variables = + boundary_mesh.getProperties().getNodalNComponentPropertyVector<double>( + coefficient_mixed_variables_name, 1); std::string const mapping_to_bulk_nodes_property = "bulk_node_ids"; auto const* const mapping_to_bulk_nodes =