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