OGS
NodePartitionedMesh.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6namespace MeshLib
7{
8std::vector<int> getEndNodeIDRanks(
9 std::size_t const n_global_nodes,
10 std::vector<std::size_t> const& n_regular_base_nodes_at_rank,
11 std::vector<std::size_t> const& n_regular_high_order_nodes_at_rank)
12{
13 std::vector<int> data;
14
15 std::transform(n_regular_base_nodes_at_rank.begin() + 1,
16 n_regular_base_nodes_at_rank.end(),
17 n_regular_high_order_nodes_at_rank.begin() + 1,
18 std::back_inserter(data), std::plus<int>());
19
20 data.push_back(n_global_nodes);
21
22 return data;
23}
24
26 const std::string& name,
27 const std::vector<Node*>& nodes,
28 const std::vector<std::size_t>& glb_node_ids,
29 const std::vector<Element*>& elements,
30 Properties const& properties,
31 const std::size_t n_global_base_nodes,
32 const std::size_t n_global_nodes,
33 const std::size_t n_regular_nodes,
34 std::vector<std::size_t>&& n_regular_base_nodes_at_rank,
35 std::vector<std::size_t>&& n_regular_high_order_nodes_at_rank)
36 : Mesh(name, nodes, elements, true /* compute_element_neighbors */,
37 properties),
38 _global_node_ids(glb_node_ids),
39 _n_global_base_nodes(n_global_base_nodes),
40 _n_global_nodes(n_global_nodes),
41 _n_regular_nodes(n_regular_nodes),
42 _n_regular_base_nodes_at_rank(std::move(n_regular_base_nodes_at_rank)),
44 std::move(n_regular_high_order_nodes_at_rank)),
49{
50}
51
52bool NodePartitionedMesh::isGhostNode(const std::size_t node_id) const
53{
54 return node_id >= _n_regular_nodes;
55}
56
58{
59 auto const& nodes_connections =
61 auto const max_connections = std::max_element(
62 nodes_connections.cbegin(), nodes_connections.cend(),
63 [](auto const& connections_node_a, auto const& connections_node_b)
64 { return (connections_node_a.size() < connections_node_b.size()); });
65 // Return the number of connected nodes +1 for the node itself.
66 return static_cast<std::size_t>(max_connections->size() + 1);
67}
68
70 const std::size_t global_node_id) const
71{
72 return std::upper_bound(std::cbegin(_end_node_id_at_rank),
73 std::cend(_end_node_id_at_rank),
74 global_node_id) -
76}
77} // namespace MeshLib
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:52
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:298
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)