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