/home/runner/work/amr-wind/amr-wind/amr-wind/utilities/sampling/RadarSampler.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/sampling/RadarSampler.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
RadarSampler.H
Go to the documentation of this file.
1#ifndef RADARSAMPLER_H
2#define RADARSAMPLER_H
3
8
9namespace amr_wind::sampling {
10
18class RadarSampler : public SamplerBase::Register<RadarSampler>
19{
20public:
21 static std::string identifier() { return "RadarSampler"; }
22
23 explicit RadarSampler(const CFDSim& /*sim*/);
24
25 ~RadarSampler() override;
26
27 using LosRotType = amrex::Vector<vs::Tensor>;
28 using LosUnitType = amrex::Vector<vs::Vector>;
29
34 void initialize(const std::string& key) override;
35
37
39 void check_bounds() override;
40
41 void new_cone();
42
43 double total_sweep_time() const;
44 double periodic_time();
45 int sweep_count() const;
47 double determine_current_sweep_angle() const;
48
50 void sampling_locations(SampleLocType& /*sample_locs**/) const override;
51
55 SampleLocType& /*sample_locs*/,
56 const amrex::Box& /*box*/) const override;
57
58 bool update_sampling_locations() override;
59 void cone_axis_locations(SampleLocType& /*sample_locs*/) const;
60 void output_locations(SampleLocType& sample_locs) const override
61 {
62 cone_axis_locations(sample_locs);
63 }
64
65 void post_sample_actions() override;
66
67 void
68 define_netcdf_metadata(const ncutils::NCGroup& /*unused*/) const override;
69 void
70 populate_netcdf_metadata(const ncutils::NCGroup& /*unused*/) const override;
72 const ncutils::NCGroup& /*unused*/,
73 const size_t /*unused*/) const override;
74
76 const std::vector<double>& output_buffer,
78 const size_t nt) override;
79
81 std::string label() const override { return m_label; }
82 std::string& label() override { return m_label; }
83
85 std::string sampletype() const override { return identifier(); }
86
88 int id() const override { return m_id; }
89 int& id() override { return m_id; }
90
92 long num_points() const override
93 {
94 return m_interp_steps * m_ntotal *
95 (m_npts + m_ntheta * m_npts * (m_nphi - 1));
96 }
97
99 long num_output_points() const override { return m_ntotal * m_npts; }
100
102 long num_points_scan() const
103 {
104 return m_ntotal * (m_npts + m_ntheta * m_npts * (m_nphi - 1));
105 }
106
108 long num_points_axis() const { return m_npts; }
109
111 long num_points_cone() const
112 {
113 return m_npts + m_ntheta * m_npts * (m_nphi - 1);
114 }
115
117 long num_points_quad() const { return 1 + m_ntheta * (m_nphi - 1); }
118
119 static void line_average(
120 const std::vector<double>& weights,
121 const std::vector<double>& values,
122 std::vector<double>& reduced,
123 long offset);
124
126 bool do_data_modification() override { return true; }
127 bool do_convert_velocity_los() override { return true; }
128 bool do_subsampling_interp() override { return true; }
129
131 std::vector<double> modify_sample_data(
132 const std::vector<double>& sample_data,
133 const std::string& /*unused*/) override;
134
136 const std::vector<std::vector<double>>& /*velocity_raw*/,
137 const int /*interp_idx*/) override;
138
139protected:
140 const CFDSim& m_sim;
141
142 std::string m_label;
143 int m_id{-1};
144
145 amrex::Real m_radtodeg{180.0 / M_PI};
146
147 amrex::Vector<amrex::Real> m_start;
148 amrex::Vector<amrex::Real> m_end;
149
154
157
158 std::vector<double> m_los_velocity;
159 std::vector<double> m_los_velocity_next;
160 std::vector<double> m_los_velocity_prior;
161 std::vector<double> m_los_velocity_interp;
162
163 std::vector<double> m_weights;
164 std::vector<vs::Vector> m_rays;
165
166 amrex::Real m_sample_freq; // Simulation sample rate
167 amrex::Real m_radar_sample_freq; // Actual device sample rate
168 int m_npts{0};
169 amrex::Real m_cone_angle;
170 std::string m_radar_quad_type;
172 amrex::Real m_beam_length;
173 amrex::Real m_angular_speed;
174 amrex::Vector<amrex::Real> m_axis;
175 amrex::Vector<amrex::Real> m_vertical;
176 amrex::Real m_sweep_angle;
177 amrex::Real m_reset_time;
178 amrex::Vector<amrex::Real> m_elevation_angles;
179
180 int m_nphi{5};
181 int m_ntheta{5};
182
184
185 long m_radar_iter{0}; // Iteration tracking from radar perspective
186 amrex::Real m_radar_time; // Current radar time
187 amrex::Real
188 m_periodic_time; // Running cycle time (Forward, pause, reverse, pause)
189 int m_ns; // Number of radar steps in current timestep
190 long m_ntotal; // Max number of radar timesteps in any timestep
193
194 bool m_debug_print{false};
196
202
203 amrex::Real m_fill_val{-99999.99};
204};
205
206} // namespace amr_wind::sampling
207
208#endif /* RADARSAMPLER_H */
Definition CFDSim.H:47
Definition RadarSampler.H:19
amrex::Real m_sample_freq
Definition RadarSampler.H:166
long num_output_points() const override
Number of probe locations to output.
Definition RadarSampler.H:99
void initialize(const std::string &key) override
Definition RadarSampler.cpp:14
long m_num_output_points_prior
Definition RadarSampler.H:201
int m_ns_prior
Definition RadarSampler.H:198
void sampling_locations(SampleLocType &) const override
Populate and return a vector of probe locations to be sampled.
Definition RadarSampler.cpp:461
SampleLocType::LocType m_current_cones
Definition RadarSampler.H:151
std::string & label() override
Definition RadarSampler.H:82
double determine_current_sweep_angle() const
Definition RadarSampler.cpp:170
void define_netcdf_metadata(const ncutils::NCGroup &) const override
Definition RadarSampler.cpp:544
long m_ntotal_prior
Definition RadarSampler.H:199
amrex::Vector< vs::Vector > LosUnitType
Definition RadarSampler.H:28
amrex::Real m_cone_angle
Definition RadarSampler.H:169
long m_num_points_prior
Definition RadarSampler.H:200
amrex::Real m_fill_val
Definition RadarSampler.H:203
int m_nphi
Definition RadarSampler.H:180
void check_bounds() override
Check and fix the bounds of the sampler so the probes are in the domain.
Definition RadarSampler.cpp:99
amrex::Vector< amrex::Real > m_end
Definition RadarSampler.H:148
long num_points_cone() const
Number of probe locations in a cone.
Definition RadarSampler.H:111
std::vector< double > modify_sample_data(const std::vector< double > &sample_data, const std::string &) override
Modify sample buffer after sampling happens.
Definition RadarSampler.cpp:413
phase determine_operation_phase() const
Definition RadarSampler.cpp:151
amrex::Vector< amrex::Real > m_vertical
Definition RadarSampler.H:175
void calc_lineofsight_velocity(const std::vector< std::vector< double > > &, const int) override
Definition RadarSampler.cpp:375
amrex::Vector< amrex::Real > m_elevation_angles
Definition RadarSampler.H:178
std::vector< double > m_los_velocity
Definition RadarSampler.H:158
double total_sweep_time() const
Definition RadarSampler.cpp:131
amrex::Real m_radar_time
Definition RadarSampler.H:186
amrex::Real m_reset_time
Definition RadarSampler.H:177
long m_ntotal
Definition RadarSampler.H:190
phase m_current_phase
Definition RadarSampler.H:192
amrex::Real m_sweep_angle
Definition RadarSampler.H:176
long m_radar_iter
Definition RadarSampler.H:185
amrex::Real m_periodic_time
Definition RadarSampler.H:188
std::string m_label
Definition RadarSampler.H:142
long m_cone_size
Definition RadarSampler.H:191
std::vector< double > m_weights
Definition RadarSampler.H:163
SampleLocType::LocType m_initial_cone
Definition RadarSampler.H:150
std::vector< double > m_los_velocity_next
Definition RadarSampler.H:159
bool m_output_cone_points
Definition RadarSampler.H:195
int m_ntheta
Definition RadarSampler.H:181
long num_points_scan() const
Number of sampling container locations per interp step.
Definition RadarSampler.H:102
long m_interp_steps
Definition RadarSampler.H:197
int sweep_count() const
Definition RadarSampler.cpp:145
std::string label() const override
Name of this sampling object.
Definition RadarSampler.H:81
void new_cone()
Definition RadarSampler.cpp:311
std::string sampletype() const override
Type of this sampling object.
Definition RadarSampler.H:85
amrex::Real m_angular_speed
Definition RadarSampler.H:173
amrex::Real m_radtodeg
Definition RadarSampler.H:145
amrex::Real m_radar_sample_freq
Definition RadarSampler.H:167
long num_points_axis() const
Number of probe locations on Radar axis.
Definition RadarSampler.H:108
const CFDSim & m_sim
Definition RadarSampler.H:140
vs::Vector m_radar_rotation_axis
Definition RadarSampler.H:183
std::vector< double > m_los_velocity_interp
Definition RadarSampler.H:161
void cone_axis_locations(SampleLocType &) const
Definition RadarSampler.cpp:512
int m_id
Definition RadarSampler.H:143
long num_points_quad() const
Number of probe locations in a spherical cap.
Definition RadarSampler.H:117
std::string m_radar_quad_type
Definition RadarSampler.H:170
SampleLocType::LocType m_prior_cones
Definition RadarSampler.H:152
double periodic_time()
Definition RadarSampler.cpp:136
amrex::Vector< amrex::Real > m_axis
Definition RadarSampler.H:174
amrex::Vector< amrex::Real > m_start
Definition RadarSampler.H:147
int & id() override
Definition RadarSampler.H:89
int id() const override
Unique identifier for this set of probe locations.
Definition RadarSampler.H:88
void output_locations(SampleLocType &sample_locs) const override
Definition RadarSampler.H:60
int m_npts_azimuth
Definition RadarSampler.H:171
LosRotType m_los_proj
Definition RadarSampler.H:155
RadarSampler(const CFDSim &)
Definition RadarSampler.cpp:10
void output_netcdf_data(const ncutils::NCGroup &, const size_t) const override
Definition RadarSampler.cpp:565
bool do_convert_velocity_los() override
Definition RadarSampler.H:127
static void line_average(const std::vector< double > &weights, const std::vector< double > &values, std::vector< double > &reduced, long offset)
Definition RadarSampler.cpp:437
void post_sample_actions() override
Definition RadarSampler.cpp:528
long num_points() const override
Number of sampling container locations in a timestep.
Definition RadarSampler.H:92
phase
Definition RadarSampler.H:36
void populate_netcdf_metadata(const ncutils::NCGroup &) const override
Definition RadarSampler.cpp:561
int m_ns
Definition RadarSampler.H:189
SampleLocType::LocType m_sample_cones
Definition RadarSampler.H:153
LosUnitType m_los_unit
Definition RadarSampler.H:156
static std::string identifier()
Definition RadarSampler.H:21
amrex::Real m_beam_length
Definition RadarSampler.H:172
bool do_subsampling_interp() override
Definition RadarSampler.H:128
bool output_netcdf_field(const std::vector< double > &output_buffer, ncutils::NCGroup &grp, const size_t nt) override
Definition RadarSampler.cpp:591
amrex::Vector< vs::Tensor > LosRotType
Definition RadarSampler.H:27
bool do_data_modification() override
Run data modification for specific sampler.
Definition RadarSampler.H:126
std::vector< double > m_los_velocity_prior
Definition RadarSampler.H:160
int m_npts
Definition RadarSampler.H:168
bool update_sampling_locations() override
Definition RadarSampler.cpp:189
bool m_debug_print
Definition RadarSampler.H:194
std::vector< vs::Vector > m_rays
Definition RadarSampler.H:164
Representation of a NetCDF group.
Definition nc_interface.H:166
Definition DTUSpinnerSampler.cpp:16
Definition SamplerBase.H:15
amrex::Vector< amrex::RealVect > LocType
Definition SamplerBase.H:16
Definition vector.H:13