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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/disk/disk_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
disk_ops.H
Go to the documentation of this file.
1#ifndef DISK_OPS_H_
2#define DISK_OPS_H_
3
8
9namespace amr_wind::actuator {
10namespace disk {
11// refactor these when we add more disk types later
13 const std::string& name,
14 const DiskBaseData& data,
15 const ActInfo& info,
16 const ActGrid& grid);
17
18void write_netcdf(
19 const std::string& name,
20 const DiskBaseData& data,
21 const ActInfo& info,
22 const ActGrid& /*unused*/,
23 const amrex::Real time);
24} // namespace disk
25
26namespace ops {
27namespace base {
28
30{
31public:
33 const amrex::Real radius, const int num_r, const int num_theta);
34
35 amrex::Real area_section(const int iRadius) const;
36
37 amrex::Real weight(const int iRadius) const;
38
39private:
40 const amrex::Real m_area;
41 const amrex::Real m_geometry_factor;
42};
43
45
47 const utils::ActParser& pp,
48 const std::string& p1,
49 const std::string& p2,
50 std::ostringstream& ss);
52 const utils::ActParser& pp,
53 const std::string& independent,
54 const std::string& dependent,
55 std::ostringstream& ss);
57 const utils::ActParser& pp,
58 const std::string& p1,
59 const std::string& p2,
60 std::ostringstream& ss);
61
62void check_error_stream(const std::ostringstream& error_collector);
63
65
67
68std::ostringstream check_for_parse_conflicts(const utils::ActParser& pp);
69
71
72void final_checks(const DiskBaseData& meta);
73
74amrex::RealBox compute_bounding_box(const DiskBaseData& meta);
75
76template <typename T>
77void allocate_basic_grid_quantities(typename T::DataType& data)
78{
79 auto& grid = data.grid();
80 auto& meta = data.meta();
81 // only resize the members we are going to use
82 grid.pos.resize(meta.num_force_pts);
83 grid.force.resize(meta.num_force_pts);
84 grid.vel.resize(meta.num_vel_pts);
85 grid.vel_pos.resize(meta.num_vel_pts);
86 grid.density.resize(meta.num_vel_pts);
87}
88
89template <typename T>
91{
92 auto& meta = data.meta();
93 auto& info = data.info();
94
96 info.bound_box = compute_bounding_box(meta);
97}
98
100 const DiskBaseData& meta,
101 VecList& points,
102 const vs::Vector& cylAxis,
103 const int offset,
104 const double dOffset);
105
106template <typename T>
107void parse_and_gather_params(const utils::ActParser& pp, T& metaData)
108{
110 required_parameters(metaData, pp);
111 optional_parameters(metaData, pp);
112}
113
115{
116 const auto& normal = data.normal_vec;
117 // only use velocity components normal to disk
118 // make sure uInfSqr is always positive by squaring the projection of
119 // reference_velocity onto the normal
120 return (data.reference_velocity & normal) *
121 (data.reference_velocity & normal);
122}
123
124// we use a setter function since we want to cache this variable for netcdf
125// output
126inline void
127set_thrust_coefficient(DiskBaseData& data, const amrex::Real& uInfSqr)
128{
129 const amrex::Real uInfMag = std::sqrt(uInfSqr);
131 data.table_velocity, data.thrust_coeff, uInfMag);
132}
133
134} // namespace base
135
136template <typename ActTrait>
138 ActTrait,
140 std::enable_if_t<std::is_base_of_v<DiskType, ActTrait>>>
141{
142 void operator()(typename ActTrait::DataType& data)
143 {
144 auto& meta = data.meta();
145 const auto& grid = data.grid();
146 meta.reference_velocity = {0.0, 0.0, 0.0};
147 meta.mean_disk_velocity = {0.0, 0.0, 0.0};
148 meta.density = 0.0;
149 auto& refVel = meta.reference_velocity;
150 auto& diskVel = meta.mean_disk_velocity;
151 auto& density = meta.density;
152 const int np = meta.num_vel_pts / 2;
153 const int num_r = meta.num_vel_pts_r;
154 const int num_t = meta.num_vel_pts_t;
155
156 const base::AreaComputer area(meta.radius(), num_r, num_t);
157
158 for (int i = 0; i < num_r; i++) {
159 const auto weight = area.weight(i);
160 for (int j = 0; j < num_t; ++j) {
161 density += grid.density[j + i * num_t] * weight;
162 refVel = refVel + grid.vel[j + i * num_t] * weight;
163 diskVel = diskVel + grid.vel[j + i * num_t + np] * weight;
164 }
165 }
166 }
167};
168
169template <typename ActTrait>
171 ActTrait,
173 std::enable_if_t<std::is_base_of_v<DiskType, ActTrait>>>
174{
175 void operator()(typename ActTrait::DataType& /*data*/) {}
176};
177} // namespace ops
178} // namespace amr_wind::actuator
179
180#endif /* DISK_OPS_H_ */
Definition actuator_types.H:184
ActTrait::InfoType & info()
Definition actuator_types.H:214
ActTrait::MetaType & meta()
Definition actuator_types.H:220
const amrex::Real m_geometry_factor
Definition disk_ops.H:41
amrex::Real weight(const int iRadius) const
Definition disk_ops.cpp:113
amrex::Real area_section(const int iRadius) const
Definition disk_ops.cpp:107
AreaComputer(const amrex::Real radius, const int num_r, const int num_theta)
Definition disk_ops.cpp:101
const amrex::Real m_area
Definition disk_ops.H:40
Definition MultiParser.H:18
void prepare_netcdf_file(const std::string &name, const DiskBaseData &data, const ActInfo &info, const ActGrid &grid)
Definition disk_ops.cpp:6
void write_netcdf(const std::string &name, const DiskBaseData &data, const ActInfo &info, const ActGrid &, const amrex::Real time)
Definition disk_ops.cpp:70
void collect_parse_dependencies(const utils::ActParser &pp, const std::string &p1, const std::string &p2, std::ostringstream &ss)
Definition disk_ops.cpp:165
vs::Vector compute_coplanar_vector(const vs::Vector &normal)
Definition disk_ops.cpp:315
void final_checks(const DiskBaseData &meta)
Definition disk_ops.cpp:339
void set_thrust_coefficient(DiskBaseData &data, const amrex::Real &uInfSqr)
Definition disk_ops.H:127
void check_error_stream(const std::ostringstream &error_collector)
Definition disk_ops.cpp:266
amrex::RealBox compute_bounding_box(const DiskBaseData &meta)
Definition disk_ops.cpp:345
void collect_parse_dependencies_one_way(const utils::ActParser &pp, const std::string &independent, const std::string &dependent, std::ostringstream &ss)
Definition disk_ops.cpp:153
void optional_parameters(DiskBaseData &meta, const utils::ActParser &pp)
Definition disk_ops.cpp:182
void compute_disk_points(const DiskBaseData &meta, VecList &points, const vs::Vector &cylAxis, const int offset, const double dOffset)
Definition disk_ops.cpp:362
void collect_parse_conflicts(const utils::ActParser &pp, const std::string &p1, const std::string &p2, std::ostringstream &ss)
Definition disk_ops.cpp:142
void allocate_basic_grid_quantities(typename T::DataType &data)
Definition disk_ops.H:77
std::ostringstream check_for_parse_conflicts(const utils::ActParser &pp)
Definition disk_ops.cpp:274
void parse_and_gather_params(const utils::ActParser &pp, T &metaData)
Definition disk_ops.H:107
void compute_and_normalize_coplanar_vector(DiskBaseData &meta)
Definition disk_ops.cpp:321
amrex::Real compute_reference_velocity_sqr(DiskBaseData &data)
Definition disk_ops.H:114
void do_parse_based_computations(ActDataHolder< T > &data)
Definition disk_ops.H:90
void required_parameters(DiskBaseData &meta, const utils::ActParser &pp)
Definition disk_ops.cpp:175
Definition ActParser.H:6
amrex::Vector< amr_wind::vs::Vector > VecList
Definition actuator_types.H:62
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::iterator_traits< C2 >::value_type linear(const C1 xbegin, const C1 xend, const C2 yinp, const typename std::iterator_traits< C1 >::value_type &xout, const int ncomp=1, const int comp=0)
Definition linear_interpolation.H:126
Definition actuator_types.H:53
Definition ActuatorDisk.H:10
RealList thrust_coeff
Definition ActuatorDisk.H:28
amrex::Real current_ct
Definition ActuatorDisk.H:26
vs::Vector reference_velocity
Definition ActuatorDisk.H:20
RealList table_velocity
Definition ActuatorDisk.H:29
vs::Vector normal_vec
Definition ActuatorDisk.H:17
Definition actuator_ops.H:43
Definition actuator_ops.H:54
Definition vector.H:13