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 "ElementsToSimplicesConverter.h" 11 : 12 : #include "CastUniquePointer.h" 13 : 14 : #include "libmesh/mesh_modification.h" 15 : #include "libmesh/unstructured_mesh.h" 16 : 17 : registerMooseObject("MooseApp", ElementsToSimplicesConverter); 18 : 19 : InputParameters 20 3221 : ElementsToSimplicesConverter::validParams() 21 : { 22 3221 : InputParameters params = MeshGenerator::validParams(); 23 : 24 12884 : params.addRequiredParam<MeshGeneratorName>("input", "Input mesh to convert to all-simplex mesh"); 25 : 26 3221 : params.addClassDescription("Splits all non-simplex elements in a mesh into simplices."); 27 : 28 3221 : return params; 29 0 : } 30 : 31 80 : ElementsToSimplicesConverter::ElementsToSimplicesConverter(const InputParameters & parameters) 32 160 : : MeshGenerator(parameters), _input_ptr(getMesh("input")) 33 : { 34 80 : } 35 : 36 : std::unique_ptr<MeshBase> 37 80 : ElementsToSimplicesConverter::generate() 38 : { 39 : // Put the input mesh in a local pointer 40 : std::unique_ptr<UnstructuredMesh> mesh = 41 80 : dynamic_pointer_cast<UnstructuredMesh>(std::move(_input_ptr)); 42 : 43 : // all_tri() on a ReplicatedMesh skips its internal prepare_for_use() call (it only prepares 44 : // for non-replicated meshes). Without preparation, element_ptr_range() may not iterate over 45 : // all elements correctly, producing incomplete results. Prepare here to ensure correctness. 46 80 : if (!mesh->is_prepared()) 47 80 : mesh->prepare_for_use(); 48 : 49 80 : MeshTools::Modification::all_tri(*mesh); 50 : 51 160 : return mesh; 52 80 : }