https://mooseframework.inl.gov
MeshCutUserObjectBase.C
Go to the documentation of this file.
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 
20 {
22  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  params.addParam<std::string>("mesh_generator_name",
28  "Mesh generator for the XFEM geometric cutter.");
29  params.addClassDescription("Base class for mesh-based cutters used with XFEM.");
30  return params;
31 }
32 
34  : GeometricCutUserObject(parameters, true)
35 {
36  if (isParamValid("mesh_generator_name"))
37  {
38  std::string cutterMeshName = getParam<std::string>("mesh_generator_name");
39  auto & mesh_generator_system = _app.getMeshGeneratorSystem();
40  _cutter_mesh = mesh_generator_system.getSavedMesh(cutterMeshName);
41  }
42  else if (isParamValid("mesh_file"))
43  {
44  MeshFileName cutterMeshName = getParam<MeshFileName>("mesh_file");
45  _cutter_mesh = std::make_unique<ReplicatedMesh>(_communicator);
46  _cutter_mesh->read(cutterMeshName);
47  }
48  else
49  {
50  mooseError("Must specify 'mesh_generator_name' or 'mesh_file'. ");
51  }
52 
53  if (!_cutter_mesh)
54  mooseError("Not able to read in a cutter mesh.");
55 }
56 
57 MeshBase &
59 {
60  mooseAssert(_cutter_mesh, "MeshCutUserObjectBase::getCutterMesh _cutter_mesh is nullptr");
61  return *_cutter_mesh;
62 }
static InputParameters validParams()
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
MeshBase & getCutterMesh() const
Get a reference to the cutter mesh.
static InputParameters validParams()
const Parallel::Communicator & _communicator
MeshCutUserObjectBase(const InputParameters &parameters)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
bool isParamValid(const std::string &name) const
MeshGeneratorSystem & getMeshGeneratorSystem()
std::unique_ptr< MeshBase > _cutter_mesh
The xfem cutter mesh.