diff --git a/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp index c4f2b4cb3dfbe01b9e6b065e96528fea49090e4e..4efc1805feff70ab82ca80a24de38952e3bf9bdd 100644 --- a/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp @@ -15,10 +15,10 @@ #include "DirichletBoundaryCondition.h" #include "DirichletBoundaryConditionWithinTimeInterval.h" #include "NeumannBoundaryCondition.h" -#include "NonuniformVariableDependentNeumannBoundaryCondition.h" #include "NormalTractionBoundaryCondition.h" #include "PhaseFieldIrreversibleDamageOracleBoundaryCondition.h" #include "RobinBoundaryCondition.h" +#include "VariableDependentNeumannBoundaryCondition.h" #include "BaseLib/TimeInterval.h" @@ -76,13 +76,12 @@ std::unique_ptr<BoundaryCondition> createBoundaryCondition( *config.component_id, integration_order, shapefunction_order, bulk_mesh.getDimension(), parameters); } - if (type == "NonuniformVariableDependentNeumann") + if (type == "VariableDependentNeumann") { - return ProcessLib:: - createNonuniformVariableDependentNeumannBoundaryCondition( - config.config, config.boundary_mesh, dof_table, variable_id, - *config.component_id, integration_order, shapefunction_order, - bulk_mesh); + return ProcessLib::createVariableDependentNeumannBoundaryCondition( + config.config, config.boundary_mesh, dof_table, variable_id, + *config.component_id, integration_order, shapefunction_order, + bulk_mesh.getDimension(), parameters); } if (type == "Python") diff --git a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryCondition.cpp similarity index 51% rename from ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp rename to ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryCondition.cpp index 2af6cb375039f0f1f4710a61976e631798936db3..36f30cd6753d1f4b4eb6fdeb092b11cd4dacbf9c 100644 --- a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryCondition.cpp @@ -7,69 +7,59 @@ * */ -#include "NonuniformVariableDependentNeumannBoundaryCondition.h" +#include "VariableDependentNeumannBoundaryCondition.h" -#include "MeshLib/IO/readMeshFromFile.h" #include "ProcessLib/Utils/ProcessUtils.h" namespace ProcessLib { -std::unique_ptr<NonuniformVariableDependentNeumannBoundaryCondition> -createNonuniformVariableDependentNeumannBoundaryCondition( - BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_mesh, +std::unique_ptr<VariableDependentNeumannBoundaryCondition> +createVariableDependentNeumannBoundaryCondition( + BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id, int const component_id, unsigned const integration_order, - unsigned const shapefunction_order, MeshLib::Mesh const& bulk_mesh) + unsigned const shapefunction_order, unsigned const global_dim, + std::vector<std::unique_ptr<ParameterBase>> const& parameters) { - DBUG("Constructing NonuniformVariableDependentNeumann BC from config."); + DBUG("Constructing VariableDependentNeumann BC from config."); //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type} - config.checkConfigParameter("type", "NonuniformVariableDependentNeumann"); + config.checkConfigParameter("type", "VariableDependentNeumann"); if (dof_table.getNumberOfVariables() != 2) { OGS_FATAL( - "NonuniformVariableDependentNeumann BC only implemented for 2 " + "VariableDependentNeumann BC only implemented for 2 " "variable processes."); } assert(variable_id == 0 || variable_id == 1); - // TODO finally use ProcessLib::Parameter here auto const constant_name = - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__constant_name} + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__VariableDependentNeumann__constant_name} config.getConfigParameter<std::string>("constant_name"); - auto const& constant = - *boundary_mesh.getProperties().getPropertyVector<double>( - constant_name, MeshLib::MeshItemType::Node, 1); + auto const& constant = findParameter<double>(constant_name, parameters, 1); auto const coefficient_current_variable_name = - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__coefficient_current_variable_name} + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__VariableDependentNeumann__coefficient_current_variable_name} config.getConfigParameter<std::string>( "coefficient_current_variable_name"); auto const& coefficient_current_variable = - *boundary_mesh.getProperties().getPropertyVector<double>( - coefficient_current_variable_name, MeshLib::MeshItemType::Node, 1); + findParameter<double>(coefficient_current_variable_name, parameters, 1); auto const coefficient_other_variable_name = - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__coefficient_other_variable_name} + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__VariableDependentNeumann__coefficient_other_variable_name} config.getConfigParameter<std::string>( "coefficient_other_variable_name"); auto const& coefficient_other_variable = - *boundary_mesh.getProperties().getPropertyVector<double>( - coefficient_other_variable_name, MeshLib::MeshItemType::Node, 1); + findParameter<double>(coefficient_other_variable_name, parameters, 1); auto const coefficient_mixed_variables_name = - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__NonuniformVariableDependentNeumann__coefficient_mixed_variables_name} + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__VariableDependentNeumann__coefficient_mixed_variables_name} config.getConfigParameter<std::string>( "coefficient_mixed_variables_name"); auto const& coefficient_mixed_variables = - *boundary_mesh.getProperties().getPropertyVector<double>( - coefficient_mixed_variables_name, MeshLib::MeshItemType::Node, 1); + findParameter<double>(coefficient_mixed_variables_name, parameters, 1); - std::string const mapping_to_bulk_nodes_property = "bulk_node_ids"; - 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); + std::vector<MeshLib::Node*> const& bc_nodes = bc_mesh.getNodes(); + MeshLib::MeshSubset bc_mesh_subset(bc_mesh, bc_nodes); auto const& dof_table_boundary_other_variable = *dof_table.deriveBoundaryConstrainedMap( (variable_id + 1) % 2, {component_id}, std::move(bc_mesh_subset)); @@ -81,19 +71,17 @@ createNonuniformVariableDependentNeumannBoundaryCondition( // parameters are not read and will cause an error. // TODO (naumov): Add a function to ConfigTree for skipping the tags of the // subtree and move the code up in createBoundaryCondition(). - if (boundary_mesh.getDimension() == 0 && - boundary_mesh.getNumberOfNodes() == 0 && - boundary_mesh.getNumberOfElements() == 0) + if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 && + bc_mesh.getNumberOfElements() == 0) { return nullptr; } #endif // USE_PETSC - return std::make_unique< - NonuniformVariableDependentNeumannBoundaryCondition>( + return std::make_unique<VariableDependentNeumannBoundaryCondition>( integration_order, shapefunction_order, dof_table, variable_id, - component_id, bulk_mesh.getDimension(), boundary_mesh, - NonuniformVariableDependentNeumannBoundaryConditionData{ + component_id, global_dim, bc_mesh, + VariableDependentNeumannBoundaryConditionData{ constant, coefficient_current_variable, coefficient_other_variable, coefficient_mixed_variables, dof_table_boundary_other_variable}); } diff --git a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.h b/ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryCondition.h similarity index 58% rename from ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.h rename to ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryCondition.h index fe7483df0f1fa6ce9ad8540ae3d51df46b5ed9ab..3c8a820e0d0ef5f45906583e9cacfe55624a0728 100644 --- a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryCondition.h @@ -11,20 +11,21 @@ #include "GenericNonuniformNaturalBoundaryCondition.h" #include "MeshLib/PropertyVector.h" -#include "NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler.h" +#include "VariableDependentNeumannBoundaryConditionLocalAssembler.h" namespace ProcessLib { -using NonuniformVariableDependentNeumannBoundaryCondition = +using VariableDependentNeumannBoundaryCondition = GenericNonuniformNaturalBoundaryCondition< - NonuniformVariableDependentNeumannBoundaryConditionData, - NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler>; + VariableDependentNeumannBoundaryConditionData, + VariableDependentNeumannBoundaryConditionLocalAssembler>; -std::unique_ptr<NonuniformVariableDependentNeumannBoundaryCondition> -createNonuniformVariableDependentNeumannBoundaryCondition( +std::unique_ptr<VariableDependentNeumannBoundaryCondition> +createVariableDependentNeumannBoundaryCondition( BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_mesh, NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id, int const component_id, unsigned const integration_order, - unsigned const shapefunction_order, const MeshLib::Mesh& bulk_mesh); + unsigned const shapefunction_order, unsigned const global_dim, + std::vector<std::unique_ptr<ParameterBase>> const& parameters); } // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler.h b/ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryConditionLocalAssembler.h similarity index 73% rename from ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler.h rename to ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryConditionLocalAssembler.h index df2972c85c5bcde7225c48a2c01bf62428363dbb..3365a8acb329efa24ae63f9b8cb5451de884f789 100644 --- a/ProcessLib/BoundaryCondition/NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler.h +++ b/ProcessLib/BoundaryCondition/VariableDependentNeumannBoundaryConditionLocalAssembler.h @@ -18,20 +18,19 @@ namespace ProcessLib { -struct NonuniformVariableDependentNeumannBoundaryConditionData +struct VariableDependentNeumannBoundaryConditionData { - /* TODO use Parameter */ - MeshLib::PropertyVector<double> const& constant; - MeshLib::PropertyVector<double> const& coefficient_current_variable; - MeshLib::PropertyVector<double> const& coefficient_other_variable; - MeshLib::PropertyVector<double> const& coefficient_mixed_variables; + Parameter<double> const& constant; + Parameter<double> const& coefficient_current_variable; + Parameter<double> const& coefficient_other_variable; + Parameter<double> const& coefficient_mixed_variables; // Used for mapping boundary nodes to bulk nodes. NumLib::LocalToGlobalIndexMap const& dof_table_boundary_other_variable; }; template <typename ShapeFunction, typename IntegrationMethod, unsigned GlobalDim> -class NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler final +class VariableDependentNeumannBoundaryConditionLocalAssembler final : public GenericNonuniformNaturalBoundaryConditionLocalAssembler< ShapeFunction, IntegrationMethod, GlobalDim> { @@ -43,12 +42,12 @@ class NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler final public: /// The neumann_bc_term factor is directly integrated into the local /// element matrix. - NonuniformVariableDependentNeumannBoundaryConditionLocalAssembler( + VariableDependentNeumannBoundaryConditionLocalAssembler( MeshLib::Element const& e, std::size_t const local_matrix_size, bool const is_axially_symmetric, unsigned const integration_order, - NonuniformVariableDependentNeumannBoundaryConditionData const& data) + VariableDependentNeumannBoundaryConditionData const& data) : Base(e, is_axially_symmetric, integration_order), _data(data), _local_matrix_size(local_matrix_size) @@ -62,26 +61,18 @@ public: { NodalVectorType _local_rhs(_local_matrix_size); _local_rhs.setZero(); - MeshNodeParameter<double> constant_values{"ConstantValues", - _data.constant}; - MeshNodeParameter<double> coefficient_current_variable_values{ - "CurrentVariableValues", _data.coefficient_current_variable}; - MeshNodeParameter<double> coefficient_other_variable_values{ - "OtherVariableValues", _data.coefficient_other_variable}; - MeshNodeParameter<double> coefficient_mixed_variables_values{ - "MixedVariablesValues", _data.coefficient_mixed_variables}; // Get element nodes for the interpolation from nodes to // integration point. NodalVectorType const constant_node_values = - constant_values.getNodalValuesOnElement(Base::_element, t); + _data.constant.getNodalValuesOnElement(Base::_element, t); NodalVectorType const coefficient_current_variable_node_values = - coefficient_current_variable_values.getNodalValuesOnElement( + _data.coefficient_current_variable.getNodalValuesOnElement( Base::_element, t); NodalVectorType const coefficient_other_variable_node_values = - coefficient_other_variable_values.getNodalValuesOnElement( + _data.coefficient_other_variable.getNodalValuesOnElement( Base::_element, t); NodalVectorType const coefficient_mixed_variables_node_values = - coefficient_mixed_variables_values.getNodalValuesOnElement( + _data.coefficient_mixed_variables.getNodalValuesOnElement( Base::_element, t); unsigned const n_integration_points = _local_matrix_size; @@ -121,7 +112,7 @@ public: } private: - NonuniformVariableDependentNeumannBoundaryConditionData const& _data; + VariableDependentNeumannBoundaryConditionData const& _data; std::size_t const _local_matrix_size; };