-
Notifications
You must be signed in to change notification settings - Fork 9
/
test_geometry.cc
124 lines (106 loc) · 3.72 KB
/
test_geometry.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* Copyright (c) 2016 - 2024, the adamantine authors.
*
* This file is subject to the Modified BSD License and may not be distributed
* without copyright and license information. Please refer to the file LICENSE
* for the text and further information on this license.
*/
#define BOOST_TEST_MODULE Geometry
#include <Geometry.hh>
#include <MaterialStates.hh>
#include <types.hh>
#include <deal.II/grid/filtered_iterator.h>
#include <boost/property_tree/ptree.hpp>
#include "main.cc"
template <int dim>
void check_material_id(
dealii::parallel::distributed::Triangulation<dim> const &tria,
dealii::types::boundary_id top_boundary)
{
for (auto cell :
dealii::filter_iterators(tria.active_cell_iterators(),
dealii::IteratorFilters::LocallyOwnedCell()))
{
if (cell->at_boundary())
{
bool powder = false;
for (unsigned int i = 0; i < dealii::GeometryInfo<dim>::faces_per_cell;
++i)
{
if ((cell->face(i)->at_boundary()) &&
(cell->face(i)->boundary_id() == top_boundary))
{
BOOST_TEST(cell->user_index() ==
static_cast<unsigned int>(
adamantine::SolidLiquidPowder::State::powder));
powder = true;
break;
}
}
if (powder == false)
BOOST_TEST(cell->user_index() ==
static_cast<unsigned int>(
adamantine::SolidLiquidPowder::State::solid));
}
else
BOOST_TEST(cell->user_index() ==
static_cast<unsigned int>(
adamantine::SolidLiquidPowder::State::solid));
}
}
BOOST_AUTO_TEST_CASE(geometry_2D)
{
MPI_Comm communicator = MPI_COMM_WORLD;
boost::property_tree::ptree database;
database.put("import_mesh", false);
database.put("length", 12);
database.put("length_divisions", 4);
database.put("height", 6);
database.put("height_divisions", 5);
database.put("material_height", 6.);
database.put("use_powder", true);
database.put("powder_layer", 1.2);
adamantine::Geometry<2> geometry(communicator, database);
dealii::parallel::distributed::Triangulation<2> const &tria =
geometry.get_triangulation();
BOOST_TEST(tria.n_active_cells() == 20);
dealii::types::boundary_id const top_boundary = 3;
check_material_id(tria, top_boundary);
}
BOOST_AUTO_TEST_CASE(geometry_3D)
{
MPI_Comm communicator = MPI_COMM_WORLD;
boost::property_tree::ptree database;
database.put("import_mesh", false);
database.put("length", 12);
database.put("length_divisions", 4);
database.put("height", 4);
database.put("height_divisions", 2);
database.put("width", 6);
database.put("width_divisions", 5);
database.put("material_height", 4);
database.put("use_powder", true);
database.put("powder_layer", 2);
adamantine::Geometry<3> geometry(communicator, database);
dealii::parallel::distributed::Triangulation<3> const &tria =
geometry.get_triangulation();
BOOST_TEST(tria.n_active_cells() == 40);
dealii::types::boundary_id const top_boundary = 5;
check_material_id(tria, top_boundary);
}
BOOST_AUTO_TEST_CASE(gmsh)
{
MPI_Comm communicator = MPI_COMM_WORLD;
boost::property_tree::ptree database;
database.put("import_mesh", true);
database.put("mesh_file", "extruded_cube.msh");
database.put("mesh_format", "gmsh");
database.put("material_height", 1.);
database.put("use_powder", true);
database.put("powder_layer", 0.05);
adamantine::Geometry<3> geometry(communicator, database);
dealii::parallel::distributed::Triangulation<3> const &tria =
geometry.get_triangulation();
BOOST_TEST(tria.n_active_cells() == 320);
dealii::types::boundary_id const top_boundary = 1;
check_material_id(tria, top_boundary);
}