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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/udfs/LinearProfile.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
LinearProfile.H
Go to the documentation of this file.
1#ifndef LINEARPROFILE_H
2#define LINEARPROFILE_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 int idir{2};
18 amrex::Real zmin;
19 amrex::Real zmax;
20 amrex::RealArray fld_min;
21 amrex::RealArray fld_max;
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 /*unused*/,
29 amrex::Orientation /*unused*/,
30 const int comp,
31 const int dcomp,
32 const int orig_comp) const
33 {
34 const auto* problo = geom.ProbLo();
35 const auto* dx = geom.CellSize();
36 const auto zco = problo[idir] + (iv[idir] + 0.5) * dx[idir];
37
38 amrex::Real val;
39 if (zco < zmin) {
40 val = fld_min[orig_comp + comp];
41 } else if (zco > zmax) {
42 val = fld_max[orig_comp + comp];
43 } else {
44 val = fld_min[orig_comp + comp] +
45 (fld_max[orig_comp + comp] - fld_min[orig_comp + comp]) *
46 (zco - zmin) / (zmax - zmin);
47 }
48 field(iv[0], iv[1], iv[2], dcomp + comp) = val;
49 }
50 };
51
53
54 static std::string identifier() { return "LinearProfile"; }
55
56 explicit LinearProfile(const Field& fld);
57
58 DeviceType device_instance() const { return m_op; }
59
61};
62
63} // namespace udf
64} // namespace amr_wind
65
66#endif /* LINEARPROFILE_H */
Definition Field.H:116
Definition BCInterface.cpp:7
Definition LinearProfile.H:16
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 LinearProfile.H:24
amrex::RealArray fld_max
Definition LinearProfile.H:21
amrex::RealArray fld_min
Definition LinearProfile.H:20
amrex::Real zmin
Definition LinearProfile.H:18
amrex::Real zmax
Definition LinearProfile.H:19
int idir
Definition LinearProfile.H:17
Definition LinearProfile.H:14
DeviceOp m_op
Definition LinearProfile.H:60
LinearProfile(const Field &fld)
Definition LinearProfile.cpp:9
DeviceType device_instance() const
Definition LinearProfile.H:58
static std::string identifier()
Definition LinearProfile.H:54