diff --git a/ProcessLib/BoundaryCondition/BoundaryCondition.h b/ProcessLib/BoundaryCondition/BoundaryCondition.h index ea15b454fee7bb1e2fa6feb8b3fd447d2f85e097..c284739c87b94a2c6aef11ce120421d2ac11fa50 100644 --- a/ProcessLib/BoundaryCondition/BoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/BoundaryCondition.h @@ -20,6 +20,8 @@ class Mesh; namespace NumLib { class LocalToGlobalIndexMap; +template <typename> +struct IndexValueVector; } namespace ProcessLib @@ -35,6 +37,13 @@ public: virtual void apply(const double t, GlobalVector const& x, GlobalMatrix& K, GlobalVector& b) = 0; + // TODO docu + virtual void getDirichletBCValues( + const double /*t*/, + NumLib::IndexValueVector<GlobalIndexType>& /*bc_values*/) const + { + } + virtual ~BoundaryCondition() = default; }; diff --git a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp index df611ca5715f53a017e7e7810851e8e4dbf65dec..889d6cd1a3bdcdd308beb33a489b6bdf7dff63d7 100644 --- a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp +++ b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp @@ -9,21 +9,6 @@ #include "BoundaryConditionCollection.h" -void initializeDirichletBCs( - std::vector<std::unique_ptr<ProcessLib::BoundaryCondition>> const& - boundary_conditions, - std::vector<NumLib::IndexValueVector<GlobalIndexType>>& - dirichlet_bcs) -{ - for (auto const& bc : boundary_conditions) { - if (auto* dirichlet_bc = - dynamic_cast<ProcessLib::DirichletBoundaryCondition*>( - bc.get())) { - dirichlet_bcs.emplace_back(dirichlet_bc->getBCValues()); - } - } -} - namespace ProcessLib { void BoundaryConditionCollection::apply(const double t, GlobalVector const& x, @@ -52,6 +37,9 @@ void BoundaryConditionCollection::addBCsForProcessVariables( std::back_inserter(_boundary_conditions)); } - initializeDirichletBCs(_boundary_conditions, _dirichlet_bcs); + // For each BC there will be storage for Dirichlet BC. This storage will be + // uninitialized by default, and has to be filled by the respective BC + // object if needed. + _dirichlet_bcs.resize(_boundary_conditions.size()); } } diff --git a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h index 646aa2ce751f84c130aa113d4c9124b77686eade..140721a5289224be0afc7f346ba4ca48c25f929d 100644 --- a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h +++ b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h @@ -10,12 +10,11 @@ #ifndef PROCESSLIB_BOUNDARYCONDITIONCOLLECTION_H #define PROCESSLIB_BOUNDARYCONDITIONCOLLECTION_H -#include "DirichletBoundaryCondition.h" +#include "NumLib/IndexValueVector.h" #include "ProcessLib/ProcessVariable.h" namespace ProcessLib { - class BoundaryConditionCollection final { public: @@ -29,9 +28,13 @@ public: GlobalVector& b); std::vector<NumLib::IndexValueVector<GlobalIndexType>> const* - getKnownSolutions(double const /*t*/) const + getKnownSolutions(double const t) const { - // TODO time-dependent Dirichlet BCs. + for (std::size_t i=0; i<_boundary_conditions.size(); ++i) { + auto const& bc = *_boundary_conditions[i]; + auto& dirichlet_storage = _dirichlet_bcs[i]; + bc.getDirichletBCValues(t, dirichlet_storage); + } return &_dirichlet_bcs; } @@ -42,7 +45,7 @@ public: unsigned const integration_order); private: - std::vector<NumLib::IndexValueVector<GlobalIndexType>> _dirichlet_bcs; + mutable std::vector<NumLib::IndexValueVector<GlobalIndexType>> _dirichlet_bcs; std::vector<std::unique_ptr<BoundaryCondition>> _boundary_conditions; std::vector<std::unique_ptr<ParameterBase>> const& _parameters; }; diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.h b/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.h deleted file mode 100644 index 9dccf2e1820404e44f22783026e41a37ed8ee0d0..0000000000000000000000000000000000000000 --- a/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef PROCESS_LIB_DIRICHLETBC_H -#define PROCESS_LIB_DIRICHLETBC_H - -#include "NumLib/IndexValueVector.h" -#include "BoundaryCondition.h" - -namespace ProcessLib -{ -class DirichletBoundaryCondition : public BoundaryCondition -{ -public: - virtual NumLib::IndexValueVector<GlobalIndexType> getBCValues() = 0; - - void apply(const double /*t*/, - GlobalVector const& /*x*/, - GlobalMatrix& /*K*/, - GlobalVector& /*b*/) override final - { - // Do nothing. Dirichlet BCs are handled specially. - } -}; - -} // namespace ProcessLib - -#endif // PROCESS_LIB_DIRICHLETBC_H diff --git a/ProcessLib/BoundaryCondition/UniformDirichletBoundaryCondition.h b/ProcessLib/BoundaryCondition/UniformDirichletBoundaryCondition.h index fc3088a0e40f312d920da170c9254844702a5b1e..5044da0ba3ba3735abbb27cd9ac3b691ca9733b6 100644 --- a/ProcessLib/BoundaryCondition/UniformDirichletBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/UniformDirichletBoundaryCondition.h @@ -11,9 +11,8 @@ #define PROCESS_LIB_BOUNDARY_CONDITION_H_ #include "NumLib/DOF/LocalToGlobalIndexMap.h" -#include "NumLib/NumericsConfig.h" // for GlobalIndexType - -#include "DirichletBoundaryCondition.h" +#include "NumLib/IndexValueVector.h" +#include "BoundaryCondition.h" namespace ProcessLib { @@ -21,7 +20,7 @@ namespace ProcessLib /// and time Dirichlet boundary condition. /// The expected parameter in the passed configuration is "value" which, when /// not present defaults to zero. -class UniformDirichletBoundaryCondition : public DirichletBoundaryCondition +class UniformDirichletBoundaryCondition : public BoundaryCondition { public: UniformDirichletBoundaryCondition( @@ -30,13 +29,21 @@ public: { } - NumLib::IndexValueVector<GlobalIndexType> getBCValues() + void apply(const double, GlobalVector const&, GlobalMatrix&, + GlobalVector&) override + { + } + + void getDirichletBCValues( + const double /*t*/, + NumLib::IndexValueVector<GlobalIndexType>& bc_values) const { - return std::move(_bc); + if (!_bc.ids.empty()) + bc_values = std::move(_bc); } private: - NumLib::IndexValueVector<GlobalIndexType> _bc; + mutable NumLib::IndexValueVector<GlobalIndexType> _bc; }; std::unique_ptr<UniformDirichletBoundaryCondition>