libMesh
Public Member Functions | List of all members
PartitionerTest< PartitionerSubclass, MeshClass > Class Template Reference

#include <partitioner_test.h>

Inheritance diagram for PartitionerTest< PartitionerSubclass, MeshClass >:
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void testPartition (processor_id_type n_parts)
 
void testPartitionEmpty ()
 
void testPartition1 ()
 
void testPartition2 ()
 
void testPartitionNProc ()
 

Detailed Description

template<typename PartitionerSubclass, typename MeshClass>
class PartitionerTest< PartitionerSubclass, MeshClass >

Definition at line 27 of file partitioner_test.h.

Member Function Documentation

◆ setUp()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::setUp ( )
inline

Definition at line 29 of file partitioner_test.h.

30  {}

◆ tearDown()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::tearDown ( )
inline

Definition at line 32 of file partitioner_test.h.

33  {}

◆ testPartition()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::testPartition ( processor_id_type  n_parts)
inline

Definition at line 35 of file partitioner_test.h.

36  {
37  MeshClass mesh(*TestCommWorld);
38 
40  3, 3, 3,
41  0., 1., 0., 1., 0., 1.,
42  HEX8);
43 
44  // FIXME: Splitting meshes into more than n_proc parts currently
45  // requires us to start with a mesh entirely assigned to proc 0
46  PartitionerSubclass newpart;
47  newpart.partition(mesh, 1);
48 
49  for (auto elem : mesh.element_ptr_range())
50  CPPUNIT_ASSERT_EQUAL(elem->processor_id(), processor_id_type(0));
51 
52  for (auto node : mesh.node_ptr_range())
53  CPPUNIT_ASSERT_EQUAL(node->processor_id(), processor_id_type(0));
54 
55  // But then we can manually partition, into at most many parts as
56  // were requested.
57  newpart.partition(mesh, n_parts);
58 
59  // We expect the partitioner not to suck - every processor
60  // rank (up to n_elem()) ought to have at least one element on it.
61  const processor_id_type n_nonempty =
62  std::min(n_parts, processor_id_type(3*3*3));
63 
64  // Let's make sure we can see them all even on a DistributedMesh
65  mesh.allgather();
66 
67  processor_id_type nonempty_procs = 0;
68  for (processor_id_type p=0; p != n_nonempty; ++p)
69  {
70  const std::size_t n_elem_on_p =
73  if (n_elem_on_p)
74  nonempty_procs++;
75  }
76 
77  // Unfortunately, it turns out that our METIS and ParMETIS
78  // partitioners *do* suck, and can't reliabily give us more than
79  // 13 non-empty ranks on the above 27 element mesh.
80  CPPUNIT_ASSERT(nonempty_procs >= n_nonempty ||
81  nonempty_procs >= 13);
82  }

References libMesh::MeshBase::allgather(), libMesh::MeshTools::Generation::build_cube(), distance(), libMesh::MeshBase::element_ptr_range(), libMesh::HEX8, mesh, libMesh::MeshBase::node_ptr_range(), libMesh::MeshBase::pid_elements_begin(), libMesh::MeshBase::pid_elements_end(), and TestCommWorld.

◆ testPartition1()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::testPartition1 ( )
inline

Definition at line 94 of file partitioner_test.h.

95  {
96  this->testPartition(1);
97  }

◆ testPartition2()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::testPartition2 ( )
inline

Definition at line 99 of file partitioner_test.h.

100  {
101  this->testPartition(2);
102  }

◆ testPartitionEmpty()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::testPartitionEmpty ( )
inline

Definition at line 84 of file partitioner_test.h.

85  {
86  MeshClass mesh(*TestCommWorld);
87  PartitionerSubclass newpart;
88 
89  // With a 0 element mesh this should just give us 0 subpartitions
90  // regardless of n_procs
91  newpart.partition(mesh, TestCommWorld->size());
92  }

References mesh, and TestCommWorld.

◆ testPartitionNProc()

template<typename PartitionerSubclass , typename MeshClass >
void PartitionerTest< PartitionerSubclass, MeshClass >::testPartitionNProc ( )
inline

Definition at line 104 of file partitioner_test.h.

105  {
106  this->testPartition(TestCommWorld->size());
107  }

References TestCommWorld.


The documentation for this class was generated from the following file:
libMesh::MeshBase::pid_elements_begin
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
Iterate over all elements with a specified processor id.
libMesh::HEX8
Definition: enum_elem_type.h:47
libMesh::MeshBase::pid_elements_end
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0
PartitionerTest::testPartition
void testPartition(processor_id_type n_parts)
Definition: partitioner_test.h:35
libMesh::MeshTools::Generation::build_cube
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
Definition: mesh_generation.C:298
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::MeshBase::element_ptr_range
virtual SimpleRange< element_iterator > element_ptr_range()=0
libMesh::MeshBase::node_ptr_range
virtual SimpleRange< node_iterator > node_ptr_range()=0
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::MeshBase::allgather
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition: mesh_base.h:188
distance
Real distance(const Point &p)
Definition: subdomains_ex3.C:50