libMesh::MeshTools Namespace Reference
Detailed Description
Utility functions for operations on a Mesh object. Here is where useful functions for interfacing with a Mesh should be defined. In general this namespace should be used to prevent the Mesh class from becoming too cluttered.
- Date:
- 2004
Function Documentation
| MeshTools::BoundingBox libMesh::MeshTools::bounding_box | ( | const MeshBase & | mesh | ) |
- Returns:
- two points defining a cartesian box that bounds the mesh. The first entry in the pair is the mininum, the second is the maximim.
Definition at line 415 of file mesh_tools.C.
References libMesh::CommWorld, libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::Parallel::Communicator::max(), libMesh::Parallel::Communicator::min(), libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_nodes_begin(), and libMesh::MeshBase::pid_nodes_end().
Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::MeshCommunication::assign_global_indices(), bounding_sphere(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::PointLocatorTree::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Tree< N >::Tree(), and libMesh::PostscriptIO::write().
00416 { 00417 // This function must be run on all processors at once 00418 parallel_only(); 00419 00420 FindBBox find_bbox; 00421 00422 Threads::parallel_reduce (ConstNodeRange (mesh.local_nodes_begin(), 00423 mesh.local_nodes_end()), 00424 find_bbox); 00425 00426 // and the unpartitioned nodes 00427 Threads::parallel_reduce (ConstNodeRange (mesh.pid_nodes_begin(DofObject::invalid_processor_id), 00428 mesh.pid_nodes_end(DofObject::invalid_processor_id)), 00429 find_bbox); 00430 00431 // Compare the bounding boxes across processors 00432 CommWorld.min(find_bbox.min()); 00433 CommWorld.max(find_bbox.max()); 00434 00435 return find_bbox.bbox(); 00436 }
Same, but returns a sphere instead of a box.
Definition at line 441 of file mesh_tools.C.
References bounding_box(), and libMesh::Real.
00442 { 00443 BoundingBox bbox = bounding_box(mesh); 00444 00445 const Real diag = (bbox.second - bbox.first).size(); 00446 const Point cent = (bbox.second + bbox.first)/2; 00447 00448 return Sphere (cent, .5*diag); 00449 }
| void libMesh::MeshTools::build_nodes_to_elem_map | ( | const MeshBase & | mesh, | |
| std::vector< std::vector< const Elem * > > & | nodes_to_elem_map | |||
| ) |
The same, except element pointers are returned instead of indices.
Definition at line 368 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, and libMesh::MeshBase::n_nodes().
00370 { 00371 nodes_to_elem_map.resize (mesh.n_nodes()); 00372 00373 MeshBase::const_element_iterator el = mesh.elements_begin(); 00374 const MeshBase::const_element_iterator end = mesh.elements_end(); 00375 00376 for (; el != end; ++el) 00377 for (unsigned int n=0; n<(*el)->n_nodes(); n++) 00378 { 00379 libmesh_assert_less ((*el)->node(n), nodes_to_elem_map.size()); 00380 00381 nodes_to_elem_map[(*el)->node(n)].push_back(*el); 00382 } 00383 }
| void libMesh::MeshTools::build_nodes_to_elem_map | ( | const MeshBase & | mesh, | |
| std::vector< std::vector< dof_id_type > > & | nodes_to_elem_map | |||
| ) |
After calling this function the input vector nodes_to_elem_map will contain the node to element connectivity. That is to say nodes_to_elem_map[i][j] is the global number of
element connected to node i.
Definition at line 348 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, libMesh::MeshBase::n_elem(), and libMesh::MeshBase::n_nodes().
Referenced by libMesh::VariationalMeshSmoother::readgr(), and libMesh::Tree< N >::Tree().
00350 { 00351 nodes_to_elem_map.resize (mesh.n_nodes()); 00352 00353 MeshBase::const_element_iterator el = mesh.elements_begin(); 00354 const MeshBase::const_element_iterator end = mesh.elements_end(); 00355 00356 for (; el != end; ++el) 00357 for (unsigned int n=0; n<(*el)->n_nodes(); n++) 00358 { 00359 libmesh_assert_less ((*el)->node(n), nodes_to_elem_map.size()); 00360 libmesh_assert_less ((*el)->id(), mesh.n_elem()); 00361 00362 nodes_to_elem_map[(*el)->node(n)].push_back((*el)->id()); 00363 } 00364 }
| void libMesh::MeshTools::correct_node_proc_ids | ( | MeshBase & | mesh, | |
| LocationMap< Node > & | loc_map | |||
| ) |
Changes the processor ids on each node so be the same as the id of the lowest element touching that node.
This corrects "orphaned" processor ids that may occur from element coarsening.
On a distributed mesh, this function must be called in parallel to sync everyone's corrected processor ids on ghost nodes.
Definition at line 888 of file mesh_tools.C.
References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::LocationMap< T >::empty(), libMesh::Elem::get_node(), libMesh::DofObject::invalid_processor_id, libMesh::DofObject::invalidate_processor_id(), libMesh::Elem::n_nodes(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), and libMesh::DofObject::processor_id().
Referenced by libMesh::MeshCommunication::make_nodes_parallel_consistent().
00890 { 00891 // This function must be run on all processors at once 00892 parallel_only(); 00893 00894 // We'll need the new_nodes_map to answer other processors' 00895 // requests. It should never be empty unless we don't have any 00896 // nodes. 00897 libmesh_assert(mesh.nodes_begin() == mesh.nodes_end() || 00898 !loc_map.empty()); 00899 00900 // Fix all nodes' processor ids. Coarsening may have left us with 00901 // nodes which are no longer touched by any elements of the same 00902 // processor id, and for DofMap to work we need to fix that. 00903 00904 // In the first pass, invalidate processor ids for nodes on active 00905 // elements. We avoid touching subactive-only nodes. 00906 MeshBase::element_iterator e_it = mesh.active_elements_begin(); 00907 const MeshBase::element_iterator e_end = mesh.active_elements_end(); 00908 for (; e_it != e_end; ++e_it) 00909 { 00910 Elem *elem = *e_it; 00911 for (unsigned int n=0; n != elem->n_nodes(); ++n) 00912 { 00913 Node *node = elem->get_node(n); 00914 node->invalidate_processor_id(); 00915 } 00916 } 00917 00918 // In the second pass, find the lowest processor ids on active 00919 // elements touching each node, and set the node processor id. 00920 for (e_it = mesh.active_elements_begin(); e_it != e_end; ++e_it) 00921 { 00922 Elem *elem = *e_it; 00923 processor_id_type proc_id = elem->processor_id(); 00924 for (unsigned int n=0; n != elem->n_nodes(); ++n) 00925 { 00926 Node *node = elem->get_node(n); 00927 if (node->processor_id() == DofObject::invalid_processor_id || 00928 node->processor_id() > proc_id) 00929 node->processor_id() = proc_id; 00930 } 00931 } 00932 00933 // Those two passes will correct every node that touches a local 00934 // element, but we can't be sure about nodes touching remote 00935 // elements. Fix those now. 00936 MeshCommunication().make_node_proc_ids_parallel_consistent 00937 (mesh, loc_map); 00938 }
| void libMesh::MeshTools::elem_types | ( | const MeshBase & | mesh, | |
| std::vector< ElemType > & | et | |||
| ) |
Return a vector of all element types for the mesh. Implemented in terms of element_iterators.
Definition at line 521 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), and end.
Referenced by libMesh::LegacyXdrIO::write_mesh().
00523 { 00524 MeshBase::const_element_iterator el = mesh.elements_begin(); 00525 const MeshBase::const_element_iterator end = mesh.elements_end(); 00526 00527 // Automatically get the first type 00528 et.push_back((*el)->type()); ++el; 00529 00530 // Loop over the rest of the elements. 00531 // If the current element type isn't in the 00532 // vector, insert it. 00533 for (; el != end; ++el) 00534 if (!std::count(et.begin(), et.end(), (*el)->type())) 00535 et.push_back((*el)->type()); 00536 }
| void libMesh::MeshTools::find_boundary_nodes | ( | const MeshBase & | mesh, | |
| std::vector< bool > & | on_boundary | |||
| ) |
Calling this function on a 2D mesh will convert all the elements to triangles. QUAD4s will be converted to TRI3s, QUAD8s and QUAD9s will be converted to TRI6s. Fills the vector "on_boundary" with flags that tell whether each node is on the domain boundary (true)) or not (false).
Definition at line 387 of file mesh_tools.C.
References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), end, libMesh::MeshBase::n_nodes(), and side.
Referenced by libMesh::MeshTools::Modification::distort(), libMesh::VariationalMeshSmoother::readgr(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::MeshTools::Modification::smooth().
00389 { 00390 // Resize the vector which holds boundary nodes and fill with false. 00391 on_boundary.resize(mesh.n_nodes()); 00392 std::fill(on_boundary.begin(), 00393 on_boundary.end(), 00394 false); 00395 00396 // Loop over elements, find those on boundary, and 00397 // mark them as true in on_boundary. 00398 MeshBase::const_element_iterator el = mesh.active_elements_begin(); 00399 const MeshBase::const_element_iterator end = mesh.active_elements_end(); 00400 00401 for (; el != end; ++el) 00402 for (unsigned int s=0; s<(*el)->n_neighbors(); s++) 00403 if ((*el)->neighbor(s) == NULL) // on the boundary 00404 { 00405 const AutoPtr<Elem> side((*el)->build_side(s)); 00406 00407 for (unsigned int n=0; n<side->n_nodes(); n++) 00408 on_boundary[side->node(n)] = true; 00409 } 00410 }
| void libMesh::MeshTools::find_hanging_nodes_and_parents | ( | const MeshBase & | mesh, | |
| std::map< dof_id_type, std::vector< dof_id_type > > & | hanging_nodes | |||
| ) |
Given a mesh hanging_nodes will be filled with an associative array keyed off the global id of all the hanging nodes in the mesh. It will hold an array of the parents of the node (meaning the two nodes to either side of it that make up the side the hanging node is on.
Definition at line 784 of file mesh_tools.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), end, libMesh::Elem::is_node_on_side(), libMesh::Elem::level(), libMesh::Elem::n_neighbors(), libMesh::Elem::n_sides(), libMesh::Elem::neighbor(), libMesh::Elem::node(), libMesh::Elem::parent(), libMeshEnums::QUAD4, libMesh::Elem::type(), and libMesh::Elem::which_neighbor_am_i().
Referenced by libMesh::VariationalMeshSmoother::smooth().
00785 { 00786 MeshBase::const_element_iterator it = mesh.active_local_elements_begin(); 00787 const MeshBase::const_element_iterator end = mesh.active_local_elements_end(); 00788 00789 //Loop through all the elements 00790 for (; it != end; ++it) 00791 { 00792 //Save it off for easier access 00793 const Elem* elem = (*it); 00794 00795 //Right now this only works for quad4's 00796 //libmesh_assert_equal_to (elem->type(), libMeshEnums::QUAD4); 00797 if(elem->type() == libMeshEnums::QUAD4) 00798 { 00799 //Loop over the sides looking for sides that have hanging nodes 00800 //This code is inspired by compute_proj_constraints() 00801 for (unsigned int s=0; s<elem->n_sides(); s++) 00802 { 00803 //If not a boundary node 00804 if (elem->neighbor(s) != NULL) 00805 { 00806 // Get pointers to the element's neighbor. 00807 const Elem* neigh = elem->neighbor(s); 00808 00809 //Is there a coarser element next to this one? 00810 if (neigh->level() < elem->level()) 00811 { 00812 const Elem *ancestor = elem; 00813 while (neigh->level() < ancestor->level()) 00814 ancestor = ancestor->parent(); 00815 unsigned int s_neigh = neigh->which_neighbor_am_i(ancestor); 00816 libmesh_assert_less (s_neigh, neigh->n_neighbors()); 00817 00818 //Couple of helper uints... 00819 unsigned int local_node1=0; 00820 unsigned int local_node2=0; 00821 00822 bool found_in_neighbor = false; 00823 00824 //Find the two vertices that make up this side 00825 while(!elem->is_node_on_side(local_node1++,s)) { } 00826 local_node1--; 00827 00828 //Start looking for the second one with the next node 00829 local_node2=local_node1+1; 00830 00831 //Find the other one 00832 while(!elem->is_node_on_side(local_node2++,s)) { } 00833 local_node2--; 00834 00835 //Pull out their global ids: 00836 dof_id_type node1 = elem->node(local_node1); 00837 dof_id_type node2 = elem->node(local_node2); 00838 00839 //Now find which node is present in the neighbor 00840 //FIXME This assumes a level one rule! 00841 //The _other_ one is the hanging node 00842 00843 //First look for the first one 00844 //FIXME could be streamlined a bit 00845 for(unsigned int n=0;n<neigh->n_sides();n++) 00846 { 00847 if(neigh->node(n) == node1) 00848 found_in_neighbor=true; 00849 } 00850 00851 dof_id_type hanging_node=0; 00852 00853 if(!found_in_neighbor) 00854 hanging_node=node1; 00855 else //If it wasn't node1 then it must be node2! 00856 hanging_node=node2; 00857 00858 //Reset these for reuse 00859 local_node1=0; 00860 local_node2=0; 00861 00862 //Find the first node that makes up the side in the neighbor (these should be the parent nodes) 00863 while(!neigh->is_node_on_side(local_node1++,s_neigh)) { } 00864 local_node1--; 00865 00866 local_node2=local_node1+1; 00867 00868 //Find the second node... 00869 while(!neigh->is_node_on_side(local_node2++,s_neigh)) { } 00870 local_node2--; 00871 00872 //Save them if we haven't already found the parents for this one 00873 if(hanging_nodes[hanging_node].size()<2) 00874 { 00875 hanging_nodes[hanging_node].push_back(neigh->node(local_node1)); 00876 hanging_nodes[hanging_node].push_back(neigh->node(local_node2)); 00877 } 00878 } 00879 } 00880 } 00881 } 00882 } 00883 }
| void libMesh::MeshTools::find_nodal_neighbors | ( | const MeshBase & | mesh, | |
| const Node & | n, | |||
| std::vector< std::vector< const Elem * > > & | nodes_to_elem_map, | |||
| std::vector< const Node * > & | neighbors | |||
| ) |
Given a mesh and a node in the mesh, the vector will be filled with every node directly attached to the given one.
Definition at line 703 of file mesh_tools.C.
References libMesh::DofObject::id().
Referenced by libMesh::VariationalMeshSmoother::readgr().
00706 { 00707 dof_id_type global_id = n.id(); 00708 00709 //Iterators to iterate through the elements that include this node 00710 std::vector<const Elem*>::const_iterator el = nodes_to_elem_map[global_id].begin(); 00711 std::vector<const Elem*>::const_iterator end_el = nodes_to_elem_map[global_id].end(); 00712 00713 unsigned int n_ed=0; // Number of edges on the element 00714 unsigned int ed=0; // Current edge 00715 unsigned int l_n=0; // Local node number 00716 unsigned int o_n=0; // Other node on this edge 00717 00718 //Assume we find a edge... then prove ourselves wrong... 00719 bool found_edge=true; 00720 00721 Node * node_to_save = NULL; 00722 00723 //Look through the elements that contain this node 00724 //find the local node id... then find the side that 00725 //node lives on in the element 00726 //next, look for the _other_ node on that side 00727 //That other node is a "nodal_neighbor"... save it 00728 for(;el != end_el;el++) 00729 { 00730 //We only care about active elements... 00731 if((*el)->active()) 00732 { 00733 n_ed=(*el)->n_edges(); 00734 00735 //Find the local node id 00736 while(global_id != (*el)->node(l_n++)) { } 00737 l_n--; //Hmmm... take the last one back off 00738 00739 while(ed<n_ed) 00740 { 00741 00742 //Find the edge the node is on 00743 while(found_edge && !(*el)->is_node_on_edge(l_n,ed++)) 00744 { 00745 //This only happens if all the edges have already been found 00746 if(ed>=n_ed) 00747 found_edge=false; 00748 } 00749 00750 //Did we find one? 00751 if(found_edge) 00752 { 00753 ed--; //Take the last one back off again 00754 00755 //Now find the other node on that edge 00756 while(!(*el)->is_node_on_edge(o_n++,ed) || global_id==(*el)->node(o_n-1)) { } 00757 o_n--; 00758 00759 //We've found one! Save it.. 00760 node_to_save=(*el)->get_node(o_n); 00761 00762 //Search to see if we've already found this one 00763 std::vector<const Node*>::const_iterator result = std::find(neighbors.begin(),neighbors.end(),node_to_save); 00764 00765 //If we didn't find it and add it to the vector 00766 if(result == neighbors.end()) 00767 neighbors.push_back(node_to_save); 00768 } 00769 00770 //Reset to look for another 00771 o_n=0; 00772 00773 //Keep looking for edges, node may be on more than one edge 00774 ed++; 00775 } 00776 00777 //Reset to get ready for the next element 00778 l_n=ed=0; 00779 found_edge=true; 00780 } 00781 } 00782 }
| void libMesh::MeshTools::get_not_subactive_node_ids | ( | const MeshBase & | mesh, | |
| std::set< dof_id_type > & | not_subactive_node_ids | |||
| ) |
Builds a set of node IDs for nodes which belong to non-subactive elements. Non-subactive elements are those which are either active or inactive. This is useful for determining which nodes should be written to a data file, and is used by the XDA mesh writing methods.
Definition at line 644 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::n_nodes(), libMesh::Elem::node(), and libMesh::Elem::subactive().
00646 { 00647 MeshBase::const_element_iterator el = mesh.elements_begin(); 00648 const MeshBase::const_element_iterator end_el = mesh.elements_end(); 00649 for( ; el != end_el; ++el) 00650 { 00651 const Elem* elem = (*el); 00652 if(!elem->subactive()) 00653 for (unsigned int n=0; n<elem->n_nodes(); ++n) 00654 not_subactive_node_ids.insert(elem->node(n)); 00655 } 00656 }
| void libMesh::MeshTools::libmesh_assert_connected_nodes | ( | const MeshBase & | mesh | ) |
A function for verifying that all nodes are connected to at least one element.
This will fail in the most general case. When ParallelMesh and NodeConstraints are enabled, we expect the possibility that a processor will be given remote nodes to satisfy node constraints without also being given the remote elements connected to those nodes.
Definition at line 1126 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::get_node(), libMesh::Elem::n_nodes(), libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().
01127 { 01128 std::set<const Node*> used_nodes; 01129 01130 const MeshBase::const_element_iterator el_end = 01131 mesh.elements_end(); 01132 for (MeshBase::const_element_iterator el = 01133 mesh.elements_begin(); el != el_end; ++el) 01134 { 01135 const Elem* elem = *el; 01136 libmesh_assert (elem); 01137 01138 for (unsigned int n=0; n<elem->n_nodes(); ++n) 01139 used_nodes.insert(elem->get_node(n)); 01140 } 01141 01142 const MeshBase::const_node_iterator node_end = mesh.nodes_end(); 01143 01144 for (MeshBase::const_node_iterator node_it = mesh.nodes_begin(); 01145 node_it != node_end; ++node_it) 01146 { 01147 Node *node = *node_it; 01148 libmesh_assert(node); 01149 libmesh_assert(used_nodes.count(node)); 01150 } 01151 }
| void libMesh::MeshTools::libmesh_assert_equal_n_systems | ( | const MeshBase & | mesh | ) |
A function for testing that all DofObjects within a mesh have the same n_systems count
Definition at line 943 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::n_systems(), libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().
00944 { 00945 MeshBase::const_element_iterator el = 00946 mesh.elements_begin(); 00947 const MeshBase::const_element_iterator el_end = 00948 mesh.elements_end(); 00949 if (el == el_end) 00950 return; 00951 00952 const unsigned int n_sys = (*el)->n_systems(); 00953 00954 for (; el != el_end; ++el) 00955 { 00956 const Elem *elem = *el; 00957 libmesh_assert_equal_to (elem->n_systems(), n_sys); 00958 } 00959 00960 MeshBase::const_node_iterator node_it = 00961 mesh.nodes_begin(); 00962 const MeshBase::const_node_iterator node_end = 00963 mesh.nodes_end(); 00964 00965 if (node_it == node_end) 00966 return; 00967 00968 for (; node_it != node_end; ++node_it) 00969 { 00970 const Node *node = *node_it; 00971 libmesh_assert_equal_to (node->n_systems(), n_sys); 00972 } 00973 }
| void libMesh::MeshTools::libmesh_assert_no_links_to_elem | ( | const MeshBase & | mesh, | |
| const Elem * | bad_elem | |||
| ) |
A function for verifying that an element has been cut off from the rest of the mesh
Definition at line 1056 of file mesh_tools.C.
References libMesh::Elem::child(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::Elem::n_children(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), and libMesh::Elem::parent().
01058 { 01059 const MeshBase::const_element_iterator el_end = 01060 mesh.elements_end(); 01061 for (MeshBase::const_element_iterator el = 01062 mesh.elements_begin(); el != el_end; ++el) 01063 { 01064 const Elem* elem = *el; 01065 libmesh_assert (elem); 01066 libmesh_assert_not_equal_to (elem->parent(), bad_elem); 01067 for (unsigned int n=0; n != elem->n_neighbors(); ++n) 01068 libmesh_assert_not_equal_to (elem->neighbor(n), bad_elem); 01069 #ifdef LIBMESH_ENABLE_AMR 01070 if (elem->has_children()) 01071 for (unsigned int c=0; c != elem->n_children(); ++c) 01072 libmesh_assert_not_equal_to (elem->child(c), bad_elem); 01073 #endif 01074 } 01075 }
| void libMesh::MeshTools::libmesh_assert_old_dof_objects | ( | const MeshBase & | mesh | ) |
A function for testing that all non-recently-created DofObjects within a mesh have old_dof_object data. This is not expected to be true at all points within a simulation code.
Definition at line 977 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::get_node(), libMesh::DofObject::has_dofs(), libMesh::Elem::INACTIVE, libMesh::Elem::JUST_REFINED, libMesh::Elem::n_nodes(), libMesh::DofObject::old_dof_object, and libMesh::Elem::refinement_flag().
00978 { 00979 #ifdef LIBMESH_ENABLE_AMR 00980 MeshBase::const_element_iterator el = 00981 mesh.elements_begin(); 00982 const MeshBase::const_element_iterator el_end = 00983 mesh.elements_end(); 00984 00985 for (; el != el_end; ++el) 00986 { 00987 const Elem *elem = *el; 00988 00989 if (elem->refinement_flag() == Elem::JUST_REFINED || 00990 elem->refinement_flag() == Elem::INACTIVE) 00991 continue; 00992 00993 if (elem->has_dofs()) 00994 libmesh_assert(elem->old_dof_object); 00995 00996 for (unsigned int n=0; n != elem->n_nodes(); ++n) 00997 { 00998 const Node *node = elem->get_node(n); 00999 if (node->has_dofs()) 01000 libmesh_assert(elem->get_node(n)->old_dof_object); 01001 } 01002 } 01003 #endif // LIBMESH_ENABLE_AMR 01004 }
| void libMesh::MeshTools::libmesh_assert_valid_amr_elem_ids | ( | const MeshBase & | mesh | ) |
A function for verifying that ids of elements are correctly sorted for AMR (parents have lower ids than children)
Definition at line 1104 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::id(), libMesh::Elem::parent(), and libMesh::DofObject::processor_id().
Referenced by libMesh::UnstructuredMesh::copy_nodes_and_elements().
01105 { 01106 const MeshBase::const_element_iterator el_end = 01107 mesh.elements_end(); 01108 for (MeshBase::const_element_iterator el = 01109 mesh.elements_begin(); el != el_end; ++el) 01110 { 01111 const Elem* elem = *el; 01112 libmesh_assert (elem); 01113 01114 const Elem* parent = elem->parent(); 01115 01116 if (parent) 01117 { 01118 libmesh_assert_greater_equal (elem->id(), parent->id()); 01119 libmesh_assert_greater_equal (elem->processor_id(), parent->processor_id()); 01120 } 01121 } 01122 }
| void libMesh::MeshTools::libmesh_assert_valid_dof_ids | ( | const MeshBase & | mesh | ) |
A function for verifying that degree of freedom indexing matches across processors.
Referenced by libMesh::DofMap::distribute_dofs().
| void libMesh::MeshTools::libmesh_assert_valid_elem_ids | ( | const MeshBase & | mesh | ) |
A function for verifying that ids and processor assignment of elements are correctly sorted (monotone increasing)
Definition at line 1079 of file mesh_tools.C.
References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::DofObject::id(), and libMesh::DofObject::processor_id().
Referenced by libMesh::ParallelMesh::renumber_nodes_and_elements().
01080 { 01081 processor_id_type lastprocid = 0; 01082 dof_id_type lastelemid = 0; 01083 01084 const MeshBase::const_element_iterator el_end = 01085 mesh.active_elements_end(); 01086 for (MeshBase::const_element_iterator el = 01087 mesh.active_elements_begin(); el != el_end; ++el) 01088 { 01089 const Elem* elem = *el; 01090 libmesh_assert (elem); 01091 processor_id_type elemprocid = elem->processor_id(); 01092 dof_id_type elemid = elem->id(); 01093 01094 libmesh_assert_greater_equal (elemid, lastelemid); 01095 libmesh_assert_greater_equal (elemprocid, lastprocid); 01096 01097 lastelemid = elemid; 01098 lastprocid = elemprocid; 01099 } 01100 }
| void libMesh::MeshTools::libmesh_assert_valid_neighbors | ( | const MeshBase & | mesh | ) |
A function for verifying that neighbor connectivity is correct (each element is a neighbor of or descendant of a neighbor of its neighbors)
Definition at line 1423 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), and libMesh::Elem::libmesh_assert_valid_neighbors().
Referenced by libMesh::ParallelMesh::allgather(), libMesh::ParallelMesh::delete_remote_elements(), and libMesh::UnstructuredMesh::find_neighbors().
01424 { 01425 const MeshBase::const_element_iterator el_end = mesh.elements_end(); 01426 for (MeshBase::const_element_iterator el = mesh.elements_begin(); 01427 el != el_end; ++el) 01428 { 01429 const Elem* elem = *el; 01430 libmesh_assert (elem); 01431 elem->libmesh_assert_valid_neighbors(); 01432 } 01433 }
| void libMesh::MeshTools::libmesh_assert_valid_node_pointers | ( | const MeshBase & | mesh | ) |
A function for walking across the mesh to try and ferret out invalidated or misassigned pointers
Definition at line 1008 of file mesh_tools.C.
References libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::libmesh_assert_valid_node_pointers(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), libMesh::Elem::parent(), and libMesh::remote_elem.
01009 { 01010 const MeshBase::const_element_iterator el_end = 01011 mesh.elements_end(); 01012 for (MeshBase::const_element_iterator el = 01013 mesh.elements_begin(); el != el_end; ++el) 01014 { 01015 const Elem* elem = *el; 01016 libmesh_assert (elem); 01017 while (elem) 01018 { 01019 elem->libmesh_assert_valid_node_pointers(); 01020 for (unsigned int n=0; n != elem->n_neighbors(); ++n) 01021 if (elem->neighbor(n) && 01022 elem->neighbor(n) != remote_elem) 01023 elem->neighbor(n)->libmesh_assert_valid_node_pointers(); 01024 01025 libmesh_assert_not_equal_to (elem->parent(), remote_elem); 01026 elem = elem->parent(); 01027 } 01028 } 01029 }
| void libMesh::MeshTools::libmesh_assert_valid_procids | ( | const MeshBase & | mesh | ) | [inline] |
A function for verifying that processor assignment is self-consistent on nodes (each node part of an active element on its processor) or elements (each parent has the processor id of one of its children), and verifying that assignment is consistent (every processor agrees on the processor id of each dof object it can see)
| void libMesh::MeshTools::libmesh_assert_valid_procids< Elem > | ( | const MeshBase & | mesh | ) | [inline] |
Referenced by libMesh::Partitioner::partition().
| void libMesh::MeshTools::libmesh_assert_valid_refinement_flags | ( | const MeshBase & | mesh | ) |
A function for verifying that refinement flags on elements are consistent between processors
Definition at line 1339 of file mesh_tools.C.
References libMesh::CommWorld, libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::id(), libMesh::MeshBase::max_elem_id(), libMesh::Parallel::Communicator::min(), libMesh::n_processors(), libMesh::Elem::p_refinement_flag(), and libMesh::Elem::refinement_flag().
01340 { 01341 parallel_only(); 01342 if (libMesh::n_processors() == 1) 01343 return; 01344 01345 std::vector<unsigned char> my_elem_h_state(mesh.max_elem_id(), 255); 01346 std::vector<unsigned char> my_elem_p_state(mesh.max_elem_id(), 255); 01347 01348 const MeshBase::const_element_iterator el_end = 01349 mesh.elements_end(); 01350 for (MeshBase::const_element_iterator el = 01351 mesh.elements_begin(); el != el_end; ++el) 01352 { 01353 const Elem* elem = *el; 01354 libmesh_assert (elem); 01355 dof_id_type elemid = elem->id(); 01356 01357 my_elem_h_state[elemid] = 01358 static_cast<unsigned char>(elem->refinement_flag()); 01359 01360 my_elem_p_state[elemid] = 01361 static_cast<unsigned char>(elem->p_refinement_flag()); 01362 } 01363 std::vector<unsigned char> min_elem_h_state(my_elem_h_state); 01364 CommWorld.min(min_elem_h_state); 01365 01366 std::vector<unsigned char> min_elem_p_state(my_elem_p_state); 01367 CommWorld.min(min_elem_p_state); 01368 01369 for (dof_id_type i=0; i!= mesh.max_elem_id(); ++i) 01370 { 01371 libmesh_assert(my_elem_h_state[i] == 255 || 01372 my_elem_h_state[i] == min_elem_h_state[i]); 01373 libmesh_assert(my_elem_p_state[i] == 255 || 01374 my_elem_p_state[i] == min_elem_p_state[i]); 01375 } 01376 }
| void libMesh::MeshTools::libmesh_assert_valid_refinement_tree | ( | const MeshBase & | mesh | ) |
A function for verifying that elements on this processor have valid descendants and consistent active flags.
Definition at line 1386 of file mesh_tools.C.
References libMesh::Elem::active(), libMesh::Elem::ancestor(), libMesh::Elem::child(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::Elem::has_children(), libMesh::Elem::n_children(), libMesh::Elem::parent(), libMesh::remote_elem, and libMesh::Elem::subactive().
Referenced by libMesh::ParallelMesh::delete_remote_elements(), and libMesh::MeshCommunication::delete_remote_elements().
01387 { 01388 const MeshBase::const_element_iterator el_end = 01389 mesh.elements_end(); 01390 for (MeshBase::const_element_iterator el = 01391 mesh.elements_begin(); el != el_end; ++el) 01392 { 01393 const Elem *elem = *el; 01394 libmesh_assert(elem); 01395 if (elem->has_children()) 01396 for (unsigned int n=0; n != elem->n_children(); ++n) 01397 { 01398 libmesh_assert(elem->child(n)); 01399 if (elem->child(n) != remote_elem) 01400 libmesh_assert_equal_to (elem->child(n)->parent(), elem); 01401 } 01402 if (elem->active()) 01403 { 01404 libmesh_assert(!elem->ancestor()); 01405 libmesh_assert(!elem->subactive()); 01406 } 01407 else if (elem->ancestor()) 01408 { 01409 libmesh_assert(!elem->subactive()); 01410 } 01411 else 01412 libmesh_assert(elem->subactive()); 01413 } 01414 }
| void libMesh::MeshTools::libmesh_assert_valid_remote_elems | ( | const MeshBase & | mesh | ) |
A function for verifying that active local elements' neighbors are never remote elements
Definition at line 1032 of file mesh_tools.C.
References libMesh::Elem::child(), libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::Elem::n_children(), libMesh::Elem::n_neighbors(), libMesh::Elem::neighbor(), libMesh::Elem::parent(), and libMesh::remote_elem.
Referenced by libMesh::Partitioner::partition().
01033 { 01034 const MeshBase::const_element_iterator el_end = 01035 mesh.local_elements_end(); 01036 for (MeshBase::const_element_iterator el = 01037 mesh.local_elements_begin(); el != el_end; ++el) 01038 { 01039 const Elem* elem = *el; 01040 libmesh_assert (elem); 01041 for (unsigned int n=0; n != elem->n_neighbors(); ++n) 01042 libmesh_assert_not_equal_to (elem->neighbor(n), remote_elem); 01043 #ifdef LIBMESH_ENABLE_AMR 01044 const Elem* parent = elem->parent(); 01045 if (parent) 01046 { 01047 libmesh_assert_not_equal_to (parent, remote_elem); 01048 for (unsigned int c=0; c != elem->n_children(); ++c) 01049 libmesh_assert_not_equal_to (parent->child(c), remote_elem); 01050 } 01051 #endif 01052 } 01053 }
| unsigned int libMesh::MeshTools::max_level | ( | const MeshBase & | mesh | ) |
Find the maxium h-refinement level in a mesh.
Referenced by libMesh::MeshRefinement::make_coarsening_compatible(), n_active_local_levels(), and n_local_levels().
| dof_id_type libMesh::MeshTools::n_active_elem_of_type | ( | const MeshBase & | mesh, | |
| const ElemType | type | |||
| ) |
Return the number of active elements of type type. Implemented in terms of active_type_element_iterators.
Definition at line 549 of file mesh_tools.C.
References libMesh::MeshBase::active_type_elements_begin(), and libMesh::MeshBase::active_type_elements_end().
Referenced by libMesh::DivaIO::write_stream().
00551 { 00552 return static_cast<dof_id_type>(std::distance(mesh.active_type_elements_begin(type), 00553 mesh.active_type_elements_end (type))); 00554 }
| unsigned int libMesh::MeshTools::n_active_levels | ( | const MeshBase & | mesh | ) |
Return the number of levels of refinement in the active mesh. Implemented by looping over all the active local elements and finding the maximum level, then summing in parallel.
Definition at line 588 of file mesh_tools.C.
References libMesh::CommWorld, libMesh::Parallel::Communicator::max(), std::max(), n_active_local_levels(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().
00589 { 00590 parallel_only(); 00591 00592 unsigned int nl = MeshTools::n_active_local_levels(mesh); 00593 00594 MeshBase::const_element_iterator el = 00595 mesh.unpartitioned_elements_begin(); 00596 const MeshBase::const_element_iterator end_el = 00597 mesh.unpartitioned_elements_end(); 00598 00599 for( ; el != end_el; ++el) 00600 if ((*el)->active()) 00601 nl = std::max((*el)->level() + 1, nl); 00602 00603 CommWorld.max(nl); 00604 return nl; 00605 }
| unsigned int libMesh::MeshTools::n_active_local_levels | ( | const MeshBase & | mesh | ) |
Return the number of levels of refinement in the active local mesh. Implemented by looping over all the active local elements and finding the maximum level.
Definition at line 573 of file mesh_tools.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), std::max(), and max_level().
Referenced by n_active_levels().
00574 { 00575 unsigned int max_level = 0; 00576 00577 MeshBase::const_element_iterator el = mesh.active_local_elements_begin(); 00578 const MeshBase::const_element_iterator end_el = mesh.active_local_elements_end(); 00579 00580 for( ; el != end_el; ++el) 00581 max_level = std::max((*el)->level(), max_level); 00582 00583 return max_level + 1; 00584 }
| dof_id_type libMesh::MeshTools::n_elem | ( | const MeshBase::const_element_iterator & | begin, | |
| const MeshBase::const_element_iterator & | end | |||
| ) |
Count up the number of elements of a specific type (as defined by an iterator range).
Definition at line 660 of file mesh_tools.C.
Referenced by libMesh::SFCPartitioner::_do_partition(), libMesh::CentroidPartitioner::_do_partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::XdrIO::read(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_tetgen(), libMesh::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::XdrIO::write(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::MeshData::write_xdr().
| dof_id_type libMesh::MeshTools::n_elem_of_type | ( | const MeshBase & | mesh, | |
| const ElemType | type | |||
| ) |
Return the number of elements of type type. Implemented in terms of type_element_iterators.
Definition at line 540 of file mesh_tools.C.
References libMesh::MeshBase::type_elements_begin(), and libMesh::MeshBase::type_elements_end().
00542 { 00543 return static_cast<dof_id_type>(std::distance(mesh.type_elements_begin(type), 00544 mesh.type_elements_end (type))); 00545 }
| unsigned int libMesh::MeshTools::n_levels | ( | const MeshBase & | mesh | ) |
Return the number of levels of refinement in the mesh. Implemented by looping over all the local elements and finding the maximum level, then summing in parallel.
Definition at line 624 of file mesh_tools.C.
References libMesh::CommWorld, libMesh::Parallel::Communicator::max(), std::max(), n_local_levels(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().
Referenced by libMesh::MeshCommunication::delete_remote_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::LegacyXdrIO::read_mesh(), libMesh::MeshTools::Modification::smooth(), and libMesh::LegacyXdrIO::write_mesh().
00625 { 00626 parallel_only(); 00627 00628 unsigned int nl = MeshTools::n_local_levels(mesh); 00629 00630 MeshBase::const_element_iterator el = 00631 mesh.unpartitioned_elements_begin(); 00632 const MeshBase::const_element_iterator end_el = 00633 mesh.unpartitioned_elements_end(); 00634 00635 for( ; el != end_el; ++el) 00636 nl = std::max((*el)->level() + 1, nl); 00637 00638 CommWorld.max(nl); 00639 return nl; 00640 }
| unsigned int libMesh::MeshTools::n_local_levels | ( | const MeshBase & | mesh | ) |
Return the number of levels of refinement in the local mesh. Implemented by looping over all the local elements and finding the maximum level.
Definition at line 609 of file mesh_tools.C.
References libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), std::max(), and max_level().
Referenced by n_levels().
00610 { 00611 unsigned int max_level = 0; 00612 00613 MeshBase::const_element_iterator el = mesh.local_elements_begin(); 00614 const MeshBase::const_element_iterator end_el = mesh.local_elements_end(); 00615 00616 for( ; el != end_el; ++el) 00617 max_level = std::max((*el)->level(), max_level); 00618 00619 return max_level + 1; 00620 }
| dof_id_type libMesh::MeshTools::n_nodes | ( | const MeshBase::const_node_iterator & | begin, | |
| const MeshBase::const_node_iterator & | end | |||
| ) |
Count up the number of nodes of a specific type (as defined by an iterator range).
Definition at line 668 of file mesh_tools.C.
| dof_id_type libMesh::MeshTools::n_non_subactive_elem_of_type_at_level | ( | const MeshBase & | mesh, | |
| const ElemType | type, | |||
| const unsigned int | level | |||
| ) |
Return the number of elements of type type at the specified refinement level.
TODO: Replace all of the n_xxx_elem() functions like this with a single function which takes a range of iterators and returns the std::distance between them.
Definition at line 556 of file mesh_tools.C.
References end, libMesh::MeshBase::type_elements_begin(), and libMesh::MeshBase::type_elements_end().
Referenced by libMesh::LegacyXdrIO::write_mesh().
00559 { 00560 dof_id_type cnt = 0; 00561 // iterate over the elements of the specified type 00562 MeshBase::const_element_iterator el = mesh.type_elements_begin(type); 00563 const MeshBase::const_element_iterator end = mesh.type_elements_end(type); 00564 00565 for(; el!=end; ++el) 00566 if( ((*el)->level() == level) && !(*el)->subactive()) 00567 cnt++; 00568 00569 return cnt; 00570 }
| unsigned int libMesh::MeshTools::n_p_levels | ( | const MeshBase & | mesh | ) |
Return the number of p-levels of refinement in the mesh. Implemented by looping over all the local elements and finding the maximum p-level, then summing in parallel.
Definition at line 676 of file mesh_tools.C.
References libMesh::CommWorld, libMesh::MeshBase::local_elements_begin(), libMesh::MeshBase::local_elements_end(), libMesh::Parallel::Communicator::max(), std::max(), libMesh::MeshBase::unpartitioned_elements_begin(), and libMesh::MeshBase::unpartitioned_elements_end().
Referenced by libMesh::XdrIO::write().
00677 { 00678 parallel_only(); 00679 00680 unsigned int max_p_level = 0; 00681 00682 // first my local elements 00683 MeshBase::const_element_iterator 00684 el = mesh.local_elements_begin(), 00685 end_el = mesh.local_elements_end(); 00686 00687 for( ; el != end_el; ++el) 00688 max_p_level = std::max((*el)->p_level(), max_p_level); 00689 00690 // then any unpartitioned objects 00691 el = mesh.unpartitioned_elements_begin(); 00692 end_el = mesh.unpartitioned_elements_end(); 00693 00694 for( ; el != end_el; ++el) 00695 max_p_level = std::max((*el)->p_level(), max_p_level); 00696 00697 CommWorld.max(max_p_level); 00698 return max_p_level + 1; 00699 }
| MeshTools::BoundingBox libMesh::MeshTools::processor_bounding_box | ( | const MeshBase & | mesh, | |
| const processor_id_type | pid | |||
| ) |
- Returns:
- two points defining a cartesian box that bounds the elements belonging to processor pid.
Definition at line 454 of file mesh_tools.C.
References libMesh::n_processors(), libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().
Referenced by processor_bounding_sphere().
00456 { 00457 libmesh_assert_less (pid, libMesh::n_processors()); 00458 00459 FindBBox find_bbox; 00460 00461 Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(pid), 00462 mesh.pid_elements_end(pid)), 00463 find_bbox); 00464 00465 return find_bbox.bbox(); 00466 }
| Sphere libMesh::MeshTools::processor_bounding_sphere | ( | const MeshBase & | mesh, | |
| const processor_id_type | pid | |||
| ) |
Same, but returns a sphere instead of a box.
Definition at line 471 of file mesh_tools.C.
References processor_bounding_box(), and libMesh::Real.
00473 { 00474 BoundingBox bbox = processor_bounding_box(mesh,pid); 00475 00476 const Real diag = (bbox.second - bbox.first).size(); 00477 const Point cent = (bbox.second + bbox.first)/2; 00478 00479 return Sphere (cent, .5*diag); 00480 }
| MeshTools::BoundingBox libMesh::MeshTools::subdomain_bounding_box | ( | const MeshBase & | mesh, | |
| const subdomain_id_type | sid | |||
| ) |
- Returns:
- two points defining a Cartesian box that bounds the elements belonging to subdomain sid.
Definition at line 485 of file mesh_tools.C.
References libMesh::MeshBase::elem(), std::max(), std::min(), libMesh::MeshBase::n_elem(), libMesh::Elem::n_nodes(), libMesh::MeshBase::n_nodes(), libMesh::Elem::node(), libMesh::MeshBase::point(), libMesh::MeshBase::spatial_dimension(), and libMesh::Elem::subdomain_id().
Referenced by subdomain_bounding_sphere().
00487 { 00488 libmesh_assert_not_equal_to (mesh.n_nodes(), 0); 00489 00490 Point min( 1.e30, 1.e30, 1.e30); 00491 Point max(-1.e30, -1.e30, -1.e30); 00492 00493 for (unsigned int e=0; e<mesh.n_elem(); e++) 00494 if (mesh.elem(e)->subdomain_id() == sid) 00495 for (unsigned int n=0; n<mesh.elem(e)->n_nodes(); n++) 00496 for (unsigned int i=0; i<mesh.spatial_dimension(); i++) 00497 { 00498 min(i) = std::min(min(i), mesh.point(mesh.elem(e)->node(n))(i)); 00499 max(i) = std::max(max(i), mesh.point(mesh.elem(e)->node(n))(i)); 00500 } 00501 00502 return BoundingBox (min, max); 00503 }
| Sphere libMesh::MeshTools::subdomain_bounding_sphere | ( | const MeshBase & | mesh, | |
| const subdomain_id_type | sid | |||
| ) |
Same, but returns a sphere instead of a box.
Definition at line 508 of file mesh_tools.C.
References libMesh::Real, and subdomain_bounding_box().
00510 { 00511 BoundingBox bbox = subdomain_bounding_box(mesh,sid); 00512 00513 const Real diag = (bbox.second - bbox.first).size(); 00514 const Point cent = (bbox.second + bbox.first)/2; 00515 00516 return Sphere (cent, .5*diag); 00517 }
| dof_id_type libMesh::MeshTools::total_weight | ( | const MeshBase & | mesh | ) |
This function returns the sum over all the elemenents of the number of nodes per element. This can be useful for partitioning hybrid meshes. A feasible load balancing scheme is to keep the weight per processor as uniform as possible.
Definition at line 313 of file mesh_tools.C.
References libMesh::CommWorld, libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_serial(), libMesh::Threads::parallel_reduce(), libMesh::processor_id(), libMesh::Parallel::Communicator::sum(), and weight().
Referenced by libMesh::LegacyXdrIO::write_mesh().
00314 { 00315 if (!mesh.is_serial()) 00316 { 00317 parallel_only(); 00318 dof_id_type weight = MeshTools::weight (mesh, libMesh::processor_id()); 00319 CommWorld.sum(weight); 00320 dof_id_type unpartitioned_weight = 00321 MeshTools::weight (mesh, DofObject::invalid_processor_id); 00322 return weight + unpartitioned_weight; 00323 } 00324 00325 SumElemWeight sew; 00326 00327 Threads::parallel_reduce (ConstElemRange (mesh.elements_begin(), 00328 mesh.elements_end()), 00329 sew); 00330 return sew.weight(); 00331 00332 }
| dof_id_type libMesh::MeshTools::weight | ( | const MeshBase & | mesh, | |
| const processor_id_type | pid = libMesh::processor_id() | |||
| ) |
This function returns the sum over all the elemenents on processor pid of nodes per element. This can be useful for partitioning hybrid meshes. A feasible load balancing scheme is to keep the weight per processor as uniform as possible.
Definition at line 336 of file mesh_tools.C.
References libMesh::Threads::parallel_reduce(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().
Referenced by libMesh::QGrundmann_Moller::gm_rule(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshTools::Modification::smooth(), and total_weight().
00337 { 00338 SumElemWeight sew; 00339 00340 Threads::parallel_reduce (ConstElemRange (mesh.pid_elements_begin(pid), 00341 mesh.pid_elements_end(pid)), 00342 sew); 00343 return sew.weight(); 00344 }
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:44 UTC
Hosted By: