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 #include "TimedPrint.h"
16 
17 registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh");
18 
19 registerMooseAction("MooseApp",
21  "delete_remote_elements_post_equation_systems_init");
22 
23 registerMooseAction("MooseApp", SetupMeshCompleteAction, "execute_mesh_modifiers");
24 
25 registerMooseAction("MooseApp", SetupMeshCompleteAction, "uniform_refine_mesh");
26 
27 registerMooseAction("MooseApp", SetupMeshCompleteAction, "setup_mesh_complete");
28 
30 
33 {
35  return params;
36 }
37 
39  : Action(params), _uniform_refine_timer(registerTimedSection("uniformRefine", 2))
40 {
41 }
42 
43 bool
45 {
46  bool prepared = mesh->prepared();
47 
48  if (!prepared)
49  mesh->prepare();
50 
51  // Clear the modifiers, they are not used again during the simulation after the mesh has been
52  // completed
54 
55  return prepared;
56 }
57 
58 void
60 {
61  if (!_mesh)
62  mooseError("No mesh file was supplied and no generation block was provided");
63 
64  if (_current_task == "execute_mesh_modifiers")
65  {
66  // we don't need to run mesh modifiers *again* after they ran already during the mesh
67  // splitting process
68  if (_app.isUseSplit())
69  return;
71  }
72  else if (_current_task == "uniform_refine_mesh")
73  {
74  // we don't need to run mesh modifiers *again* after they ran already during the mesh
75  // splitting process
76  if (_app.isUseSplit())
77  return;
78 
79  // uniform refinement has been done on master, so skip
80  if (_app.masterMesh())
81  return;
82 
89  if (_app.setFileRestart() == false && _app.isRecovering() == false)
90  {
91  TIME_SECTION(_uniform_refine_timer);
92 
93  auto & _communicator = *_app.getCommunicator();
94  CONSOLE_TIMED_PRINT("Uniformly refining mesh");
95 
96  if (_mesh->uniformRefineLevel())
97  {
99  // After refinement we need to make sure that all of our MOOSE-specific containers are
100  // up-to-date
101  _mesh->update();
102 
103  if (_displaced_mesh)
104  {
106  // After refinement we need to make sure that all of our MOOSE-specific containers are
107  // up-to-date
108  _displaced_mesh->update();
109  }
110  }
111  }
112  }
113  else if (_current_task == "delete_remote_elements_post_equation_systems_init")
114  {
115  if (_mesh->needsRemoteElemDeletion())
116  {
117  _mesh->getMesh().delete_remote_elements();
118  if (_displaced_mesh)
119  _displaced_mesh->getMesh().delete_remote_elements();
120  }
121  }
122  else
123  {
124  // Prepare the mesh (may occur multiple times)
125  completeSetup(_mesh.get());
126 
127  if (_displaced_mesh)
129  }
130 }
Adaptivity::uniformRefine
static void uniformRefine(MooseMesh *mesh, unsigned int level=libMesh::invalid_uint)
Performs uniform refinement of the passed Mesh object.
Definition: Adaptivity.C:208
MooseApp::executeMeshModifiers
void executeMeshModifiers()
Execute and clear the Mesh Modifiers data structure.
Definition: MooseApp.C:1466
MooseMesh::prepared
bool prepared() const
Setter/getter for the _is_prepared flag.
Definition: MooseMesh.C:2313
SetupMeshCompleteAction::_uniform_refine_timer
PerfID _uniform_refine_timer
Definition: SetupMeshCompleteAction.h:30
Action::_app
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:213
MooseApp::setFileRestart
bool & setFileRestart()
Returns a writable Boolean to determine whether or not we need to use a separate reader to read the m...
Definition: MooseApp.h:325
MooseMesh.h
SetupMeshCompleteAction
Definition: SetupMeshCompleteAction.h:19
Action::_current_task
const std::string & _current_task
The current action (even though we have seperate instances for each action)
Definition: Action.h:240
SetupMeshCompleteAction::validParams
static InputParameters validParams()
Definition: SetupMeshCompleteAction.C:32
registerMooseAction
registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh")
SetupMeshCompleteAction::SetupMeshCompleteAction
SetupMeshCompleteAction(InputParameters params)
Definition: SetupMeshCompleteAction.C:38
defineLegacyParams
defineLegacyParams(SetupMeshCompleteAction)
SetupMeshCompleteAction::completeSetup
bool completeSetup(MooseMesh *mesh)
Definition: SetupMeshCompleteAction.C:44
Moose.h
MooseApp::clearMeshModifiers
void clearMeshModifiers()
Clear all mesh modifers.
Definition: MooseApp.C:1519
MooseApp::isUseSplit
bool isUseSplit() const
Whether or not we are running with pre-split (distributed mesh)
Definition: MooseApp.C:952
Action
Base class for actions.
Definition: Action.h:39
mooseError
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition: MooseError.h:210
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
MooseApp.h
MooseMesh::prepare
void prepare(bool force=false)
Calls prepare_for_use() if force=true on the underlying Mesh object, then communicates various bounda...
Definition: MooseMesh.C:354
MooseApp::isRecovering
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:934
Action::_displaced_mesh
std::shared_ptr< MooseMesh > & _displaced_mesh
Definition: Action.h:243
MooseApp::getCommunicator
const std::shared_ptr< Parallel::Communicator > getCommunicator() const
Definition: MooseApp.h:724
TimedPrint.h
Adaptivity.h
MooseMesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
SetupMeshCompleteAction::act
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
Definition: SetupMeshCompleteAction.C:59
Action::_mesh
std::shared_ptr< MooseMesh > & _mesh
Definition: Action.h:242
MooseApp::masterMesh
const MooseMesh * masterMesh() const
Returns a pointer to the master mesh.
Definition: MooseApp.h:566
Action::validParams
static InputParameters validParams()
Definition: Action.C:23
SetupMeshCompleteAction.h