Skip to content
Permalink
Browse files

Merge pull request #13201 from lindsayad/ghosting-fixes

Ghosting fixes
  • Loading branch information...
permcody committed Apr 10, 2019
2 parents b4065cc + 026fd62 commit 4708f0deebc47aa285b5f80c25f4fd731e56da3e
@@ -45,6 +45,21 @@ class Action : public ConsoleStreamInterface, public PerfGraphInterface
*/
void timedAct();

protected:
/**
* Method to add a relationship manager for the objects being added to the system. Relationship
* managers have to be added relatively early. In many cases before the Action::act() method
* is called.
* @param when_type The parameter indicating the normal time for adding either Geometric or
* Algebraic RelationshipManagers. It may not always be possible to add your
* RelationshipManager as early as you'd like. In these cases, your DistributedMesh may
* consume more memory during the problem setup.
* @param moose_object_pars The MooseObject to inspect for RelationshipManagers to add
*/
void addRelationshipManagers(Moose::RelationshipManagerType when_type,
const InputParameters & moose_object_pars);

public:
/**
* Method to add a relationship manager for the objects being added to the system. Relationship
* managers have to be added relatively early. In many cases before the Action::act() method
@@ -109,8 +124,7 @@ class Action : public ConsoleStreamInterface, public PerfGraphInterface
* back to the normal behavior of mooseError - only printing a message using the given args.
*/
template <typename... Args>
[[noreturn]] void paramError(const std::string & param, Args... args)
{
[[noreturn]] void paramError(const std::string & param, Args... args) {
auto prefix = param + ": ";
if (!_pars.inputLocation(param).empty())
prefix = _pars.inputLocation(param) + ": (" + _pars.paramFullpath(param) + "):\n";
@@ -24,6 +24,7 @@ class MooseObjectAction : public Action
public:
MooseObjectAction(InputParameters params);

using Action::addRelationshipManagers;
virtual void addRelationshipManagers(Moose::RelationshipManagerType when_type) override;

/**
@@ -13,6 +13,9 @@
#include "MooseTypes.h"
#include "MooseUtils.h" // remove when getBaseName is removed
#include "MooseMesh.h"
#include "FEProblemBase.h"
#include "DisplacedProblem.h"
#include "RelationshipManager.h"

template <>
InputParameters
@@ -88,6 +91,88 @@ Action::timedAct()

void Action::addRelationshipManagers(Moose::RelationshipManagerType) {}

void
Action::addRelationshipManagers(Moose::RelationshipManagerType input_rm_type,
const InputParameters & moose_object_pars)
{
const auto & buildable_types = moose_object_pars.getBuildableRelationshipManagerTypes();

// These need unique names
static unsigned int unique_object_id = 0;

for (const auto & buildable_type : buildable_types)
{
unique_object_id++;

auto & rm_name = std::get<0>(buildable_type);
auto & rm_type = std::get<1>(buildable_type);
auto rm_input_parameter_func = std::get<2>(buildable_type);

auto new_name = moose_object_pars.get<std::string>("_moose_base") + '_' + name() + '_' +
rm_name + "_" + Moose::stringify(rm_type) + " " +
std::to_string(unique_object_id);

auto rm_params = _factory.getValidParams(rm_name);
rm_params.set<Moose::RelationshipManagerType>("rm_type") = rm_type;
rm_params.set<std::string>("for_whom") = name();

// Figure out if we shouldn't be adding this one yet
if (((rm_type & input_rm_type) != input_rm_type) // Does this RM not have the type passed in?

|| // Or are we adding Geometric but this one needs to be delayed

(((input_rm_type & Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC) &&
((rm_type & Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC) &&
!rm_params.template get<bool>("attach_geometric_early"))

|| // Or is this an Algebraic and Geometric one that we already added earlier?

(((input_rm_type & Moose::RelationshipManagerType::ALGEBRAIC) ==
Moose::RelationshipManagerType::ALGEBRAIC) &&
(rm_type == (Moose::RelationshipManagerType::GEOMETRIC |
Moose::RelationshipManagerType::ALGEBRAIC)) &&
rm_params.template get<bool>("attach_geometric_early")))
continue;

// If there is a callback for setting the RM parameters let's use it
if (rm_input_parameter_func)
rm_input_parameter_func(moose_object_pars, rm_params);

// If we're doing geometric but we can't build it early - then let's not build it yet
// (It will get built when we do algebraic)
if ((input_rm_type & Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC &&
!rm_params.get<bool>("attach_geometric_early"))
{
// We also need to tell the mesh not to delete remote elements yet
// Note this will get reset in AddRelationshipManager::act() when attaching Algebraic
_mesh->getMesh().allow_remote_element_removal(false);

if (_problem->getDisplacedProblem())
_problem->getDisplacedProblem()->mesh().getMesh().allow_remote_element_removal(false);

// Keep looking for more RMs
continue;
}

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

if (rm_params.areAllRequiredParamsValid())
{
auto rm_obj = _factory.create<RelationshipManager>(rm_name, new_name, rm_params);

// Delete the resources created on behalf of the RM if it ends up not being added to the App.
if (!_app.addRelationshipManager(rm_obj))
_factory.releaseSharedObjects(*rm_obj);
}
else
mooseError("Missing required parameters for RelationshipManager " + rm_name + " for object " +
name());
}
}

/// DEPRECATED METHODS
std::string
Action::getShortName() const
@@ -137,7 +137,7 @@ CreateDisplacedProblemAction::act()

if (_current_task == "add_algebraic_rm")
{
auto & undisplaced_nl = _problem->getNonlinearSystem();
auto & undisplaced_nl = _problem->getNonlinearSystemBase();
auto & undisplaced_aux = _problem->getAuxiliarySystem();

auto displaced_problem_ptr = _problem->getDisplacedProblem();
@@ -11,12 +11,9 @@
#include "MooseObjectAction.h"
#include "MooseUtils.h"
#include "Factory.h"
#include "RelationshipManager.h"
#include "Conversion.h"
#include "MooseMesh.h"
#include "MooseApp.h"
#include "FEProblemBase.h"
#include "DisplacedProblem.h"

template <>
InputParameters
@@ -50,80 +47,5 @@ MooseObjectAction::MooseObjectAction(InputParameters params)
void
MooseObjectAction::addRelationshipManagers(Moose::RelationshipManagerType input_rm_type)
{
const auto & buildable_types = _moose_object_pars.getBuildableRelationshipManagerTypes();

// These need unique names
static unsigned int unique_object_id = 0;

for (const auto & buildable_type : buildable_types)
{
unique_object_id++;

auto & rm_name = std::get<0>(buildable_type);
auto & rm_type = std::get<1>(buildable_type);
auto rm_input_parameter_func = std::get<2>(buildable_type);

auto new_name = _moose_object_pars.get<std::string>("_moose_base") + '_' + name() + '_' +
rm_name + "_" + Moose::stringify(rm_type) + " " +
std::to_string(unique_object_id);

auto rm_params = _factory.getValidParams(rm_name);
rm_params.set<Moose::RelationshipManagerType>("rm_type") = rm_type;
rm_params.set<std::string>("for_whom") = name();

// Figure out if we shouldn't be adding this one yet
if (((rm_type & input_rm_type) != input_rm_type) // Does this RM not have the type passed in?

|| // Or are we adding Geometric but this one needs to be delayed

(((input_rm_type & Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC) &&
((rm_type & Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC) &&
!rm_params.template get<bool>("attach_geometric_early"))

|| // Or is this an Algebraic and Geometric one that we already added earlier?

(((input_rm_type & Moose::RelationshipManagerType::ALGEBRAIC) ==
Moose::RelationshipManagerType::ALGEBRAIC) &&
(rm_type == (Moose::RelationshipManagerType::GEOMETRIC |
Moose::RelationshipManagerType::ALGEBRAIC)) &&
rm_params.template get<bool>("attach_geometric_early")))
continue;

// If there is a callback for setting the RM parameters let's use it
if (rm_input_parameter_func)
rm_input_parameter_func(_moose_object_pars, rm_params);

// If we're doing geometric but we can't build it early - then let's not build it yet
// (It will get built when we do algebraic)
if ((input_rm_type & Moose::RelationshipManagerType::GEOMETRIC) ==
Moose::RelationshipManagerType::GEOMETRIC &&
!rm_params.get<bool>("attach_geometric_early"))
{
// We also need to tell the mesh not to delete remote elements yet
// Note this will get reset in AddRelationshipManager::act() when attaching Algebraic
_mesh->getMesh().allow_remote_element_removal(false);

if (_problem->getDisplacedProblem())
_problem->getDisplacedProblem()->mesh().getMesh().allow_remote_element_removal(false);

// Keep looking for more RMs
continue;
}

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

if (rm_params.areAllRequiredParamsValid())
{
auto rm_obj = _factory.create<RelationshipManager>(rm_name, new_name, rm_params);

// Delete the resources created on behalf of the RM if it ends up not being added to the App.
if (!_app.addRelationshipManager(rm_obj))
_factory.releaseSharedObjects(*rm_obj);
}
else
mooseError("Missing required parameters for RelationshipManager " + rm_name + " for object " +
name());
}
addRelationshipManagers(input_rm_type, _moose_object_pars);
}
@@ -17,7 +17,7 @@
// libmesh includes
#include "libmesh/threads.h"

defineADBaseValidParams(ADDGKernel, DGKernelBase, params.registerBase("DGKernel"););
defineADBaseValidParams(ADDGKernel, DGKernelBase, );

template <ComputeStage compute_stage>
ADDGKernel<compute_stage>::ADDGKernel(const InputParameters & parameters)
@@ -28,7 +28,6 @@ InputParameters
validParams<DGKernel>()
{
InputParameters params = validParams<DGKernelBase>();
params.registerBase("DGKernel");
return params;
}

@@ -61,6 +61,7 @@ validParams<DGKernelBase>()
params.addRelationshipManager("ElementSideNeighborLayers",
Moose::RelationshipManagerType::GEOMETRIC |
Moose::RelationshipManagerType::ALGEBRAIC);
params.registerBase("DGKernel");

return params;
}

0 comments on commit 4708f0d

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