Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
test_core_mesh.cpp File Reference
#include <catch.hpp>
#include <boost/log/trivial.hpp>
#include "../core_mesh.cpp"
Include dependency graph for test_core_mesh.cpp:

Go to the source code of this file.

Macros

#define BOOST_LOG_DYN_LINK   1
 

Functions

 TEST_CASE ("UNIT TEST: sign function {sgn<T>}","[core]")
 
 TEST_CASE ("UNIT TEST: periodicity functions {get_per}","[core_mesh]")
 
 TEST_CASE ("UNIT TEST: assign functions iterator {IT}","[core_mesh]")
 

Macro Definition Documentation

#define BOOST_LOG_DYN_LINK   1

Definition at line 3 of file test_core_mesh.cpp.

Function Documentation

TEST_CASE ( "UNIT TEST: sign function {sgn<T>}"  ,
""  [core] 
)

Definition at line 8 of file test_core_mesh.cpp.

References CHECK, and sgn().

8  : sign function {sgn<T>}", "[core]" )
9 {
10  BOOST_LOG_TRIVIAL(info) << "sign function {sgn<T>}";
11 
12  CHECK( sgn(0) == 0 );
13  CHECK( sgn(10) == 1 );
14  CHECK( sgn(-5) == -1 );
15  CHECK( sgn(0.) == 0 );
16  CHECK( sgn(0.34534f) == 1 );
17  CHECK( sgn(-1.34534E16) == -1 );
18 }
TEST_CASE ( "UNIT TEST: periodicity functions {get_per}"  ,
""  [core_mesh] 
)

Definition at line 20 of file test_core_mesh.cpp.

References CHECK, and get_per().

20  : periodicity functions {get_per}", "[core_mesh]" )
21 {
22  BOOST_LOG_TRIVIAL(info) << "periodicity functions {get_per}";
23 
24  CHECK( get_per(9.4, 10) == Approx(9.4) );
25  CHECK( get_per(31.4, 10) == Approx(1.4) );
26  CHECK( get_per(-7.4, 10) == Approx(2.6) );
27  CHECK( get_per(10.0, 10) == Approx(0.0) );
28  CHECK( get_per(0.0, 10) == Approx(0.0) );
29  CHECK( get_per(-0.0, 10) == Approx(0.0) );
30  CHECK( get_per(-10.0, 10) == Approx(0.0) );
31 
32  CHECK( get_per(9, 10) == 9 );
33  CHECK( get_per(31, 10) == 1 );
34  CHECK( get_per(-7, 10) == 3 );
35  CHECK( get_per(10, 10) == 0 );
36  CHECK( get_per(0, 10) == 0 );
37  CHECK( get_per(-0, 10) == 0 );
38  CHECK( get_per(-10, 10) == 0 );
39 
40  Vec_3D<double> pos(0., -10., 10.);
41  get_per(pos, 10);
42  Vec_3D<double> pos2(4.3, -7.8, 18.4);
43  get_per(pos2, 10);
44 
45  CHECK( pos[0] == Approx(0.) );
46  CHECK( pos[1] == Approx(0.) );
47  CHECK( pos[2] == Approx(0.) );
48  CHECK( pos2[0] == Approx(4.3) );
49  CHECK( pos2[1] == Approx(2.2) );
50  CHECK( pos2[2] == Approx(8.4) );
51 
52  Vec_3D<int> posi(0, -10, 10);
53  get_per(posi, 10);
54  Vec_3D<int> pos2i(4, -7, 18);
55  get_per(pos2i, 10);
56 
57  CHECK( posi == Vec_3D<int>(0, 0, 0) );
58  CHECK( pos2i == Vec_3D<int>(4, 3, 8) );
59 
60  Vec_3D<int> pos4i(0, -10, 10);
61  get_per(pos4i, 5, 10, 4);
62  CHECK( pos4i == Vec_3D<int>(0, 0, 2) );
63 }
static std::enable_if< std::is_integral< T >::value, T >::type get_per(T vec, size_t per)
Definition: core_mesh.cpp:48
TEST_CASE ( "UNIT TEST: assign functions iterator {IT}"  ,
""  [core_mesh] 
)

Definition at line 65 of file test_core_mesh.cpp.

References CHECK, CHECK_FALSE, IT< points >::counter, IT< points >::iter(), REQUIRE, and IT< points >::vec.

65  : assign functions iterator {IT}", "[core_mesh]" )
66 {
67  BOOST_LOG_TRIVIAL(info) << "assign functions iterator {IT}";
68 
69  IT<1> it1(Vec_3D<FTYPE_t>(3.2, 7.8, 4.0));
70  REQUIRE( it1.vec == Vec_3D<size_t>(3, 8, 4) );
71  CHECK( it1.counter == 0);
72  CHECK_FALSE( it1.iter() );
73 
74  IT<2> it2(Vec_3D<FTYPE_t>(3.2, 7.8, 4.0));
75  REQUIRE( it2.vec == Vec_3D<size_t>(3, 7, 4) );
76  CHECK( it2.iter() );
77 
78  IT<3> it3(Vec_3D<FTYPE_t>(3.2, 7.8, 4.0), 2);
79  REQUIRE( it3.vec == Vec_3D<size_t>(0, 2, 1) );
80 
81  CHECK( it2.vec == Vec_3D<size_t>(3, 7, 5) );
82  CHECK( it2.iter() );
83  CHECK( it2.vec == Vec_3D<size_t>(3, 8, 4) );
84 
85  do{} while( it2.iter() );
86  CHECK( it2.vec == Vec_3D<size_t>(4, 8, 5) );
87 }
: class for effective iteration of cube of mesh cells
Definition: core_mesh.h:66