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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/ABLBoundaryPlane.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
ABLBoundaryPlane.H
Go to the documentation of this file.
1#ifndef ABLBOUNDARYPLANE_H
2#define ABLBOUNDARYPLANE_H
3
5#include "amr-wind/CFDSim.H"
6#include "AMReX_Gpu.H"
8#include <AMReX_BndryRegister.H>
9
10namespace amr_wind {
11
12enum struct io_mode { output, input, undefined };
13
15{
16 amrex::Gpu::ManagedVector<amrex::Real> data;
17 amrex::Vector<size_t> start{0, 0, 0, 0};
18 amrex::Vector<size_t> count{0, 0, 0, 0};
19};
20
28{
29 using PlaneVector = amrex::Vector<amrex::FArrayBox>;
30
31public:
32 InletData() = default;
33
34 void resize(const int /*size*/);
35
36 void define_plane(const amrex::Orientation /*ori*/);
37
39 const amrex::Orientation /*ori*/,
40 const amrex::Box& /*bx*/,
41 const size_t /*nc*/);
42
43#ifdef AMR_WIND_USE_NETCDF
44 void read_data(
45 ncutils::NCGroup& /*grp*/,
46 const amrex::Orientation /*ori*/,
47 const int /*lev*/,
48 const Field* /*fld*/,
49 const amrex::Real /*time*/,
50 const amrex::Vector<amrex::Real>& /*times*/);
51#endif
52
54 const amrex::OrientationIter oit,
55 amrex::BndryRegister& bndry_n,
56 amrex::BndryRegister& bndry_np1,
57 const int lev,
58 const Field* /*fld*/,
59 const amrex::Real time,
60 const amrex::Vector<amrex::Real>& /*times*/);
61
62 void interpolate(const amrex::Real /*time*/);
63 bool is_populated(amrex::Orientation /*ori*/) const;
64 const amrex::FArrayBox&
65 interpolate_data(const amrex::Orientation ori, const int lev) const
66 {
67 return (*m_data_interp[ori])[lev];
68 }
69
70 int& component(const int id) { return m_components[id]; }
71
72 int component(const int id) const { return m_components.at(id); }
73
74 int nlevels(const amrex::Orientation ori) const
75 {
76 return static_cast<int>((*m_data_interp[ori]).size());
77 }
78
79 amrex::Real tn() const { return m_tn; }
80 amrex::Real tnp1() const { return m_tnp1; }
81 amrex::Real tinterp() const { return m_tinterp; }
82
83private:
84 amrex::Vector<std::unique_ptr<PlaneVector>> m_data_n;
85 amrex::Vector<std::unique_ptr<PlaneVector>> m_data_np1;
86 amrex::Vector<std::unique_ptr<PlaneVector>> m_data_interp;
87
89 amrex::Real m_tn{-1.0};
90
92 amrex::Real m_tnp1{-1.0};
93
95 amrex::Real m_tinterp{-1.0};
96
98 std::unordered_map<int, int> m_components;
99};
100
110{
111 static_assert(AMREX_SPACEDIM == 3, "ABL requires 3 dimensional mesh");
112
113public:
114 explicit ABLBoundaryPlane(CFDSim& /*sim*/);
115
117 void post_init_actions();
118
119 void pre_advance_work();
120
121 void pre_predictor_work();
122
123 void post_advance_work();
124
125 void initialize_data();
126
127 void write_header();
128
129 void write_file();
130
131 void read_header();
132
133 void read_file(const bool /* nph_target_time*/);
134
135 void populate_data(
136 const int /*lev*/,
137 const amrex::Real /*time*/,
138 Field& /*fld*/,
139 amrex::MultiFab& /*mfab*/,
140 const int dcomp = 0,
141 const int orig_comp = 0) const;
142
143#ifdef AMR_WIND_USE_NETCDF
144 static void impl_buffer_field(
145 const amrex::Box& /*bx*/,
146 const int /*n1*/,
147 const int /*nc*/,
148 const amrex::GpuArray<int, 2>& /*perp*/,
149 const amrex::IntVect& /*v_offset*/,
150 const amrex::Array4<const amrex::Real>& /*fld*/,
151 amrex::Gpu::ManagedVector<amrex::Real>& /*buffer*/);
152#endif
153
154 bool is_initialized() const { return m_is_initialized; }
155
157 const amrex::Box& /*bx*/,
158 const int /*lev*/,
159 const amrex::Orientation /*ori*/) const;
160
161 bool is_data_newer_than(const amrex::Real time) const
162 {
163 return (m_in_data.tinterp() - time > 1e-12);
164 }
165
166 io_mode mode() const { return m_io_mode; }
167
168private:
171 const amrex::AmrCore& m_mesh;
172
173#ifdef AMR_WIND_USE_NETCDF
174 void write_data(
175 const ncutils::NCGroup& grp,
176 const amrex::Orientation /*ori*/,
177 const int /*lev*/,
178 const Field* /*fld*/);
179#endif
181
182 std::string m_title{"ABL boundary planes"};
183
186
188 amrex::Vector<std::string> m_plane_names{"xlo", "ylo", "zlo",
189 "xhi", "yhi", "zhi"};
190
192 amrex::Vector<std::string> m_planes;
193
195 amrex::Real m_out_start_time{0.0};
196
197#ifdef AMR_WIND_USE_NETCDF
199 size_t m_out_counter{0};
200#endif
201
203 std::string m_filename;
204
206 std::string m_time_file;
207
209 amrex::Vector<std::string> m_var_names;
210
212 amrex::Vector<Field*> m_fields;
213
215 amrex::Vector<amrex::Real> m_in_times;
216 amrex::Vector<int> m_in_timesteps;
217
220
223
225 bool m_is_initialized{false};
226
228 const int m_in_rad = 1;
229 const int m_out_rad = 1;
230 const int m_extent_rad = 0;
231
233 std::string m_out_fmt{"native"};
234};
235
236} // namespace amr_wind
237
238#endif /* ABLBOUNDARYPLANE_H */
Definition ABLBoundaryPlane.H:110
bool box_intersects_boundary(const amrex::Box &, const int, const amrex::Orientation) const
True if box intersects the boundary.
Definition ABLBoundaryPlane.cpp:1091
const int m_extent_rad
Definition ABLBoundaryPlane.H:230
void read_header()
Definition ABLBoundaryPlane.cpp:596
io_mode mode() const
Definition ABLBoundaryPlane.H:166
amrex::Vector< std::string > m_var_names
Variables for IO.
Definition ABLBoundaryPlane.H:209
std::string m_time_file
File name for Native time file.
Definition ABLBoundaryPlane.H:206
const int m_in_rad
controls extents on native bndry output
Definition ABLBoundaryPlane.H:228
void post_init_actions()
Execute initialization actions after mesh has been fully generated.
Definition ABLBoundaryPlane.cpp:295
std::string m_out_fmt
output format for bndry output
Definition ABLBoundaryPlane.H:233
InletData m_in_data
Inlet data.
Definition ABLBoundaryPlane.H:219
void pre_advance_work()
Definition ABLBoundaryPlane.cpp:307
size_t m_out_counter
NetCDF time output counter.
Definition ABLBoundaryPlane.H:199
amrex::Vector< Field * > m_fields
List of fields for IO.
Definition ABLBoundaryPlane.H:212
int m_write_frequency
Normal direction for the boundary plane.
Definition ABLBoundaryPlane.H:185
void post_advance_work()
Definition ABLBoundaryPlane.cpp:323
bool is_initialized() const
Definition ABLBoundaryPlane.H:154
io_mode m_io_mode
IO mode.
Definition ABLBoundaryPlane.H:222
const int m_out_rad
Definition ABLBoundaryPlane.H:229
amrex::Vector< std::string > m_planes
IO boundary planes.
Definition ABLBoundaryPlane.H:192
void populate_data(const int, const amrex::Real, Field &, amrex::MultiFab &, const int dcomp=0, const int orig_comp=0) const
Definition ABLBoundaryPlane.cpp:879
void write_data(const ncutils::NCGroup &grp, const amrex::Orientation, const int, const Field *)
Definition ABLBoundaryPlane.cpp:955
static void impl_buffer_field(const amrex::Box &, const int, const int, const amrex::GpuArray< int, 2 > &, const amrex::IntVect &, const amrex::Array4< const amrex::Real > &, amrex::Gpu::ManagedVector< amrex::Real > &)
Definition ABLBoundaryPlane.cpp:1051
int boundary_native_file_levels()
Definition ABLBoundaryPlane.cpp:1074
ABLBoundaryPlane(CFDSim &)
Definition ABLBoundaryPlane.cpp:246
void pre_predictor_work()
Definition ABLBoundaryPlane.cpp:315
amrex::Vector< int > m_in_timesteps
Definition ABLBoundaryPlane.H:216
amrex::Vector< amrex::Real > m_in_times
NetCDF input level time.
Definition ABLBoundaryPlane.H:215
const amrex::AmrCore & m_mesh
Definition ABLBoundaryPlane.H:171
const FieldRepo & m_repo
Definition ABLBoundaryPlane.H:170
void write_file()
Definition ABLBoundaryPlane.cpp:481
const amr_wind::SimTime & m_time
Definition ABLBoundaryPlane.H:169
std::string m_filename
File name for IO.
Definition ABLBoundaryPlane.H:203
void write_header()
Definition ABLBoundaryPlane.cpp:349
void initialize_data()
Definition ABLBoundaryPlane.cpp:331
amrex::Real m_out_start_time
Start outputting after this time.
Definition ABLBoundaryPlane.H:195
amrex::Vector< std::string > m_plane_names
Plane names.
Definition ABLBoundaryPlane.H:188
std::string m_title
Definition ABLBoundaryPlane.H:182
bool m_is_initialized
Flag indicating if this capability is available.
Definition ABLBoundaryPlane.H:225
bool is_data_newer_than(const amrex::Real time) const
Definition ABLBoundaryPlane.H:161
void read_file(const bool)
Definition ABLBoundaryPlane.cpp:764
Definition CFDSim.H:47
Definition Field.H:116
Definition FieldRepo.H:86
Definition ABLBoundaryPlane.H:28
void read_data(ncutils::NCGroup &, const amrex::Orientation, const int, const Field *, const amrex::Real, const amrex::Vector< amrex::Real > &)
Definition ABLBoundaryPlane.cpp:69
void read_data_native(const amrex::OrientationIter oit, amrex::BndryRegister &bndry_n, amrex::BndryRegister &bndry_np1, const int lev, const Field *, const amrex::Real time, const amrex::Vector< amrex::Real > &)
Definition ABLBoundaryPlane.cpp:140
bool is_populated(amrex::Orientation) const
Definition ABLBoundaryPlane.cpp:241
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_interp
Definition ABLBoundaryPlane.H:86
void interpolate(const amrex::Real)
Definition ABLBoundaryPlane.cpp:219
int & component(const int id)
Definition ABLBoundaryPlane.H:70
amrex::Real tn() const
Definition ABLBoundaryPlane.H:79
amrex::Real m_tnp1
Time for plane at n + 1.
Definition ABLBoundaryPlane.H:92
amrex::Real tnp1() const
Definition ABLBoundaryPlane.H:80
const amrex::FArrayBox & interpolate_data(const amrex::Orientation ori, const int lev) const
Definition ABLBoundaryPlane.H:65
amrex::Real m_tinterp
Time for plane at interpolation.
Definition ABLBoundaryPlane.H:95
int component(const int id) const
Definition ABLBoundaryPlane.H:72
void resize(const int)
Definition ABLBoundaryPlane.cpp:43
amrex::Real tinterp() const
Definition ABLBoundaryPlane.H:81
void define_level_data(const amrex::Orientation, const amrex::Box &, const size_t)
Definition ABLBoundaryPlane.cpp:57
std::unordered_map< int, int > m_components
Map of {variableId : component}
Definition ABLBoundaryPlane.H:98
amrex::Real m_tn
Time for plane at n.
Definition ABLBoundaryPlane.H:89
amrex::Vector< amrex::FArrayBox > PlaneVector
Definition ABLBoundaryPlane.H:29
int nlevels(const amrex::Orientation ori) const
Definition ABLBoundaryPlane.H:74
void define_plane(const amrex::Orientation)
Definition ABLBoundaryPlane.cpp:50
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_n
Definition ABLBoundaryPlane.H:84
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_np1
Definition ABLBoundaryPlane.H:85
Definition SimTime.H:30
Representation of a NetCDF group.
Definition nc_interface.H:166
Definition BCInterface.cpp:7
io_mode
Definition ABLBoundaryPlane.H:12
Definition ABLBoundaryPlane.H:15
amrex::Gpu::ManagedVector< amrex::Real > data
Definition ABLBoundaryPlane.H:16
amrex::Vector< size_t > start
Definition ABLBoundaryPlane.H:17
amrex::Vector< size_t > count
Definition ABLBoundaryPlane.H:18