Skip to content

Commit

Permalink
Added a optional parameter to allow user to control whether or not
Browse files Browse the repository at this point in the history
to repartion mesh and delete remote elements

Closes idaholab#18571
  • Loading branch information
fdkong committed Aug 10, 2021
1 parent be666b2 commit b4ba696
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
12 changes: 11 additions & 1 deletion framework/include/mesh/MooseMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,14 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
/**
* Set uniform refinement level
*/
void setUniformRefineLevel(unsigned int);
void setUniformRefineLevel(unsigned int, bool deletion = true);

/**
* Return a flag indicating whether or not we should have a remote deletion
* after uniform refinements. Note: If the flag is false (no remote deletion),
* uniform refinements will run more efficient.
*/
bool uniformRefineRemoteDeletion() const { return _uniform_refine_remote_deletion; }

/**
* This will add the boundary ids to be ghosted to this processor
Expand Down Expand Up @@ -1122,6 +1129,9 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
/// The level of uniform refinement requested (set to zero if AMR is disabled)
unsigned int _uniform_refine_level;

/// Whether or not delete remote "extra" elements after uniform refinements
bool _uniform_refine_remote_deletion;

/// true if mesh is changed (i.e. after adaptivity step)
bool _is_changed;

Expand Down
11 changes: 10 additions & 1 deletion framework/src/actions/SetupMeshAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ SetupMeshAction::validParams()

params.addParam<unsigned int>(
"uniform_refine", 0, "Specify the level of uniform refinement applied to the initial mesh");

params.addParam<bool>(
"uniform_refine_remote_deletion",
true,
"If it is false, remote deletion will be avoided for efficiency of uniform refinements. "
"This flag has no impact on a replicated mesh. For a distributed mesh, the remote elements "
"are already deleted, "
"and the mesh is already distributed properly, before uniform refinements.");

params.addParam<bool>("skip_partitioning",
false,
"If true the mesh won't be partitioned. This may cause large load "
Expand Down Expand Up @@ -130,7 +139,7 @@ SetupMeshAction::setupMesh(MooseMesh * mesh)
// Did they specify extra refinement levels on the command-line?
level += _app.getParam<unsigned int>("refinements");

mesh->setUniformRefineLevel(level);
mesh->setUniformRefineLevel(level, getParam<bool>("uniform_refine_remote_deletion"));
#endif // LIBMESH_ENABLE_AMR

// Add entity names to the mesh
Expand Down
13 changes: 10 additions & 3 deletions framework/src/base/Adaptivity.C
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,16 @@ Adaptivity::uniformRefine(MooseMesh * mesh, unsigned int level /*=libMesh::inval
if (level == libMesh::invalid_uint)
level = mesh->uniformRefineLevel();

mesh->getMesh().skip_partitioning(true);
mesh->getMesh().allow_remote_element_removal(false);
mesh->needsRemoteElemDeletion(false);
// Remote deletion and repartition for uniformly refined meshs
// are not necessary while they time-consuming. Have a optional
// parameter to allow users turn them off.
if (!mesh->uniformRefineRemoteDeletion())
{
mesh->getMesh().skip_partitioning(true);
mesh->getMesh().allow_remote_element_removal(false);
mesh->needsRemoteElemDeletion(false);
}

mesh_refinement.uniformly_refine(level);
}

Expand Down
5 changes: 4 additions & 1 deletion framework/src/mesh/MooseMesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ MooseMesh::MooseMesh(const InputParameters & parameters)
_partitioner_overridden(false),
_custom_partitioner_requested(false),
_uniform_refine_level(0),
_uniform_refine_remote_deletion(true),
_is_nemesis(getParam<bool>("nemesis")),
_node_to_elem_map_built(false),
_node_to_active_semilocal_elem_map_built(false),
Expand Down Expand Up @@ -241,6 +242,7 @@ MooseMesh::MooseMesh(const MooseMesh & other_mesh)
_partitioner_overridden(other_mesh._partitioner_overridden),
_custom_partitioner_requested(other_mesh._custom_partitioner_requested),
_uniform_refine_level(other_mesh.uniformRefineLevel()),
_uniform_refine_remote_deletion(other_mesh._uniform_refine_remote_deletion),
_is_nemesis(false),
_node_to_elem_map_built(false),
_node_to_active_semilocal_elem_map_built(false),
Expand Down Expand Up @@ -2690,9 +2692,10 @@ MooseMesh::uniformRefineLevel() const
}

void
MooseMesh::setUniformRefineLevel(unsigned int level)
MooseMesh::setUniformRefineLevel(unsigned int level, bool deletion)
{
_uniform_refine_level = level;
_uniform_refine_remote_deletion = deletion;
}

void
Expand Down

0 comments on commit b4ba696

Please sign in to comment.