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_MESH_SMOOTHER_LAPLACE_H 21 : #define LIBMESH_MESH_SMOOTHER_LAPLACE_H 22 : 23 : // C++ Includes 24 : #include <vector> 25 : 26 : // Local Includes 27 : #include "libmesh/libmesh.h" 28 : #include "libmesh/mesh_smoother.h" 29 : 30 : namespace libMesh 31 : { 32 : 33 : /** 34 : * This class defines the data structures necessary for Laplace 35 : * smoothing. 36 : * 37 : * \note This is a simple averaging smoother, which does \e not 38 : * guarantee that points will be smoothed to valid locations, e.g. 39 : * locations inside the boundary! This aspect could use work. 40 : * 41 : * \author John W. Peterson 42 : * \date 2002-2007 43 : */ 44 : class LaplaceMeshSmoother : public MeshSmoother 45 : { 46 : public: 47 : /** 48 : * Constructor. Sets the constant mesh reference 49 : * in the protected data section of the class. 50 : */ 51 : explicit 52 : LaplaceMeshSmoother(UnstructuredMesh & mesh); 53 : 54 : /** 55 : * Destructor. 56 : */ 57 768 : virtual ~LaplaceMeshSmoother() = default; 58 : 59 : /** 60 : * Redefinition of the smooth function from the 61 : * base class. All this does is call the smooth 62 : * function in this class which takes an int, using 63 : * a default value of 1. 64 : */ 65 0 : virtual void smooth() override { this->smooth(1); } 66 : 67 : /** 68 : * The actual smoothing function, gets called whenever 69 : * the user specifies an actual number of smoothing 70 : * iterations. 71 : */ 72 : void smooth(unsigned int n_iterations); 73 : 74 : /** 75 : * Initialization for the Laplace smoothing routine 76 : * is basically identical to building an "L-graph" 77 : * which is expensive. It's provided separately from 78 : * the constructor since you may or may not want 79 : * to build the L-graph on construction. 80 : */ 81 : void init(); 82 : 83 : /** 84 : * Mainly for debugging, this function will print 85 : * out the connectivity graph which has been created. 86 : */ 87 : void print_graph(std::ostream & out_stream = libMesh::out) const; 88 : 89 : private: 90 : /** 91 : * This function allgather's the (local) graph after 92 : * it is computed on each processor by the init() function. 93 : */ 94 : void allgather_graph(); 95 : 96 : /** 97 : * True if the L-graph has been created, false otherwise. 98 : */ 99 : bool _initialized; 100 : 101 : /** 102 : * Data structure for holding the L-graph 103 : */ 104 : std::vector<std::vector<dof_id_type>> _graph; 105 : }; 106 : 107 : 108 : } // namespace libMesh 109 : 110 : #endif // LIBMESH_MESH_SMOOTHER_LAPLACE_H