32 auto & v1 = mesh.createVertex(Eigen::Vector3d(0, 2, 0));
33 auto & v2 = mesh.createVertex(Eigen::Vector3d(2, 1, 0));
34 auto & v3 = mesh.createVertex(Eigen::Vector3d(3, 0, 0));
35 auto & v4 = mesh.createVertex(Eigen::Vector3d(1, 0, 0));
37 auto &e1 = mesh.createEdge(v1, v2);
38 auto &e2 = mesh.createEdge(v2, v3);
39 auto &e3 = mesh.createEdge(v3, v4);
40 auto &e4 = mesh.createEdge(v4, v1);
42 auto &e5 = mesh.createEdge(v2, v4);
44 mesh.createTriangle(e1, e5, e4);
45 mesh.createTriangle(e2, e3, e5);
52 mesh->createVertex(Eigen::Vector3d(0, 0, 0));
53 mesh->createVertex(Eigen::Vector3d(0, 0, 1));
54 mesh->createVertex(Eigen::Vector3d(0, 1, 0));
55 mesh->createVertex(Eigen::Vector3d(0, 1, 1));
56 mesh->createVertex(Eigen::Vector3d(1, 0, 0));
57 mesh->createVertex(Eigen::Vector3d(1, 0, 1));
58 auto &v1 = mesh->createVertex(Eigen::Vector3d(1, 1, 0));
59 auto &v2 = mesh->createVertex(Eigen::Vector3d(1, 1, 1));
60 mesh->createEdge(v1, v2);
67 mesh->createVertex(Eigen::Vector2d(0, 0));
68 mesh->createVertex(Eigen::Vector2d(0, 1));
69 auto &v1 = mesh->createVertex(Eigen::Vector2d(1, 0));
70 auto &v2 = mesh->createVertex(Eigen::Vector2d(1, 1));
71 mesh->createEdge(v1, v2);
78 mesh->createVertex(Eigen::Vector3d(0, 0, 0));
79 mesh->createVertex(Eigen::Vector3d(0, 0, 1));
80 mesh->createVertex(Eigen::Vector3d(0, 1, 0));
81 mesh->createVertex(Eigen::Vector3d(0, 1, 1));
82 mesh->createVertex(Eigen::Vector3d(1, 0, 0));
83 mesh->createVertex(Eigen::Vector3d(1, 0, 1));
84 mesh->createVertex(Eigen::Vector3d(1, 1, 0));
85 mesh->createVertex(Eigen::Vector3d(1, 1, 1));
86 mesh->computeBoundingBox();
98 auto mesh = edgeMesh2D();
99 Index indexTree(mesh);
100 Eigen::Vector2d location(0.2, 0.8);
103 BOOST_TEST(mesh->vertex(result.index).getCoords() == Eigen::Vector2d(0, 1));
109 auto mesh = edgeMesh3D();
110 Index indexTree(mesh);
111 Eigen::Vector3d location(0.8, 0.0, 0.8);
114 BOOST_TEST(mesh->vertex(result.index).getCoords() == Eigen::Vector3d(1, 0, 1));
121 const double z1 = 0.1;
122 const double z2 = -0.1;
123 auto & v00 = mesh->
createVertex(Eigen::Vector3d(0, 0, 0));
124 auto & v01 = mesh->
createVertex(Eigen::Vector3d(0, 1, 0));
125 auto & v10 = mesh->
createVertex(Eigen::Vector3d(1, 0, z1));
126 auto & v11 = mesh->
createVertex(Eigen::Vector3d(1, 1, z1));
127 auto & v20 = mesh->
createVertex(Eigen::Vector3d(2, 0, z2));
128 auto & v21 = mesh->
createVertex(Eigen::Vector3d(2, 1, z2));
129 auto & v30 = mesh->
createVertex(Eigen::Vector3d(3, 0, z2));
130 auto & v31 = mesh->
createVertex(Eigen::Vector3d(3, 1, z2));
146 Index indexTree(mesh);
148 Eigen::Vector3d location(0.8, 0.0, 0.8);
151 BOOST_TEST(mesh->
vertex(result.index).
getID() == v10.getID());
154 Eigen::Vector3d location(0.8, 0.0, 0.8);
159 BOOST_TEST(result.
size() == nVertices);
163 Eigen::Vector3d location(3.5, 3.5, 0.0);
168 BOOST_TEST(result.
size() == nVertices);
177 auto mesh = vertexMesh3D();
178 Index indexTree(mesh);
179 mesh::Vertex searchVertex(Eigen::Vector3d(0.8, 1, 0), 0);
183 BOOST_TEST(results.empty());
190 auto mesh = vertexMesh3D();
191 Index indexTree(mesh);
193 mesh::Vertex searchVertex(Eigen::Vector3d(0.8, 1, 0), 0);
194 double radius = 0.81;
197 BOOST_TEST(results.size() == 2);
198 BOOST_TEST(mesh->vertex(results.at(0)).getCoords() == Eigen::Vector3d(0, 1, 0));
199 BOOST_TEST(mesh->vertex(results.at(1)).getCoords() == Eigen::Vector3d(1, 1, 0));
206 auto mesh = vertexMesh3D();
207 Index indexTree(mesh);
209 mesh::Vertex searchVertex(Eigen::Vector3d(0.8, 1, 0), 0);
213 BOOST_TEST(results.size() == 8);
219 auto mesh = edgeMesh2D();
220 auto result = mesh->index().getRtreeBounds();
221 mesh->computeBoundingBox();
222 auto comparison = mesh->getBoundingBox();
224 BOOST_TEST(result == comparison);
225 BOOST_TEST(result.minCorner() == Eigen::Vector2d(0, 0));
226 BOOST_TEST(result.maxCorner() == Eigen::Vector2d(1, 1));
232 auto mesh = vertexMesh3D();
233 auto result = mesh->index().getRtreeBounds();
234 mesh->computeBoundingBox();
235 auto comparison = mesh->getBoundingBox();
237 BOOST_TEST(result == comparison);
238 BOOST_TEST(result.minCorner() == Eigen::Vector3d(0, 0, 0));
239 BOOST_TEST(result.maxCorner() == Eigen::Vector3d(1, 1, 1));
248 mesh->
createVertex(Eigen::Vector3d(-23.4, 100000.2, 7));
249 mesh->
createVertex(Eigen::Vector3d(0.211, -21.37, 0.00003));
254 BOOST_TEST(result == comparison);
255 BOOST_TEST(result.minCorner() == Eigen::Vector3d(-23.4, -21.37, 0.00003));
256 BOOST_TEST(result.maxCorner() == Eigen::Vector3d(26.4777, 100000.2, 8));
266 auto mesh = edgeMesh2D();
267 Index indexTree(mesh);
268 Eigen::Vector2d location(0.2, 0.8);
271 BOOST_TEST(results.size() == 1);
272 auto &edge = mesh->edges().at(results.front().index);
274 BOOST_TEST(edge.vertex(0).getCoords() == Eigen::Vector2d(1, 0));
275 BOOST_TEST(edge.vertex(1).getCoords() == Eigen::Vector2d(1, 1));
281 auto mesh = edgeMesh3D();
282 Index indexTree(mesh);
283 Eigen::Vector3d location(1.8, 0.0, 0.8);
287 BOOST_TEST(results.size() == 1);
288 auto match = results.front().index;
290 BOOST_TEST(match < mesh->edges().size());
291 auto & edge = mesh->edges().at(match);
292 Eigen::Vector3d p1(1, 1, 0);
293 Eigen::Vector3d p2(1, 1, 1);
294 BOOST_TEST((edge.vertex(0).getCoords() == p1 || edge.vertex(0).getCoords() == p2));
295 if (edge.vertex(0).getCoords() == p1) {
296 BOOST_TEST(edge.vertex(1).getCoords() == p2);
298 BOOST_TEST(edge.vertex(1).getCoords() == p1);
306 const double z1 = 0.1;
307 const double z2 = -0.1;
308 auto & v00 = mesh->
createVertex(Eigen::Vector3d(0, 0, 0));
309 auto & v01 = mesh->
createVertex(Eigen::Vector3d(0, 1, 0));
310 auto & v10 = mesh->
createVertex(Eigen::Vector3d(1, 0, z1));
311 auto & v11 = mesh->
createVertex(Eigen::Vector3d(1, 1, z1));
312 auto & v20 = mesh->
createVertex(Eigen::Vector3d(2, 0, z2));
313 auto & v21 = mesh->
createVertex(Eigen::Vector3d(2, 1, z2));
329 Index indexTree(mesh);
330 Eigen::Vector3d location(0.8, 0.5, 0.0);
334 &mesh->
edges().
at(results.at(0).index),
335 &mesh->
edges().
at(results.at(1).index),
339 BOOST_TEST(matches.size() == 2);
340 BOOST_TEST(matches == expected, boost::test_tools::per_element());
352 const double z1 = 0.1;
353 const double z2 = -0.1;
354 auto & v00 = mesh->
createVertex(Eigen::Vector3d(0, 0, 0));
355 auto & v01 = mesh->
createVertex(Eigen::Vector3d(0, 1, 0));
356 auto & v10 = mesh->
createVertex(Eigen::Vector3d(1, 0, z1));
357 auto & v11 = mesh->
createVertex(Eigen::Vector3d(1, 1, z1));
358 auto & v20 = mesh->
createVertex(Eigen::Vector3d(2, 0, z2));
359 auto & v21 = mesh->
createVertex(Eigen::Vector3d(2, 1, z2));
375 Index indexTree(mesh);
377 Eigen::Vector3d location(0.7, 0.5, 0.0);
380 BOOST_TEST(results.size() == 3);
388 BOOST_TEST(matches.size() == 3);
389 BOOST_TEST(matches == expected, boost::test_tools::per_element());
399 auto meshPtr = fullMesh();
400 Index indexTree(meshPtr);
402 Eigen::Vector3d location(4.0, 0.0, 0.0);
408 BOOST_TEST(match.polation.getWeightedElements().size() == 1);
409 BOOST_TEST(match.polation.distance() == 1.0);
410 BOOST_TEST(match.polation.isInterpolation());
412 for (
int i = 0; i < static_cast<int>(match.polation.getWeightedElements().size()); ++i) {
413 BOOST_TEST(match.polation.getWeightedElements().at(i).vertexID == expectedIndices.
at(i));
414 BOOST_TEST(match.polation.getWeightedElements().at(i).weight == expectedWeights.
at(i));
421 auto meshPtr = fullMesh();
422 Index indexTree(meshPtr);
424 Eigen::Vector3d location(2.0, -1.0, 0.0);
430 BOOST_TEST(match.polation.getWeightedElements().size() == 2);
431 BOOST_TEST(match.polation.distance() == 1.0);
432 BOOST_TEST(match.polation.isInterpolation());
434 for (
int i = 0; i < static_cast<int>(match.polation.getWeightedElements().size()); ++i) {
435 BOOST_TEST(match.polation.getWeightedElements().at(i).vertexID == expectedIndices.
at(i));
436 BOOST_TEST(match.polation.getWeightedElements().at(i).weight == expectedWeights.
at(i));
443 auto meshPtr = fullMesh();
444 Index indexTree(meshPtr);
446 Eigen::Vector3d location(1.0, 1.0, 0.1);
452 BOOST_TEST(match.polation.getWeightedElements().size() == 3);
453 BOOST_TEST(match.polation.distance() == 0.1);
454 BOOST_TEST(match.polation.isInterpolation());
456 for (
int i = 0; i < static_cast<int>(match.polation.getWeightedElements().size()); ++i) {
457 BOOST_TEST(match.polation.getWeightedElements().at(i).vertexID == expectedIndices.
at(i));
458 BOOST_TEST(match.polation.getWeightedElements().at(i).weight == expectedWeights.
at(i));
473 Eigen::Vector3d location(0.5, 0.5, 0.5);
476 auto &v00 = mesh.createVertex(Eigen::Vector3d(0, 0, 0));
477 auto &v01 = mesh.createVertex(Eigen::Vector3d(1, 0, 0));
478 auto &v02 = mesh.createVertex(Eigen::Vector3d(0, 1, 0));
479 auto &v03 = mesh.createVertex(Eigen::Vector3d(1, 0, 1));
480 auto &v04 = mesh.createVertex(Eigen::Vector3d(1, 1, 1));
482 mesh.createTetrahedron(v00, v01, v02, v03);
483 mesh.createTetrahedron(v04, v01, v02, v03);
487 BOOST_TEST(match.size() == 2);
504 Eigen::Vector3d location(0.2, 0.2, 0.2);
508 auto &v00 = mesh.createVertex(Eigen::Vector3d(0, 0, 0));
509 auto &v01 = mesh.createVertex(Eigen::Vector3d(1, 0, 0));
510 auto &v02 = mesh.createVertex(Eigen::Vector3d(0, 1, 0));
511 auto &v03 = mesh.createVertex(Eigen::Vector3d(0, 0, 1));
512 mesh.createTetrahedron(v00, v01, v02, v03);
515 auto &v10 = mesh.createVertex(Eigen::Vector3d(1, 1, 1));
516 auto &v11 = mesh.createVertex(Eigen::Vector3d(1, 0, 0));
517 auto &v12 = mesh.createVertex(Eigen::Vector3d(0, 1, 0));
518 auto &v13 = mesh.createVertex(Eigen::Vector3d(0, 0, 1));
519 mesh.createTetrahedron(v10, v11, v12, v13);
522 auto &v20 = mesh.createVertex(Eigen::Vector3d(1, 1, 1));
523 auto &v21 = mesh.createVertex(Eigen::Vector3d(2, 1, 1));
524 auto &v22 = mesh.createVertex(Eigen::Vector3d(1, 2, 1));
525 auto &v23 = mesh.createVertex(Eigen::Vector3d(1, 1, 2));
526 mesh.createTetrahedron(v20, v21, v22, v23);
530 BOOST_TEST(match.size() == 2);
531 BOOST_TEST(((match[0] == 0 && match[1] == 1) || (match[0] == 1 && match[1] == 0)));
545 locations.
push_back(Eigen::Vector3d(0, 0, 0));
546 locations.
push_back(Eigen::Vector3d(1, 0, 0));
547 locations.
push_back(Eigen::Vector3d(0, 1, 0));
548 locations.
push_back(Eigen::Vector3d(0, 0, 1));
551 auto &v00 = mesh.createVertex(Eigen::Vector3d(0, 0, 0));
552 auto &v01 = mesh.createVertex(Eigen::Vector3d(1, 0, 0));
553 auto &v02 = mesh.createVertex(Eigen::Vector3d(0, 1, 0));
554 auto &v03 = mesh.createVertex(Eigen::Vector3d(0, 0, 1));
555 mesh.createTetrahedron(v00, v01, v02, v03);
557 for (
const auto &vertex : locations) {
559 BOOST_TEST(match.size() == 1);
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Query2DVertex)
#define PRECICE_TEST(...)
Linear edge of a mesh, defined by two Vertex objects.
Container and creator for meshes.
Triangle & createTriangle(Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
Creates and initializes a Triangle object.
Vertex & vertex(VertexID id)
Mutable access to a vertex by VertexID.
const query::Index & index() const
Call preprocess() before index() to ensure correct projection handling.
void computeBoundingBox()
Computes the boundingBox for the vertices.
TriangleContainer & triangles()
Returns modifiable container holding all triangles.
const BoundingBox & getBoundingBox() const
Returns the bounding box of the mesh.
Edge & createEdge(Vertex &vertexOne, Vertex &vertexTwo)
Creates and initializes an Edge object.
EdgeContainer & edges()
Returns modifiable container holding all edges.
Vertex & createVertex(const Eigen::VectorXd &coords)
Creates and initializes a Vertex object.
Triangle of a mesh, defined by three vertices.
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
Class to query the index trees of the mesh.
mesh::BoundingBox getRtreeBounds()
std::vector< TetrahedronID > getEnclosingTetrahedra(const Eigen::VectorXd &location)
Return all the tetrahedra whose axis-aligned bounding box contains a vertex.
VertexMatch getClosestVertex(const Eigen::VectorXd &sourceCoord)
Get the closest vertex to the given vertex.
ProjectionMatch findNearestProjection(const Eigen::VectorXd &location, int n)
Find the closest interpolation element to the given location. If exists, triangle or edge projection ...
std::vector< TriangleMatch > getClosestTriangles(const Eigen::VectorXd &sourceCoord, int n)
Get n number of closest triangles to the given vertex.
std::vector< VertexID > getVerticesInsideBox(const mesh::Vertex ¢erVertex, double radius)
Return all the vertices inside the box formed by vertex and radius (boundary exclusive)
std::vector< VertexID > getClosestVertices(const Eigen::VectorXd &sourceCoord, int n)
Get n number of closest vertices to the given vertex.
std::vector< EdgeMatch > getClosestEdges(const Eigen::VectorXd &sourceCoord, int n)
Get n number of closest edges to the given vertex.
T is_permutation(T... args)
provides Mesh, Data and primitives.
contains geometrical queries.
Main namespace of the precice library.