diff --git a/BaseLib/TimeInterval.cpp b/BaseLib/TimeInterval.cpp index 52b4035765432d2c9ea4d3ad8814a4f69b9dacdd..24494ef7bcc0a65bbd37d41a227c77c4206d7e71 100644 --- a/BaseLib/TimeInterval.cpp +++ b/BaseLib/TimeInterval.cpp @@ -14,12 +14,11 @@ #include "TimeInterval.h" -#include "BaseLib/ConfigTree.h" +#include "ConfigTree.h" namespace BaseLib { -std::unique_ptr<TimeInterval> createTimeInterval( - BaseLib::ConfigTree const& config) +TimeInterval createTimeInterval(ConfigTree const& config) { //! \ogs_file_param{prj__time_loop__processes__process__time_interval} auto const& time_interval_config = config.getConfigSubtree("time_interval"); @@ -32,6 +31,6 @@ std::unique_ptr<TimeInterval> createTimeInterval( //! \ogs_file_param{prj__time_loop__processes__process__time_interval__end} time_interval_config.getConfigParameter<double>("end"); - return std::make_unique<BaseLib::TimeInterval>(start_time, end_time); + return {start_time, end_time}; } } // namespace BaseLib diff --git a/BaseLib/TimeInterval.h b/BaseLib/TimeInterval.h index 0ba7f7f131a8b686f18482292d3a7c33c721adae..c02e46c75ea88e74f3ba0357587bc00621a1c61d 100644 --- a/BaseLib/TimeInterval.h +++ b/BaseLib/TimeInterval.h @@ -12,8 +12,6 @@ */ #pragma once -#include <memory> - namespace BaseLib { class ConfigTree; @@ -22,29 +20,18 @@ class ConfigTree; * Class for a time interval, which has a member to check whether the given time * is in this time interval. */ -class TimeInterval final +struct TimeInterval final { public: - TimeInterval(const double start_time, const double end_time) - : _start_time(start_time), _end_time(end_time) - { - } - - TimeInterval(const TimeInterval& time_inverval) = default; - - TimeInterval& operator=(const TimeInterval& time_inverval) = default; - bool contains(const double current_time) const { - return (current_time >= _start_time && current_time <= _end_time); + return (current_time >= start_time && current_time <= end_time); } -private: - double _start_time; - double _end_time; + double start_time; + double end_time; }; -std::unique_ptr<TimeInterval> createTimeInterval( - BaseLib::ConfigTree const& config); +TimeInterval createTimeInterval(ConfigTree const& config); } // namespace BaseLib diff --git a/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp index 612ee76d23b590b43a7d737a29b21774b50dd869..269a6df376aa777658b194c73485c666ddbd2fa4 100644 --- a/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/CreateBoundaryCondition.cpp @@ -10,9 +10,11 @@ #include "CreateBoundaryCondition.h" +#include "BaseLib/TimeInterval.h" #include "BoundaryCondition.h" #include "BoundaryConditionConfig.h" #include "ConstraintDirichletBoundaryCondition.h" +#include "CreateDirichletBoundaryConditionWithinTimeInterval.h" #include "DirichletBoundaryCondition.h" #include "DirichletBoundaryConditionWithinTimeInterval.h" #include "HCNonAdvectiveFreeComponentFlowBoundaryCondition.h" @@ -24,8 +26,6 @@ #include "SolutionDependentDirichletBoundaryCondition.h" #include "VariableDependentNeumannBoundaryCondition.h" -#include "BaseLib/TimeInterval.h" - #ifdef OGS_USE_PYTHON #include "Python/PythonBoundaryCondition.h" #endif diff --git a/ProcessLib/BoundaryCondition/CreateDirichletBoundaryConditionWithinTimeInterval.cpp b/ProcessLib/BoundaryCondition/CreateDirichletBoundaryConditionWithinTimeInterval.cpp new file mode 100644 index 0000000000000000000000000000000000000000..90ef7229614f500256e7a4b62c52b5e36e0e2a79 --- /dev/null +++ b/ProcessLib/BoundaryCondition/CreateDirichletBoundaryConditionWithinTimeInterval.cpp @@ -0,0 +1,63 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "BaseLib/ConfigTree.h" +#include "BaseLib/TimeInterval.h" +#include "DirichletBoundaryConditionWithinTimeInterval.h" +#include "NumLib/DOF/LocalToGlobalIndexMap.h" +#include "ParameterLib/Parameter.h" +#include "ParameterLib/Utils.h" + +namespace ProcessLib +{ + +std::unique_ptr<BoundaryCondition> +createDirichletBoundaryConditionWithinTimeInterval( + BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, + NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, + int const component_id, + const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters) +{ + DBUG( + "Constructing DirichletBoundaryConditionWithinTimeInterval from " + "config."); + + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type} + config.checkConfigParameter("type", "DirichletWithinTimeInterval"); + + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__parameter} + auto const param_name = config.getConfigParameter<std::string>("parameter"); + DBUG("Using parameter {:s}", param_name); + + auto& param = ParameterLib::findParameter<double>(param_name, parameters, 1, + &bc_mesh); + + //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__time_interval} + config.peekConfigParameter<std::string>("time_interval"); + auto time_interval = BaseLib::createTimeInterval(config); + +// In case of partitioned mesh the boundary could be empty, i.e. there is no +// boundary condition. +#ifdef USE_PETSC + // This can be extracted to createBoundaryCondition() but then the config + // 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 (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 && + bc_mesh.getNumberOfElements() == 0) + { + return nullptr; + } +#endif // USE_PETSC + + return std::make_unique<DirichletBoundaryConditionWithinTimeInterval>( + std::move(time_interval), param, bc_mesh, dof_table_bulk, + variable_id, component_id); +} +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/CreateDirichletBoundaryConditionWithinTimeInterval.h b/ProcessLib/BoundaryCondition/CreateDirichletBoundaryConditionWithinTimeInterval.h new file mode 100644 index 0000000000000000000000000000000000000000..cfcf20a6d1772240abe4f5d51c24e25a2d230176 --- /dev/null +++ b/ProcessLib/BoundaryCondition/CreateDirichletBoundaryConditionWithinTimeInterval.h @@ -0,0 +1,41 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include <memory> +#include <vector> + +namespace BaseLib +{ +class ConfigTree; +} + +namespace ParameterLib +{ +template <typename T> +struct Parameter; +} + +namespace ProcessLib +{ +class BoundaryCondition; +} + +namespace ProcessLib +{ +std::unique_ptr<BoundaryCondition> +createDirichletBoundaryConditionWithinTimeInterval( + BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, + NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, + int const component_id, + const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& + parameters); + +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1fcf4942d99640e55e75b50c95a86f8fbd595216 --- /dev/null +++ b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp @@ -0,0 +1,67 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "DeactivatedSubdomainDirichlet.h" + +#include "BaseLib/TimeInterval.h" +#include "DirichletBoundaryCondition.h" +#include "DirichletBoundaryConditionAuxiliaryFunctions.h" +#include "NumLib/DOF/LocalToGlobalIndexMap.h" +#include "NumLib/IndexValueVector.h" +#include "ParameterLib/Parameter.h" +#include "ProcessLib/DeactivatedSubdomain.h" + +namespace ProcessLib +{ +DeactivatedSubdomainDirichlet::DeactivatedSubdomainDirichlet( + BaseLib::TimeInterval const& time_interval, + ParameterLib::Parameter<double> const& parameter, + DeactivatedSubdomainMesh const& subdomain, + NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, + int const component_id) + : _parameter(parameter), + _subdomain(subdomain), + _variable_id(variable_id), + _component_id(component_id), + _time_interval(time_interval) +{ + config(dof_table_bulk); +} + +void DeactivatedSubdomainDirichlet::config( + NumLib::LocalToGlobalIndexMap const& dof_table_bulk) +{ + checkParametersOfDirichletBoundaryCondition(*_subdomain.mesh, dof_table_bulk, + _variable_id, _component_id); + + std::vector<MeshLib::Node*> const& bc_nodes = _subdomain.mesh->getNodes(); + MeshLib::MeshSubset subdomain_mesh_subset(*_subdomain.mesh, bc_nodes); + + // Create local DOF table from the BC mesh subset for the given variable + // and component id. + _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( + _variable_id, {_component_id}, std::move(subdomain_mesh_subset))); +} + +void DeactivatedSubdomainDirichlet::getEssentialBCValues( + const double t, GlobalVector const& x, + NumLib::IndexValueVector<GlobalIndexType>& bc_values) const +{ + if (_time_interval.contains(t)) + { + getEssentialBCValuesLocal(_parameter, *_subdomain.mesh, + _subdomain.inner_nodes, *_dof_table_boundary, + _variable_id, _component_id, t, x, bc_values); + return; + } + + bc_values.ids.clear(); + bc_values.values.clear(); +} +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h new file mode 100644 index 0000000000000000000000000000000000000000..7166e05e56f76853f70e3e4034546c3b08ffcc06 --- /dev/null +++ b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h @@ -0,0 +1,68 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ +#pragma once + +#include <memory> +#include <vector> + +#include "BaseLib/TimeInterval.h" +#include "BoundaryCondition.h" + +namespace BaseLib +{ +class ConfigTree; +} // namespace BaseLib + +namespace MeshLib +{ +class Node; +} + +namespace ParameterLib +{ +template <typename T> +struct Parameter; +} + +namespace ProcessLib +{ +struct DeactivatedSubdomainMesh; +} + +namespace ProcessLib +{ +class DeactivatedSubdomainDirichlet final : public BoundaryCondition +{ +public: + DeactivatedSubdomainDirichlet( + BaseLib::TimeInterval const& time_interval, + ParameterLib::Parameter<double> const& parameter, + DeactivatedSubdomainMesh const& subdomain, + NumLib::LocalToGlobalIndexMap const& dof_table_bulk, + int const variable_id, int const component_id); + + void getEssentialBCValues( + const double t, GlobalVector const& x, + NumLib::IndexValueVector<GlobalIndexType>& bc_values) const override; + +private: + void config(NumLib::LocalToGlobalIndexMap const& dof_table_bulk); + +private: + ParameterLib::Parameter<double> const& _parameter; + + DeactivatedSubdomainMesh const& _subdomain; + + std::unique_ptr<NumLib::LocalToGlobalIndexMap const> _dof_table_boundary; + int const _variable_id; + int const _component_id; + + BaseLib::TimeInterval const _time_interval; +}; +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.cpp b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.cpp index 98eac6d1e97133765b9158d697a41199131ca95f..0061e6142ab6f90e939b7c437a83808295eb1672 100644 --- a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.cpp +++ b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.cpp @@ -14,46 +14,21 @@ #include "DirichletBoundaryCondition.h" #include "DirichletBoundaryConditionAuxiliaryFunctions.h" - -#include "BaseLib/ConfigTree.h" -#include "BaseLib/TimeInterval.h" - #include "NumLib/DOF/LocalToGlobalIndexMap.h" #include "NumLib/IndexValueVector.h" - #include "ParameterLib/Parameter.h" -#include "ParameterLib/Utils.h" namespace ProcessLib { DirichletBoundaryConditionWithinTimeInterval:: DirichletBoundaryConditionWithinTimeInterval( - std::unique_ptr<BaseLib::TimeInterval> time_interval, - ParameterLib::Parameter<double> const& parameter, - MeshLib::Mesh const& bc_mesh, - NumLib::LocalToGlobalIndexMap const& dof_table_bulk, - int const variable_id, int const component_id) - : _parameter(parameter), - _bc_mesh(bc_mesh), - _nodes_in_bc_mesh(bc_mesh.getNodes()), - _variable_id(variable_id), - _component_id(component_id), - _time_interval(std::move(time_interval)) -{ - config(dof_table_bulk); -} - -DirichletBoundaryConditionWithinTimeInterval:: - DirichletBoundaryConditionWithinTimeInterval( - std::unique_ptr<BaseLib::TimeInterval> time_interval, + BaseLib::TimeInterval time_interval, ParameterLib::Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh, - std::vector<MeshLib::Node*> const& nodes_in_bc_mesh, NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, int const component_id) : _parameter(parameter), _bc_mesh(bc_mesh), - _nodes_in_bc_mesh(nodes_in_bc_mesh), _variable_id(variable_id), _component_id(component_id), _time_interval(std::move(time_interval)) @@ -80,9 +55,9 @@ void DirichletBoundaryConditionWithinTimeInterval::getEssentialBCValues( const double t, GlobalVector const& x, NumLib::IndexValueVector<GlobalIndexType>& bc_values) const { - if (_time_interval->contains(t)) + if (_time_interval.contains(t)) { - getEssentialBCValuesLocal(_parameter, _bc_mesh, _nodes_in_bc_mesh, + getEssentialBCValuesLocal(_parameter, _bc_mesh, _bc_mesh.getNodes(), *_dof_table_boundary, _variable_id, _component_id, t, x, bc_values); return; @@ -91,49 +66,4 @@ void DirichletBoundaryConditionWithinTimeInterval::getEssentialBCValues( bc_values.ids.clear(); bc_values.values.clear(); } - -std::unique_ptr<DirichletBoundaryConditionWithinTimeInterval> -createDirichletBoundaryConditionWithinTimeInterval( - BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, - NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, - int const component_id, - const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters) -{ - DBUG( - "Constructing DirichletBoundaryConditionWithinTimeInterval from " - "config."); - - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type} - config.checkConfigParameter("type", "DirichletWithinTimeInterval"); - - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__parameter} - auto const param_name = config.getConfigParameter<std::string>("parameter"); - DBUG("Using parameter {:s}", param_name); - - auto& param = ParameterLib::findParameter<double>(param_name, parameters, 1, - &bc_mesh); - - //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__DirichletWithinTimeInterval__time_interval} - config.peekConfigParameter<std::string>("time_interval"); - auto time_interval = BaseLib::createTimeInterval(config); - -// In case of partitioned mesh the boundary could be empty, i.e. there is no -// boundary condition. -#ifdef USE_PETSC - // This can be extracted to createBoundaryCondition() but then the config - // 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 (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 && - bc_mesh.getNumberOfElements() == 0) - { - return nullptr; - } -#endif // USE_PETSC - - return std::make_unique<DirichletBoundaryConditionWithinTimeInterval>( - std::move(time_interval), param, bc_mesh, dof_table_bulk, - variable_id, component_id); -} - } // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.h b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.h index 087175669d3cdba853cbba3588e14d378f57add3..c6e07e8efb64bcc3178121025e885107b184ab06 100644 --- a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.h +++ b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.h @@ -15,12 +15,13 @@ #include <memory> #include <vector> +#include "BaseLib/TimeInterval.h" #include "BoundaryCondition.h" namespace BaseLib { class ConfigTree; -class TimeInterval; +struct TimeInterval; } namespace MeshLib @@ -41,46 +42,28 @@ class DirichletBoundaryConditionWithinTimeInterval final { public: DirichletBoundaryConditionWithinTimeInterval( - std::unique_ptr<BaseLib::TimeInterval> time_interval, + BaseLib::TimeInterval time_interval, ParameterLib::Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh, NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, int const component_id); - DirichletBoundaryConditionWithinTimeInterval( - std::unique_ptr<BaseLib::TimeInterval> time_interval, - ParameterLib::Parameter<double> const& parameter, - MeshLib::Mesh const& bc_mesh, - std::vector<MeshLib::Node*> const& nodes_in_bc_mesh, - NumLib::LocalToGlobalIndexMap const& dof_table_bulk, - int const variable_id, int const component_id); - void getEssentialBCValues( const double t, GlobalVector const& x, NumLib::IndexValueVector<GlobalIndexType>& bc_values) const override; +private: + void config(NumLib::LocalToGlobalIndexMap const& dof_table_bulk); + private: ParameterLib::Parameter<double> const& _parameter; MeshLib::Mesh const& _bc_mesh; - /// Some nodes in _bc_mesh - std::vector<MeshLib::Node*> const& _nodes_in_bc_mesh; std::unique_ptr<NumLib::LocalToGlobalIndexMap const> _dof_table_boundary; int const _variable_id; int const _component_id; - std::unique_ptr<BaseLib::TimeInterval const> _time_interval; - - void config(NumLib::LocalToGlobalIndexMap const& dof_table_bulk); + BaseLib::TimeInterval const _time_interval; }; - -std::unique_ptr<DirichletBoundaryConditionWithinTimeInterval> -createDirichletBoundaryConditionWithinTimeInterval( - BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh, - NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id, - int const component_id, - const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& - parameters); - } // namespace ProcessLib diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp index b91dedeeec1e6136c81038dce0f8a7a2b416840b..4aa7e563ceca4d468671ed965e4451691bb6001a 100644 --- a/ProcessLib/DeactivatedSubdomain.cpp +++ b/ProcessLib/DeactivatedSubdomain.cpp @@ -33,11 +33,11 @@ DeactivatedSubdomainMesh::DeactivatedSubdomainMesh( } DeactivatedSubdomain::DeactivatedSubdomain( - std::unique_ptr<BaseLib::TimeInterval> time_interval_, + BaseLib::TimeInterval const& time_interval_, std::vector<int>&& materialIDs_, std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&& deactivated_subdomain_meshes_) - : time_interval(std::move(time_interval_)), + : time_interval(time_interval_), materialIDs(std::move(materialIDs_)), deactivated_subdomain_meshes(std::move(deactivated_subdomain_meshes_)) { @@ -45,7 +45,7 @@ DeactivatedSubdomain::DeactivatedSubdomain( bool DeactivatedSubdomain::includesTimeOf(double const t) const { - return time_interval->contains(t); + return time_interval.contains(t); } template <typename IsActive> @@ -149,7 +149,7 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( } return std::make_unique<DeactivatedSubdomain const>( - std::move(time_interval), + time_interval, std::move(deactivated_subdomain_material_ids), std::move(deactivated_subdomain_meshes)); } diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h index 75385e7d33a1ac8b9a6c5e4cbf140e3d10d0070a..a752bb44e12616600bdb89a27552197b3f6651f3 100644 --- a/ProcessLib/DeactivatedSubdomain.h +++ b/ProcessLib/DeactivatedSubdomain.h @@ -17,9 +17,6 @@ #include <string> #include <vector> -// TimeInterval cannot be forwardly declared because that -// std::unique_ptr<BaseLib::TimeInterval> type member requires its full -// definition (see https://stackoverflow.com/a/6089065). #include "BaseLib/TimeInterval.h" namespace BaseLib @@ -48,14 +45,14 @@ struct DeactivatedSubdomainMesh struct DeactivatedSubdomain { DeactivatedSubdomain( - std::unique_ptr<BaseLib::TimeInterval> time_interval_, + BaseLib::TimeInterval const& time_interval_, std::vector<int>&& materialIDs_, std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&& deactivated_subdomain_meshes_); bool includesTimeOf(double const t) const; - std::unique_ptr<BaseLib::TimeInterval const> const time_interval; + BaseLib::TimeInterval const time_interval; /// The material IDs of the deactivated the subdomains std::vector<int> const materialIDs; diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 990bdf1c6b23024d019276cd692342580951d9e8..5c14b4fcbe69ff4cb08af465890a95cd5d498ab7 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -12,9 +12,9 @@ #include <algorithm> #include <utility> -#include "BaseLib/Logging.h" #include "BaseLib/Algorithm.h" +#include "BaseLib/Logging.h" #include "BaseLib/TimeInterval.h" #include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h" #include "MeshLib/Mesh.h" @@ -22,7 +22,7 @@ #include "ParameterLib/Utils.h" #include "ProcessLib/BoundaryCondition/BoundaryCondition.h" #include "ProcessLib/BoundaryCondition/CreateBoundaryCondition.h" -#include "ProcessLib/BoundaryCondition/DirichletBoundaryConditionWithinTimeInterval.h" +#include "ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h" #include "ProcessLib/SourceTerms/CreateSourceTerm.h" #include "ProcessLib/SourceTerms/SourceTerm.h" @@ -252,17 +252,10 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( dof_table.getNumberOfVariableComponents(variable_id); component_id++) { - // Copy the time interval. - std::unique_ptr<BaseLib::TimeInterval> time_interval = - std::make_unique<BaseLib::TimeInterval>( - *deactivated_subdomain->time_interval); - - auto bc = std::make_unique< - DirichletBoundaryConditionWithinTimeInterval>( - std::move(time_interval), parameter, - *(deactivated_subdomain_mesh->mesh), - deactivated_subdomain_mesh->inner_nodes, dof_table, - variable_id, component_id); + auto bc = std::make_unique<DeactivatedSubdomainDirichlet>( + deactivated_subdomain->time_interval, parameter, + *deactivated_subdomain_mesh, dof_table, variable_id, + component_id); #ifdef USE_PETSC // TODO: make it work under PETSc too. @@ -279,12 +272,6 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( void ProcessVariable::updateDeactivatedSubdomains(double const time) { - if (_deactivated_subdomains.empty()) - { - _ids_of_active_elements.clear(); - return; - } - auto found_a_set = std::find_if(_deactivated_subdomains.begin(), _deactivated_subdomains.end(), diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index c62fe569fedc591defe5f85760891b29707a634d..afa8edfefb2d022b6d71d5f3d25bef26a7830c27 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -67,7 +67,7 @@ public: void updateDeactivatedSubdomains(double const time); - std::vector<std::size_t>& getActiveElementIDs() const + std::vector<std::size_t> const& getActiveElementIDs() const { return _ids_of_active_elements; }