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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/sampling/SamplerBase.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
SamplerBase.H
Go to the documentation of this file.
1#ifndef SAMPLERBASE_H
2#define SAMPLERBASE_H
3
4#include <AMReX_RealVect.H>
7
8namespace amr_wind {
9
10class CFDSim;
11
12namespace sampling {
13
15{
16 using LocType = amrex::Vector<amrex::RealVect>;
17 using IdType = amrex::Vector<amrex::Long>;
18
19 void push_back(const amrex::RealVect& loc, const amrex::Long id)
20 {
21 m_locations.push_back(loc);
22 m_ids.push_back(id);
23 }
24
25 const LocType& locations() const
26 {
27 AMREX_ALWAYS_ASSERT(m_locations.size() == m_ids.size());
28 return m_locations;
29 }
30
32 {
33 AMREX_ALWAYS_ASSERT(m_locations.size() == m_ids.size());
34 return m_locations;
35 }
36
37 const IdType& ids() const
38 {
39 AMREX_ALWAYS_ASSERT(m_locations.size() == m_ids.size());
40 return m_ids;
41 }
42
45};
46
54class SamplerBase : public Factory<SamplerBase, CFDSim&>
55{
56public:
57 static std::string base_identifier() { return "SamplerBase"; }
58
59 static constexpr amrex::Real bounds_tol =
60 std::numeric_limits<amrex::Real>::epsilon();
61
62 ~SamplerBase() override = default;
63
65 virtual std::string label() const = 0;
66 virtual std::string& label() = 0;
67
69 virtual std::string sampletype() const = 0;
70
73 virtual int id() const = 0;
74 virtual int& id() = 0;
75
77 virtual long num_points() const = 0;
78
81 virtual long num_output_points() const = 0;
82
84 virtual void initialize(const std::string& key) = 0;
85
87 virtual void sampling_locations(SampleLocType&) const = 0;
88
91 virtual void
92 sampling_locations(SampleLocType&, const amrex::Box&) const = 0;
93
95 virtual void check_bounds() = 0;
96
98 virtual void output_locations(SampleLocType&) const = 0;
99
101 virtual bool update_sampling_locations() { return false; }
102
104 virtual void post_sample_actions() {}
105
107 virtual void post_regrid_actions() {}
108
111 const std::vector<double>& /*unused*/,
112 ncutils::NCGroup& /*unused*/,
113 const size_t /*unused*/)
114 {
115 return true;
116 }
117
119 virtual bool do_data_modification() { return false; }
120 virtual bool do_convert_velocity_los() { return false; }
121 virtual bool do_subsampling_interp() { return false; }
122
124 virtual std::vector<double> modify_sample_data(
125 const std::vector<double>& sampledata, const std::string& /*unused*/)
126 {
127 return sampledata;
128 }
129
131 const std::vector<std::vector<double>>& /*unused*/,
132 const int /*unused*/)
133 {}
134
136 virtual void
138 {}
139 virtual void
141 {}
142 virtual void output_netcdf_data(
143 const ncutils::NCGroup& /*unused*/, const size_t /*unused*/) const
144 {}
145};
146
147} // namespace sampling
148} // namespace amr_wind
149
150#endif /* SAMPLERBASE_H */
Definition SamplerBase.H:55
virtual void initialize(const std::string &key)=0
Read inputs and perform initialization actions.
virtual bool output_netcdf_field(const std::vector< double > &, ncutils::NCGroup &, const size_t)
Run specific output for the sampler.
Definition SamplerBase.H:110
static std::string base_identifier()
Definition SamplerBase.H:57
virtual void calc_lineofsight_velocity(const std::vector< std::vector< double > > &, const int)
Definition SamplerBase.H:130
virtual bool do_data_modification()
Run data modification for specific sampler?
Definition SamplerBase.H:119
virtual std::string label() const =0
Name used to refer to this sampler (e.g., myline1)
virtual void sampling_locations(SampleLocType &, const amrex::Box &) const =0
virtual int id() const =0
virtual bool do_subsampling_interp()
Definition SamplerBase.H:121
virtual long num_points() const =0
Total number of probes that belong to this sampling instance.
virtual std::string sampletype() const =0
Class name of this sampler (e.g., LineSampler)
static constexpr amrex::Real bounds_tol
Definition SamplerBase.H:59
virtual void output_netcdf_data(const ncutils::NCGroup &, const size_t) const
Definition SamplerBase.H:142
virtual void output_locations(SampleLocType &) const =0
Populate the vector with coordinates of the output locations.
virtual std::vector< double > modify_sample_data(const std::vector< double > &sampledata, const std::string &)
Sample buffer modification instructions.
Definition SamplerBase.H:124
virtual bool do_convert_velocity_los()
Definition SamplerBase.H:120
~SamplerBase() override=default
virtual void check_bounds()=0
Check and fix the bounds of the sampler so the probes are in the domain.
virtual void define_netcdf_metadata(const ncutils::NCGroup &) const
Populate metadata in the NetCDF file.
Definition SamplerBase.H:137
virtual void populate_netcdf_metadata(const ncutils::NCGroup &) const
Definition SamplerBase.H:140
virtual void post_regrid_actions()
Run actions after regrid (important when using field-based quantities)
Definition SamplerBase.H:107
virtual void sampling_locations(SampleLocType &) const =0
Populate the vector with coordinates of the sampling locations.
virtual long num_output_points() const =0
virtual std::string & label()=0
virtual void post_sample_actions()
Run actions after sample (useful in interpolated subsampling)
Definition SamplerBase.H:104
virtual bool update_sampling_locations()
Update the sampling locations.
Definition SamplerBase.H:101
Representation of a NetCDF group.
Definition nc_interface.H:166
Definition BCInterface.cpp:7
Definition Factory.H:65
Definition SamplerBase.H:15
const LocType & locations() const
Definition SamplerBase.H:25
const IdType & ids() const
Definition SamplerBase.H:37
void push_back(const amrex::RealVect &loc, const amrex::Long id)
Definition SamplerBase.H:19
amrex::Vector< amrex::Long > IdType
Definition SamplerBase.H:17
IdType m_ids
Definition SamplerBase.H:44
LocType m_locations
Definition SamplerBase.H:43
LocType & locations()
Definition SamplerBase.H:31
amrex::Vector< amrex::RealVect > LocType
Definition SamplerBase.H:16