/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#include "AMReX_REAL.H"
9
10using namespace amrex::literals;
11
12namespace amr_wind::ib::ops {
13
14template <>
16{
17 void
18 operator()(Sphere::DataType& data, const ::amr_wind::utils::MultiParser& pp)
19 {
20 auto& wdata = data.meta();
21 auto& info = data.info();
22
23 bluff_body::read_inputs(wdata, info, pp);
24
25 pp.get("center", wdata.center_loc);
26 pp.get("radius", wdata.radius);
27
28 amrex::Real search_radius = 3.0_rt * wdata.radius;
29 // clang-format off
30 const auto& origin=wdata.center_loc;
31 info.bound_box = amrex::RealBox(
32 origin[0] - search_radius,
33 origin[1] - search_radius,
34 origin[2] - search_radius,
35 origin[0] + search_radius,
36 origin[1] + search_radius,
37 origin[2] + search_radius);
38 // clang-format on
39 }
40};
41
42template <>
44{
46 {
47 const auto& wdata = data.meta();
48
49 auto& sim = data.sim();
50 // cppcheck-suppress constVariableReference
51 auto& mask_node = sim.repo().get_int_field("mask_node");
52 // cppcheck-suppress constVariableReference
53 auto& levelset = sim.repo().get_field("ib_levelset");
54
55 auto nlevels = sim.repo().num_active_levels();
56 auto geom = sim.mesh().Geom();
57
58 for (int lev = 0; lev < nlevels; ++lev) {
59 const auto& problo = geom[lev].ProbLoArray();
60 const auto& dx = geom[lev].CellSizeArray();
61
62#ifdef AMREX_USE_OMP
63#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
64#endif
65 for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) {
66 const auto& bx = mfi.growntilebox();
67 const auto& phi = levelset(lev).array(mfi);
68
69 const amrex::Real x0 = wdata.center_loc[0];
70 const amrex::Real y0 = wdata.center_loc[1];
71 const amrex::Real z0 = wdata.center_loc[2];
72 const amrex::Real R = wdata.radius;
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_rt) * dx[0];
76 const amrex::Real y = problo[1] + (j + 0.5_rt) * dx[1];
77 const amrex::Real z = problo[2] + (k + 0.5_rt) * dx[2];
78 const amrex::Real phi_glob = phi(i, j, k);
79 const amrex::Real r = std::sqrt(
80 (x - x0) * (x - x0) + (y - y0) * (y - y0) +
81 (z - z0) * (z - z0));
82
83 const amrex::Real phi_loc = r - R;
84 phi(i, j, k) =
85 amrex::min<amrex::Real>(phi_loc, phi_glob);
86 });
87
88 const auto& nbx = mfi.nodaltilebox();
89 const auto& epsilon_node = mask_node(lev).array(mfi);
90 amrex::ParallelFor(
91 nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
92 const amrex::Real x = problo[0] + i * dx[0];
93 const amrex::Real y = problo[1] + j * dx[1];
94 const amrex::Real z = problo[2] + k * dx[2];
95
96 const amrex::Real r = std::sqrt(
97 (x - x0) * (x - x0) + (y - y0) * (y - y0) +
98 (z - z0) * (z - z0));
99 if (r <= R) {
100 epsilon_node(i, j, k) = 0;
101 }
102 });
103 }
104 }
105 }
106};
107
108} // namespace amr_wind::ib::ops
109
110#endif /* CYLINDER_OPS_H */
FieldRepo & repo()
Return the field repository.
Definition CFDSim.H:75
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:152
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:279
const FieldRepo & repo() const
Reference to the FieldRepo that holds the fabs.
Definition IntField.H:43
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:19
Definition bluff_body_ops.H:49
Definition Sphere.H:18
IBDataHolder< Sphere > DataType
Definition Sphere.H:21
void operator()(Sphere::DataType &data)
Definition sphere_ops.H:45
Definition IBOps.H:32
void operator()(Sphere::DataType &data, const ::amr_wind::utils::MultiParser &pp)
Definition sphere_ops.H:18
Definition IBOps.H:19