1 #include <libmesh/parallel.h> 2 #include <libmesh/parallel_eigen.h> 3 #include <libmesh/int_range.h> 14 #ifdef LIBMESH_HAVE_EIGEN 20 CPPUNIT_TEST( testDynamicEigenMatrix );
21 CPPUNIT_TEST( testDynamicEigenVector );
22 CPPUNIT_TEST( testNonFixedScalar );
24 CPPUNIT_TEST_SUITE_END();
41 typedef Eigen::Matrix<Real, Eigen::Dynamic, Eigen::Dynamic> DynamicEigenMatrix;
42 typedef std::vector<DynamicEigenMatrix> DynamicMatrixVector;
43 std::map<processor_id_type, DynamicMatrixVector> send_data;
49 send_data[i] = DynamicMatrixVector{ DynamicEigenMatrix(i+1, i+2) };
52 send_data[i][0](row, col) = row * 100000.0 + col * 1000.0 + 10.0 * i + j;
60 const std::size_t rows = recv_data[0].rows();
61 const std::size_t cols = recv_data[0].cols();
63 CPPUNIT_ASSERT_EQUAL( rows, static_cast<std::size_t>(i+1) );
64 CPPUNIT_ASSERT_EQUAL( cols, static_cast<std::size_t>(i+2) );
68 CPPUNIT_ASSERT_EQUAL( recv_data[0](row, col), static_cast<Real>(row * 100000.0 + col * 1000.0 + j + 10.0 * i) );
72 Parallel::push_parallel_vector_data(*
TestCommWorld, send_data, verify_data);
79 typedef Eigen::Matrix<Real, Eigen::Dynamic, 1> DynamicEigenVector;
80 typedef std::vector<DynamicEigenVector> DynamicVectorVector;
81 std::map<processor_id_type, DynamicVectorVector> send_data;
87 send_data[i] = DynamicVectorVector{ DynamicEigenVector(i+1, 1) };
89 send_data[i][0](row) = row * 1000.0 + 10.0 * i + j;
97 const std::size_t rows = recv_data[0].rows();
98 const std::size_t cols = recv_data[0].cols();
100 CPPUNIT_ASSERT_EQUAL( rows, static_cast<std::size_t>(i+1) );
101 CPPUNIT_ASSERT_EQUAL( cols, 1lu );
104 CPPUNIT_ASSERT_EQUAL( recv_data[0](row), static_cast<Real>(row * 1000.0 + j + 10.0 * i) );
108 Parallel::push_parallel_vector_data(*
TestCommWorld, send_data, verify_data);
115 typedef Eigen::Matrix<std::vector<Real>, 3, 3> VectorEigenMatrix;
116 typedef std::vector<VectorEigenMatrix> VectorMatrixVector;
117 std::map<processor_id_type, VectorMatrixVector> send_data;
123 send_data[i] = VectorMatrixVector(1);
126 send_data[i][0](row, col).assign(row + col + 1, 10.0 * i + j);
134 const std::size_t rows = recv_data[0].rows();
135 const std::size_t cols = recv_data[0].cols();
137 CPPUNIT_ASSERT_EQUAL( rows, static_cast<std::size_t>(3) );
138 CPPUNIT_ASSERT_EQUAL( cols, static_cast<std::size_t>(3) );
143 CPPUNIT_ASSERT_EQUAL( recv_data[0](row, col).size(), static_cast<std::size_t>(row + col + 1) );
144 for (
const auto & val : recv_data[0](row, col))
145 CPPUNIT_ASSERT_EQUAL( val, static_cast<Real>(j + 10.0 * i) );
150 Parallel::push_parallel_vector_data(*
TestCommWorld, send_data, verify_data);
158 #endif // LIBMESH_HAVE_EIGEN libMesh::Parallel::Communicator * TestCommWorld
void testDynamicEigenMatrix()
void testNonFixedScalar()
processor_id_type rank() const
The libMesh namespace provides an interface to certain functionality in the library.
CPPUNIT_TEST_SUITE_REGISTRATION(PackingTypesTest)
uint8_t processor_id_type
void testDynamicEigenVector()
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...