Debian Codegraph @

test/unit/cpp/mesh/MultiMesh.cpp

raw
1 // Copyright (C) 2017 August Johansson, Benjamin Kehlet
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // Unit tests for the multimesh functionality
19
20 // These tests currently only instantiates and initializes some
21 // multimesh objects, ie. the only thing that is tested is that it
22 // doesn't crash
23
24 #include <dolfin.h>
25 #include <catch.hpp>
26
27 using namespace dolfin;
28
29 TEST_CASE("MultiMesh", "[!hide]")
30 {
31 SECTION("Trivial test case 3D")
32 {
33 // DISABLED
34
35 // FIXME: Enable this test when it is working
36
37 std::shared_ptr<Mesh> background(new Mesh(UnitTetrahedronMesh::create()));
38 std::shared_ptr<Mesh> overlapping(new Mesh(UnitTetrahedronMesh::create()));
39 overlapping->translate(Point(.1, .1, .1));
40
41 MultiMesh multimesh(background, overlapping, 1);
42 }
43
44 SECTION("Trivial case 3D 2")
45 {
46 // FIXME: Enable this test when it is working
47
48 std::shared_ptr<Mesh> background = std::make_shared<UnitCubeMesh>(1,1,1);
49
50 std::shared_ptr<Mesh> refmesh = std::make_shared<BoxMesh>(Point(0.394383, 0.783099, 0.197551),
51 Point(0.840188, 0.79844, 0.911647),
52 1,1,1);
53 const std::vector<double>& refmeshcoords = refmesh->coordinates();
54
55 std::shared_ptr<Mesh> tetmesh(new Mesh(UnitTetrahedronMesh::create()));
56 std::vector<double>& tetmesh_coords = tetmesh->coordinates();
57
58 for (CellIterator cell(*refmesh); !cell.end(); ++cell)
59 {
60 const unsigned int* vertex_indices = cell->entities(0);
61
62 for (int i = 0; i < 4; i++)
63 {
64 tetmesh_coords[i*3] = refmeshcoords[vertex_indices[i]];
65 tetmesh_coords[i*3 + 1] = refmeshcoords[vertex_indices[i] + 1];
66 tetmesh_coords[i*3 + 2] = refmeshcoords[vertex_indices[i] + 2];
67 }
68
69 MultiMesh multimesh(background, tetmesh, 1);
70 }
71 }
72
73 SECTION("Takes forever")
74 {
75 // FIXME: Enable this test when it is working
76
77 std::shared_ptr<Mesh> background(new Mesh(UnitTetrahedronMesh::create()));
78 {
79 std::vector<double>& coords = background->coordinates();
80 coords = { 0, 0, 0,
81 0, 0, 1,
82 1, 0, 1,
83 1, 1, 1 };
84 }
85
86 std::shared_ptr<Mesh> overlapping = std::make_shared<BoxMesh>(Point(0.394383, 0.783099, 0.197551),
87 Point(0.840188, 0.79844, 0.911647),
88 1,1,1);
89 MultiMesh multimesh(background, overlapping, 1);
90 }
91 }