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 "MeshCutUserObjectBase.h" 11 : 12 : #include "MooseError.h" 13 : #include "MooseUtils.h" 14 : #include "MooseMesh.h" 15 : #include "libmesh/serial_mesh.h" 16 : #include "libmesh/mesh_tools.h" 17 : 18 : InputParameters 19 123 : MeshCutUserObjectBase::validParams() 20 : { 21 123 : InputParameters params = GeometricCutUserObject::validParams(); 22 246 : params.addDeprecatedParam<MeshFileName>( 23 : "mesh_file", 24 : "Mesh file for the XFEM geometric cut.", 25 : "This parameter is deprecated in favor of reading in the cuttermesh from the mesh system " 26 : "using 'mesh_generator_name'."); 27 246 : params.addParam<std::string>("mesh_generator_name", 28 : "Mesh generator for the XFEM geometric cutter."); 29 123 : params.addClassDescription("Base class for mesh-based cutters used with XFEM."); 30 123 : return params; 31 0 : } 32 : 33 62 : MeshCutUserObjectBase::MeshCutUserObjectBase(const InputParameters & parameters) 34 62 : : GeometricCutUserObject(parameters, true) 35 : { 36 124 : if (isParamValid("mesh_generator_name")) 37 : { 38 82 : std::string cutterMeshName = getParam<std::string>("mesh_generator_name"); 39 41 : auto & mesh_generator_system = _app.getMeshGeneratorSystem(); 40 82 : _cutter_mesh = mesh_generator_system.getSavedMesh(cutterMeshName); 41 : } 42 42 : else if (isParamValid("mesh_file")) 43 : { 44 21 : MeshFileName cutterMeshName = getParam<MeshFileName>("mesh_file"); 45 21 : _cutter_mesh = std::make_unique<ReplicatedMesh>(_communicator); 46 21 : _cutter_mesh->read(cutterMeshName); 47 : } 48 : else 49 : { 50 0 : mooseError("Must specify 'mesh_generator_name' or 'mesh_file'. "); 51 : } 52 : 53 62 : if (!_cutter_mesh) 54 0 : mooseError("Not able to read in a cutter mesh."); 55 62 : } 56 : 57 : MeshBase & 58 80 : MeshCutUserObjectBase::getCutterMesh() const 59 : { 60 : mooseAssert(_cutter_mesh, "MeshCutUserObjectBase::getCutterMesh _cutter_mesh is nullptr"); 61 80 : return *_cutter_mesh; 62 : }