/home/runner/work/amr-wind/amr-wind/amr-wind/immersed_boundary/bluff_body/box_ops.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/immersed_boundary/bluff_body/box_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
box_ops.H
Go to the documentation of this file.
1#ifndef BOX_OPS_H
2#define BOX_OPS_H
3
8
9namespace amr_wind::ib::ops {
10
11template <>
13{
14 void
15 operator()(Box::DataType& data, const ::amr_wind::utils::MultiParser& pp)
16 {
17 auto& wdata = data.meta();
18 auto& info = data.info();
19
20 bluff_body::read_inputs(wdata, info, pp);
21
22 pp.get("center", wdata.center_loc);
23 pp.get("length", wdata.length);
24 pp.get("width", wdata.width);
25 pp.get("height", wdata.height);
26
27 amrex::Real search_radius =
28 2.0 * std::max(wdata.length, std::max(wdata.width, wdata.height));
29
30 // clang-format off
31 const auto& origin=wdata.center_loc;
32 info.bound_box = amrex::RealBox(
33 origin[0] - search_radius,
34 origin[1] - search_radius,
35 origin[2] - search_radius,
36 origin[0] + search_radius,
37 origin[1] + search_radius,
38 origin[2] + search_radius);
39 // clang-format on
40 }
41};
42
43template <>
45{
47 {
48 const auto& wdata = data.meta();
49
50 auto& sim = data.sim();
51 // cppcheck-suppress constVariableReference
52 auto& mask_node = sim.repo().get_int_field("mask_node");
53 // cppcheck-suppress constVariableReference
54 auto& levelset = sim.repo().get_field("ib_levelset");
55
56 auto nlevels = sim.repo().num_active_levels();
57 auto geom = sim.mesh().Geom();
58
59 for (int lev = 0; lev < nlevels; ++lev) {
60 const auto& problo = geom[lev].ProbLoArray();
61 const auto& dx = geom[lev].CellSizeArray();
62 for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) {
63 const auto& bx = mfi.growntilebox();
64 const auto& epsilon_node = mask_node(lev).array(mfi);
65 const auto& phi = levelset(lev).array(mfi);
66
67 const amrex::Real x0 = wdata.center_loc[0];
68 const amrex::Real y0 = wdata.center_loc[1];
69 const amrex::Real z0 = wdata.center_loc[2];
70 const amrex::Real l = wdata.length;
71 const amrex::Real w = wdata.width;
72 const amrex::Real h = wdata.height;
73 amrex::ParallelFor(
74 bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
75 const amrex::Real x = problo[0] + (i + 0.5) * dx[0];
76 const amrex::Real y = problo[1] + (j + 0.5) * dx[1];
77 const amrex::Real z = problo[2] + (k + 0.5) * dx[2];
78
79 amrex::Real phi_loc = 0;
80 if ((std::abs(x - x0) <= 0.5 * l) &&
81 (std::abs(y - y0) <= 0.5 * w) &&
82 (std::abs(z - z0) <= 0.5 * h)) {
83 phi_loc = std::max(
84 std::abs(x - x0) - 0.5 * l,
85 std::max(
86 std::abs(y - y0) - 0.5 * w,
87 std::abs(z - z0) - 0.5 * h));
88 } else {
89 phi_loc = std::min(
90 std::abs(std::abs(x - x0) - 0.5 * l),
91 std::min(
92 std::abs(std::abs(y - y0) - 0.5 * w),
93 std::abs(std::abs(z - z0) - 0.5 * h)));
94 }
95 phi(i, j, k) = std::min(phi_loc, phi(i, j, k));
96 });
97 const auto& nbx = mfi.nodaltilebox();
98 amrex::ParallelFor(
99 nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
100 const amrex::Real x = problo[0] + i * dx[0];
101 const amrex::Real y = problo[1] + j * dx[1];
102 const amrex::Real z = problo[2] + k * dx[2];
103
104 if ((std::abs(x - x0) <= 0.5 * l + 0.5 * dx[0]) &&
105 (std::abs(y - y0) <= 0.5 * w + 0.5 * dx[1]) &&
106 (std::abs(z - z0) <= 0.5 * h + 0.5 * dx[2])) {
107 epsilon_node(i, j, k) = 0;
108 }
109 });
110 }
111 }
112 }
113};
114
115} // namespace amr_wind::ib::ops
116
117#endif /* BOX_OPS_H */
FieldRepo & repo()
Return the field repository.
Definition CFDSim.H:66
FieldRepo & repo() const
FieldRepo instance that manages this field.
Definition Field.H:159
Field & get_field(const std::string &name, const FieldState fstate=FieldState::New) const
Definition FieldRepo.cpp:149
int num_active_levels() const noexcept
Total number of levels currently active in the AMR mesh.
Definition FieldRepo.H:361
IntField & get_int_field(const std::string &name, const FieldState fstate=FieldState::New) const
Return a reference to an integer field.
Definition FieldRepo.cpp:276
const FieldRepo & repo() const
Reference to the FieldRepo that holds the fabs.
Definition IntField.H:43
Definition IBTypes.H:62
IBTrait::MetaType & meta()
Definition IBTypes.H:92
IBTrait::InfoType & info()
Definition IBTypes.H:89
CFDSim & sim()
Definition IBTypes.H:86
void read_inputs(BluffBodyBaseData &wdata, IBInfo &, const ::amr_wind::utils::MultiParser &pp)
Definition bluff_body_ops.cpp:16
Definition bluff_body_ops.H:49
Definition Box.H:17
void operator()(Box::DataType &data)
Definition box_ops.H:46
Definition IBOps.H:32
void operator()(Box::DataType &data, const ::amr_wind::utils::MultiParser &pp)
Definition box_ops.H:15
Definition IBOps.H:19