Skip to content
Snippets Groups Projects
Commit 4209d23a authored by wenqing's avatar wenqing
Browse files

[deactivation] Added members to ProcessVariable for element deactivation

parent 85178bd5
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,11 @@ DeactivatedSubdomain::DeactivatedSubdomain( ...@@ -47,6 +47,11 @@ DeactivatedSubdomain::DeactivatedSubdomain(
{ {
} }
bool DeactivatedSubdomain::includesTimeOf(double const t) const
{
return time_interval->contains(t);
}
std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain(
BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh) BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh)
{ {
......
...@@ -21,13 +21,13 @@ namespace BaseLib ...@@ -21,13 +21,13 @@ namespace BaseLib
{ {
class ConfigTree; class ConfigTree;
class TimeInterval; class TimeInterval;
} } // namespace BaseLib
namespace MeshLib namespace MeshLib
{ {
class Mesh; class Mesh;
class Node; class Node;
} } // namespace MeshLib
namespace ProcessLib namespace ProcessLib
{ {
...@@ -49,6 +49,8 @@ struct DeactivatedSubdomain ...@@ -49,6 +49,8 @@ struct DeactivatedSubdomain
std::vector<std::unique_ptr<DeactivetedSubdomainMesh>>&& std::vector<std::unique_ptr<DeactivetedSubdomainMesh>>&&
deactivated_sudomain_meshes_); deactivated_sudomain_meshes_);
bool includesTimeOf(double const t) const;
std::unique_ptr<BaseLib::TimeInterval const> time_interval; std::unique_ptr<BaseLib::TimeInterval const> time_interval;
/// The material IDs of the deactivated the subdomains /// The material IDs of the deactivated the subdomains
...@@ -64,4 +66,4 @@ std::vector<std::unique_ptr<DeactivatedSubdomain const>> ...@@ -64,4 +66,4 @@ std::vector<std::unique_ptr<DeactivatedSubdomain const>>
createDeactivatedSubdomains(BaseLib::ConfigTree const& config, createDeactivatedSubdomains(BaseLib::ConfigTree const& config,
MeshLib::Mesh const& mesh); MeshLib::Mesh const& mesh);
} // end of namespace } // namespace ProcessLib
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "ProcessVariable.h" #include "ProcessVariable.h"
#include <iostream>
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
...@@ -55,8 +57,6 @@ MeshLib::Mesh const& findMeshInConfig( ...@@ -55,8 +57,6 @@ MeshLib::Mesh const& findMeshInConfig(
} }
else else
{ {
// Looking for the mesh created before for the given geometry.
#ifdef DOXYGEN_DOCU_ONLY #ifdef DOXYGEN_DOCU_ONLY
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__geometrical_set} //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__geometrical_set}
config.getConfigParameterOptional<std::string>("geometrical_set"); config.getConfigParameterOptional<std::string>("geometrical_set");
...@@ -64,6 +64,7 @@ MeshLib::Mesh const& findMeshInConfig( ...@@ -64,6 +64,7 @@ MeshLib::Mesh const& findMeshInConfig(
config.getConfigParameter<std::string>("geometry"); config.getConfigParameter<std::string>("geometry");
#endif // DOXYGEN_DOCU_ONLY #endif // DOXYGEN_DOCU_ONLY
// Looking for the mesh created before for the given geometry.
auto const geometrical_set_name = auto const geometrical_set_name =
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometrical_set} //! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometrical_set}
config.getConfigParameter<std::string>("geometrical_set"); config.getConfigParameter<std::string>("geometrical_set");
...@@ -237,11 +238,6 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( ...@@ -237,11 +238,6 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains(
for (auto const& deactivated_subdomain : _deactivated_subdomains) for (auto const& deactivated_subdomain : _deactivated_subdomains)
{ {
// Copy the time interval.
std::unique_ptr<BaseLib::TimeInterval> time_interval =
std::make_unique<BaseLib::TimeInterval>(
(*(*deactivated_subdomain).time_interval));
auto const& deactivated_sudomain_meshes = auto const& deactivated_sudomain_meshes =
(*deactivated_subdomain).deactivated_sudomain_meshes; (*deactivated_subdomain).deactivated_sudomain_meshes;
for (auto const& deactivated_sudomain_mesh : for (auto const& deactivated_sudomain_mesh :
...@@ -251,6 +247,11 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( ...@@ -251,6 +247,11 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains(
component_id < dof_table.getNumberOfComponents(); component_id < dof_table.getNumberOfComponents();
component_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< auto bc = std::make_unique<
DirichletBoundaryConditionWithinTimeInterval>( DirichletBoundaryConditionWithinTimeInterval>(
std::move(time_interval), parameter, std::move(time_interval), parameter,
...@@ -270,6 +271,46 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( ...@@ -270,6 +271,46 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains(
} }
} }
void ProcessVariable::checkElementDeactivation(double const time)
{
if (_deactivated_subdomains.empty())
{
_element_deactivation_flags.clear();
return;
}
auto found_a_set =
std::find_if(_deactivated_subdomains.begin(),
_deactivated_subdomains.end(),
[&](auto& _deactivated_subdomain) {
return _deactivated_subdomain->includesTimeOf(time);
});
if (found_a_set == _deactivated_subdomains.end())
{
_element_deactivation_flags.clear();
return;
}
// Already initialized.
if (!_element_deactivation_flags.empty())
return;
auto const& deactivated_materialIDs = (*found_a_set)->materialIDs;
auto const* const material_ids = MeshLib::materialIDs(_mesh);
_element_deactivation_flags.resize(_mesh.getNumberOfElements());
auto const number_of_elements = _mesh.getNumberOfElements();
for (std::size_t i = 0; i < number_of_elements; i++)
{
_element_deactivation_flags[i] =
std::binary_search(deactivated_materialIDs.begin(),
deactivated_materialIDs.end(),
(*material_ids)[i]);
}
}
std::vector<std::unique_ptr<SourceTerm>> ProcessVariable::createSourceTerms( std::vector<std::unique_ptr<SourceTerm>> ProcessVariable::createSourceTerms(
const NumLib::LocalToGlobalIndexMap& dof_table, const NumLib::LocalToGlobalIndexMap& dof_table,
const int variable_id, const int variable_id,
......
...@@ -60,6 +60,13 @@ public: ...@@ -60,6 +60,13 @@ public:
return _deactivated_subdomains; return _deactivated_subdomains;
} }
void checkElementDeactivation(double const time);
std::vector<bool>& getElementDeactivationFlags() const
{
return _element_deactivation_flags;
}
/// Returns the number of components of the process variable. /// Returns the number of components of the process variable.
int getNumberOfComponents() const { return _n_components; } int getNumberOfComponents() const { return _n_components; }
std::vector<std::unique_ptr<BoundaryCondition>> createBoundaryConditions( std::vector<std::unique_ptr<BoundaryCondition>> createBoundaryConditions(
...@@ -101,6 +108,8 @@ private: ...@@ -101,6 +108,8 @@ private:
std::vector<std::unique_ptr<DeactivatedSubdomain const>> std::vector<std::unique_ptr<DeactivatedSubdomain const>>
_deactivated_subdomains; _deactivated_subdomains;
mutable std::vector<bool> _element_deactivation_flags;
void createBoundaryConditionsForDeactivatedSubDomains( void createBoundaryConditionsForDeactivatedSubDomains(
const NumLib::LocalToGlobalIndexMap& dof_table, const int variable_id, const NumLib::LocalToGlobalIndexMap& dof_table, const int variable_id,
std::vector<std::unique_ptr<ParameterBase>> const& parameters, std::vector<std::unique_ptr<ParameterBase>> const& parameters,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment