-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadapt.cpp
69 lines (58 loc) · 2.08 KB
/
adapt.cpp
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
/*
* 'examples/adapt.cpp'
* This file is part of the "trinity" project.
* (https://github.com/hobywan/trinity)
* Copyright (c) 2016 Hoby Rakotoarivelo.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <trinity.h>
int main(int argc, char* argv[]) {
int const verbose = 1;
int const bucket = 64;
int const depth = 3;
int const rounds = 8;
int const max_col = 8;
auto const norm = 2;
auto const target = 1.0;
auto const h_min = 1.E-9;
auto const h_max = 0.4;
auto const input = std::string(TRINITY_EXAMP_DIR) + "/mesh/GRID4.mesh";
auto const solut = std::string(TRINITY_EXAMP_DIR) + "/solut/shock4.bb";
auto const result = std::string(TRINITY_BUILD_DIR) + "/data/adapted.mesh";
assert(trinity::tools::exists(input));
assert(trinity::tools::exists(solut));
std::ifstream file(input, std::ios::in);
assert(file.good());
int size[] = {
trinity::io::find("Vertices", file),
trinity::io::find("Triangles", file)
};
file.close();
trinity::Mesh mesh (size, bucket, depth, verbose, rounds);
trinity::Metrics metric (&mesh, target, norm, h_min, h_max);
trinity::Partit heuris (&mesh, max_col);
trinity::Refine refine (&mesh, depth);
trinity::Swap swap (&mesh);
trinity::Coarse coarse (&mesh, &heuris);
trinity::Smooth smooth (&mesh, &heuris, depth);
mesh.load(input, solut);
metric.run();
for (int iter = 0; iter < rounds; ++iter) {
refine.run();
coarse.run();
swap.run();
smooth.run();
}
mesh.store(result);
}