Skip to content
Permalink
Browse files

Merge pull request #13205 from lindsayad/ghosting-fixes

Delete remote elements if its needed
  • Loading branch information...
permcody committed Apr 10, 2019
2 parents 9248be2 + 1f7d9d2 commit 68e175598a5e6cf504b038dbcdb4f514938316e2
@@ -864,6 +864,16 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
/// Helper type for building periodic node maps
using PeriodicNodeInfo = std::pair<const Node *, BoundaryID>;

/**
* Set whether we need to delete remote elements
*/
void needsRemoteElemDeletion(bool need_delete) { _need_delete = need_delete; }

/**
* Whether we need to delete remote elements
*/
bool needsRemoteElemDeletion() const { return _need_delete; }

protected:
/// Deprecated (DO NOT USE)
std::vector<std::unique_ptr<GhostingFunctor>> _ghosting_functors;
@@ -1184,6 +1194,9 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
PerfID _read_recovered_mesh_timer;
PerfID _ghost_ghosted_boundaries_timer;
PerfID _add_mortar_interface_timer;

/// Whether we need to delete remote elements after init'ing the EquationSystems
bool _need_delete;
};

/**
@@ -156,6 +156,21 @@ Action::addRelationshipManagers(Moose::RelationshipManagerType input_rm_type,
// Keep looking for more RMs
continue;
}
// Ok the above block may have told the mesh not to allow remote element removal during the
// initial MeshBase::prepare_for_use, which is called after attaching geometric ghosting
// functors. If we did tell the mesh not to allow remote element removal **and** we're using a
// DistributedMesh, then we need to tell the mesh to allow remote element removal and ensure
// that the mesh will delete its remote elements after the EquationSystems init
else if (input_rm_type == Moose::RelationshipManagerType::ALGEBRAIC &&
(rm_params.get<Moose::RelationshipManagerType>("rm_type") &
Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC &&
!rm_params.get<bool>("attach_geometric_early") && _mesh->isDistributedMesh())
{
_mesh->needsRemoteElemDeletion(true);
if (_displaced_mesh)
_displaced_mesh->needsRemoteElemDeletion(true);
}

rm_params.set<MooseMesh *>("mesh") = _mesh.get();

@@ -35,14 +35,4 @@ AddRelationshipManager::act()
action_ptr->addRelationshipManagers(rm_type);

_app.attachRelationshipManagers(rm_type);

if (_current_task == "attach_algebraic_rm")
{
// If we're doing Algebraic then we're done adding ghosting functors
// and we can tell the mesh that it's safe to remove remote elements again
_mesh->getMesh().allow_remote_element_removal(true);

if (_problem->getDisplacedProblem())
_problem->getDisplacedProblem()->mesh().getMesh().allow_remote_element_removal(true);
}
}
@@ -155,6 +155,17 @@ CreateDisplacedProblemAction::act()

addProxyGeometricRelationshipManagers(undisplaced_nl, displaced_nl);
addProxyGeometricRelationshipManagers(displaced_nl, undisplaced_nl);

// When adding the geometric relationship mangers we told the mesh not to allow remote element
// removal during the initial MeshBase::prepare_for_use call. If we're using a distributed
// mesh we need to make sure we now allow remote element removal and then delete the remote
// elmeents after the EquationSystems init
if (_mesh->isDistributedMesh())
{
_mesh->needsRemoteElemDeletion(true);
if (_displaced_mesh)
_displaced_mesh->needsRemoteElemDeletion(true);
}
}
}
}
@@ -15,6 +15,10 @@

registerMooseAction("MooseApp", SetupMeshCompleteAction, "prepare_mesh");

registerMooseAction("MooseApp",
SetupMeshCompleteAction,
"delete_remote_elements_post_equation_systems_init");

registerMooseAction("MooseApp", SetupMeshCompleteAction, "execute_mesh_modifiers");

registerMooseAction("MooseApp", SetupMeshCompleteAction, "uniform_refine_mesh");
@@ -89,6 +93,15 @@ SetupMeshCompleteAction::act()
}
}
}
else if (_current_task == "delete_remote_elements_post_equation_systems_init")
{
if (_mesh->needsRemoteElemDeletion())
{
_mesh->getMesh().delete_remote_elements();
if (_displaced_mesh)
_displaced_mesh->getMesh().delete_remote_elements();
}
}
else
{
// Prepare the mesh (may occur multiple times)
@@ -169,6 +169,7 @@ addActionTypes(Syntax & syntax)
registerTask("execute_mesh_generators", true);
registerTask("uniform_refine_mesh", false);
registerTask("prepare_mesh", false);
registerTask("delete_remote_elements_post_equation_systems_init", false);
registerTask("setup_mesh_complete", true); // calls prepare
registerTask("add_geometric_rm", false);
registerTask("attach_geometric_rm", true);
@@ -285,6 +286,7 @@ addActionTypes(Syntax & syntax)
"(add_algebraic_rm)"
"(attach_algebraic_rm)"
"(init_problem)"
"(delete_remote_elements_post_equation_systems_init)"
"(add_output)"
"(add_postprocessor)"
"(add_vector_postprocessor)" // MaterialVectorPostprocessor requires this
@@ -389,8 +391,6 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/)
registerSyntax("DynamicObjectRegistrationAction", "Problem");
registerSyntax("SetupMeshAction", "Mesh");
registerSyntax("SetupMeshCompleteAction", "Mesh");
// registerSyntaxTask("SetupMeshCompleteAction", "Mesh", "prepare_mesh");
// registerSyntaxTask("SetupMeshCompleteAction", "Mesh", "setup_mesh_complete");
registerSyntax("CreateDisplacedProblemAction", "Mesh");
registerSyntax("AddMeshModifierAction", "MeshModifiers/*");
registerSyntax("AddMeshGeneratorAction", "MeshGenerators/*");
@@ -206,7 +206,8 @@ MooseMesh::MooseMesh(const InputParameters & parameters)
_init_timer(registerTimedSection("init", 2)),
_read_recovered_mesh_timer(registerTimedSection("readRecoveredMesh", 2)),
_ghost_ghosted_boundaries_timer(registerTimedSection("GhostGhostedBoundaries", 3)),
_add_mortar_interface_timer(registerTimedSection("addMortarInterface", 5))
_add_mortar_interface_timer(registerTimedSection("addMortarInterface", 5)),
_need_delete(false)
{
if (isParamValid("ghosting_patch_size") && (_patch_update_strategy != Moose::Iteration))
mooseError("Ghosting patch size parameter has to be set in the mesh block "

0 comments on commit 68e1755

Please sign in to comment.
You can’t perform that action at this time.