/home/runner/work/kynema-sgf/kynema-sgf/src/immersed_boundary/bluff_body/cylinder_ops.H Source File

Kynema-SGF API: /home/runner/work/kynema-sgf/kynema-sgf/src/immersed_boundary/bluff_body/cylinder_ops.H Source File
Kynema-SGF 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#include "AMReX_REAL.H"
9
10using namespace amrex::literals;
11
12namespace kynema_sgf::ib::ops {
13
14template <>
16{
18 Cylinder::DataType& data, const ::kynema_sgf::utils::MultiParser& pp)
19 {
20
21 auto& wdata = data.meta();
22 auto& info = data.info();
23
24 bluff_body::read_inputs(wdata, info, pp);
25
26 pp.get("center", wdata.center_loc);
27 pp.get("radius", wdata.radius);
28 pp.get("height", wdata.height);
29
30 amrex::Real search_radius = 2.0_rt * wdata.radius;
31 // clang-format off
32 const auto& origin=wdata.center_loc;
33 info.bound_box = amrex::RealBox(
34 origin[0] - search_radius,
35 origin[1] - search_radius,
36 origin[2] - search_radius,
37 origin[0] + search_radius,
38 origin[1] + search_radius,
39 origin[2] + search_radius);
40 // clang-format on
41 }
42};
43
44template <>
46{
48 {
49 const auto& wdata = data.meta();
50
51 auto& sim = data.sim();
52 auto& mask_node = sim.repo().get_int_field("mask_node");
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 for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) {
63 const auto& phi = levelset(lev).array(mfi);
64
65 const amrex::Real x0 = wdata.center_loc[0];
66 const amrex::Real y0 = wdata.center_loc[1];
67 const amrex::Real R = wdata.radius;
68 const auto& bx = mfi.growntilebox();
69 amrex::ParallelFor(
70 bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) {
71 const amrex::Real x =
72 problo[0] + ((i + 0.5_rt) * dx[0]);
73 const amrex::Real y =
74 problo[1] + ((j + 0.5_rt) * dx[1]);
75 const amrex::Real phi_glob = phi(i, j, k);
76 const amrex::Real r = std::sqrt(
77 ((x - x0) * (x - x0)) + ((y - y0) * (y - y0)));
78
79 const amrex::Real phi_loc = r - R;
80
81 phi(i, j, k) =
82 amrex::min<amrex::Real>(phi_loc, phi_glob);
83 });
84
85 const auto& nbx = mfi.nodaltilebox();
86 const auto& epsilon_node = mask_node(lev).array(mfi);
87 amrex::ParallelFor(
88 nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) {
89 const amrex::Real x = problo[0] + (i * dx[0]);
90 const amrex::Real y = problo[1] + (j * dx[1]);
91
92 const amrex::Real r = std::sqrt(
93 ((x - x0) * (x - x0)) + ((y - y0) * (y - y0)));
94
95 if (r <= R) {
96 epsilon_node(i, j, k) = 0;
97 }
98 });
99 }
100 }
101 }
102};
103
104} // namespace kynema_sgf::ib::ops
105
106#endif /* CYLINDER_OPS_H */
FieldRepo & repo()
Return the field repository.
Definition CFDSim.H:76
FieldRepo & repo() const
FieldRepo instance that manages this field.
Definition Field.H:164
Field & get_field(const std::string &name, FieldState fstate=FieldState::New) const
Definition FieldRepo.cpp:152
IntField & get_int_field(const std::string &name, FieldState fstate=FieldState::New) const
Return a reference to an integer field.
Definition FieldRepo.cpp:279
int num_active_levels() const
Total number of levels currently active in the AMR mesh.
Definition FieldRepo.H:351
const FieldRepo & repo() const
Reference to the FieldRepo that holds the fabs.
Definition IntField.H:43
IBTrait::InfoType & info()
Definition IBTypes.H:89
IBTrait::MetaType & meta()
Definition IBTypes.H:95
CFDSim & sim()
Definition IBTypes.H:86
void read_inputs(BluffBodyBaseData &wdata, IBInfo &, const ::kynema_sgf::utils::MultiParser &pp)
Definition bluff_body_ops.cpp:20
Definition bluff_body_ops.H:49
Definition Cylinder.H:19
IBDataHolder< Cylinder > DataType
Definition Cylinder.H:22
void operator()(Cylinder::DataType &data)
Definition cylinder_ops.H:47
Definition IBOps.H:32
void operator()(Cylinder::DataType &data, const ::kynema_sgf::utils::MultiParser &pp)
Definition cylinder_ops.H:17