OGS
NodePartitionedMesh.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <algorithm>
7#include <string>
8#include <vector>
9
10#include "Mesh.h"
11#include "Node.h"
12
13namespace MeshLib
14{
18{
19public:
20 // Copy a global mesh for the case of the thread number is one,
21 // i.e the global mesh is not partitioned.
22 // \param mesh The global mesh
23 explicit NodePartitionedMesh(const Mesh& mesh)
24 : Mesh(mesh),
30 {
31 for (std::size_t i = 0; i < _nodes.size(); i++)
32 {
33 _global_node_ids[i] = _nodes[i]->getID();
34 }
35 }
36
58 const std::string& name,
59 const std::vector<Node*>& nodes,
60 const std::vector<std::size_t>& glb_node_ids,
61 const std::vector<Element*>& elements,
62 Properties const& properties,
63 const std::size_t n_global_base_nodes,
64 const std::size_t n_global_nodes,
65 const std::size_t n_regular_nodes,
66 std::vector<std::size_t>&& n_regular_base_nodes_at_rank,
67 std::vector<std::size_t>&& n_regular_high_order_nodes_at_rank);
68
70 std::size_t getNumberOfGlobalBaseNodes() const
71 {
73 }
74
76 std::size_t getNumberOfGlobalNodes() const { return _n_global_nodes; }
78 std::size_t getGlobalNodeID(const std::size_t node_id) const
79 {
80 return _global_node_ids[node_id];
81 }
82
84 std::size_t getNumberOfRegularNodes() const { return _n_regular_nodes; }
86 bool isGhostNode(const std::size_t node_id) const;
87
88 std::size_t getNumberOfRegularBaseNodesAtRank(int const partition_id) const
89 {
90 return _n_regular_base_nodes_at_rank[partition_id];
91 }
92
94 int const partition_id) const
95 {
96 return _n_regular_high_order_nodes_at_rank[partition_id];
97 }
98
99 // TODO I guess that is a simplified version of computeSparsityPattern()
101 std::size_t getMaximumNConnectedNodesToNode() const;
102
103 std::size_t getPartitionID(const std::size_t global_node_id) const;
104
106 {
107 return _n_regular_base_nodes_at_rank.size();
108 }
109
110 bool isForSingleThread() const { return _is_single_thread; }
111
112private:
114 std::vector<std::size_t> _global_node_ids;
115
118
120 std::size_t _n_global_nodes;
121
123 std::size_t _n_regular_nodes;
124
127 std::vector<std::size_t> _n_regular_base_nodes_at_rank;
128
130 std::vector<std::size_t> _n_regular_high_order_nodes_at_rank;
131
133 std::vector<int> _end_node_id_at_rank;
134
136};
137
138} // namespace MeshLib
std::size_t computeNumberOfBaseNodes() const
Get the number of base nodes.
Definition Mesh.cpp:228
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 getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:91
std::vector< Node * > _nodes
Definition Mesh.h:149
std::size_t _n_global_base_nodes
Number of the nodes of the global mesh linear interpolations.
std::size_t getNumberOfRegularNodes() const
Get the number of all regular nodes of the partition.
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 getNumberOfRegularHighOrderNodesAtRank(int const partition_id) const
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::size_t getGlobalNodeID(const std::size_t node_id) const
Get the global node ID of a node with its local ID.
std::size_t getNumberOfGlobalNodes() const
Get the number of all nodes of the global mesh.
std::size_t getNumberOfGlobalBaseNodes() const
Get the number of nodes of the global mesh for linear elements.
std::size_t getNumberOfRegularBaseNodesAtRank(int const partition_id) const
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....