node.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 
26 namespace 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 
37 bool 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 
45 void Node::print_info (std::ostream & os) const
46 {
47  os << this->get_info()
48  << std::endl;
49 }
50 
51 
52 
53 std::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 (unsigned int s=0; s != this->n_systems(); ++s)
69  for (unsigned int v=0; v != this->n_vars(s); ++v)
70  for (unsigned int c=0; c != this->n_comp(s,v); ++c)
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
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:833
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:803
uint8_t processor_id_type
Definition: id_types.h:99
long double max(long double a, double b)
processor_id_type choose_processor_id(processor_id_type pid1, processor_id_type pid2) const
Definition: node.C:78
void print_info(std::ostream &os=libMesh::out) const
Definition: node.C:45
dof_id_type id() const
Definition: dof_object.h:655
static const processor_id_type invalid_processor_id
Definition: dof_object.h:358
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
Definition: dof_object.h:768
unsigned int n_systems() const
Definition: dof_object.h:749
bool operator==(const Node &rhs) const
Definition: node.C:37
bool valid_id() const
Definition: dof_object.h:697
bool operator==(const TypeVector< Real > &rhs) const
Definition: type_vector.h:1015
bool on_command_line(std::string arg)
Definition: libmesh.C:876
processor_id_type processor_id() const
Definition: dof_object.h:717
long double min(long double a, double b)
A geometric point in (x,y,z) space.
Definition: point.h:38
std::string get_info() const
Definition: node.C:53