Skip to content

Commit

Permalink
Make partitioner block a mesh subblock, remove custom partitioner type (
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schunert committed Sep 24, 2015
1 parent 628e45b commit 00acb72
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 135 deletions.
7 changes: 7 additions & 0 deletions framework/include/mesh/MooseMesh.h
Expand Up @@ -687,6 +687,12 @@ class MooseMesh :
Partitioner * getCustomPartitioner() const;
void setCustomPartitioner(Partitioner * custom_partitioner);

/**
* Setter and getter for _custom_partitioner_requested
*/
bool isCustomPartitionerRequested() const;
void setIsCustomPartitionerRequested(bool cpr);

protected:
/// Can be set to PARALLEL, SERIAL, or DEFAULT. Determines whether
/// the underlying libMesh mesh is a SerialMesh or ParallelMesh.
Expand All @@ -707,6 +713,7 @@ class MooseMesh :

/// The custom partitioner
Partitioner * _custom_partitioner;
bool _custom_partitioner_requested;

/// Convenience enums
enum {
Expand Down
1 change: 1 addition & 0 deletions framework/src/actions/PartitionerAction.C
Expand Up @@ -38,6 +38,7 @@ PartitionerAction::PartitionerAction(InputParameters params) :
void
PartitionerAction::act()
{
_mesh->setIsCustomPartitionerRequested(true);
switch (_partitioner_type)
{
case 0:
Expand Down
112 changes: 67 additions & 45 deletions framework/src/mesh/MooseMesh.C
Expand Up @@ -72,7 +72,7 @@ InputParameters validParams<MooseMesh>()
"In particular you must supply this for GMSH meshes. "
"Note: This is completely ignored for ExodusII meshes!");

MooseEnum partitioning("default=-3 metis=-2 parmetis=-1 linear=0 centroid hilbert_sfc morton_sfc custom", "default");
MooseEnum partitioning("default=-3 metis=-2 parmetis=-1 linear=0 centroid hilbert_sfc morton_sfc", "default");
params.addParam<MooseEnum>("partitioner", partitioning, "Specifies a mesh partitioner to use when splitting the mesh for a parallel computation.");
MooseEnum direction("x y z radial");
params.addParam<MooseEnum>("centroid_partitioner_direction", direction, "Specifies the sort direction if using the centroid partitioner. Available options: x, y, z, radial");
Expand All @@ -99,6 +99,7 @@ MooseMesh::MooseMesh(const InputParameters & parameters) :
_mesh(NULL),
_partitioner_name(getParam<MooseEnum>("partitioner")),
_partitioner_overridden(false),
_custom_partitioner_requested(false),
_uniform_refine_level(0),
_is_changed(false),
_is_nemesis(getParam<bool>("nemesis")),
Expand Down Expand Up @@ -1699,54 +1700,63 @@ MooseMesh::getNormalByBoundaryID(BoundaryID id) const
void
MooseMesh::init()
{
// Set the partitioner
switch (_partitioner_name)
if (_custom_partitioner_requested)
{
case -3: // default
// We'll use the default partitioner, but notify the user of which one is being used...
if (_use_parallel_mesh)
_partitioner_name = "parmetis";
else
_partitioner_name = "metis";
break;

// No need to explicitily create the metis or parmetis partitioners,
// They are the default for serial and parallel mesh respectively
case -2: // metis
case -1: // parmetis
break;

case 0: // linear
getMesh().partitioner().reset(new LinearPartitioner);
break;
case 1: // centroid
{
if (!isParamValid("centroid_partitioner_direction"))
mooseError("If using the centroid partitioner you _must_ specify centroid_partitioner_direction!");

MooseEnum direction = getParam<MooseEnum>("centroid_partitioner_direction");

if (direction == "x")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::X));
else if (direction == "y")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::Y));
else if (direction == "z")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::Z));
else if (direction == "radial")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::RADIAL));
break;
}
case 2: // hilbert_sfc
getMesh().partitioner().reset(new HilbertSFCPartitioner);
break;
case 3: // morton_sfc
getMesh().partitioner().reset(new MortonSFCPartitioner);
break;
case 4: // custom
// Check of partitioner is supplied (not allowed if custom partitioner is used)
if (!parameters().isParamSetByAddParam("partitioner"))
mooseError("If partitioner block is provded, partitioner keyword cannot be used!");
// Set custom partitioner
if (!_custom_partitioner)
mooseError("If using partitioner type custom you must explicitly provide a partitioner in your input file!");
getMesh().partitioner().reset(_custom_partitioner);
break;
}
else
{
// Set standard partitioner
// Set the partitioner based on partitioner name
switch (_partitioner_name)
{
case -3: // default
// We'll use the default partitioner, but notify the user of which one is being used...
if (_use_parallel_mesh)
_partitioner_name = "parmetis";
else
_partitioner_name = "metis";
break;

// No need to explicitily create the metis or parmetis partitioners,
// They are the default for serial and parallel mesh respectively
case -2: // metis
case -1: // parmetis
break;

case 0: // linear
getMesh().partitioner().reset(new LinearPartitioner);
break;
case 1: // centroid
{
if (!isParamValid("centroid_partitioner_direction"))
mooseError("If using the centroid partitioner you _must_ specify centroid_partitioner_direction!");

MooseEnum direction = getParam<MooseEnum>("centroid_partitioner_direction");

if (direction == "x")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::X));
else if (direction == "y")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::Y));
else if (direction == "z")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::Z));
else if (direction == "radial")
getMesh().partitioner().reset(new CentroidPartitioner(CentroidPartitioner::RADIAL));
break;
}
case 2: // hilbert_sfc
getMesh().partitioner().reset(new HilbertSFCPartitioner);
break;
case 3: // morton_sfc
getMesh().partitioner().reset(new MortonSFCPartitioner);
break;
}
}

if (_app.isRecovering() && _allow_recovery && _app.isUltimateMaster())
Expand Down Expand Up @@ -2185,6 +2195,18 @@ MooseMesh::setCustomPartitioner(Partitioner * custom_partitioner)
_custom_partitioner = custom_partitioner;
}

bool
MooseMesh::isCustomPartitionerRequested() const
{
return _custom_partitioner_requested;
}

void
MooseMesh::setIsCustomPartitionerRequested(bool cpr)
{
_custom_partitioner_requested = cpr;
}

void
MooseMesh::addMortarInterface(const std::string & name, BoundaryName master, BoundaryName slave, SubdomainName domain_name)
{
Expand Down
2 changes: 1 addition & 1 deletion framework/src/parser/MooseSyntax.C
Expand Up @@ -104,7 +104,7 @@ void associateSyntax(Syntax & syntax, ActionFactory & action_factory)
syntax.registerActionSyntax("AdaptivityAction", "Executioner/Adaptivity");
#endif

syntax.registerActionSyntax("PartitionerAction", "Partitioner");
syntax.registerActionSyntax("PartitionerAction", "Mesh/Partitioner");

syntax.registerActionSyntax("AddDiracKernelAction", "DiracKernels/*");

Expand Down
Expand Up @@ -11,15 +11,12 @@
ymin = 0.0
ymax = 10.0

partitioner = custom


[./Partitioner]
partitioner = linear
[../]
distribution = serial
[]

[Partitioner]
partitioner_type = linear
[]

[Variables]
active = 'u'
Expand Down Expand Up @@ -79,7 +76,7 @@
[]

[Outputs]
file_base = out
file_base = custom_linear_partitioner_test_out
[./exodus]
type = Exodus
elemental_as_nodal = true
Expand Down
Binary file not shown.
82 changes: 0 additions & 82 deletions test/tests/mesh/custom_partitioner/linear_partitioner_test.i

This file was deleted.

7 changes: 7 additions & 0 deletions test/tests/mesh/custom_partitioner/tests
@@ -0,0 +1,7 @@
[Tests]
[./custom_linear_partitioner]
type = 'Exodiff'
input = 'custom_linear_partitioner_test.i'
exodiff = 'custom_linear_partitioner_test_out.e'
[../]
[]

0 comments on commit 00acb72

Please sign in to comment.