Skip to content
Snippets Groups Projects
Commit 5ad524d2 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL/DS] Extract also the outer nodes.

parent 897541b9
No related branches found
No related tags found
No related merge requests found
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
namespace ProcessLib namespace ProcessLib
{ {
template <typename IsActive> template <typename IsActive>
static std::vector<MeshLib::Node*> extractInnerNodes( static std::pair<std::vector<MeshLib::Node*>, std::vector<MeshLib::Node*>>
MeshLib::Mesh const& mesh, extractInnerAndOuterNodes(MeshLib::Mesh const& mesh,
MeshLib::Mesh const& sub_mesh, MeshLib::Mesh const& sub_mesh,
IsActive is_active) IsActive is_active)
{ {
auto* const bulk_node_ids = auto* const bulk_node_ids =
sub_mesh.getProperties().template getPropertyVector<std::size_t>( sub_mesh.getProperties().template getPropertyVector<std::size_t>(
...@@ -38,21 +38,25 @@ static std::vector<MeshLib::Node*> extractInnerNodes( ...@@ -38,21 +38,25 @@ static std::vector<MeshLib::Node*> extractInnerNodes(
std::vector<MeshLib::Node*> inner_nodes; std::vector<MeshLib::Node*> inner_nodes;
// Reserve for more than needed, but not much, because almost all nodes will // Reserve for more than needed, but not much, because almost all nodes will
// be found and copied. // be the inner nodes.
inner_nodes.reserve(sub_mesh.getNumberOfNodes()); inner_nodes.reserve(sub_mesh.getNumberOfNodes());
std::copy_if(begin(sub_mesh.getNodes()), end(sub_mesh.getNodes()),
back_inserter(inner_nodes), [&](MeshLib::Node* const n) { std::vector<MeshLib::Node*> outer_nodes;
auto const bulk_node =
mesh.getNode((*bulk_node_ids)[n->getID()]); std::partition_copy(
const auto& connected_elements = bulk_node->getElements(); begin(sub_mesh.getNodes()), end(sub_mesh.getNodes()),
back_inserter(inner_nodes), back_inserter(outer_nodes),
// Check whether this node is connected to an active [&](MeshLib::Node* const n) {
// element. auto const bulk_node = mesh.getNode((*bulk_node_ids)[n->getID()]);
return std::all_of(begin(connected_elements), const auto& connected_elements = bulk_node->getElements();
end(connected_elements), is_active);
}); // Check whether this node is connected only to an active
// elements. Then it is an inner node, and outer otherwise.
return inner_nodes; return std::all_of(begin(connected_elements),
end(connected_elements), is_active);
});
return {std::move(inner_nodes), std::move(outer_nodes)};
} }
static std::unique_ptr<DeactivatedSubdomainMesh> createDeactivatedSubdomainMesh( static std::unique_ptr<DeactivatedSubdomainMesh> createDeactivatedSubdomainMesh(
...@@ -75,9 +79,10 @@ static std::unique_ptr<DeactivatedSubdomainMesh> createDeactivatedSubdomainMesh( ...@@ -75,9 +79,10 @@ static std::unique_ptr<DeactivatedSubdomainMesh> createDeactivatedSubdomainMesh(
"deactivate_subdomain_" + std::to_string(material_id), "deactivate_subdomain_" + std::to_string(material_id),
MeshLib::cloneElements(deactivated_elements)); MeshLib::cloneElements(deactivated_elements));
auto inner_nodes = extractInnerNodes(mesh, *sub_mesh, is_active); auto [inner_nodes, outer_nodes] =
return std::make_unique<DeactivatedSubdomainMesh>(std::move(sub_mesh), extractInnerAndOuterNodes(mesh, *sub_mesh, is_active);
std::move(inner_nodes)); return std::make_unique<DeactivatedSubdomainMesh>(
std::move(sub_mesh), std::move(inner_nodes), std::move(outer_nodes));
} }
static MathLib::PiecewiseLinearInterpolation parseTimeIntervalOrCurve( static MathLib::PiecewiseLinearInterpolation parseTimeIntervalOrCurve(
......
...@@ -24,9 +24,11 @@ const std::string DeactivatedSubdomain::zero_parameter_name = ...@@ -24,9 +24,11 @@ const std::string DeactivatedSubdomain::zero_parameter_name =
DeactivatedSubdomainMesh::DeactivatedSubdomainMesh( DeactivatedSubdomainMesh::DeactivatedSubdomainMesh(
std::unique_ptr<MeshLib::Mesh> deactivated_subdomain_mesh_, std::unique_ptr<MeshLib::Mesh> deactivated_subdomain_mesh_,
std::vector<MeshLib::Node*>&& inner_nodes_) std::vector<MeshLib::Node*>&& inner_nodes_,
std::vector<MeshLib::Node*>&& outer_nodes_)
: mesh(std::move(deactivated_subdomain_mesh_)), : mesh(std::move(deactivated_subdomain_mesh_)),
inner_nodes(std::move(inner_nodes_)) inner_nodes(std::move(inner_nodes_)),
outer_nodes(std::move(outer_nodes_))
{ {
} }
......
...@@ -32,10 +32,12 @@ struct DeactivatedSubdomainMesh ...@@ -32,10 +32,12 @@ struct DeactivatedSubdomainMesh
{ {
DeactivatedSubdomainMesh( DeactivatedSubdomainMesh(
std::unique_ptr<MeshLib::Mesh> deactivated_subdomain_mesh_, std::unique_ptr<MeshLib::Mesh> deactivated_subdomain_mesh_,
std::vector<MeshLib::Node*>&& inner_nodes_); std::vector<MeshLib::Node*>&& inner_nodes_,
std::vector<MeshLib::Node*>&& outer_nodes_);
std::unique_ptr<MeshLib::Mesh> const mesh; std::unique_ptr<MeshLib::Mesh> const mesh;
std::vector<MeshLib::Node*> const inner_nodes; std::vector<MeshLib::Node*> const inner_nodes;
std::vector<MeshLib::Node*> const outer_nodes;
}; };
/// Time depend subdomain deactivation. /// Time depend subdomain deactivation.
......
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