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 : #ifndef LIBMESH_PATCH_H 21 : #define LIBMESH_PATCH_H 22 : 23 : // Local includes 24 : #include "libmesh/id_types.h" 25 : 26 : // C++ includes 27 : #include <vector> 28 : #include <string> 29 : #include <set> 30 : 31 : namespace libMesh 32 : { 33 : 34 : // Forward Declarations 35 : class Elem; 36 : 37 : /** 38 : * This class implements useful utility functions for a patch of 39 : * elements 40 : * 41 : * \author Varis Carey 42 : * \author Benjamin S. Kirk 43 : * \date 2004 44 : * \author Roy H. Stogner 45 : * \date 2007 46 : */ 47 : class Patch : public std::set<const Elem *> 48 : { 49 : public: 50 : 51 : /** 52 : * Constructor. Requires the processor ID to be interpreted as "local". 53 : */ 54 296139 : Patch(const processor_id_type my_procid = static_cast<processor_id_type>(-1)) : 55 296139 : _my_procid(my_procid) 56 29097 : {} 57 : 58 : /** 59 : * Destructor. 60 : */ 61 158297 : ~Patch() = default; 62 : 63 : /** 64 : * This function finds all elements which touch the current patch at 65 : * a face, and adds them to the patch. 66 : */ 67 : void add_face_neighbors(); 68 : 69 : /** 70 : * This function finds all elements on the current processor which 71 : * touch the current patch at a face, and adds them to the patch. 72 : */ 73 : void add_local_face_neighbors(); 74 : 75 : /** 76 : * This function finds all elements which touch the current patch at 77 : * a face and which touch one of our processor's elements at any 78 : * point, and it adds them to the patch. 79 : */ 80 : void add_semilocal_face_neighbors(); 81 : 82 : /** 83 : * This function finds all elements which touch the current patch at 84 : * any point, and adds them to the patch. 85 : */ 86 : void add_point_neighbors(); 87 : 88 : /** 89 : * This function finds all elements on the current processor which 90 : * touch the current patch at any point, and adds them to the patch. 91 : */ 92 : void add_local_point_neighbors(); 93 : 94 : /** 95 : * This function finds all elements which touch the current patch at 96 : * any point and which touch one of our processor's elements at any 97 : * point, and it adds them to the patch. 98 : */ 99 : void add_semilocal_point_neighbors(); 100 : 101 : /** 102 : * Pointer to Member Function typedef 103 : */ 104 : typedef void (Patch::*PMF)(); 105 : 106 : /** 107 : * Erases any elements in the current patch, then builds a new patch 108 : * containing element \p elem by repeated addition of neighbors on 109 : * the current processor. This procedure is repeated until the 110 : * number of elements meets or exceeds \p target_patch_size, or 111 : * until the patch has no more local neighbors. 112 : */ 113 : void build_around_element(const Elem * elem, 114 : const unsigned int target_patch_size = 10, 115 : PMF patchtype = &Patch::add_local_face_neighbors); 116 : 117 : protected: 118 : 119 : /** 120 : * This function finds all elements which 121 : * touch the current patch at a face 122 : */ 123 : void find_face_neighbors(std::set<const Elem *> & neighbor_set); 124 : 125 : /** 126 : * This function finds all elements which 127 : * touch the current patch at any point 128 : */ 129 : void find_point_neighbors(std::set<const Elem *> & neighbor_set); 130 : 131 : const processor_id_type _my_procid; 132 : }; 133 : 134 : } // namespace libMesh 135 : 136 : 137 : #endif // LIBMESH_PATCH_H