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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/sampling/Sampling.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
Sampling.H
Go to the documentation of this file.
1#ifndef SAMPLING_H
2#define SAMPLING_H
3
4#include <memory>
5
6#include "amr-wind/CFDSim.H"
11
25namespace amr_wind::sampling {
26
40class Sampling : public PostProcessBase::Register<Sampling>
41{
42public:
43 static std::string identifier() { return "Sampling"; }
44
45 Sampling(CFDSim& /*sim*/, std::string /*label*/);
46
47 ~Sampling() override;
48
50 void pre_init_actions() override {}
51
53 void initialize() override;
54
56 void post_advance_work() override;
57
59 void post_regrid_actions() override;
60
61 // Public for CUDA
62
64 virtual void impl_write_native();
65
66 void sampling_workflow();
67 void sampling_post();
68 void fill_buffer();
71
73 {
74 return static_cast<int>(m_total_particles);
75 }
76
77#ifdef AMR_WIND_USE_NETCDF
79 {
80 if (m_out_fmt == "netcdf") {
81 return static_cast<int>(m_netcdf_output_particles);
82 }
83 return 0;
84 }
85#endif
86
87 const amrex::Vector<std::string>& var_names() const { return m_var_names; }
88
89protected:
91 void update_container();
92
95
97 virtual void process_output();
98
100 virtual void prepare_netcdf_file();
101
103 void write_netcdf();
104
110 virtual void write_ascii();
111
113
114private:
116
117 std::unique_ptr<SamplingContainer> m_scontainer;
118 amrex::Vector<std::unique_ptr<SamplerBase>> m_samplers;
119
121 amrex::Vector<std::string> m_var_names;
122
124 amrex::Vector<Field*> m_fields;
125
127 amrex::Vector<IntField*> m_int_fields;
128
130 std::unique_ptr<DerivedQtyMgr> m_derived_mgr;
131
137 const std::string m_label;
138
140#ifdef AMR_WIND_USE_NETCDF
141 std::string m_out_fmt{"netcdf"};
142 std::string m_ncfile_name;
143
144 // Current sample buffer for full container
145 std::vector<double> m_sample_buf;
146
147 // Current sample buffer for output
148 std::vector<double> m_output_buf;
149
152#else
153 std::string m_out_fmt{"native"};
154#endif
155
156 // Sample initial condition for interpolation consistency
157 bool m_restart_sample{false};
158
159 // number of field components
160 int m_ncomp{0};
161
162 // number of int field components
163 int m_nicomp{0};
164
165 // number of derived field components
166 int m_ndcomp{0};
167
170
172 int m_out_freq{100};
173
176};
177
178} // namespace amr_wind::sampling
179
180#endif /* SAMPLING_H */
Definition CFDSim.H:47
Definition SamplingContainer.H:65
Definition Sampling.H:41
std::unique_ptr< DerivedQtyMgr > m_derived_mgr
List of derived fields to be sampled for this collection of probes.
Definition Sampling.H:130
bool m_restart_sample
Definition Sampling.H:157
int m_ncomp
Definition Sampling.H:160
amrex::Vector< IntField * > m_int_fields
List of IntFields to be sampled for this collection of probes.
Definition Sampling.H:127
int num_netcdf_output_particles() const
Definition Sampling.H:78
SamplingContainer & sampling_container()
Definition Sampling.H:112
int m_out_freq
Frequency of data sampling and output.
Definition Sampling.H:172
void post_advance_work() override
Interpolate fields at a given timestep and output to disk.
Definition Sampling.cpp:180
virtual void impl_write_native()
Write sampled data in binary format.
Definition Sampling.cpp:385
void sampling_workflow()
Definition Sampling.cpp:204
std::unique_ptr< SamplingContainer > m_scontainer
Definition Sampling.H:117
std::vector< double > m_output_buf
Definition Sampling.H:148
std::vector< double > m_sample_buf
Definition Sampling.H:145
virtual void write_ascii()
Definition Sampling.cpp:403
size_t m_total_particles
Number of sampling container particles:
Definition Sampling.H:169
void post_regrid_actions() override
Actions to perform post regrid e.g. redistribute particles.
Definition Sampling.cpp:241
int num_total_particles() const
Definition Sampling.H:72
void initialize() override
Read user inputs and create the different data probe instances.
Definition Sampling.cpp:21
std::string m_ncfile_name
Definition Sampling.H:142
size_t m_netcdf_output_particles
Number of output particles in netcdf.
Definition Sampling.H:151
int m_nicomp
Definition Sampling.H:163
void update_sampling_locations()
Conduct work to update the particles.
Definition Sampling.cpp:163
void fill_buffer()
Definition Sampling.cpp:356
void update_container()
Update the container by re-initializing the particles.
Definition Sampling.cpp:145
void convert_velocity_lineofsight()
Definition Sampling.cpp:252
virtual void process_output()
Output data based on user-defined format.
Definition Sampling.cpp:371
void write_netcdf()
Write sampled data into a NetCDF file.
Definition Sampling.cpp:492
int m_ndcomp
Definition Sampling.H:166
amrex::Vector< Field * > m_fields
List of fields to be sampled for this collection of probes.
Definition Sampling.H:124
amrex::Vector< std::string > m_var_names
List of variable names for output.
Definition Sampling.H:121
void sampling_post()
Definition Sampling.cpp:225
amrex::Vector< std::unique_ptr< SamplerBase > > m_samplers
Definition Sampling.H:118
static std::string identifier()
Definition Sampling.H:43
void pre_init_actions() override
Perform actions before mesh is created.
Definition Sampling.H:50
std::string m_out_fmt
Format of the data output (native, ascii, netcdf, etc.)
Definition Sampling.H:141
virtual void prepare_netcdf_file()
Prepare NetCDF metadata.
Definition Sampling.cpp:418
CFDSim & m_sim
Definition Sampling.H:115
int m_out_delay
Delay number of timestep before output.
Definition Sampling.H:175
Sampling(CFDSim &, std::string)
Definition Sampling.cpp:13
void create_output_buffer()
Definition Sampling.cpp:314
const amrex::Vector< std::string > & var_names() const
Definition Sampling.H:87
const std::string m_label
Definition Sampling.H:137
Definition DTUSpinnerSampler.cpp:16