www.mooseframework.org
SetupMeshCompleteAction.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 
11 #include "MooseMesh.h"
12 #include "Moose.h"
13 #include "Adaptivity.h"
14 #include "MooseApp.h"
15 
16 registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh");
17 
18 registerMooseAction("MooseApp",
20  "delete_remote_elements_post_equation_systems_init");
21 
22 registerMooseAction("MooseApp", SetupMeshCompleteAction, "execute_mesh_modifiers");
23 
24 registerMooseAction("MooseApp", SetupMeshCompleteAction, "uniform_refine_mesh");
25 
26 registerMooseAction("MooseApp", SetupMeshCompleteAction, "setup_mesh_complete");
27 
28 template <>
31 {
33  return params;
34 }
35 
37  : Action(params), _uniform_refine_timer(registerTimedSection("uniformRefine", 2))
38 {
39 }
40 
41 bool
43 {
44  bool prepared = mesh->prepared();
45 
46  if (!prepared)
47  mesh->prepare();
48 
49  // Clear the modifiers, they are not used again during the simulation after the mesh has been
50  // completed
52 
53  return prepared;
54 }
55 
56 void
58 {
59  if (!_mesh)
60  mooseError("No mesh file was supplied and no generation block was provided");
61 
62  if (_current_task == "execute_mesh_modifiers")
63  {
64  // we don't need to run mesh modifiers *again* after they ran already during the mesh
65  // splitting process
66  if (_app.isUseSplit())
67  return;
69  }
70  else if (_current_task == "uniform_refine_mesh")
71  {
72  // we don't need to run mesh modifiers *again* after they ran already during the mesh
73  // splitting process
74  if (_app.isUseSplit())
75  return;
76 
83  if (_app.setFileRestart() == false && _app.isRecovering() == false)
84  {
85  if (_mesh->uniformRefineLevel())
86  {
87  TIME_SECTION(_uniform_refine_timer);
88 
90 
91  if (_displaced_mesh)
93  }
94  }
95  }
96  else if (_current_task == "delete_remote_elements_post_equation_systems_init")
97  {
98  if (_mesh->needsRemoteElemDeletion())
99  {
100  _mesh->getMesh().delete_remote_elements();
101  if (_displaced_mesh)
102  _displaced_mesh->getMesh().delete_remote_elements();
103  }
104  }
105  else
106  {
107  // Prepare the mesh (may occur multiple times)
108  completeSetup(_mesh.get());
109 
110  if (_displaced_mesh)
112  }
113 }
bool prepared() const
Setter/getter for the _is_prepared flag.
Definition: MooseMesh.C:2291
registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh")
bool & setFileRestart()
This method is here so we can determine whether or not we need to use a separate reader to read the m...
Definition: MooseApp.h:306
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
SetupMeshCompleteAction(InputParameters params)
InputParameters validParams< SetupMeshCompleteAction >()
void executeMeshModifiers()
Execute and clear the Mesh Modifiers data structure.
Definition: MooseApp.C:1379
bool completeSetup(MooseMesh *mesh)
Base class for actions.
Definition: Action.h:35
static void uniformRefine(MooseMesh *mesh)
Performs uniform refinement of the passed Mesh object.
Definition: Adaptivity.C:206
std::shared_ptr< MooseMesh > & _displaced_mesh
Definition: Action.h:213
bool isUseSplit() const
Whether or not we are running with pre-split (distributed mesh)
Definition: MooseApp.C:877
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
const std::string & _current_task
The current action (even though we have seperate instances for each action)
Definition: Action.h:210
void clearMeshModifiers()
Clear all mesh modifers.
Definition: MooseApp.C:1432
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
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
std::shared_ptr< MooseMesh > & _mesh
Definition: Action.h:212
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:183
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:859
InputParameters validParams< Action >()
Definition: Action.C:22