Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally allow uniform refinements when using a pre-split mesh #18576

Merged
merged 4 commits into from Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions framework/include/mesh/MooseMesh.h
Expand Up @@ -488,6 +488,11 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
*/
void setUniformRefineLevel(unsigned int);

/**
* Whether or not skip uniform refinements when using a pre-split mesh
*/
bool skipRefineWhenUseSplit() const { return _skip_refine_when_use_split; }

/**
* This will add the boundary ids to be ghosted to this processor
*/
Expand Down Expand Up @@ -1122,6 +1127,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 to skip uniform refinements when using a pre-split mesh
bool _skip_refine_when_use_split;

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

Expand Down
8 changes: 7 additions & 1 deletion framework/src/actions/SetupMeshCompleteAction.C
Expand Up @@ -49,7 +49,13 @@ SetupMeshCompleteAction::act()
{
// we don't need to run mesh modifiers *again* after they ran already during the mesh
// splitting process
if (_app.isUseSplit())
// A uniform refinement is helpful for some instances when using a pre-split mesh.
// For example, a 'coarse' mesh might completely resolve geometry (also is large)
// but does not have enough resolution for the interior. For this scenario,
// we pre-split the coarse mesh, and load the pre-split mesh in parallel,
// and then do a few levels of uniform refinements to have a fine mesh that
// potentially resolves physics features.
if (_app.isUseSplit() && _mesh->skipRefineWhenUseSplit())
return;

// uniform refinement has been done on master, so skip
Expand Down
6 changes: 6 additions & 0 deletions framework/src/mesh/MooseMesh.C
Expand Up @@ -145,6 +145,10 @@ MooseMesh::validParams()
false,
"True to build the lower-dimensional mesh for all sides.");

params.addParam<bool>("skip_refine_when_use_split",
true,
"True to skip uniform refinements when using a pre-split mesh.");

// This indicates that the derived mesh type accepts a MeshGenerator, and should be set to true in
// derived types that do so.
params.addPrivateParam<bool>("_mesh_generator_mesh", false);
Expand Down Expand Up @@ -173,6 +177,7 @@ MooseMesh::MooseMesh(const InputParameters & parameters)
_partitioner_overridden(false),
_custom_partitioner_requested(false),
_uniform_refine_level(0),
_skip_refine_when_use_split(getParam<bool>("skip_refine_when_use_split")),
_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 +246,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()),
_skip_refine_when_use_split(other_mesh._skip_refine_when_use_split),
_is_nemesis(false),
_node_to_elem_map_built(false),
_node_to_active_semilocal_elem_map_built(false),
Expand Down
49 changes: 49 additions & 0 deletions test/tests/mesh/split_uniform_refine/3d_diffusion.i
@@ -0,0 +1,49 @@
[Mesh]
[./square]
type = GeneratedMeshGenerator
nx = 16
ny = 16
nz = 16
dim = 3
[../]
[]

[Variables]
[./u]
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[]

[BCs]
[./left]
type = DirichletBC
variable = u
preset = false
boundary = 3
value = 0
[../]

[./right]
type = DirichletBC
variable = u
preset = false
boundary = 1
value = 1
[../]
[]

[Executioner]
type = Steady

solve_type = 'NEWTON'
[]

[Outputs]
exodus = true
[]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions test/tests/mesh/split_uniform_refine/tests
@@ -0,0 +1,21 @@
[Tests]
design = 'Mesh/index.md Mesh/splitting.md'

[./square]
type = 'Exodiff'
input = '3d_diffusion.i'
cli_args = '-r 1 Mesh/skip_refine_when_use_split=false --use-split --split-file square'
exodiff = '3d_diffusion_out.e'
# Pre-split mesh was generated for this particular configuration.
# MOOSE will check these when we read meshes from cpr files
# if (_error_on_different_number_of_processors && (this_n_procs != n_procs))
# mooseError("Cannot restart using a different number of processors!");
# if (_error_on_different_number_of_threads && (this_n_threads != n_threads))
# mooseError("Cannot restart using a different number of threads!");
min_parallel = 3
max_parallel = 3
max_threads = 1
issues = '#18575'
requirement = 'The system shall support optionally allowing uniform refinements when using a pre-split mesh'
[../]
[]