https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SetupMeshCompleteAction.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
11#include "MooseMesh.h"
12#include "Moose.h"
13#include "Adaptivity.h"
14#include "MooseApp.h"
15#include "FEProblemBase.h"
16
17registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh");
18
21 "delete_remote_elements_after_late_geometric_ghosting");
22
23registerMooseAction("MooseApp", SetupMeshCompleteAction, "uniform_refine_mesh");
24
25registerMooseAction("MooseApp", SetupMeshCompleteAction, "setup_mesh_complete");
26
29{
31 params.addClassDescription("Perform operations on the mesh in preparation for a simulation.");
32 return params;
33}
34
36
37void
39{
40 if (!_mesh)
41 mooseError("No mesh file was supplied and no generation block was provided");
42
43 if (_current_task == "uniform_refine_mesh")
44 {
45 // we don't need to run mesh modifiers *again* after they ran already during the mesh
46 // splitting process
47 // A uniform refinement is helpful for some instances when using a pre-split mesh.
48 // For example, a 'coarse' mesh might completely resolve geometry (also is large)
49 // but does not have enough resolution for the interior. For this scenario,
50 // we pre-split the coarse mesh, and load the pre-split mesh in parallel,
51 // and then do a few levels of uniform refinements to have a fine mesh that
52 // potentially resolves physics features.
53 if (_mesh->isSplit() && _mesh->skipRefineWhenUseSplit())
54 return;
55
56 // uniform refinement has been done on master, so skip
57 if (_app.useMasterMesh())
58 return;
59
66 if (_app.getExodusFileRestart() == false)
67 {
68 if (_app.isRecovering() == false || !_app.isUltimateMaster())
69 {
70 TIME_SECTION("uniformRefine", 2, "Uniformly Refining");
71
72 if (_mesh->uniformRefineLevel())
73 {
74 if (!_mesh->interiorLowerDBlocks().empty() || !_mesh->boundaryLowerDBlocks().empty())
75 mooseError("HFEM does not support mesh uniform refinement currently.");
76
78 // After refinement we need to make sure that all of our MOOSE-specific containers are
79 // up-to-date
80 _mesh->meshChanged();
81
83 {
85 // After refinement we need to make sure that all of our MOOSE-specific containers are
86 // up-to-date
87 _displaced_mesh->meshChanged();
88 }
89 }
90 }
91 }
92 }
93 else if (_current_task == "delete_remote_elements_after_late_geometric_ghosting")
94 {
95 TIME_SECTION("deleteRemoteElems", 2, "Deleting Remote Elements");
96
97 if (_displaced_mesh &&
98 (_mesh->needsRemoteElemDeletion() != _displaced_mesh->needsRemoteElemDeletion()))
99 mooseError("Our reference and displaced meshes are not in sync with respect to whether we "
100 "should delete remote elements.");
101
102 // We currently only trigger the needsRemoteDeletion flag if somebody has requested a late
103 // geometric ghosting functor and/or we have a displaced mesh
104 if (_mesh->needsRemoteElemDeletion())
105 {
106 // Must make sure to create the mortar meshes to build our data structures that ensure we will
107 // keep the correct elements in the mesh around
108 _problem->updateMortarMesh();
109 _mesh->deleteRemoteElements();
110 if (_displaced_mesh)
111 _displaced_mesh->deleteRemoteElements();
112 }
113 }
114 else
115 {
116 // Prepare the mesh (may occur multiple times)
117 bool prepare_for_use_called_on_undisplaced = false;
118 {
119 TIME_SECTION("completeSetupUndisplaced", 2, "Setting Up Undisplaced Mesh");
120 prepare_for_use_called_on_undisplaced = _mesh->prepare(/*mesh_to_clone=*/nullptr);
121 }
122
123 if (_displaced_mesh)
124 {
125 TIME_SECTION("completeSetupDisplaced", 2, "Setting Up Displaced Mesh");
126 // If the reference mesh was prepared, then we must prepare also
127 _displaced_mesh->prepare(
128 /*mesh_to_clone=*/prepare_for_use_called_on_undisplaced ? &_mesh->getMesh() : nullptr);
129 }
130 }
131}
registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh")
Base class for actions.
Definition Action.h:38
std::shared_ptr< MooseMesh > & _mesh
Definition Action.h:174
static InputParameters validParams()
Definition Action.C:26
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::shared_ptr< MooseMesh > & _displaced_mesh
Definition Action.h:175
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition Action.h:172
static void uniformRefine(MooseMesh *mesh, unsigned int level=libMesh::invalid_uint)
Performs uniform refinement of the passed Mesh object.
Definition Adaptivity.C:301
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
Definition MooseApp.h:866
bool getExodusFileRestart() const
Whether or not we need to use a separate Exodus reader to read the mesh BEFORE we create the mesh.
Definition MooseApp.h:436
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition MooseApp.C:1669
bool useMasterMesh() const
Returns whether to use the parent app mesh as the mesh for this app.
Definition MooseApp.h:871
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
static InputParameters validParams()
SetupMeshCompleteAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.