LCOV - code coverage report
Current view: top level - include/mesh - mesh_smoother_laplace.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4300 (1cc1b6) with base e27e71 Lines: 1 1 100.0 %
Date: 2025-10-30 01:56:38 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          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             :    * @param n_iterations The number of smoothing iterations to be performed.
      51             :    */
      52             :   explicit LaplaceMeshSmoother(UnstructuredMesh &mesh,
      53             :                                const unsigned int n_iterations);
      54             : 
      55             : #ifdef LIBMESH_ENABLE_DEPRECATED
      56             :   /**
      57             :    * Constructor. Sets the constant mesh reference
      58             :    * in the protected data section of the class.
      59             :    *
      60             :    * \deprecated This constructor has been deprecated in favor of the
      61             :    * (UnstructuredMesh, const unsigned int) constructor. By specifying the
      62             :    * number of smoothing iterations in the constructor, there is no need to pass
      63             :    * this parameter to the smooth method. As such, the smooth method's signature
      64             :    * will match that of the parent class and the sister VariationalMeshSmoother
      65             :    * class.
      66             :    */
      67             :   explicit LaplaceMeshSmoother(UnstructuredMesh &mesh)
      68             :       : LaplaceMeshSmoother(mesh, 1) {
      69             :     libmesh_deprecated();
      70             :   }
      71             : #endif
      72             : 
      73             :   /**
      74             :    * Destructor.
      75             :    */
      76         768 :   virtual ~LaplaceMeshSmoother() = default;
      77             : 
      78             :   /**
      79             :    * Redefinition of the smooth function from the
      80             :    * base class.
      81             :    */
      82             :   virtual void smooth() override;
      83             : 
      84             : #ifdef LIBMESH_ENABLE_DEPRECATED
      85             :   /**
      86             :    * The actual smoothing function, gets called whenever
      87             :    * the user specifies an actual number of smoothing
      88             :    * iterations.
      89             :    *
      90             :    * \deprecated The number of iterations should be set in the class constructor.
      91             :    * The parameterless smooth() override should be used to smooth.
      92             :    */
      93             :   void smooth(unsigned int n_iterations);
      94             : #endif
      95             : 
      96             :   /**
      97             :    * Initialization for the Laplace smoothing routine
      98             :    * is basically identical to building an "L-graph"
      99             :    * which is expensive.  It's provided separately from
     100             :    * the constructor since you may or may not want
     101             :    * to build the L-graph on construction.
     102             :    */
     103             :   void init();
     104             : 
     105             :   /**
     106             :    * Mainly for debugging, this function will print
     107             :    * out the connectivity graph which has been created.
     108             :    */
     109             :   void print_graph(std::ostream & out_stream = libMesh::out) const;
     110             : 
     111             : private:
     112             :   /**
     113             :    * This function allgather's the (local) graph after
     114             :    * it is computed on each processor by the init() function.
     115             :    */
     116             :   void allgather_graph();
     117             : 
     118             :   /**
     119             :    * True if the L-graph has been created, false otherwise.
     120             :    */
     121             :   bool _initialized;
     122             : 
     123             :   /**
     124             :    * Data structure for holding the L-graph
     125             :    */
     126             :   std::vector<std::vector<dof_id_type>> _graph;
     127             : 
     128             :   /**
     129             :   * Number of smoothing iterations to perform
     130             :   */
     131             :   unsigned int _n_iterations;
     132             : };
     133             : 
     134             : 
     135             : } // namespace libMesh
     136             : 
     137             : #endif // LIBMESH_MESH_SMOOTHER_LAPLACE_H

Generated by: LCOV version 1.14