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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/udfs/CustomScalar.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
CustomScalar.H
Go to the documentation of this file.
1#ifndef CUSTOM_SCALAR_H
2#define CUSTOM_SCALAR_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
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 const auto* problo = geom.ProbLo();
36 const auto* dx = geom.CellSize();
37 const auto x = problo[0] + (iv[0] + 0.5_rt) * dx[0];
38 const auto y = problo[1] + (iv[1] + 0.5_rt) * dx[1];
39 const auto z = problo[2] + (iv[2] + 0.5_rt) * dx[2];
40 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> vel = {
41 1.0_rt, 0.0_rt, 0.0_rt};
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 amrex::ignore_unused(x, y, z);
46 }
47 };
49
50 static std::string identifier() { return "CustomScalar"; }
51
52 explicit CustomScalar(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_SCALAR_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 CustomScalar.H:19
amrex::Real foo
Definition CustomScalar.H:21
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 CustomScalar.H:24
DeviceOp DeviceType
Definition CustomScalar.H:48
CustomScalar(const Field &fld)
Definition CustomScalar.cpp:11
DeviceType device_instance() const
Definition CustomScalar.H:54
DeviceOp m_op
Definition CustomScalar.H:56
static std::string identifier()
Definition CustomScalar.H:50