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 31 of file partitioner_test.h.

Member Function Documentation

◆ setUp()

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

Definition at line 33 of file partitioner_test.h.

34  {}

◆ tearDown()

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

Definition at line 36 of file partitioner_test.h.

37  {}

◆ testPartition()

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

Definition at line 39 of file partitioner_test.h.

References libMesh::MeshTools::Generation::build_cube(), libMesh::HEX8, std::min(), and TestCommWorld.

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

Definition at line 98 of file partitioner_test.h.

99  {
100  this->testPartition(1);
101  }
void testPartition(processor_id_type n_parts)

◆ testPartition2()

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

Definition at line 103 of file partitioner_test.h.

104  {
105  this->testPartition(2);
106  }
void testPartition(processor_id_type n_parts)

◆ testPartitionEmpty()

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

Definition at line 88 of file partitioner_test.h.

References libMesh::Parallel::Communicator::size(), and TestCommWorld.

89  {
90  MeshClass mesh(*TestCommWorld);
91  PartitionerSubclass newpart;
92 
93  // With a 0 element mesh this should just give us 0 subpartitions
94  // regardless of n_procs
95  newpart.partition(mesh, TestCommWorld->size());
96  }
processor_id_type size() const
Definition: communicator.h:175
libMesh::Parallel::Communicator * TestCommWorld

◆ testPartitionNProc()

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

Definition at line 108 of file partitioner_test.h.

References libMesh::Parallel::Communicator::size(), and TestCommWorld.

109  {
110  this->testPartition(TestCommWorld->size());
111  }
processor_id_type size() const
Definition: communicator.h:175
libMesh::Parallel::Communicator * TestCommWorld
void testPartition(processor_id_type n_parts)

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