LCOV - code coverage report
Current view: top level - src/meshgenerators - SphereMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 27 27 100.0 %
Date: 2026-05-29 20:35:17 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        3333 : SphereMeshGenerator::validParams()
      20             : {
      21        3333 :   InputParameters params = MeshGenerator::validParams();
      22        6666 :   params.addClassDescription("Generate a 3-D sphere mesh centered on the origin");
      23       19998 :   params.addRequiredRangeCheckedParam<Real>("radius", "radius > 0.0", "Sphere radius");
      24       19998 :   params.addRequiredRangeCheckedParam<unsigned int>("nr", "nr > 0", "Number of radial elements");
      25             : 
      26       13332 :   MooseEnum types("HEX8 HEX27", "HEX8");
      27       13332 :   params.addParam<MooseEnum>("elem_type", types, "The type of element to generate");
      28        9999 :   params.addParam<unsigned int>("n_smooth", 0, "Number of smoothing operations");
      29        6666 :   return params;
      30        3333 : }
      31             : 
      32         136 : SphereMeshGenerator::SphereMeshGenerator(const InputParameters & parameters)
      33             :   : MeshGenerator(parameters),
      34         136 :     _radius(getParam<Real>("radius")),
      35         272 :     _nr(getParam<unsigned int>("nr")),
      36         272 :     _elem_type(getParam<MooseEnum>("elem_type")),
      37         408 :     _n_smooth(getParam<unsigned int>("n_smooth"))
      38             : {
      39         136 : }
      40             : 
      41             : std::unique_ptr<MeshBase>
      42         135 : SphereMeshGenerator::generate()
      43             : {
      44         135 :   auto mesh = buildMeshBaseObject();
      45         135 :   mesh->set_mesh_dimension(3);
      46         135 :   mesh->set_spatial_dimension(3);
      47             : 
      48         135 :   ElemType et = Utility::string_to_enum<ElemType>(_elem_type);
      49             : 
      50         135 :   MeshTools::Generation::build_sphere(static_cast<UnstructuredMesh &>(*mesh),
      51         135 :                                       _radius,
      52         135 :                                       _nr,
      53             :                                       et,
      54         135 :                                       _n_smooth,
      55             :                                       false /* dummy value; not used for 3-D meshes */);
      56             : 
      57         270 :   return dynamic_pointer_cast<MeshBase>(mesh);
      58         135 : }

Generated by: LCOV version 1.14