diff --git a/ProcessLib/BoundaryCondition.h b/ProcessLib/BoundaryCondition.h index b460359e089f36252eff1463c7ab7e58d7b2ec43..9d24524321454efd73cc858ea5ffc1232c45836f 100644 --- a/ProcessLib/BoundaryCondition.h +++ b/ProcessLib/BoundaryCondition.h @@ -35,14 +35,6 @@ public: virtual ~BoundaryCondition() = default; - /// Initialization interface of Dirichlet type boundary conditions. - /// Fills in global_ids of the particular geometry of the boundary condition - /// and the corresponding values. - /// The ids are appended to the global_ids and also the values. - virtual void initialize( - MeshGeoToolsLib::MeshNodeSearcher& searcher, - std::vector<std::size_t>& global_ids, std::vector<double>& values) = 0; - protected: GeoLib::GeoObject const* const _geometry; }; diff --git a/ProcessLib/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlowProcess.h index bb089f92c19a12dd3838e87af0774c6f37d771fd..7dd74b09a9e3e8fefbc52ff271c122cafa8cdd06 100644 --- a/ProcessLib/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlowProcess.h @@ -55,7 +55,7 @@ public: // Find the corresponding process variable. std::string const name = config.get<std::string>("process_variable"); - auto const& variable = std::find_if(variables.cbegin(), variables.cend(), + auto variable = std::find_if(variables.cbegin(), variables.cend(), [&name](ProcessVariable const& v) { return v.getName() == name; }); @@ -66,7 +66,7 @@ public: DBUG("Associate hydraulic_head with process variable \'%s\'.", name.c_str()); - _hydraulic_head = &*variable; + _hydraulic_head = const_cast<ProcessVariable*>(&*variable); } @@ -130,15 +130,9 @@ public: MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher( _hydraulic_head->getMesh()); - using BCCI = ProcessVariable::BoundaryConditionCI; - for (BCCI bc = _hydraulic_head->beginBoundaryConditions(); - bc != _hydraulic_head->endBoundaryConditions(); ++bc) - { - (*bc)->initialize( + _hydraulic_head->initializeDirichletBCs( hydraulic_head_mesh_node_searcher, _dirichlet_bc.global_ids, _dirichlet_bc.values); - } - } void solve() @@ -179,7 +173,7 @@ public: } private: - ProcessVariable const* _hydraulic_head = nullptr; + ProcessVariable* _hydraulic_head = nullptr; double const _hydraulic_conductivity = 1e-6; diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 78d33361bcc870de7c1737944d4a35899627310a..3dedf3e7f42178f4f2885927c9ab27fa629c7b83 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -76,7 +76,7 @@ ProcessVariable::ProcessVariable( if (type == "UniformDirichlet") { - _boundary_conditions.emplace_back( + _dirichlet_bcs.emplace_back( new UniformDirichletBoundaryCondition( geometry, bc_config)); } @@ -94,7 +94,7 @@ ProcessVariable::~ProcessVariable() { delete _initial_condition; - for(auto p : _boundary_conditions) + for(auto p : _dirichlet_bcs) delete p; } @@ -108,4 +108,12 @@ MeshLib::Mesh const& ProcessVariable::getMesh() const return _mesh; } +void ProcessVariable::initializeDirichletBCs( + MeshGeoToolsLib::MeshNodeSearcher& searcher, + std::vector<std::size_t>& global_ids, std::vector<double>& values) +{ + for (UniformDirichletBoundaryCondition* bc : _dirichlet_bcs) + bc->initialize(searcher, global_ids, values); +} + } // namespace ProcessLib diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index 7ac4c81f6d96f9d1ed8a8dca49820897250cf8a3..b78bbfa83dc4cf7a61971b3e4b8fd00fab67eced 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -15,10 +15,12 @@ #include "GeoLib/GEOObjects.h" #include "MeshLib/Mesh.h" +#include "MeshGeoToolsLib/MeshNodeSearcher.h" + namespace ProcessLib { - class BoundaryCondition; class InitialCondition; + class UniformDirichletBoundaryCondition; } namespace ProcessLib @@ -40,28 +42,15 @@ public: /// Returns a mesh on which the process variable is defined. MeshLib::Mesh const& getMesh() const; - /// Const iterator over boundary conditions of the process variable. - using BoundaryConditionCI = std::vector<BoundaryCondition*>::const_iterator; - - /// Returns a BoundaryConditionCI iterator to the beginning. - BoundaryConditionCI - beginBoundaryConditions() const - { - return _boundary_conditions.cbegin(); - } + void initializeDirichletBCs(MeshGeoToolsLib::MeshNodeSearcher& searcher, + std::vector<std::size_t>& global_ids, std::vector<double>& values); - /// Returns a past-the-end BoundaryConditionCI iterator. - BoundaryConditionCI - endBoundaryConditions() const - { - return _boundary_conditions.cend(); - } private: std::string const _name; MeshLib::Mesh const& _mesh; InitialCondition* _initial_condition; - std::vector<BoundaryCondition*> _boundary_conditions; + std::vector<UniformDirichletBoundaryCondition*> _dirichlet_bcs; }; } // namespace ProcessLib