Skip to content

Commit

Permalink
Do coupling check for dgs and iks
Browse files Browse the repository at this point in the history
We should also do a coupling check for objects that need
more than 0 layers of ghosting like dgkernels and interfacekernels.
This will also be very beneficial for applications like Rattlesnake
which uses complex actions to set up their simulations.
In Rattlesnake, there is often complex logic that may or may not
add dgs or iks depending on the input file. Instead of always
adding 1 layer of ghosting/coupling always, which is what is
being currently done since the addition of coupling functors,
we should just do the check for Rattlesnake and not worry about
adding relationship managers from the Rattlesnake actions. By
inspecting the warehouses after everything has been added, we
will always get the amount of coupling needed correct, no guessing
involved.

Refs #13736
  • Loading branch information
lindsayad committed Jul 26, 2019
1 parent 84500ef commit f9cb45c
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions framework/src/actions/CouplingFunctorCheckAction.C
Expand Up @@ -12,6 +12,7 @@
#include "MooseApp.h"
#include "FEProblemBase.h"
#include "NonlinearSystemBase.h"
#include "DGKernelBase.h"

#include "libmesh/system.h"

Expand Down Expand Up @@ -40,30 +41,39 @@ CouplingFunctorCheckAction::act()
auto & kernels = nl.getKernelWarehouse();
auto & nbcs = nl.getNodalBCWarehouse();
auto & ibcs = nl.getIntegratedBCWarehouse();
auto & dgs = nl.getDGKernelWarehouse();
auto & iks = nl.getInterfaceKernelWarehouse();

// If we have any of these, we need default coupling (e.g. element intra-dof coupling)
if (kernels.size() || nbcs.size() || ibcs.size())
{
auto original_size = _app.relationshipManagers().size();
auto original_size = _app.relationshipManagers().size();

// If we have any DGKernels or InterfaceKernels we need one layer of sparsity
if (dgs.size() || iks.size())
// It doesn't really matter what T is in validParams<T> as long as it will add our single layer
// of coupling
addRelationshipManagers(Moose::RelationshipManagerType::COUPLING, validParams<DGKernelBase>());

// If we have any of these, we need default coupling, e.g. 0 layers of sparsity, otherwise known
// as element intra-dof coupling. The `else if` below is important; if we already added 1 layer of
// sparsity above, then we don't need to add another coupling functor that is a subset of the
// previous one
else if (kernels.size() || nbcs.size() || ibcs.size())
// It doesn't really matter what T is in validParams<T> as long as it will add our default
// coupling functor object (ElementSideNeighborLayers with n_levels of 0)
addRelationshipManagers(Moose::RelationshipManagerType::COUPLING, validParams<Kernel>());

// See whether we've actually added anything new
if (original_size != _app.relationshipManagers().size())
{
// There's no concern of duplicating functors previously added here since functors are stored
// as std::sets
_app.attachRelationshipManagers(Moose::RelationshipManagerType::COUPLING);
// See whether we've actually added anything new
if (original_size != _app.relationshipManagers().size())
{
// There's no concern of duplicating functors previously added here since functors are stored
// as std::sets
_app.attachRelationshipManagers(Moose::RelationshipManagerType::COUPLING);

// Make sure that coupling matrices are attached to the coupling functors
_app.dofMapReinitForRMs();
// Make sure that coupling matrices are attached to the coupling functors
_app.dofMapReinitForRMs();

// Reinit the libMesh (Implicit)System. This re-computes the sparsity pattern and then applies
// it to the ImplicitSystem's matrices. Note that does NOT make a call to DofMap::reinit,
// hence we have to call GhostingFunctor::dofmap_reinit ourselves in the call above
nl.system().reinit();
}
// Reinit the libMesh (Implicit)System. This re-computes the sparsity pattern and then applies
// it to the ImplicitSystem's matrices. Note that does NOT make a call to DofMap::reinit,
// hence we have to call GhostingFunctor::dofmap_reinit ourselves in the call above
nl.system().reinit();
}
}

0 comments on commit f9cb45c

Please sign in to comment.