www.mooseframework.org
MeshModifier.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "MeshModifier.h"
11 #include "MooseMesh.h"
12 
13 template <>
16 {
18  params.addParam<std::vector<std::string>>(
19  "depends_on",
20  "The MeshModifiers that this modifier relies upon (i.e. must execute before this one)");
21  params.addParam<bool>("force_prepare",
22  false,
23  "Normally all MeshModifiers run before the mesh is prepared for use. This "
24  "flag can be set on an individual modifier "
25  "to force preparation between modifiers where they might be needed.");
26 
27  params.addPrivateParam<MooseMesh *>("_mesh");
28 
29  params.registerBase("MeshModifier");
30  return params;
31 }
32 
34  : MooseObject(parameters),
35  Restartable(this, "MeshModifiers"),
36  _mesh_ptr(NULL),
37  _depends_on(getParam<std::vector<std::string>>("depends_on")),
38  _force_prepare(getParam<bool>("force_prepare"))
39 {
40 }
41 
42 void
43 MeshModifier::modifyMesh(MooseMesh * mesh, MooseMesh * displaced_mesh)
44 {
45  // Initialize or reinitialize any mesh related structures.
46  initialize();
47 
48  modifyMeshHelper(mesh);
49 
50  // Now do the same thing for the displaced mesh if it exists
51  if (displaced_mesh)
52  modifyMeshHelper(displaced_mesh);
53 }
54 
55 void
57 {
58  // Set pointer to the mesh so that derived classes may use them
59  _mesh_ptr = mesh;
60 
61  // Modify the mesh!
62  modify();
63 
64  // Prepare the mesh if requested
65  if (_force_prepare)
66  mesh->prepare();
67 }
virtual void modify()=0
Pure virtual modify function MUST be overridden by children classes.
A class for creating restricted objects.
Definition: Restartable.h:29
const bool _force_prepare
Flag to determine if the mesh should be prepared after this modifier is run.
Definition: MeshModifier.h:75
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialize()
This method is called immediatly before modify to perform any necessary initialization on the modifif...
Definition: MeshModifier.h:53
MooseMesh * _mesh_ptr
Pointer to the mesh.
Definition: MeshModifier.h:68
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
void prepare(bool force=false)
Calls prepare_for_use() if force=true on the underlying Mesh object, then communicates various bounda...
Definition: MooseMesh.C:343
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:25
void modifyMesh(MooseMesh *mesh, MooseMesh *displaced_mesh)
The base method called to trigger modification to the Mesh.
Definition: MeshModifier.C:43
MeshModifier(const InputParameters &parameters)
Constructor.
Definition: MeshModifier.C:33
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
InputParameters validParams< MeshModifier >()
Definition: MeshModifier.C:15
void modifyMeshHelper(MooseMesh *mesh)
Utility for performing the same operation on both undiplaced and displaced meshes.
Definition: MeshModifier.C:56