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

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