/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
7namespace amr_wind {
8
9class Field;
10
11namespace udf {
12
14{
15 struct DeviceOp
16 {
17 // clang-format off
18 // Declare parameters here if needed. For example:
19 // amrex::Real foo{1.0};
20 // amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> bar = {0.0};
21 // clang-format on
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 // Compute quantities to set the field values. For example:
35 // clang-format off
36 // const auto* problo = geom.ProbLo();
37 // const auto* dx = geom.CellSize();
38 // const auto x = problo[0] + (iv[0] + 0.5) * dx[0];
39 // const auto y = problo[1] + (iv[1] + 0.5) * dx[1];
40 // const auto z = problo[2] + (iv[2] + 0.5) * dx[2];
41 // const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel = {1.0, 0.0, 0.0};
42
43 // Once the above is done, fill the field as:
44 // field(iv[0], iv[1], iv[2], dcomp + comp) = vel[orig_comp + comp];
45 // clang-format on
46 }
47 };
49
50 static std::string identifier() { return "CustomVelocity"; }
51
52 explicit CustomVelocity(const Field& fld);
53
54 DeviceType device_instance() const { return m_op; }
55
57};
58
59} // namespace udf
60} // namespace amr_wind
61
62#endif /* CUSTOM_VELOCITY_H */
Definition Field.H:116
Definition BCInterface.cpp:7
Definition CustomVelocity.H:16
AMREX_GPU_DEVICE void operator()(const amrex::IntVect &, amrex::Array4< amrex::Real > const &, amrex::GeometryData const &, const amrex::Real, amrex::Orientation, const int, const int, const int) const
Definition CustomVelocity.H:24
Definition CustomVelocity.H:14
DeviceOp m_op
Definition CustomVelocity.H:56
DeviceType device_instance() const
Definition CustomVelocity.H:54
static std::string identifier()
Definition CustomVelocity.H:50
CustomVelocity(const Field &fld)
Definition CustomVelocity.cpp:11