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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/udfs/PowerLawProfile.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
PowerLawProfile.H
Go to the documentation of this file.
1#ifndef POWERLAWPROFILE_H
2#define POWERLAWPROFILE_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 zoffset{0.0};
19 amrex::Real zref;
20 amrex::Real uref;
21 amrex::Real shear_exp;
22 amrex::Real umin{0.0};
23 amrex::Real umax{100.0};
24 amrex::RealArray uvec;
25
26 AMREX_GPU_DEVICE
27 inline void operator()(
28 const amrex::IntVect& iv,
29 amrex::Array4<amrex::Real> const& field,
30 amrex::GeometryData const& geom,
31 const amrex::Real /*unused*/,
32 amrex::Orientation /*unused*/,
33 const int comp,
34 const int dcomp,
35 const int orig_comp) const
36 {
37 const auto* problo = geom.ProbLo();
38 const auto* dx = geom.CellSize();
39 const auto zco = problo[idir] + (iv[idir] + 0.5) * dx[idir];
40
41 const amrex::Real zeff = zco - zoffset;
42 amrex::Real pfac =
43 (zeff > 0.0) ? std::pow((zeff / zref), shear_exp) : 0.0;
44 pfac = amrex::min(amrex::max(pfac, umin), umax);
45
46 field(iv[0], iv[1], iv[2], dcomp + comp) =
47 uvec[orig_comp + comp] * pfac;
48 }
49 };
50
52
53 static std::string identifier() { return "PowerLawProfile"; }
54
55 explicit PowerLawProfile(const Field& fld);
56
57 DeviceType device_instance() const { return m_op; }
58
60
61}; // namespace udf
62
63} // namespace udf
64} // namespace amr_wind
65
66#endif /* POWERLAWPROFILE_H */
Definition Field.H:116
Definition BCInterface.cpp:7
Definition PowerLawProfile.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 PowerLawProfile.H:27
int idir
Definition PowerLawProfile.H:17
amrex::Real zoffset
Definition PowerLawProfile.H:18
amrex::Real shear_exp
Definition PowerLawProfile.H:21
amrex::Real umin
Definition PowerLawProfile.H:22
amrex::Real uref
Definition PowerLawProfile.H:20
amrex::Real umax
Definition PowerLawProfile.H:23
amrex::RealArray uvec
Definition PowerLawProfile.H:24
amrex::Real zref
Definition PowerLawProfile.H:19
Definition PowerLawProfile.H:14
static std::string identifier()
Definition PowerLawProfile.H:53
DeviceType device_instance() const
Definition PowerLawProfile.H:57
PowerLawProfile(const Field &fld)
Definition PowerLawProfile.cpp:11
DeviceOp m_op
Definition PowerLawProfile.H:59