Skip to content
Permalink
Browse files

Merge pull request #13206 from permcody/ghost_uo_improvements

Ghost uo improvements
  • Loading branch information...
lindsayad committed Apr 11, 2019
2 parents 504b617 + 9500001 commit c27dd9c97e03d867c269aa5e625467183a136b2a
Showing with 442 additions and 216 deletions.
  1. +24 −0 framework/doc/content/source/actions/DisplayGhostingAction.md
  2. +2 −0 framework/doc/content/source/auxkernels/GhostingAux.md
  3. +17 −0 framework/doc/content/source/userobject/GhostingUserObject.md
  4. +39 −0 framework/include/actions/DisplayGhostingAction.h
  5. +0 −6 framework/include/auxkernels/AuxKernel.h
  6. +0 −6 framework/include/auxkernels/AuxScalarKernel.h
  7. +12 −7 framework/include/auxkernels/GhostingAux.h
  8. +63 −0 framework/include/userobject/GhostingUserObject.h
  9. +87 −0 framework/src/actions/DisplayGhostingAction.C
  10. +25 −40 framework/src/auxkernels/GhostingAux.C
  11. +3 −7 framework/src/base/Moose.C
  12. +3 −3 framework/src/outputs/ConsoleUtils.C
  13. +0 −29 framework/src/systems/AuxiliarySystem.C
  14. +111 −0 framework/src/userobject/GhostingUserObject.C
  15. +2 −2 modules/phase_field/include/auxkernels/FeatureFloodCountAux.h
  16. +16 −34 test/tests/auxkernels/ghosting_aux/ghosting_aux.i
  17. BIN test/tests/auxkernels/ghosting_aux/gold/ghosting_aux_out.e
  18. BIN test/tests/auxkernels/ghosting_aux/gold/ghosting_aux_with_local_out.e
  19. BIN test/tests/auxkernels/ghosting_aux/gold/no_ghosting_out.e
  20. +2 −20 test/tests/auxkernels/ghosting_aux/no_ghosting.i
  21. +15 −1 test/tests/auxkernels/ghosting_aux/tests
  22. BIN test/tests/relationship_managers/two_rm/gold/two_rm_dist_out.e
  23. BIN test/tests/relationship_managers/two_rm/gold/two_rm_out.e
  24. +18 −0 test/tests/relationship_managers/two_rm/tests
  25. +3 −61 test/tests/relationship_managers/two_rm/two_rm.i
@@ -0,0 +1,24 @@
#DisplayGhostingAction

The DisplayGhostingAction is for outputting the ghosting of your simulation. In MOOSE, we attempt
to ghost only the minimum amount of data for running the simulation. In order to know what ghosting
we need each object can add one or more RelationshipManager classes. This object sets up
several AuxVariables and AuxKernels for outputting both the "Geometric" and "Algebraic" ghosting.

To output ghosting add the following parameter(s) to your Mesh block:
```
[Mesh]
...
output_ghosting = true
include_local_in_ghosting = true
[]
```

The `include_local_in_ghosting` parameter will also include all of a processors local elements
in the ghosting field to give you a complete view of ghosting.

Example:

!listing test/tests/auxkernels/ghosting_aux/ghosting_aux.i block=Mesh

!bibtex bibliography
@@ -8,6 +8,8 @@

At any one time it will only show you the ghosted elements for one processor ID.

Normally, this class shouldn't be used directly. Instead set it up through the (DisplayGhostingAction.md).

!row!
!col! class=s12 m6 l6

@@ -0,0 +1,17 @@
# GhostingUserObject

The GhostingUserObject maintains local data structures of elements involved in both
"Geometric" and "Algebraic" ghosting. This object is normally setup automatically through the
(DisplayGhostingAction.md).

## Example Input Syntax:

!syntax description /UserObjects/GhostingUserObject

!syntax parameters /UserObjects/GhostingUserObject

!syntax inputs /UserObjects/GhostingUserObject

!syntax children /UserObjects/GhostingUserObject

!bibtex bibliography
@@ -0,0 +1,39 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifndef DISPLAYGHOSTINGACTION_H
#define DISPLAYGHOSTINGACTION_H

#include "Action.h"

#include "libmesh/fe_base.h"

class DisplayGhostingAction;

template <>
InputParameters validParams<DisplayGhostingAction>();

/**
* Class to setup multiple AuxVariables and AuxKernels to display the ghosting when running in
* parallel.
*/
class DisplayGhostingAction : public Action
{
public:
DisplayGhostingAction(InputParameters params);

protected:
virtual void act() override;

private:
bool _display_ghosting;
bool _include_local;
};

#endif // DISPLAYGHOSTINGACTION_H
@@ -66,12 +66,6 @@ class AuxKernel : public MooseObject,

virtual ~AuxKernel();

/**
* Called just before the compute loop starts so an AuxKernel can initialize
* any internal datastructures
*/
virtual void initialize() {}

/**
* Computes the value and stores it in the solution vector
*/
@@ -48,12 +48,6 @@ class AuxScalarKernel : public MooseObject,

virtual ~AuxScalarKernel();

/**
* Called just before the compute loop starts so an AuxKernel can initialize
* any internal datastructures
*/
virtual void initialize() {}

/**
* Evaluate the kernel
*/
@@ -14,30 +14,35 @@

#include "libmesh/ghosting_functor.h"

// Forward Declarations
class GhostingAux;
class GhostingUserObject;

template <>
InputParameters validParams<GhostingAux>();

/**
*
*/
class GhostingAux : public AuxKernel
{
public:
GhostingAux(const InputParameters & parameters);

virtual void initialize() override;

protected:
virtual Real computeValue() override;
virtual void precalculateValue() override;

/// The PID to show the ghosting for
processor_id_type _pid;

/// The type of ghosting functor to get
int _functor_type;
Moose::RelationshipManagerType _rm_type;

/// Whether or not to include local elements in the display field
bool _include_local;

/// precalculated element value
Real _value;

/// The reference to the ghosting user object
const GhostingUserObject & _ghost_uo;

/// Ghosted elems
libMesh::GhostingFunctor::map_type _ghosted_elems;
@@ -0,0 +1,63 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifndef GHOSTINGUSEROBJECT_H
#define GHOSTINGUSEROBJECT_H

#include "GeneralUserObject.h"

#include "libmesh/ghosting_functor.h"

#include <unordered_map>

// Forward Declarations
class GhostingUserObject;
class MooseMesh;
class NonlinearSystemBase;

template <>
InputParameters validParams<GhostingUserObject>();

/**
* This object loops over all of the underlying ghosting functors added by libMesh or MOOSE through
* RelationshipManagers to display the effective ghosting for a particular simulation. Normally this
* information is output through several AuxVariables.
*/
class GhostingUserObject : public GeneralUserObject
{
public:
GhostingUserObject(const InputParameters & parameters);

virtual void initialSetup() override;

virtual void initialize() override {}
virtual void execute() override {}
virtual void finalize() override {}

virtual void meshChanged() override;

Real getElementalValue(const Elem * elem,
Moose::RelationshipManagerType rm_type,
processor_id_type pid) const;

private:
/// The PID to show the ghosting for
std::vector<processor_id_type> _pids;

/// Ghost Functor maps
/// Dimension one: Map type (Geometric, Algebraic)
/// Dimension two: Proc ID -> Map
/// Dimension three: Elem Ptr -> Coupling Matrix
std::vector<std::unordered_map<processor_id_type, libMesh::GhostingFunctor::map_type>> _maps;

MooseMesh & _mesh;
NonlinearSystemBase & _nl;
};

#endif // GHOSTINGAUX_H
@@ -0,0 +1,87 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "DisplayGhostingAction.h"
#include "FEProblemBase.h"

registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_variable");

registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_kernel");

registerMooseAction("MooseApp", DisplayGhostingAction, "add_user_object");

template <>
InputParameters
validParams<DisplayGhostingAction>()
{
InputParameters params = validParams<Action>();
params.addParam<bool>("output_ghosting", false, "Boolean to turn on ghosting auxiliary fields");
params.addParam<bool>("include_local_in_ghosting",
false,
"Boolean used to toggle on the inclusion of local elements along with the "
"ghost elements for a complete partition map");

params.addClassDescription(
"Action to setup AuxVariables and AuxKernels to display ghosting when running in parallel");

return params;
}

DisplayGhostingAction::DisplayGhostingAction(InputParameters params)
: Action(params),
_display_ghosting(getParam<bool>("output_ghosting")),
_include_local(getParam<bool>("include_local_in_ghosting"))
{
}

void
DisplayGhostingAction::act()
{
if (_display_ghosting == false)
return;

auto n_procs = _app.n_processors();

if (_current_task == "add_aux_variable")
{
FEType fe_type(CONSTANT, MONOMIAL);

for (unsigned int i = 0; i < 2; ++i)
{
std::string var_name_base = (i == 0 ? "geometric" : "algebraic");
for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
_problem->addAuxVariable(var_name_base + std::to_string(proc_id), fe_type);
}
}
else if (_current_task == "add_aux_kernel")
{
for (unsigned int i = 0; i < 2; ++i)
{
std::string aux_kernel_name_base = i == 0 ? "geometric" : "algebraic";
for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
{
std::string name = aux_kernel_name_base + std::to_string(proc_id);

auto params = _factory.getValidParams("GhostingAux");
params.set<processor_id_type>("pid") = proc_id;
params.set<MooseEnum>("functor_type") = aux_kernel_name_base;
params.set<UserObjectName>("ghost_uo") = "ghost_uo";
params.set<AuxVariableName>("variable") = name;
params.set<bool>("include_local_elements") = _include_local;

_problem->addAuxKernel("GhostingAux", name, params);
}
}
}
else if (_current_task == "add_user_object")
{
auto params = _factory.getValidParams("GhostingUserObject");
_problem->addUserObject("GhostingUserObject", "ghost_uo", params);
}
}
Oops, something went wrong.

0 comments on commit c27dd9c

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