Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 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 543766 : bool Node::operator==(const Node & rhs) const 38 : { 39 : // Explicitly calling the operator== defined in Point 40 543766 : return this->Point::operator==(rhs); 41 : } 42 : 43 : 44 : 45 12 : void Node::print_info (std::ostream & os) const 46 : { 47 13 : os << this->get_info() 48 1 : << std::endl; 49 12 : } 50 : 51 : 52 : 53 12 : std::string Node::get_info () const 54 : { 55 14 : std::ostringstream oss; 56 : 57 12 : oss << " Node id()="; 58 : 59 12 : if (this->valid_id()) 60 1 : oss << this->id(); 61 : else 62 0 : oss << "invalid"; 63 : 64 12 : oss << ", processor_id()=" << this->processor_id() << 65 12 : ", Point=" << *static_cast<const Point *>(this) << '\n'; 66 : 67 12 : oss << " DoFs="; 68 12 : for (auto s : make_range(this->n_systems())) 69 0 : for (auto v : make_range(this->n_vars(s))) 70 0 : for (auto c : make_range(this->n_comp(s,v))) 71 0 : oss << '(' << s << '/' << v << '/' << this->dof_number(s,v,c) << ") "; 72 : 73 13 : return oss.str(); 74 10 : } 75 : 76 : 77 : processor_id_type 78 320437162 : Node::choose_processor_id(processor_id_type pid1, processor_id_type pid2) const 79 : { 80 320437162 : if (pid1 == DofObject::invalid_processor_id) 81 76513080 : 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 243937296 : 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 243924082 : if (load_balanced_nodes) 91 : { 92 0 : if (this->id() % 2 && 93 0 : pid2 != DofObject::invalid_processor_id) 94 0 : return std::max(pid1, pid2); 95 : else 96 0 : 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 243924082 : return std::min(pid1, pid2); 103 : } 104 : 105 : 106 : } // namespace libMesh