1 #ifndef __numeric_vector_test_h__
2 #define __numeric_vector_test_h__
8 #include <libmesh/parallel.h>
9 #include "libmesh/auto_ptr.h"
14 #define NUMERICVECTORTEST \
15 CPPUNIT_TEST( testLocalize ); \
16 CPPUNIT_TEST( testLocalizeBase ); \
17 CPPUNIT_TEST( testLocalizeIndices ); \
18 CPPUNIT_TEST( testLocalizeIndicesBase ); \
19 CPPUNIT_TEST( testLocalizeToOne ); \
20 CPPUNIT_TEST( testLocalizeToOneBase );
22 #ifndef LIBMESH_HAVE_CXX14_MAKE_UNIQUE
26 template <
class DerivedClass>
44 template <
class Base,
class Derived>
48 unsigned int block_size = 10;
51 unsigned int local_size = block_size +
52 static_cast<unsigned int>(
my_comm->rank());
53 unsigned int global_size = 0;
56 global_size += (block_size + static_cast<unsigned int>(p));
59 auto v_ptr = libmesh_make_unique<Derived>(*
my_comm, global_size, local_size);
61 std::vector<libMesh::Number> l(global_size);
64 first = v.first_local_index(),
65 last = v.last_local_index();
68 v.set (n, static_cast<libMesh::Number>(n));
74 v.localize_to_one(l,root_pid);
76 if (!to_one ||
my_comm->rank() == root_pid)
86 template <
class Base,
class Derived>
89 unsigned int block_size = 10;
92 unsigned int local_size = block_size +
93 static_cast<unsigned int>(
my_comm->rank());
94 unsigned int global_size = 0;
97 global_size += (block_size + static_cast<unsigned int>(p));
100 auto v_ptr = libmesh_make_unique<Derived>(*
my_comm, global_size, local_size);
104 std::vector<libMesh::Number> values(block_size *
my_comm->size());
105 std::vector<libMesh::dof_id_type> indices;
106 indices.reserve(block_size *
my_comm->size());
109 first = v.first_local_index(),
110 last = v.last_local_index();
113 v.set (n, static_cast<libMesh::Number>(n));
119 end_index += block_size + p;
120 for (
unsigned int j = 0; j != block_size; ++j)
121 indices.push_back(end_index-j-1);
124 v.localize(values, indices);
129 end_index += block_size + p;
130 for (
unsigned int j = 0; j != block_size; ++j)
140 Localize<DerivedClass,DerivedClass>();
145 Localize<libMesh::NumericVector<libMesh::Number>,DerivedClass>();
150 Localize<DerivedClass,DerivedClass >(
true);
155 Localize<libMesh::NumericVector<libMesh::Number>,DerivedClass>(
true);
160 LocalizeIndices<DerivedClass,DerivedClass >();
165 LocalizeIndices<libMesh::NumericVector<libMesh::Number>,DerivedClass>();
169 #endif // #ifdef __numeric_vector_test_h__