libMesh
Loading...
Searching...
No Matches
node.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20// C++ includes
21#include <sstream>
22
23// Local includes
24#include "libmesh/node.h"
25
26namespace libMesh
27{
28
29
30
31
32// ------------------------------------------------------------
33// Node class static member initialization
34//const unsigned int Node::invalid_id = libMesh::invalid_uint;
35
36
37bool Node::operator==(const Node & rhs) const
38{
39 // Explicitly calling the operator== defined in Point
40 return this->Point::operator==(rhs);
41}
42
43
44
45void Node::print_info (std::ostream & os) const
46{
47 os << this->get_info()
48 << std::endl;
49}
50
51
52
53std::string Node::get_info () const
54{
55 std::ostringstream oss;
56
57 oss << " Node id()=";
58
59 if (this->valid_id())
60 oss << this->id();
61 else
62 oss << "invalid";
63
64 oss << ", processor_id()=" << this->processor_id() <<
65 ", Point=" << *static_cast<const Point *>(this) << '\n';
66
67 oss << " DoFs=";
68 for (auto s : make_range(this->n_systems()))
69 for (auto v : make_range(this->n_vars(s)))
70 for (auto c : make_range(this->n_comp(s,v)))
71 oss << '(' << s << '/' << v << '/' << this->dof_number(s,v,c) << ") ";
72
73 return oss.str();
74}
75
76
79{
81 return pid2;
82
83 // Do we want the new load-balanced node partitioning heuristic
84 // instead of the default partitioner-friendlier heuristic?
85 static bool load_balanced_nodes =
86 libMesh::on_command_line ("--load-balanced-nodes");
87
88 // For better load balancing, we can use the min
89 // even-numberered nodes and the max for odd-numbered.
90 if (load_balanced_nodes)
91 {
92 if (this->id() % 2 &&
94 return std::max(pid1, pid2);
95 else
96 return std::min(pid1, pid2);
97 }
98
99 // Our default behavior, which puts too many nodes on lower MPI
100 // ranks but which keeps elements' nodes on the same partition more
101 // often, is simply:
102 return std::min(pid1, pid2);
103}
104
105
106} // namespace libMesh
unsigned int n_vars
unsigned int n_systems() const
Definition dof_object.h:913
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition dof_object.h:978
bool valid_id() const
Definition dof_object.h:861
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
processor_id_type processor_id() const
Definition dof_object.h:881
dof_id_type id() const
Definition dof_object.h:819
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition dof_object.h:484
A Node is like a Point, but with more information.
Definition node.h:55
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the node.
Definition node.C:45
bool operator==(const Node &rhs) const
Definition node.C:37
processor_id_type choose_processor_id(processor_id_type pid1, processor_id_type pid2) const
Return which of pid1 and pid2 would be preferred by the current load-balancing heuristic applied to t...
Definition node.C:78
std::string get_info() const
Prints relevant information about the node to a string.
Definition node.C:53
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
bool operator==(const TypeVector< Real > &rhs) const
The libMesh namespace provides an interface to certain functionality in the library.
bool on_command_line(std::string arg)
Definition libmesh.C:934
uint8_t processor_id_type
Definition id_types.h:104
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176