LCOV - code coverage report
Current view: top level - src/meshgenerators - SmoothMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 18 20 90.0 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "SmoothMeshGenerator.h"
      11             : 
      12             : // libMesh includes
      13             : #include "libmesh/mesh_smoother_laplace.h"
      14             : #include "libmesh/unstructured_mesh.h"
      15             : #include "libmesh/replicated_mesh.h"
      16             : 
      17             : #include "CastUniquePointer.h"
      18             : 
      19             : registerMooseObject("MooseApp", SmoothMeshGenerator);
      20             : 
      21             : InputParameters
      22       14281 : SmoothMeshGenerator::validParams()
      23             : {
      24       14281 :   InputParameters params = MeshGenerator::validParams();
      25             : 
      26       14281 :   params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to smooth.");
      27       14281 :   params.addClassDescription("Utilizes a simple Laplacian based smoother to attempt to improve "
      28             :                              "mesh quality.  Will not move boundary nodes or nodes along "
      29             :                              "block/subdomain boundaries");
      30             : 
      31       14281 :   params.addParam<unsigned int>("iterations", 1, "The number of smoothing iterations to do.");
      32             : 
      33       14281 :   return params;
      34           0 : }
      35             : 
      36           8 : SmoothMeshGenerator::SmoothMeshGenerator(const InputParameters & parameters)
      37             :   : MeshGenerator(parameters),
      38           8 :     _input(getMesh("input")),
      39          16 :     _iterations(getParam<unsigned int>("iterations"))
      40             : {
      41           8 : }
      42             : 
      43             : std::unique_ptr<MeshBase>
      44           8 : SmoothMeshGenerator::generate()
      45             : {
      46           8 :   std::unique_ptr<MeshBase> old_mesh = std::move(_input);
      47           8 :   if (!old_mesh->is_replicated())
      48           0 :     mooseError("SmoothMeshGenerator is not implemented for distributed meshes");
      49             : 
      50           8 :   auto mesh = dynamic_pointer_cast<ReplicatedMesh>(old_mesh);
      51             : 
      52           8 :   libMesh::LaplaceMeshSmoother lms(static_cast<UnstructuredMesh &>(*mesh));
      53             : 
      54           8 :   lms.smooth(_iterations);
      55             : 
      56          16 :   return dynamic_pointer_cast<MeshBase>(mesh);
      57           8 : }

Generated by: LCOV version 1.14