LCOV - code coverage report
Current view: top level - src/meshgenerators - SphereMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 27 100.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 "SphereMeshGenerator.h"
      11             : #include "CastUniquePointer.h"
      12             : 
      13             : #include "libmesh/mesh_generation.h"
      14             : #include "libmesh/string_to_enum.h"
      15             : 
      16             : registerMooseObject("MooseApp", SphereMeshGenerator);
      17             : 
      18             : InputParameters
      19       14349 : SphereMeshGenerator::validParams()
      20             : {
      21       14349 :   InputParameters params = MeshGenerator::validParams();
      22       14349 :   params.addClassDescription("Generate a 3-D sphere mesh centered on the origin");
      23       14349 :   params.addRequiredRangeCheckedParam<Real>("radius", "radius > 0.0", "Sphere radius");
      24       14349 :   params.addRequiredRangeCheckedParam<unsigned int>("nr", "nr > 0", "Number of radial elements");
      25             : 
      26       14349 :   MooseEnum types("HEX8 HEX27", "HEX8");
      27       14349 :   params.addParam<MooseEnum>("elem_type", types, "The type of element to generate");
      28       14349 :   params.addParam<unsigned int>("n_smooth", 0, "Number of smoothing operations");
      29       28698 :   return params;
      30       14349 : }
      31             : 
      32          42 : SphereMeshGenerator::SphereMeshGenerator(const InputParameters & parameters)
      33             :   : MeshGenerator(parameters),
      34          42 :     _radius(getParam<Real>("radius")),
      35          42 :     _nr(getParam<unsigned int>("nr")),
      36          42 :     _elem_type(getParam<MooseEnum>("elem_type")),
      37          84 :     _n_smooth(getParam<unsigned int>("n_smooth"))
      38             : {
      39          42 : }
      40             : 
      41             : std::unique_ptr<MeshBase>
      42          41 : SphereMeshGenerator::generate()
      43             : {
      44          41 :   auto mesh = buildMeshBaseObject();
      45          41 :   mesh->set_mesh_dimension(3);
      46          41 :   mesh->set_spatial_dimension(3);
      47             : 
      48          41 :   ElemType et = Utility::string_to_enum<ElemType>(_elem_type);
      49             : 
      50          41 :   MeshTools::Generation::build_sphere(static_cast<UnstructuredMesh &>(*mesh),
      51          41 :                                       _radius,
      52          41 :                                       _nr,
      53             :                                       et,
      54          41 :                                       _n_smooth,
      55             :                                       false /* dummy value; not used for 3-D meshes */);
      56             : 
      57          82 :   return dynamic_pointer_cast<MeshBase>(mesh);
      58          41 : }

Generated by: LCOV version 1.14