-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
115 lines (90 loc) · 2.66 KB
/
main.cpp
File metadata and controls
115 lines (90 loc) · 2.66 KB
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
#include <AMReX.H>
#include <AMReX_EB2.H>
#include <AMReX_EB2_IF.H>
#include <AMReX_ParmParse.H>
#include <AMReX_PlotFileUtil.H>
// Our include
#include "../../EBGeometry.hpp"
using namespace amrex;
template <class T, class Meta, class BV, size_t K>
class AMReXSDF
{
public:
AMReXSDF(const std::string a_filename, const bool a_use_bvh)
{
if (a_use_bvh) {
m_sdf = EBGeometry::Parser::readIntoLinearBVH<T, Meta, BV, K>(a_filename);
}
else {
m_sdf = EBGeometry::Parser::readIntoMesh<T, Meta>(a_filename);
}
}
AMReXSDF(const AMReXSDF& a_other)
{
this->m_sdf = a_other.m_sdf;
}
Real
operator()(AMREX_D_DECL(Real x, Real y, Real z)) const noexcept
{
using Vec3 = EBGeometry::Vec3T<T>;
return m_sdf->value(Vec3(x, y, z));
};
inline Real
operator()(const RealArray& p) const noexcept
{
return this->operator()(AMREX_D_DECL(p[0], p[1], p[2]));
}
protected:
std::shared_ptr<EBGeometry::ImplicitFunction<T>> m_sdf;
};
int
main(int argc, char* argv[])
{
amrex::Initialize(argc, argv);
{
int max_grid_size = 16;
int which_geom = 0;
int num_coarsen_opt = 0;
bool use_bvh = true;
std::string filename;
// read parameters
ParmParse pp;
pp.query("use_bvh", use_bvh);
pp.query("max_grid_size", max_grid_size);
pp.query("which_geom", which_geom);
pp.query("num_coarsen_opt", num_coarsen_opt);
Geometry geom;
{
RealBox rb;
rb = RealBox({-20.0, -50.0, 0.}, {332, 238, 160});
filename = "buildings_fixed.stl";
Array<int, AMREX_SPACEDIM> is_periodic{false, false, false};
Geometry::Setup(&rb, 0, is_periodic.data());
Box domain(IntVect(0), IntVect(176-1,144-1,80 - 1));
geom.define(domain);
}
// Create our signed distance function. K is the tree degree while T is the
// EBGeometry precision.
constexpr int K = 2;
using T = float;
using Meta = EBGeometry::DCEL::DefaultMetaData;
using Vec3 = EBGeometry::Vec3T<T>;
using BV = EBGeometry::BoundingVolumes::AABBT<T>;
AMReXSDF<T, Meta, BV, K> sdf(filename, use_bvh);
auto gshop = EB2::makeShop(sdf);
EB2::Build(gshop, geom, 0, 0, 1, true, true, num_coarsen_opt);
// Put some data
MultiFab mf;
{
BoxArray boxArray(geom.Domain());
boxArray.maxSize(max_grid_size);
DistributionMapping dm{boxArray};
std::unique_ptr<EBFArrayBoxFactory> factory =
amrex::makeEBFabFactory(geom, boxArray, dm, {2, 2, 2}, EBSupport::full);
mf.define(boxArray, dm, 1, 0, MFInfo(), *factory);
mf.setVal(1.0);
}
EB_WriteSingleLevelPlotfile("plt", mf, {"rho"}, geom, 0.0, 0);
}
amrex::Finalize();
}