/home/runner/work/amr-wind/amr-wind/amr-wind/physics/udfs/TwoLayer.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/udfs/TwoLayer.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
TwoLayer.H
Go to the documentation of this file.
1#ifndef TWO_LAYER_H
2#define TWO_LAYER_H
3
4#include "AMReX_Geometry.H"
5#include "AMReX_Gpu.H"
6
7namespace amr_wind {
8
9class Field;
10
11namespace udf {
12
14{
15 struct DeviceOp
16 {
17 // velocities of the top and bottom layer respectively
18 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> top_vel = {0.0};
19 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> bottom_vel = {0.0};
20 amrex::Real z_part{0.5}; // z-coordinate that divides top and bottom
21 amrex::Real init_perturb{1.0}; // initial perturbation for testing
22
23 AMREX_GPU_DEVICE
24 inline void operator()(
25 const amrex::IntVect& iv,
26 amrex::Array4<amrex::Real> const& field,
27 amrex::GeometryData const& geom,
28 const amrex::Real time,
29 amrex::Orientation /* ori */,
30 const int comp,
31 const int dcomp,
32 const int orig_comp) const
33 {
34 const auto* problo = geom.ProbLo();
35 const auto* dx = geom.CellSize();
36 const auto z = problo[2] + (iv[2] + 0.5) * dx[2];
37
38 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel;
39 if (z >= z_part) {
40 vel = {top_vel[0], top_vel[1], 0.0};
41 } else {
42 vel = {bottom_vel[0], bottom_vel[1], 0.0};
43 }
44
45 if (time == 0.0) {
46 vel[0] *= init_perturb;
47 vel[1] *= init_perturb;
48 }
49
50 field(iv[0], iv[1], iv[2], dcomp + comp) = vel[orig_comp + comp];
51 }
52 };
54
55 static std::string identifier() { return "TwoLayer"; }
56
57 explicit TwoLayer(const Field& fld);
58
59 DeviceType device_instance() const { return m_op; }
60
62};
63
64} // namespace udf
65} // namespace amr_wind
66
67#endif /* TWO_LAYER_H */
Definition Field.H:116
Definition BCInterface.cpp:7
Definition TwoLayer.H:16
amrex::Real z_part
Definition TwoLayer.H:20
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > bottom_vel
Definition TwoLayer.H:19
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > top_vel
Definition TwoLayer.H:18
AMREX_GPU_DEVICE void operator()(const amrex::IntVect &iv, amrex::Array4< amrex::Real > const &field, amrex::GeometryData const &geom, const amrex::Real time, amrex::Orientation, const int comp, const int dcomp, const int orig_comp) const
Definition TwoLayer.H:24
amrex::Real init_perturb
Definition TwoLayer.H:21
Definition TwoLayer.H:14
DeviceType device_instance() const
Definition TwoLayer.H:59
DeviceOp m_op
Definition TwoLayer.H:61
static std::string identifier()
Definition TwoLayer.H:55
TwoLayer(const Field &fld)
Definition TwoLayer.cpp:11