preCICE v3.1.2
Loading...
Searching...
No Matches
VertexTest.cpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include <iosfwd>
3#include <string>
4#include "logging/Logger.hpp"
5#include "mesh/Vertex.hpp"
7#include "testing/Testing.hpp"
8
9using namespace precice;
10
11BOOST_AUTO_TEST_SUITE(MeshTests)
12BOOST_AUTO_TEST_SUITE(VertexTests)
13
15{
16 PRECICE_TEST(1_rank);
17 mesh::Vertex vertex(Eigen::Vector3d::Constant(1.0), 0);
18
19 Eigen::Vector3d coords = vertex.getCoords();
20 BOOST_TEST(testing::equals(coords, Eigen::Vector3d::Constant(1.0)));
21
22 int id = vertex.getID();
23 BOOST_TEST(id == 0);
24}
25
26BOOST_AUTO_TEST_CASE(VertexEquality)
27{
28 PRECICE_TEST(1_rank);
29 using namespace mesh;
30 using namespace Eigen;
31 Vertex v1(Vector3d::Constant(4.0), 0);
32 Vertex v2(Vector3d::Constant(4.0), 1);
33 Vertex v3(Vector3d::Constant(2.0), 0);
34 BOOST_TEST(v1 == v2);
35 BOOST_TEST(v1 != v3);
36 BOOST_TEST(v2 != v3);
37}
38
39BOOST_AUTO_TEST_CASE(VertexWKTPrint)
40{
41 PRECICE_TEST(1_rank);
42 using namespace mesh;
43 Vertex v1(Eigen::Vector2d(1., 2.), 0);
44 std::stringstream v1stream;
45 v1stream << v1;
46 std::string v1str("POINT (1 2)");
47 BOOST_TEST(v1str == v1stream.str());
48 Vertex v2(Eigen::Vector3d(1., 2., 3.), 0);
49 std::stringstream v2stream;
50 v2stream << v2;
51 std::string v2str("POINT (1 2 3)");
52 BOOST_TEST(v2str == v2stream.str());
53}
54
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST(...)
Definition Testing.hpp:27
BOOST_AUTO_TEST_CASE(Vertices)
Vertex of a mesh.
Definition Vertex.hpp:16
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
Definition Vertex.hpp:111
Eigen::VectorXd getCoords() const
Returns the coordinates of the vertex.
Definition Vertex.hpp:116
boost::test_tools::predicate_result equals(const std::vector< float > &VectorA, const std::vector< float > &VectorB, float tolerance)
equals to be used in tests. Compares two std::vectors using a given tolerance. Prints both operands o...
Definition Testing.cpp:65
Main namespace of the precice library.
T str(T... args)