/home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/actuator_utils.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/actuator_utils.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
actuator_utils.H
Go to the documentation of this file.
1#ifndef ACUTATOR_UTILS_H
2#define ACUTATOR_UTILS_H
3
5#include "AMReX_AmrCore.H"
7#include <cmath>
8
9#include <set>
10
11namespace amr_wind::actuator {
12
13struct ActInfo;
14
15namespace utils {
16
27std::set<int> determine_influenced_procs(
28 const amrex::AmrCore& mesh, const amrex::RealBox& rbx);
29
31 ActInfo& /*info*/, amrex::Vector<int>& /*act_proc_count*/);
32
42AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real
43gaussian3d(const vs::Vector& dist, const vs::Vector& eps)
44{
45 const vs::Vector rr{
46 dist.x() / eps.x(), dist.y() / eps.y(), dist.z() / eps.z()};
47 const amrex::Real rr_sqr = vs::mag_sqr(rr);
48
49 if (rr_sqr < 16.0) {
50 constexpr amrex::Real fac = 0.17958712212516656;
51 const amrex::Real eps_fac = eps.x() * eps.y() * eps.z();
52 return (fac / eps_fac) *
53 std::exp(-rr.x() * rr.x() - rr.y() * rr.y() - rr.z() * rr.z());
54 }
55
56 return 0.0;
57}
67AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real
68gaussian1d(const amrex::Real& dist, const amrex::Real& eps)
69{
70 const amrex::Real fac = 0.5641895835477563;
71 if (std::abs(dist / eps) >= 16.0) {
72 return 0.0;
73 }
74 return fac / eps * std::exp(-(dist * dist) / (eps * eps));
75}
76
86AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE vs::Vector delta_pnts_cyl(
87 const vs::Vector& origin,
88 const vs::Vector& normal,
89 const vs::Vector& point1,
90 const vs::Vector& point2)
91{
92 const amrex::Real eps = vs::DTraits<amrex::Real>::eps();
93 const auto d1 = point1 - origin;
94 const auto d2 = point2 - origin;
95
96 // cppcheck-suppress duplicateExpression
97 const amrex::Real norm_dist1 = (d1 & normal) / (normal & normal);
98 // cppcheck-suppress duplicateExpression
99 const amrex::Real norm_dist2 = (d2 & normal) / (normal & normal);
100
101 const auto proj1 = normal * norm_dist1;
102 const auto proj2 = normal * norm_dist2;
103
104 // compute vector on disk via vector rejection
105 const auto v1 = d1 - proj1;
106 const auto v2 = d2 - proj2;
107
108 // can do magnitude since we've removed the normal component
109 const amrex::Real r1 = vs::mag(v1);
110 const amrex::Real r2 = vs::mag(v2);
111
112 const amrex::Real theta =
113 std::acos(amrex::min<amrex::Real>((v1 & v2) / (r1 * r2 + eps), 1.0));
114
115 return {std::abs(r1 - r2), theta, norm_dist1 - norm_dist2};
116}
117
125AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real
126linear_basis_1d(const amrex::Real distance, const amrex::Real dX)
127{
128 return amrex::max(0.0, 1.0 - distance / dX) / dX;
129}
130
131AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE vs::Vector compute_tangential_vector(
132 const vs::Vector& center, const vs::Vector& normal, const vs::Vector& point)
133{
134 const auto blade_axis = (point - center).normalize();
135 return vs::quaternion(normal, 90.0) & blade_axis;
136}
137
138} // namespace utils
139} // namespace amr_wind::actuator
140
141#endif /* ACUTATOR_UTILS_H */
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE vs::Vector delta_pnts_cyl(const vs::Vector &origin, const vs::Vector &normal, const vs::Vector &point1, const vs::Vector &point2)
Definition actuator_utils.H:86
std::set< int > determine_influenced_procs(const amrex::AmrCore &mesh, const amrex::RealBox &rbx)
Definition actuator_utils.cpp:6
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real gaussian3d(const vs::Vector &dist, const vs::Vector &eps)
Definition actuator_utils.H:43
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real gaussian1d(const amrex::Real &dist, const amrex::Real &eps)
Definition actuator_utils.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real linear_basis_1d(const amrex::Real distance, const amrex::Real dX)
Definition actuator_utils.H:126
void determine_root_proc(ActInfo &info, amrex::Vector< int > &act_proc_count)
Definition actuator_utils.cpp:34
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE vs::Vector compute_tangential_vector(const vs::Vector &center, const vs::Vector &normal, const vs::Vector &point)
Definition actuator_utils.H:131
Definition ActParser.H:6
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Tensor quaternion(const Vector &axis, const amrex::Real angle)
Definition tensorI.H:215
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T mag(const TensorT< T > &t)
Definition tensorI.H:182
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T mag_sqr(const TensorT< T > &t)
Definition tensorI.H:175
Definition vstraits.H:11
Definition vector.H:13
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & z() &noexcept
Definition vector.H:99
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & x() &noexcept
Definition vector.H:97
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & y() &noexcept
Definition vector.H:98