www.mooseframework.org
MeshModifier.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "MeshModifier.h"
16 #include "MooseMesh.h"
17 
18 template <>
21 {
23  params.addParam<std::vector<std::string>>(
24  "depends_on",
25  "The MeshModifiers that this modifier relies upon (i.e. must execute before this one)");
26  params.addParam<bool>("force_prepare",
27  false,
28  "Normally all MeshModifiers run before the mesh is prepared for use. This "
29  "flag can be set on an individual modifier "
30  "to force preperation between modifiers where they might be needed.");
31 
32  params.registerBase("MeshModifier");
33 
34  return params;
35 }
36 
38  : MooseObject(parameters),
39  Restartable(parameters, "MeshModifiers"),
40  _mesh_ptr(NULL),
41  _depends_on(getParam<std::vector<std::string>>("depends_on")),
42  _force_prepare(getParam<bool>("force_prepare"))
43 {
44 }
45 
46 void
47 MeshModifier::modifyMesh(MooseMesh * mesh, MooseMesh * displaced_mesh)
48 {
49  // Initialize or reinitialize any mesh related structures.
50  initialize();
51 
52  modifyMeshHelper(mesh);
53 
54  // Now do the same thing for the displaced mesh if it exists
55  if (displaced_mesh)
56  modifyMeshHelper(displaced_mesh);
57 }
58 
59 void
61 {
62  // Set pointer to the mesh so that derived classes may use them
63  _mesh_ptr = mesh;
64 
65  // Modify the mesh!
66  modify();
67 
68  // Prepare the mesh if requested
69  if (_force_prepare)
70  mesh->prepare();
71 }
virtual void modify()=0
Pure virtual modify function MUST be overridden by children classes.
A class for creating restricted objects.
Definition: Restartable.h:31
const bool _force_prepare
Flag to determine if the mesh should be prepared after this modifier is run.
Definition: MeshModifier.h:81
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:59
MooseMesh * _mesh_ptr
Pointer to the mesh.
Definition: MeshModifier.h:74
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:36
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:350
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
void modifyMesh(MooseMesh *mesh, MooseMesh *displaced_mesh)
The base method called to trigger modification to the Mesh.
Definition: MeshModifier.C:47
MeshModifier(const InputParameters &parameters)
Constructor.
Definition: MeshModifier.C:37
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:20
void modifyMeshHelper(MooseMesh *mesh)
Utility for performing the same operation on both undiplaced and displaced meshes.
Definition: MeshModifier.C:60