/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#include "AMReX_REAL.H"
7
8using namespace amrex::literals;
9
10namespace amr_wind {
11
12class Field;
13
14namespace udf {
15
17{
18 struct DeviceOp
19 {
20 // velocities of the top and bottom layer respectively
21 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> top_vel = {0.0_rt};
22 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> bottom_vel = {0.0_rt};
23 amrex::Real z_part{0.5_rt}; // z-coordinate that divides top and bottom
24 amrex::Real init_perturb{1.0_rt}; // initial perturbation for testing
25
26 AMREX_GPU_DEVICE
27 inline void operator()(
28 const amrex::IntVect& iv,
29 amrex::Array4<amrex::Real> const& field,
30 amrex::GeometryData const& geom,
31 const amrex::Real time,
32 amrex::Orientation /* ori */,
33 const int comp,
34 const int dcomp,
35 const int orig_comp) const
36 {
37 const auto* problo = geom.ProbLo();
38 const auto* dx = geom.CellSize();
39 const auto z = problo[2] + (iv[2] + 0.5_rt) * dx[2];
40
41 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel;
42 if (z >= z_part) {
43 vel = {top_vel[0], top_vel[1], 0.0_rt};
44 } else {
45 vel = {bottom_vel[0], bottom_vel[1], 0.0_rt};
46 }
47
48 if (time == 0.0_rt) {
49 vel[0] *= init_perturb;
50 vel[1] *= init_perturb;
51 }
52
53 field(iv[0], iv[1], iv[2], dcomp + comp) = vel[orig_comp + comp];
54 }
55 };
57
58 static std::string identifier() { return "TwoLayer"; }
59
60 explicit TwoLayer(const Field& fld);
61
62 DeviceType device_instance() const { return m_op; }
63
65};
66
67} // namespace udf
68} // namespace amr_wind
69
70#endif /* TWO_LAYER_H */
Definition Field.H:116
Definition BurggrafLid.cpp:9
This test case is intended as an evaluation of the momentum advection scheme.
Definition BCInterface.cpp:10
Definition TwoLayer.H:19
amrex::Real z_part
Definition TwoLayer.H:23
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > bottom_vel
Definition TwoLayer.H:22
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > top_vel
Definition TwoLayer.H:21
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:27
amrex::Real init_perturb
Definition TwoLayer.H:24
DeviceType device_instance() const
Definition TwoLayer.H:62
DeviceOp DeviceType
Definition TwoLayer.H:56
DeviceOp m_op
Definition TwoLayer.H:64
static std::string identifier()
Definition TwoLayer.H:58
TwoLayer(const Field &fld)
Definition TwoLayer.cpp:14