diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp index a22b6c4b53b4adc131c4d5718e84a12821b77118..cf5bb499a275de7e8f784dac6ff0ce4badac96ac 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp @@ -39,11 +39,11 @@ DeactivatedSubdomainDirichlet::DeactivatedSubdomainDirichlet( void DeactivatedSubdomainDirichlet::config( NumLib::LocalToGlobalIndexMap const& dof_table_bulk) { - checkParametersOfDirichletBoundaryCondition( - *_subdomain.mesh, dof_table_bulk, _variable_id, _component_id); + 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); + 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. @@ -56,7 +56,7 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( NumLib::IndexValueVector<GlobalIndexType>& bc_values) const { auto const& bulk_element_ids = - *_subdomain.mesh->getProperties() + *_subdomain.mesh.getProperties() .template getPropertyVector<std::size_t>( "bulk_element_ids", MeshLib::MeshItemType::Cell, 1); @@ -73,7 +73,7 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( [&](std::size_t const n) { const auto& connected_elements = - _subdomain.mesh->getElementsConnectedToNode(n); + _subdomain.mesh.getElementsConnectedToNode(n); return std::all_of(begin(connected_elements), end(connected_elements), is_inactive); @@ -86,7 +86,7 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( [&](std::size_t const n) { const auto& connected_elements = - _subdomain.mesh->getElementsConnectedToNode(n); + _subdomain.mesh.getElementsConnectedToNode(n); return std::all_of(begin(connected_elements), end(connected_elements), @@ -102,7 +102,7 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues( if (time_interval_contains(t)) { getEssentialBCValuesLocal( - _parameter, *_subdomain.mesh, inactive_nodes_in_bc_mesh, + _parameter, _subdomain.mesh, inactive_nodes_in_bc_mesh, *_dof_table_boundary, _variable_id, _component_id, t, x, bc_values); return; } diff --git a/ProcessLib/CreateDeactivatedSubdomain.cpp b/ProcessLib/CreateDeactivatedSubdomain.cpp index e80714eca57ff6cfdc8c5cd9c954a453e22a0b90..6c3f2293d3245b041c73fce2d8435f845c385651 100644 --- a/ProcessLib/CreateDeactivatedSubdomain.cpp +++ b/ProcessLib/CreateDeactivatedSubdomain.cpp @@ -67,7 +67,7 @@ extractInnerAndOuterNodes(MeshLib::Mesh const& mesh, return {std::move(inner_nodes), std::move(outer_nodes)}; } -static std::unique_ptr<DeactivatedSubdomainMesh> createDeactivatedSubdomainMesh( +static DeactivatedSubdomainMesh createDeactivatedSubdomainMesh( MeshLib::Mesh const& mesh, std::vector<int> const& deactivated_subdomain_material_ids) { @@ -99,9 +99,9 @@ static std::unique_ptr<DeactivatedSubdomainMesh> createDeactivatedSubdomainMesh( auto [inner_nodes, outer_nodes] = extractInnerAndOuterNodes(mesh, *sub_mesh, is_active); - return std::make_unique<DeactivatedSubdomainMesh>( - std::move(sub_mesh), std::move(bulk_element_ids), - std::move(inner_nodes), std::move(outer_nodes)); + + return {std::move(*sub_mesh), std::move(bulk_element_ids), + std::move(inner_nodes), std::move(outer_nodes)}; } static MathLib::PiecewiseLinearInterpolation parseTimeIntervalOrCurve( @@ -187,7 +187,7 @@ static std::pair<Eigen::Vector3d, Eigen::Vector3d> parseLineSegment( Eigen::Vector3d{end[0], end[1], end[2]}}; } -std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( +DeactivatedSubdomain createDeactivatedSubdomain( BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters, std::map<std::string, @@ -266,15 +266,11 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( auto deactivated_subdomain_mesh = createDeactivatedSubdomainMesh( mesh, deactivated_subdomain_material_ids); - return std::make_unique<DeactivatedSubdomain const>( - std::move(time_interval), - line_segment, - std::move(deactivated_subdomain_mesh), - boundary_value_parameter); + return {std::move(time_interval), line_segment, + std::move(deactivated_subdomain_mesh), boundary_value_parameter}; } -std::vector<std::unique_ptr<DeactivatedSubdomain const>> -createDeactivatedSubdomains( +std::vector<DeactivatedSubdomain> createDeactivatedSubdomains( BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters, @@ -282,8 +278,7 @@ createDeactivatedSubdomains( std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const& curves) { - std::vector<std::unique_ptr<DeactivatedSubdomain const>> - deactivated_subdomains; + std::vector<DeactivatedSubdomain> deactivated_subdomains; // Deactivated subdomains if (auto subdomains_config = //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains} diff --git a/ProcessLib/CreateDeactivatedSubdomain.h b/ProcessLib/CreateDeactivatedSubdomain.h index cac52e10e260b26ccd7231515198b095033337ec..0acce2a05ec5581affb71b52b93ee30d5b98cb42 100644 --- a/ProcessLib/CreateDeactivatedSubdomain.h +++ b/ProcessLib/CreateDeactivatedSubdomain.h @@ -41,8 +41,7 @@ struct DeactivatedSubdomain; } namespace ProcessLib { -std::vector<std::unique_ptr<DeactivatedSubdomain const>> -createDeactivatedSubdomains( +std::vector<DeactivatedSubdomain> createDeactivatedSubdomains( BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh, std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters, diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp index 2cc06d9a022c7c07097a8941a42cbe949e13644c..40bc97cfa9dfd6d219686bb0fa0da5b55a4a6331 100644 --- a/ProcessLib/DeactivatedSubdomain.cpp +++ b/ProcessLib/DeactivatedSubdomain.cpp @@ -14,7 +14,6 @@ #include "BaseLib/Error.h" #include "MeshLib/Elements/Element.h" -#include "MeshLib/Mesh.h" #include "MeshLib/Node.h" #include "ParameterLib/Parameter.h" @@ -23,31 +22,6 @@ namespace ProcessLib const std::string DeactivatedSubdomain::zero_parameter_name = "zero_for_element_deactivation_approach"; -DeactivatedSubdomainMesh::DeactivatedSubdomainMesh( - std::unique_ptr<MeshLib::Mesh> deactivated_subdomain_mesh_, - std::vector<std::size_t>&& bulk_element_ids_, - std::vector<std::size_t>&& inner_nodes_, - std::vector<std::size_t>&& outer_nodes_) - : mesh(std::move(deactivated_subdomain_mesh_)), - bulk_element_ids(std::move(bulk_element_ids_)), - inner_nodes(std::move(inner_nodes_)), - outer_nodes(std::move(outer_nodes_)) -{ -} - -DeactivatedSubdomain::DeactivatedSubdomain( - MathLib::PiecewiseLinearInterpolation time_interval_, - std::optional<std::pair<Eigen::Vector3d, Eigen::Vector3d>> - line_segment, - std::unique_ptr<DeactivatedSubdomainMesh>&& deactivated_subdomain_mesh_, - ParameterLib::Parameter<double> const* const boundary_value_parameter) - : time_interval(std::move(time_interval_)), - line_segment(line_segment), - deactivated_subdomain_mesh(std::move(deactivated_subdomain_mesh_)), - boundary_value_parameter(boundary_value_parameter) -{ -} - bool DeactivatedSubdomain::isInTimeSupportInterval(double const t) const { return time_interval.getSupportMin() <= t && @@ -57,7 +31,7 @@ bool DeactivatedSubdomain::isInTimeSupportInterval(double const t) const bool DeactivatedSubdomain::isDeactivated(MeshLib::Element const& element, double const time) const { - auto const& bulk_element_ids = deactivated_subdomain_mesh->bulk_element_ids; + auto const& bulk_element_ids = deactivated_subdomain_mesh.bulk_element_ids; if (!BaseLib::contains(bulk_element_ids, element.getID())) { return false; diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h index b18d1fccf984afcd5e74964bd0b14483d5d1bb18..8dfd740bddcfd994a2b9afaeaf09a4f037edec76 100644 --- a/ProcessLib/DeactivatedSubdomain.h +++ b/ProcessLib/DeactivatedSubdomain.h @@ -20,13 +20,12 @@ #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h" #include "MathLib/Point3d.h" +#include "MeshLib/Mesh.h" #include "processlib_export.h" namespace MeshLib { class Element; -class Mesh; -class Node; } // namespace MeshLib namespace ParameterLib @@ -39,16 +38,10 @@ namespace ProcessLib { struct DeactivatedSubdomainMesh { - DeactivatedSubdomainMesh( - std::unique_ptr<MeshLib::Mesh> deactivated_subdomain_mesh_, - std::vector<std::size_t>&& bulk_element_ids_, - std::vector<std::size_t>&& inner_nodes_, - std::vector<std::size_t>&& outer_nodes_); - /// A mesh created from material ids (independent of time) for the /// deactivated subdomain. - std::unique_ptr<MeshLib::Mesh> const mesh; - std::vector<std::size_t> const bulk_element_ids; + MeshLib::Mesh mesh; + std::vector<std::size_t> bulk_element_ids; /// Inner nodes owned only by elements of the deactivated subdomain. /// \see ProcessLib::createDeactivatedSubdomainMesh() @@ -80,13 +73,6 @@ struct DeactivatedSubdomainMesh /// between the active and inactive elements are not affected. struct DeactivatedSubdomain { - DeactivatedSubdomain( - MathLib::PiecewiseLinearInterpolation time_interval_, - std::optional<std::pair<Eigen::Vector3d, Eigen::Vector3d>> - line_segment, - std::unique_ptr<DeactivatedSubdomainMesh>&& deactivated_subdomain_mesh_, - ParameterLib::Parameter<double> const* boundary_value_parameter); - /// \returns true if the given time is included in the subdomains time /// support interval. bool isInTimeSupportInterval(double const t) const; @@ -101,17 +87,17 @@ struct DeactivatedSubdomain bool isDeactivated(MeshLib::Element const& element, double const time) const; - MathLib::PiecewiseLinearInterpolation const time_interval; + MathLib::PiecewiseLinearInterpolation time_interval; /// Line segment along which excavation progresses. Represented by start and /// end points. std::optional<std::pair<Eigen::Vector3d, Eigen::Vector3d>> line_segment; - std::unique_ptr<DeactivatedSubdomainMesh> const deactivated_subdomain_mesh; + DeactivatedSubdomainMesh deactivated_subdomain_mesh; /// A pararameter for the optional Dirichlet boundary condition applied on /// the surface of the deactivated subdomain/excavation. - ParameterLib::Parameter<double> const* const boundary_value_parameter; + ParameterLib::Parameter<double> const* boundary_value_parameter; PROCESSLIB_EXPORT static const std::string zero_parameter_name; }; diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 837d09da665e92160c9660a63fd44cfd9028b104..d77badc33b5f8fe3dd9ae6904be8363887b988bd 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -192,20 +192,7 @@ ProcessVariable::ProcessVariable( { INFO("No source terms for process variable '{:s}' found.", _name); } -} -ProcessVariable::ProcessVariable(ProcessVariable&& other) - : _name(std::move(other._name)), - _mesh(other._mesh), - _n_components(other._n_components), - _shapefunction_order(other._shapefunction_order), - _deactivated_subdomains(std::move(other._deactivated_subdomains)), - _initial_condition(std::move(other._initial_condition)), - _bc_configs(std::move(other._bc_configs)), - _source_term_configs(std::move(other._source_term_configs)), - _compensate_non_equilibrium_initial_residuum( - other._compensate_non_equilibrium_initial_residuum) -{ } std::string const& ProcessVariable::getName() const @@ -264,14 +251,14 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( for (auto const& deactivated_subdomain : _deactivated_subdomains) { auto const& deactivated_subdomain_mesh = - deactivated_subdomain->deactivated_subdomain_mesh; + deactivated_subdomain.deactivated_subdomain_mesh; auto const* parameter = &ParameterLib::findParameter<double>( DeactivatedSubdomain::zero_parameter_name, parameters, 1); bool const set_outer_nodes_dirichlet_values = - deactivated_subdomain->boundary_value_parameter != nullptr; + deactivated_subdomain.boundary_value_parameter != nullptr; if (set_outer_nodes_dirichlet_values) { - parameter = deactivated_subdomain->boundary_value_parameter; + parameter = deactivated_subdomain.boundary_value_parameter; } for (int component_id = 0; @@ -280,9 +267,9 @@ void ProcessVariable::createBoundaryConditionsForDeactivatedSubDomains( component_id++) { auto bc = std::make_unique<DeactivatedSubdomainDirichlet>( - &_ids_of_active_elements, deactivated_subdomain->time_interval, + &_ids_of_active_elements, deactivated_subdomain.time_interval, *parameter, set_outer_nodes_dirichlet_values, - *deactivated_subdomain_mesh, dof_table, variable_id, + deactivated_subdomain_mesh, dof_table, variable_id, component_id); #ifdef USE_PETSC @@ -305,7 +292,7 @@ void ProcessVariable::updateDeactivatedSubdomains(double const time) // _ids_of_active_elements remain empty. if (std::none_of( begin(_deactivated_subdomains), end(_deactivated_subdomains), - [&](auto const& ds) { return ds->isInTimeSupportInterval(time); })) + [&](auto const& ds) { return ds.isInTimeSupportInterval(time); })) { return; } @@ -324,7 +311,7 @@ void ProcessVariable::updateDeactivatedSubdomains(double const time) if (std::all_of(begin(_deactivated_subdomains), end(_deactivated_subdomains), [&](auto const& ds) - { return is_active_in_subdomain(element_id, *ds); })) + { return is_active_in_subdomain(element_id, ds); })) { _ids_of_active_elements.push_back(element_id); } diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index 50265a420550b5bbdfdc4fd8399f9515defd0251..68a54f2dd8499954812f1528983123674cb38fde 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -54,15 +54,14 @@ public: std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const& curves); - ProcessVariable(ProcessVariable&& other); + ProcessVariable(ProcessVariable&& other) = default; std::string const& getName() const; /// Returns a mesh on which the process variable is defined. MeshLib::Mesh const& getMesh() const; - std::vector<std::unique_ptr<DeactivatedSubdomain const>> const& - getDeactivatedSubdomains() const + std::vector<DeactivatedSubdomain> const& getDeactivatedSubdomains() const { return _deactivated_subdomains; } @@ -125,8 +124,7 @@ private: /// \sa MeshLib::CellRule MeshLib::FaceRule MeshLib::EdgeRule. unsigned _shapefunction_order; - std::vector<std::unique_ptr<DeactivatedSubdomain const>> - _deactivated_subdomains; + std::vector<DeactivatedSubdomain> _deactivated_subdomains; /// IDs of the active elements. It is initialized only if there are /// deactivated subdomains.