COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-vector-operations.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Log.hpp"
13 
14 #include "math/MatrixTypes.hpp"
15 
16 using namespace std;
17 using namespace boost;
18 using namespace cf3;
19 using namespace cf3::common;
20 
22 
24 {
27  {
28  // uncomment if you want to use arguments to the test executable
29  //int* argc = &boost::unit_test::framework::master_test_suite().argc;
30  //char*** argv = &boost::unit_test::framework::master_test_suite().argv;
31  }
32 
35  {
36  }
37 };
38 
40 
41 BOOST_FIXTURE_TEST_SUITE( VectorOperations_TestSuite, VectorOperations_Fixture )
42 
43 
46 BOOST_AUTO_TEST_CASE( VectorTimesMat )
47 {
48  RealVector3 v(1., 2., 3.);
49  RealMatrix m1(3,3);
50  RealMatrix m2(3,3);
51 
52  m1.setZero();
53  m2.setZero();
54 
55  m1(0, 0) = 0.125;
56  m1(1, 1) = 0.125;
57  m1(2, 2) = 0.125;
58 
59  m2(0, 0) = 8.;
60  m2(1, 1) = 8.;
61  m2(2, 2) = 8.;
62 
63  RealVector v2(3);
64 
65  // Test grouped matrix calculations
66  v2 = 2. * (m2 * (m1 * v));
67  BOOST_CHECK_CLOSE(v2[0], 2., 1e-6);
68  BOOST_CHECK_CLOSE(v2[1], 4., 1e-6);
69  BOOST_CHECK_CLOSE(v2[2], 6., 1e-6);
70 
71  // Test lazy writing of the expression
72  v2 = 2. * m2 * (m1 * v);
73 
74  BOOST_CHECK_CLOSE(v2[0], 2., 1e-6);
75  BOOST_CHECK_CLOSE(v2[1], 4., 1e-6);
76  BOOST_CHECK_CLOSE(v2[2], 6., 1e-6);
77 
78  // Test lazy writing of the expression
79  v2 = 2. * m2 * m1 * v;
80 
81  BOOST_CHECK_CLOSE(v2[0], 2., 1e-6);
82  BOOST_CHECK_CLOSE(v2[1], 4., 1e-6);
83  BOOST_CHECK_CLOSE(v2[2], 6., 1e-6);
84 
85 }
86 
88 
89 BOOST_AUTO_TEST_SUITE_END()
90 
91 
VectorOperations_Fixture()
common setup for each test case
external boost library namespace
BOOST_AUTO_TEST_CASE(VectorTimesMat)
Multiplication with a matrix.
STL namespace.
Real e()
Definition of the Unit charge [C].
Definition: Consts.hpp:30
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
Definition: MatrixTypes.hpp:22
~VectorOperations_Fixture()
common tear-down for each test case
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealVector
Dynamic sized column vector.
Definition: MatrixTypes.hpp:25
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Most basic kernel library.
Definition: Action.cpp:19
Eigen::Matrix< Real, 3, 1 > RealVector3
Fixed size 3x1 column vector.
Definition: MatrixTypes.hpp:41
Send comments to:
COOLFluiD Web Admin