/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"
9#include <AMReX_BndryRegister.H>
10
11namespace amr_wind {
12
13enum struct io_mode { output, input, undefined };
14
16{
17 amrex::Gpu::ManagedVector<amrex::Real> data;
18 amrex::Vector<size_t> start{0, 0, 0, 0};
19 amrex::Vector<size_t> count{0, 0, 0, 0};
20};
21
29{
30 using PlaneVector = amrex::Vector<amrex::FArrayBox>;
31
32public:
33 InletData() = default;
34
35 void resize(const int /*size*/);
36
37 void define_plane(const amrex::Orientation /*ori*/);
38
40 const amrex::Orientation /*ori*/,
41 const amrex::Box& /*bx*/,
42 const size_t /*nc*/);
43
44#ifdef AMR_WIND_USE_NETCDF
45 void read_data(
46 ncutils::NCGroup& /*grp*/,
47 const amrex::Orientation /*ori*/,
48 const int /*lev*/,
49 const Field* /*fld*/,
50 const amrex::Real /*time*/,
51 const amrex::Vector<amrex::Real>& /*times*/);
52#endif
53
55 const amrex::OrientationIter oit,
56 amrex::BndryRegister& bndry_n,
57 amrex::BndryRegister& bndry_np1,
58 const int lev,
59 const Field* /*fld*/,
60 const amrex::Real time,
61 const amrex::Vector<amrex::Real>& /*times*/);
62
63 void interpolate(const amrex::Real /*time*/);
64 bool is_populated(amrex::Orientation /*ori*/) const;
65 const amrex::FArrayBox&
66 interpolate_data(const amrex::Orientation ori, const int lev) const
67 {
68 return (*m_data_interp[ori])[lev];
69 }
70
71 int& component(const int id) { return m_components[id]; }
72
73 int component(const int id) const { return m_components.at(id); }
74
75 int nlevels(const amrex::Orientation ori) const
76 {
77 return static_cast<int>((*m_data_interp[ori]).size());
78 }
79
80 amrex::Real tn() const { return m_tn; }
81 amrex::Real tnp1() const { return m_tnp1; }
82 amrex::Real tinterp() const { return m_tinterp; }
83
84private:
85 amrex::Vector<std::unique_ptr<PlaneVector>> m_data_n;
86 amrex::Vector<std::unique_ptr<PlaneVector>> m_data_np1;
87 amrex::Vector<std::unique_ptr<PlaneVector>> m_data_interp;
88
90 amrex::Real m_tn{-1.0};
91
93 amrex::Real m_tnp1{-1.0};
94
96 amrex::Real m_tinterp{-1.0};
97
99 std::unordered_map<int, int> m_components;
100};
101
111{
112 static_assert(AMREX_SPACEDIM == 3, "ABL requires 3 dimensional mesh");
113
114public:
115 explicit ABLBoundaryPlane(CFDSim& /*sim*/);
116
118 void post_init_actions();
119
120 void pre_advance_work();
121
122 void pre_predictor_work();
123
124 void post_advance_work();
125
126 void initialize_data();
127
128 void write_header();
129
130 void write_bndry_native_header(const std::string& chkname);
131
132 void write_file();
133
134 void read_header();
135
136 amrex::Vector<amrex::BoxArray> read_bndry_native_boxarrays(
137 const std::string& chkname, const Field& field) const;
138
139 void read_file(const bool /* nph_target_time*/);
140
141 void populate_data(
142 const int /*lev*/,
143 const amrex::Real /*time*/,
144 Field& /*fld*/,
145 amrex::MultiFab& /*mfab*/,
146 const int dcomp = 0,
147 const int orig_comp = 0) const;
148
149#ifdef AMR_WIND_USE_NETCDF
150 static void impl_buffer_field(
151 const amrex::Box& /*bx*/,
152 const int /*n1*/,
153 const int /*nc*/,
154 const amrex::GpuArray<int, 2>& /*perp*/,
155 const amrex::IntVect& /*v_offset*/,
156 const amrex::Array4<const amrex::Real>& /*fld*/,
157 amrex::Gpu::ManagedVector<amrex::Real>& /*buffer*/);
158#endif
159
160 bool is_initialized() const { return m_is_initialized; }
161
163 const amrex::Box& /*bx*/,
164 const int /*lev*/,
165 const amrex::Orientation /*ori*/) const;
166
167 bool is_data_newer_than(const amrex::Real time) const
168 {
169 return (m_in_data.tinterp() - time > 1e-12);
170 }
171
172 io_mode mode() const { return m_io_mode; }
173
174private:
177 const amrex::AmrCore& m_mesh;
178
179#ifdef AMR_WIND_USE_NETCDF
180 void write_data(
181 const ncutils::NCGroup& grp,
182 const amrex::Orientation /*ori*/,
183 const int /*lev*/,
184 const Field* /*fld*/);
185#endif
186 int boundary_native_file_levels() const;
187
188 std::string m_title{"ABL boundary planes"};
189
192
194 amrex::Vector<std::string> m_plane_names{"xlo", "ylo", "zlo",
195 "xhi", "yhi", "zhi"};
196
198 amrex::Vector<std::string> m_planes;
199
201 amrex::Real m_out_start_time{0.0};
202
203#ifdef AMR_WIND_USE_NETCDF
205 size_t m_out_counter{0};
206#endif
207
209 std::string m_filename;
210
212 std::string m_time_file;
213
215 amrex::Vector<std::string> m_var_names;
216
218 amrex::Vector<Field*> m_fields;
219
221 amrex::Vector<amrex::Real> m_in_times;
222 amrex::Vector<int> m_in_timesteps;
223
226
229
231 bool m_is_initialized{false};
232
234 const int m_in_rad = 1;
235 const int m_out_rad = 1;
236 const int m_extent_rad = 0;
237
239 std::string m_out_fmt{"native"};
240};
241
242} // namespace amr_wind
243
244#endif /* ABLBOUNDARYPLANE_H */
Definition ABLBoundaryPlane.H:111
bool box_intersects_boundary(const amrex::Box &, const int, const amrex::Orientation) const
True if box intersects the boundary.
Definition ABLBoundaryPlane.cpp:1394
const int m_extent_rad
Definition ABLBoundaryPlane.H:236
void read_header()
Definition ABLBoundaryPlane.cpp:693
void write_bndry_native_header(const std::string &chkname)
Definition ABLBoundaryPlane.cpp:487
io_mode mode() const
Definition ABLBoundaryPlane.H:172
amrex::Vector< std::string > m_var_names
Variables for IO.
Definition ABLBoundaryPlane.H:215
std::string m_time_file
File name for Native time file.
Definition ABLBoundaryPlane.H:212
const int m_in_rad
controls extents on native bndry output
Definition ABLBoundaryPlane.H:234
void post_init_actions()
Execute initialization actions after mesh has been fully generated.
Definition ABLBoundaryPlane.cpp:301
std::string m_out_fmt
output format for bndry output
Definition ABLBoundaryPlane.H:239
InletData m_in_data
Inlet data.
Definition ABLBoundaryPlane.H:225
void pre_advance_work()
Definition ABLBoundaryPlane.cpp:313
size_t m_out_counter
NetCDF time output counter.
Definition ABLBoundaryPlane.H:205
amrex::Vector< Field * > m_fields
List of fields for IO.
Definition ABLBoundaryPlane.H:218
int m_write_frequency
Normal direction for the boundary plane.
Definition ABLBoundaryPlane.H:191
void post_advance_work()
Definition ABLBoundaryPlane.cpp:329
bool is_initialized() const
Definition ABLBoundaryPlane.H:160
io_mode m_io_mode
IO mode.
Definition ABLBoundaryPlane.H:228
const int m_out_rad
Definition ABLBoundaryPlane.H:235
amrex::Vector< std::string > m_planes
IO boundary planes.
Definition ABLBoundaryPlane.H:198
void populate_data(const int, const amrex::Real, Field &, amrex::MultiFab &, const int dcomp=0, const int orig_comp=0) const
Definition ABLBoundaryPlane.cpp:1157
void write_data(const ncutils::NCGroup &grp, const amrex::Orientation, const int, const Field *)
Definition ABLBoundaryPlane.cpp:1235
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:1354
int boundary_native_file_levels() const
Definition ABLBoundaryPlane.cpp:1377
ABLBoundaryPlane(CFDSim &)
Definition ABLBoundaryPlane.cpp:252
void pre_predictor_work()
Definition ABLBoundaryPlane.cpp:321
amrex::Vector< int > m_in_timesteps
Definition ABLBoundaryPlane.H:222
amrex::Vector< amrex::Real > m_in_times
NetCDF input level time.
Definition ABLBoundaryPlane.H:221
amrex::Vector< amrex::BoxArray > read_bndry_native_boxarrays(const std::string &chkname, const Field &field) const
Definition ABLBoundaryPlane.cpp:862
const amrex::AmrCore & m_mesh
Definition ABLBoundaryPlane.H:177
const FieldRepo & m_repo
Definition ABLBoundaryPlane.H:176
void write_file()
Definition ABLBoundaryPlane.cpp:576
const amr_wind::SimTime & m_time
Definition ABLBoundaryPlane.H:175
std::string m_filename
File name for IO.
Definition ABLBoundaryPlane.H:209
void write_header()
Definition ABLBoundaryPlane.cpp:355
void initialize_data()
Definition ABLBoundaryPlane.cpp:337
amrex::Real m_out_start_time
Start outputting after this time.
Definition ABLBoundaryPlane.H:201
amrex::Vector< std::string > m_plane_names
Plane names.
Definition ABLBoundaryPlane.H:194
std::string m_title
Definition ABLBoundaryPlane.H:188
bool m_is_initialized
Flag indicating if this capability is available.
Definition ABLBoundaryPlane.H:231
bool is_data_newer_than(const amrex::Real time) const
Definition ABLBoundaryPlane.H:167
void read_file(const bool)
Definition ABLBoundaryPlane.cpp:1039
Definition CFDSim.H:47
Definition Field.H:116
Definition FieldRepo.H:86
Definition ABLBoundaryPlane.H:29
void read_data(ncutils::NCGroup &, const amrex::Orientation, const int, const Field *, const amrex::Real, const amrex::Vector< amrex::Real > &)
Definition ABLBoundaryPlane.cpp:70
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:144
bool is_populated(amrex::Orientation) const
Definition ABLBoundaryPlane.cpp:247
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_interp
Definition ABLBoundaryPlane.H:87
void interpolate(const amrex::Real)
Definition ABLBoundaryPlane.cpp:225
int & component(const int id)
Definition ABLBoundaryPlane.H:71
amrex::Real tn() const
Definition ABLBoundaryPlane.H:80
amrex::Real m_tnp1
Time for plane at n + 1.
Definition ABLBoundaryPlane.H:93
amrex::Real tnp1() const
Definition ABLBoundaryPlane.H:81
const amrex::FArrayBox & interpolate_data(const amrex::Orientation ori, const int lev) const
Definition ABLBoundaryPlane.H:66
amrex::Real m_tinterp
Time for plane at interpolation.
Definition ABLBoundaryPlane.H:96
int component(const int id) const
Definition ABLBoundaryPlane.H:73
void resize(const int)
Definition ABLBoundaryPlane.cpp:44
amrex::Real tinterp() const
Definition ABLBoundaryPlane.H:82
void define_level_data(const amrex::Orientation, const amrex::Box &, const size_t)
Definition ABLBoundaryPlane.cpp:58
std::unordered_map< int, int > m_components
Map of {variableId : component}
Definition ABLBoundaryPlane.H:99
amrex::Real m_tn
Time for plane at n.
Definition ABLBoundaryPlane.H:90
amrex::Vector< amrex::FArrayBox > PlaneVector
Definition ABLBoundaryPlane.H:30
int nlevels(const amrex::Orientation ori) const
Definition ABLBoundaryPlane.H:75
void define_plane(const amrex::Orientation)
Definition ABLBoundaryPlane.cpp:51
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_n
Definition ABLBoundaryPlane.H:85
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_np1
Definition ABLBoundaryPlane.H:86
Definition SimTime.H:30
Representation of a NetCDF group.
Definition nc_interface.H:166
Definition BCInterface.cpp:7
io_mode
Definition ABLBoundaryPlane.H:13
Definition ABLBoundaryPlane.H:16
amrex::Gpu::ManagedVector< amrex::Real > data
Definition ABLBoundaryPlane.H:17
amrex::Vector< size_t > start
Definition ABLBoundaryPlane.H:18
amrex::Vector< size_t > count
Definition ABLBoundaryPlane.H:19