libMesh
Public Member Functions | Protected Attributes | 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 testBuild ()
 
void testPartition (processor_id_type n_parts)
 
void testPartitionEmpty ()
 
void testPartition1 ()
 
void testPartition2 ()
 
void testPartitionNProc ()
 

Protected Attributes

std::string libmesh_suite_name
 

Detailed Description

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

Definition at line 28 of file partitioner_test.h.

Member Function Documentation

◆ setUp()

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

Definition at line 34 of file partitioner_test.h.

35  {}

◆ tearDown()

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

Definition at line 37 of file partitioner_test.h.

38  {}

◆ testBuild()

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

Definition at line 40 of file partitioner_test.h.

References libMesh::Partitioner::build().

41  {
42  PartitionerSubclass myclass;
43 
44  PartitionerType type = myclass.type();
45 
46  auto new_build = Partitioner::build(type);
47 
48  CPPUNIT_ASSERT_EQUAL(new_build->type(), type);
49  }
PartitionerType
Defines an enum for mesh partitioner types.

◆ testPartition()

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

Definition at line 51 of file partitioner_test.h.

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

52  {
53  MeshClass mesh(*TestCommWorld);
54 
56  3, 3, 3,
57  0., 1., 0., 1., 0., 1.,
58  HEX8);
59 
60  // FIXME: Splitting meshes into more than n_proc parts currently
61  // requires us to start with a mesh entirely assigned to proc 0
62  PartitionerSubclass newpart;
63  newpart.partition(mesh, 1);
64 
65  for (auto elem : mesh.element_ptr_range())
66  CPPUNIT_ASSERT_EQUAL(elem->processor_id(), processor_id_type(0));
67 
68  for (auto node : mesh.node_ptr_range())
69  CPPUNIT_ASSERT_EQUAL(node->processor_id(), processor_id_type(0));
70 
71  // But then we can manually partition, into at most many parts as
72  // were requested.
73  newpart.partition(mesh, n_parts);
74 
75  // We expect the partitioner not to suck - every processor
76  // rank (up to n_elem()) ought to have at least one element on it.
77  const processor_id_type n_nonempty =
78  std::min(n_parts, processor_id_type(3*3*3));
79 
80  // Let's make sure we can see them all even on a DistributedMesh
81  mesh.allgather();
82 
83  processor_id_type nonempty_procs = 0;
84  for (processor_id_type p=0; p != n_nonempty; ++p)
85  {
86  const std::size_t n_elem_on_p =
87  std::distance(mesh.pid_elements_begin(p),
88  mesh.pid_elements_end(p));
89  if (n_elem_on_p)
90  nonempty_procs++;
91  }
92 
93  // Unfortunately, it turns out that our partitioners *do* suck:
94  //
95  // * Metis and ParMetis can't reliably give us more than
96  // 13 non-empty ranks on the above 27 element mesh.
97  //
98  // * Our SFC partitioners are suboptimal with 8 or more ranks for
99  // only 27 elements: the smallest integer block size for 27/8
100  // elements-per-rank that won't overflow is 4, but that only fills
101  // 7 ranks, because we don't equidistribute the underflow.
102  CPPUNIT_ASSERT(nonempty_procs >= n_nonempty ||
103  nonempty_procs >= 13 ||
104  (nonempty_procs >= 7 &&
105  n_nonempty == 8) ||
106  (nonempty_procs >= 9 &&
107  n_nonempty >= 10));
108  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition: mesh_base.h:234
MeshBase & mesh
Real distance(const Point &p)
uint8_t processor_id_type
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.

◆ testPartition1()

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

Definition at line 122 of file partitioner_test.h.

123  {
124  LOG_UNIT_TEST;
125 
126  this->testPartition(1);
127  }
void testPartition(processor_id_type n_parts)

◆ testPartition2()

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

Definition at line 129 of file partitioner_test.h.

130  {
131  LOG_UNIT_TEST;
132 
133  this->testPartition(2);
134  }
void testPartition(processor_id_type n_parts)

◆ testPartitionEmpty()

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

Definition at line 110 of file partitioner_test.h.

References mesh, TIMPI::Communicator::size(), and TestCommWorld.

111  {
112  LOG_UNIT_TEST;
113 
114  MeshClass mesh(*TestCommWorld);
115  PartitionerSubclass newpart;
116 
117  // With a 0 element mesh this should just give us 0 subpartitions
118  // regardless of n_procs
119  newpart.partition(mesh, TestCommWorld->size());
120  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
MeshBase & mesh
processor_id_type size() const

◆ testPartitionNProc()

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

Definition at line 136 of file partitioner_test.h.

References TIMPI::Communicator::size(), and TestCommWorld.

137  {
138  LOG_UNIT_TEST;
139 
140  this->testPartition(TestCommWorld->size());
141  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type size() const
void testPartition(processor_id_type n_parts)

Member Data Documentation

◆ libmesh_suite_name

template<typename PartitionerSubclass , typename MeshClass >
std::string PartitionerTest< PartitionerSubclass, MeshClass >::libmesh_suite_name
protected

Definition at line 31 of file partitioner_test.h.


The documentation for this class was generated from the following file: