libMesh
Public Member Functions | Protected Attributes | List of all members
DistributedVectorTest Class Reference
Inheritance diagram for DistributedVectorTest:
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (DistributedVectorTest)
 
NUMERICVECTORTEST CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void Localize (bool to_one=false)
 
void testLocalize ()
 
void testLocalizeBase ()
 
void testLocalizeToOne ()
 
void testLocalizeToOneBase ()
 

Protected Attributes

libMesh::Parallel::Communicatormy_comm
 

Detailed Description

Definition at line 20 of file distributed_vector_test.C.

Member Function Documentation

DistributedVectorTest::CPPUNIT_TEST_SUITE ( DistributedVectorTest  )
NUMERICVECTORTEST DistributedVectorTest::CPPUNIT_TEST_SUITE_END ( )
void NumericVectorTest< DistributedVector< Number > >::Localize ( bool  to_one = false)
inherited

Definition at line 42 of file numeric_vector_test.h.

References libMesh::libmesh_real(), libMesh::Parallel::Communicator::rank(), libMesh::Parallel::Communicator::size(), and libMesh::TOLERANCE.

43  {
44  const libMesh::processor_id_type root_pid = 0;
45  unsigned int block_size = 10;
46 
47  // a different size on each processor.
48  unsigned int local_size = block_size +
49  static_cast<unsigned int>(my_comm->rank());
50  unsigned int global_size = 0;
51 
52  for (libMesh::processor_id_type p=0; p<my_comm->size(); p++)
53  global_size += (block_size + static_cast<unsigned int>(p));
54 
55  {
56  libMesh::UniquePtr<Base> v_ptr(new Derived(*my_comm, global_size, local_size));
57  Base & v = *v_ptr;
58  std::vector<libMesh::Number> l(global_size);
59 
61  first = v.first_local_index(),
62  last = v.last_local_index();
63 
64  for (libMesh::dof_id_type n=first; n != last; n++)
65  v.set (n, static_cast<libMesh::Number>(n));
66  v.close();
67 
68  if (!to_one)
69  v.localize(l);
70  else
71  v.localize_to_one(l,root_pid);
72 
73  if (!to_one || my_comm->rank() == root_pid)
74  // Yes I really mean v.size()
75  for (libMesh::dof_id_type i=0; i<v.size(); i++)
76  CPPUNIT_ASSERT_DOUBLES_EQUAL(libMesh::libmesh_real(i),
79  }
80  }
T libmesh_real(T a)
unsigned int size() const
Definition: parallel.h:726
uint8_t processor_id_type
Definition: id_types.h:99
static const Real TOLERANCE
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
unsigned int rank() const
Definition: parallel.h:724
uint8_t dof_id_type
Definition: id_types.h:64
void NumericVectorTest< DistributedVector< Number > >::setUp ( )
inherited

Definition at line 30 of file numeric_vector_test.h.

References TestCommWorld.

31  {
32  // By default we'll use the whole communicator in parallel;
33  // Serial-only NumericVector subclasses will need to override
34  // this.
36  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
void NumericVectorTest< DistributedVector< Number > >::tearDown ( )
inherited

Definition at line 38 of file numeric_vector_test.h.

39  {}
void NumericVectorTest< DistributedVector< Number > >::testLocalize ( )
inherited

Definition at line 82 of file numeric_vector_test.h.

83  {
84  Localize<DerivedClass,DerivedClass>();
85  }
void NumericVectorTest< DistributedVector< Number > >::testLocalizeBase ( )
inherited

Definition at line 87 of file numeric_vector_test.h.

88  {
89  Localize<libMesh::NumericVector<libMesh::Number>,DerivedClass>();
90  }
void NumericVectorTest< DistributedVector< Number > >::testLocalizeToOne ( )
inherited

Definition at line 92 of file numeric_vector_test.h.

93  {
94  Localize<DerivedClass,DerivedClass >(true);
95  }
void NumericVectorTest< DistributedVector< Number > >::testLocalizeToOneBase ( )
inherited

Definition at line 97 of file numeric_vector_test.h.

98  {
99  Localize<libMesh::NumericVector<libMesh::Number>,DerivedClass>(true);
100  }

Member Data Documentation

libMesh::Parallel::Communicator* NumericVectorTest< DistributedVector< Number > >::my_comm
protectedinherited

Definition at line 27 of file numeric_vector_test.h.


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