LCOV - code coverage report
Current view: top level - src/meshgenerators - ElementsToTetrahedronsConverter.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 19 20 95.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 "ElementsToTetrahedronsConverter.h"
      11             : #include "MooseMeshElementConversionUtils.h"
      12             : 
      13             : #include "libmesh/elem.h"
      14             : #include "libmesh/boundary_info.h"
      15             : #include "libmesh/mesh_base.h"
      16             : #include "libmesh/parallel.h"
      17             : #include "libmesh/parallel_algebra.h"
      18             : #include "libmesh/cell_tet4.h"
      19             : #include "libmesh/face_tri3.h"
      20             : 
      21             : // C++ includes
      22             : #include <cmath>
      23             : 
      24             : registerMooseObject("MooseApp", ElementsToTetrahedronsConverter);
      25             : 
      26             : InputParameters
      27       14449 : ElementsToTetrahedronsConverter::validParams()
      28             : {
      29       14449 :   InputParameters params = MeshGenerator::validParams();
      30             : 
      31       14449 :   params.addRequiredParam<MeshGeneratorName>(
      32             :       "input", "The input mesh that needs to be converted to tetrahedral elements.");
      33             : 
      34       14449 :   params.addClassDescription(
      35             :       "This ElementsToTetrahedronsConverter object is designed to convert all the elements in a 3D "
      36             :       "mesh consisting only linear elements into TET4 elements.");
      37             : 
      38       14449 :   return params;
      39           0 : }
      40             : 
      41          92 : ElementsToTetrahedronsConverter::ElementsToTetrahedronsConverter(const InputParameters & parameters)
      42             :   : MeshGenerator(parameters),
      43          92 :     _input_name(getParam<MeshGeneratorName>("input")),
      44         184 :     _input(getMeshByName(_input_name))
      45             : {
      46          92 : }
      47             : 
      48             : std::unique_ptr<MeshBase>
      49          92 : ElementsToTetrahedronsConverter::generate()
      50             : {
      51          92 :   auto replicated_mesh_ptr = dynamic_cast<ReplicatedMesh *>(_input.get());
      52          92 :   if (!replicated_mesh_ptr)
      53           4 :     paramError("input", "Input is not a replicated mesh, which is required");
      54         172 :   if (*(replicated_mesh_ptr->elem_dimensions().begin()) != 3 ||
      55         172 :       *(replicated_mesh_ptr->elem_dimensions().rbegin()) != 3)
      56           4 :     paramError("input", "Only 3D meshes are supported.");
      57             : 
      58          84 :   ReplicatedMesh & mesh = *replicated_mesh_ptr;
      59             : 
      60          84 :   MooseMeshElementConversionUtils::convert3DMeshToAllTet4(mesh);
      61             : 
      62          80 :   return std::move(_input);
      63             : }

Generated by: LCOV version 1.14