-
Notifications
You must be signed in to change notification settings - Fork 83
/
GeometryRefinement.cpp
63 lines (51 loc) · 1.8 KB
/
GeometryRefinement.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
#include "amr-wind/utilities/tagging/GeometryRefinement.H"
#include "amr-wind/CFDSim.H"
#include "AMReX.H"
#include "AMReX_ParmParse.H"
namespace amr_wind {
GeometryRefinement::GeometryRefinement(const CFDSim& sim)
: m_sim(sim), m_max_level(m_sim.mesh().maxLevel())
{}
void GeometryRefinement::initialize(const std::string& key)
{
amrex::Vector<std::string> shapes;
{
amrex::ParmParse pp(key);
pp.getarr("shapes", shapes);
pp.query("level", m_set_level);
pp.query("min_level", m_min_level);
pp.query("max_level", m_max_level);
}
for (const auto& geom : shapes) {
const std::string& gkey = key + "." + geom;
amrex::ParmParse pp(gkey);
std::string gtype;
pp.get("type", gtype);
auto obj = tagging::GeometryType::create(gtype, m_sim, gkey);
m_geom_refiners.emplace_back(std::move(obj));
}
}
void GeometryRefinement::operator()(
int level, amrex::TagBoxArray& tags, amrex::Real, int)
{
// If the user has requested a particular level then check for it and exit
// early
if ((m_set_level > 1) && (level != m_set_level)) return;
// If the user has specified a range of levels, check and return early
if ((level < m_min_level) || (level > m_max_level)) return;
const auto& mesh = m_sim.mesh();
const auto& geom = mesh.Geom(level);
// We are always guaranteed to have at least one field
const auto& field_fab = (*m_sim.repo().fields()[0])(level);
#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (amrex::MFIter mfi(field_fab); mfi.isValid(); ++mfi) {
const auto& bx = mfi.tilebox();
const auto& tag = tags.array(mfi);
for (const auto& gg : m_geom_refiners) {
(*gg)(bx, geom, tag);
}
}
}
} // namespace amr_wind