OGS
NodePartitionedMesh.cpp
Go to the documentation of this file.
1
11
12#include "NodePartitionedMesh.h"
13
14namespace MeshLib
15{
16std::vector<int> getEndNodeIDRanks(
17 std::size_t const n_global_nodes,
18 std::vector<std::size_t> const& n_regular_base_nodes_at_rank,
19 std::vector<std::size_t> const& n_regular_high_order_nodes_at_rank)
20{
21 std::vector<int> data;
22
23 std::transform(n_regular_base_nodes_at_rank.begin() + 1,
24 n_regular_base_nodes_at_rank.end(),
25 n_regular_high_order_nodes_at_rank.begin() + 1,
26 std::back_inserter(data), std::plus<int>());
27
28 data.push_back(n_global_nodes);
29
30 return data;
31}
32
34 const std::string& name,
35 const std::vector<Node*>& nodes,
36 const std::vector<std::size_t>& glb_node_ids,
37 const std::vector<Element*>& elements,
38 Properties const& properties,
39 const std::size_t n_global_base_nodes,
40 const std::size_t n_global_nodes,
41 const std::size_t n_regular_nodes,
42 std::vector<std::size_t>&& n_regular_base_nodes_at_rank,
43 std::vector<std::size_t>&& n_regular_high_order_nodes_at_rank)
44 : Mesh(name, nodes, elements, true /* compute_element_neighbors */,
45 properties),
46 _global_node_ids(glb_node_ids),
47 _n_global_base_nodes(n_global_base_nodes),
48 _n_global_nodes(n_global_nodes),
49 _n_regular_nodes(n_regular_nodes),
50 _n_regular_base_nodes_at_rank(std::move(n_regular_base_nodes_at_rank)),
52 std::move(n_regular_high_order_nodes_at_rank)),
57{
58}
59
60bool NodePartitionedMesh::isGhostNode(const std::size_t node_id) const
61{
62 return node_id >= _n_regular_nodes;
63}
64
66{
67 auto const& nodes_connections =
69 auto const max_connections = std::max_element(
70 nodes_connections.cbegin(), nodes_connections.cend(),
71 [](auto const& connections_node_a, auto const& connections_node_b)
72 { return (connections_node_a.size() < connections_node_b.size()); });
73 // Return the number of connected nodes +1 for the node itself.
74 return static_cast<std::size_t>(max_connections->size() + 1);
75}
76
78 const std::size_t global_node_id) const
79{
80 return std::upper_bound(std::cbegin(_end_node_id_at_rank),
81 std::cend(_end_node_id_at_rank),
82 global_node_id) -
84}
85} // namespace MeshLib
Definition of mesh class for partitioned mesh (by node) for parallel computing within the framework o...
Mesh(std::string name, std::vector< Node * > nodes, std::vector< Element * > elements, bool const compute_element_neighbors=false, Properties const &properties=Properties())
Definition Mesh.cpp:63
std::size_t _n_global_base_nodes
Number of the nodes of the global mesh linear interpolations.
std::size_t getPartitionID(const std::size_t global_node_id) const
bool isGhostNode(const std::size_t node_id) const
Check whether a node with ID of node_id is a ghost node.
std::vector< std::size_t > _global_node_ids
Global IDs of nodes of a partition.
std::vector< std::size_t > _n_regular_base_nodes_at_rank
std::size_t _n_regular_nodes
Number of the all regular nodes.
std::vector< std::size_t > _n_regular_high_order_nodes_at_rank
Gathered numbers of the all regular high order nodes of all partitions.
std::vector< int > _end_node_id_at_rank
Gathered the end node id of each rank.
std::size_t getMaximumNConnectedNodesToNode() const
Get the maximum number of connected nodes to node.
std::size_t _n_global_nodes
Number of all nodes of the global mesh.
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
std::vector< std::vector< Node * > > calculateNodesConnectedByElements(Mesh const &mesh)
Definition Mesh.cpp:309
std::vector< int > getEndNodeIDRanks(std::size_t const n_global_nodes, std::vector< std::size_t > const &n_regular_base_nodes_at_rank, std::vector< std::size_t > const &n_regular_high_order_nodes_at_rank)