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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/immersed_boundary/bluff_body/cylinder_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
cylinder_ops.H
Go to the documentation of this file.
1#ifndef CYLINDER_OPS_H
2#define CYLINDER_OPS_H
3
8
9namespace amr_wind::ib::ops {
10
11template <>
13{
15 Cylinder::DataType& data, const ::amr_wind::utils::MultiParser& pp)
16 {
17
18 auto& wdata = data.meta();
19 auto& info = data.info();
20
21 bluff_body::read_inputs(wdata, info, pp);
22
23 pp.get("center", wdata.center_loc);
24 pp.get("radius", wdata.radius);
25 pp.get("height", wdata.height);
26
27 amrex::Real search_radius = 2.0 * wdata.radius;
28 // clang-format off
29 const auto& origin=wdata.center_loc;
30 info.bound_box = amrex::RealBox(
31 origin[0] - search_radius,
32 origin[1] - search_radius,
33 origin[2] - search_radius,
34 origin[0] + search_radius,
35 origin[1] + search_radius,
36 origin[2] + search_radius);
37 // clang-format on
38 }
39};
40
41template <>
43{
45 {
46 const auto& wdata = data.meta();
47
48 auto& sim = data.sim();
49 // cppcheck-suppress constVariableReference
50 auto& mask_node = sim.repo().get_int_field("mask_node");
51 // cppcheck-suppress constVariableReference
52 auto& levelset = sim.repo().get_field("ib_levelset");
53
54 auto nlevels = sim.repo().num_active_levels();
55 auto geom = sim.mesh().Geom();
56
57 for (int lev = 0; lev < nlevels; ++lev) {
58 const auto& problo = geom[lev].ProbLoArray();
59 const auto& dx = geom[lev].CellSizeArray();
60
61 for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) {
62 const auto& phi = levelset(lev).array(mfi);
63
64 const amrex::Real x0 = wdata.center_loc[0];
65 const amrex::Real y0 = wdata.center_loc[1];
66 const amrex::Real R = wdata.radius;
67 const auto& bx = mfi.growntilebox();
68 amrex::ParallelFor(
69 bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
70 const amrex::Real x = problo[0] + (i + 0.5) * dx[0];
71 const amrex::Real y = problo[1] + (j + 0.5) * dx[1];
72 const amrex::Real phi_glob = phi(i, j, k);
73 const amrex::Real r = std::sqrt(
74 (x - x0) * (x - x0) + (y - y0) * (y - y0));
75
76 const amrex::Real phi_loc = r - R;
77
78 phi(i, j, k) = std::min(phi_loc, phi_glob);
79 });
80
81 const auto& nbx = mfi.nodaltilebox();
82 const auto& epsilon_node = mask_node(lev).array(mfi);
83 amrex::ParallelFor(
84 nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
85 const amrex::Real x = problo[0] + i * dx[0];
86 const amrex::Real y = problo[1] + j * dx[1];
87
88 const amrex::Real r = std::sqrt(
89 (x - x0) * (x - x0) + (y - y0) * (y - y0));
90
91 if (r <= R) {
92 epsilon_node(i, j, k) = 0;
93 }
94 });
95 }
96 }
97 }
98};
99
100} // namespace amr_wind::ib::ops
101
102#endif /* CYLINDER_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 Cylinder.H:16
void operator()(Cylinder::DataType &data)
Definition cylinder_ops.H:44
Definition IBOps.H:32
void operator()(Cylinder::DataType &data, const ::amr_wind::utils::MultiParser &pp)
Definition cylinder_ops.H:14
Definition IBOps.H:19