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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/udfs/CustomVelocity.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
CustomVelocity.H
Go to the documentation of this file.
1#ifndef CUSTOM_VELOCITY_H
2#define CUSTOM_VELOCITY_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 // Declare parameters here if needed. For example:
21 amrex::Real foo{1.0_rt};
22 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> bar = {0.0_rt};
23
24 AMREX_GPU_DEVICE
25 inline void operator()(
26 const amrex::IntVect& iv,
27 amrex::Array4<amrex::Real> const& field,
28 amrex::GeometryData const& geom,
29 const amrex::Real /*time*/,
30 amrex::Orientation /*ori*/,
31 const int comp,
32 const int dcomp,
33 const int orig_comp) const
34 {
35 // Compute quantities to set the field values. For example:
36 const auto* problo = geom.ProbLo();
37 const auto* dx = geom.CellSize();
38 const auto x = problo[0] + (iv[0] + 0.5_rt) * dx[0];
39 const auto y = problo[1] + (iv[1] + 0.5_rt) * dx[1];
40 const auto z = problo[2] + (iv[2] + 0.5_rt) * dx[2];
41 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel = {
42 1.0_rt, 0.0_rt, 0.0_rt};
43
44 // Once the above is done, fill the field as:
45 field(iv[0], iv[1], iv[2], dcomp + comp) = vel[orig_comp + comp];
46 amrex::ignore_unused(x, y, z);
47 }
48 };
50
51 static std::string identifier() { return "CustomVelocity"; }
52
53 explicit CustomVelocity(const Field& fld);
54
55 DeviceType device_instance() const { return m_op; }
56
58};
59
60} // namespace udf
61} // namespace amr_wind
62
63#endif /* CUSTOM_VELOCITY_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 CustomVelocity.H:19
amrex::Real foo
Definition CustomVelocity.H:21
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > bar
Definition CustomVelocity.H:22
AMREX_GPU_DEVICE void operator()(const amrex::IntVect &iv, amrex::Array4< amrex::Real > const &field, amrex::GeometryData const &geom, const amrex::Real, amrex::Orientation, const int comp, const int dcomp, const int orig_comp) const
Definition CustomVelocity.H:25
DeviceOp m_op
Definition CustomVelocity.H:57
DeviceType device_instance() const
Definition CustomVelocity.H:55
static std::string identifier()
Definition CustomVelocity.H:51
DeviceOp DeviceType
Definition CustomVelocity.H:49
CustomVelocity(const Field &fld)
Definition CustomVelocity.cpp:14