diff --git a/framework/include/mesh/MooseMesh.h b/framework/include/mesh/MooseMesh.h index c8b545869746..14f8622e7ec3 100644 --- a/framework/include/mesh/MooseMesh.h +++ b/framework/include/mesh/MooseMesh.h @@ -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. @@ -707,6 +713,7 @@ class MooseMesh : /// The custom partitioner Partitioner * _custom_partitioner; + bool _custom_partitioner_requested; /// Convenience enums enum { diff --git a/framework/src/actions/PartitionerAction.C b/framework/src/actions/PartitionerAction.C index dd175fdd057f..5f654f6b859c 100644 --- a/framework/src/actions/PartitionerAction.C +++ b/framework/src/actions/PartitionerAction.C @@ -38,6 +38,7 @@ PartitionerAction::PartitionerAction(InputParameters params) : void PartitionerAction::act() { + _mesh->setIsCustomPartitionerRequested(true); switch (_partitioner_type) { case 0: diff --git a/framework/src/mesh/MooseMesh.C b/framework/src/mesh/MooseMesh.C index 2e03defe0fd0..d88455fef740 100644 --- a/framework/src/mesh/MooseMesh.C +++ b/framework/src/mesh/MooseMesh.C @@ -72,7 +72,7 @@ InputParameters validParams() "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("partitioner", partitioning, "Specifies a mesh partitioner to use when splitting the mesh for a parallel computation."); MooseEnum direction("x y z radial"); params.addParam("centroid_partitioner_direction", direction, "Specifies the sort direction if using the centroid partitioner. Available options: x, y, z, radial"); @@ -99,6 +99,7 @@ MooseMesh::MooseMesh(const InputParameters & parameters) : _mesh(NULL), _partitioner_name(getParam("partitioner")), _partitioner_overridden(false), + _custom_partitioner_requested(false), _uniform_refine_level(0), _is_changed(false), _is_nemesis(getParam("nemesis")), @@ -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("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("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()) @@ -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) { diff --git a/framework/src/parser/MooseSyntax.C b/framework/src/parser/MooseSyntax.C index ec69373047b9..153926688fca 100644 --- a/framework/src/parser/MooseSyntax.C +++ b/framework/src/parser/MooseSyntax.C @@ -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/*"); diff --git a/test/tests/mesh/custom_partitioner/custom_linear_partitioner_test.i b/test/tests/mesh/custom_partitioner/custom_linear_partitioner_test.i index 6dd24ac8fc79..ba158a6bce2f 100644 --- a/test/tests/mesh/custom_partitioner/custom_linear_partitioner_test.i +++ b/test/tests/mesh/custom_partitioner/custom_linear_partitioner_test.i @@ -11,15 +11,12 @@ ymin = 0.0 ymax = 10.0 - partitioner = custom - - + [./Partitioner] + partitioner = linear + [../] distribution = serial [] -[Partitioner] - partitioner_type = linear -[] [Variables] active = 'u' @@ -79,7 +76,7 @@ [] [Outputs] - file_base = out + file_base = custom_linear_partitioner_test_out [./exodus] type = Exodus elemental_as_nodal = true diff --git a/test/tests/mesh/custom_partitioner/gold/custom_linear_partitioner_test_out.e b/test/tests/mesh/custom_partitioner/gold/custom_linear_partitioner_test_out.e new file mode 100644 index 000000000000..c7715698c495 Binary files /dev/null and b/test/tests/mesh/custom_partitioner/gold/custom_linear_partitioner_test_out.e differ diff --git a/test/tests/mesh/custom_partitioner/linear_partitioner_test.i b/test/tests/mesh/custom_partitioner/linear_partitioner_test.i deleted file mode 100644 index 978a69a576e6..000000000000 --- a/test/tests/mesh/custom_partitioner/linear_partitioner_test.i +++ /dev/null @@ -1,82 +0,0 @@ -[Mesh] - type = GeneratedMesh - dim = 2 - - nx = 10 - ny = 100 - - xmin = 0.0 - xmax = 1.0 - - ymin = 0.0 - ymax = 10.0 - - partitioner = linear - - distribution = serial -[] - -[Variables] - active = 'u' - - [./u] - order = FIRST - family = LAGRANGE - [../] -[] - -[AuxVariables] - [./proc_id] - order = CONSTANT - family = MONOMIAL - [../] -[] - -[Kernels] - active = 'diff' - - [./diff] - type = Diffusion - variable = u - [../] -[] - -[AuxKernels] - [./proc_id] - type = ProcessorIDAux - variable = proc_id - [../] -[] - -[BCs] - active = 'left right' - - [./left] - type = DirichletBC - variable = u - boundary = 3 - value = 0 - [../] - - [./right] - type = DirichletBC - variable = u - boundary = 1 - value = 1 - [../] -[] - -[Executioner] - type = Steady - - # Preconditioned JFNK (default) - solve_type = 'PJFNK' -[] - -[Outputs] - file_base = out - [./exodus] - type = Exodus - elemental_as_nodal = true - [../] -[] diff --git a/test/tests/mesh/custom_partitioner/tests b/test/tests/mesh/custom_partitioner/tests new file mode 100644 index 000000000000..c071dc3a0752 --- /dev/null +++ b/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' + [../] +[]