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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/IOManager.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
IOManager.H
Go to the documentation of this file.
1#ifndef IOMANAGER_H
2#define IOMANAGER_H
3
4#include <string>
5#include <unordered_map>
6#include <set>
7
8#include "AMReX_Vector.H"
9#include "AMReX_BoxArray.H"
10#include "AMReX_DistributionMapping.H"
11
12namespace amr_wind {
13
14class CFDSim;
15class Field;
16class IntField;
17class DerivedQtyMgr;
18
32{
33public:
34 explicit IOManager(CFDSim& /*sim*/);
35
37
38 IOManager(const IOManager&) = delete;
39 IOManager& operator=(const IOManager&) = delete;
40
42 void initialize_io();
43
45 void write_plot_file();
46
48 void
49 write_checkpoint_file(const int start_level = 0, const int end_level = -1);
50
53 const std::string& restart_file,
54 const amrex::Vector<amrex::BoxArray>& ba_chk,
55 const amrex::Vector<amrex::DistributionMapping>& dm_chk,
56 const amrex::IntVect& rep);
57
59 void register_output_var(const std::string& fname)
60 {
61 m_pltvars_default.insert(fname);
62 }
63
64 void register_output_int_var(const std::string& fname)
65 {
66 m_int_pltvars_default.insert(fname);
67 }
68
70 void register_restart_var(const std::string& fname)
71 {
72 m_chkvars.insert(fname);
73 }
74
76 void register_io_var(const std::string& fname)
77 {
78 m_pltvars_default.insert(fname);
79 m_chkvars.insert(fname);
80 }
81
83 const std::string& restart_file() { return m_restart_file; }
84
85 bool is_restart() const { return !m_restart_file.empty(); }
86
87 const amrex::Vector<Field*>& plot_fields() const { return m_plt_fields; }
88
89 const amrex::Vector<Field*>& checkpoint_fields() const
90 {
91 return m_chk_fields;
92 }
93
95 const std::string& post_processing_directory()
96 {
97 if (!amrex::UtilCreateDirectory(m_post_dir, 0755)) {
98 amrex::CreateDirectoryFailed(m_post_dir);
99 }
100 return m_post_dir;
101 }
102
103private:
104 void write_header(
105 const std::string& /*chkname*/,
106 const int start_level,
107 const int end_level);
108
109 void write_info_file(const std::string& /*path*/);
110
112
113 std::unique_ptr<DerivedQtyMgr> m_derived_mgr;
114
116 std::set<std::string> m_pltvars_default;
117
119 std::set<std::string> m_int_pltvars_default;
120
122 std::set<std::string> m_chkvars;
123
125 amrex::Vector<Field*> m_plt_fields;
126
128 amrex::Vector<IntField*> m_int_plt_fields;
129
131 amrex::Vector<Field*> m_chk_fields;
132
134 amrex::Vector<std::string> m_plt_var_names;
135
137 std::string m_plt_prefix{"plt"};
138
140 std::string m_chk_prefix{"chk"};
141
143 std::string m_post_dir{"post_processing"};
144
146 std::string m_restart_file;
147
150
153
156
157#ifdef AMR_WIND_USE_HDF5
159 bool m_output_hdf5_plotfile{false};
160#ifdef AMR_WIND_USE_HDF5_ZFP
162 std::string m_hdf5_compression{"None@0"};
163#endif
164#endif
165
167 int m_nfiles{256};
168};
169
170} // namespace amr_wind
171
172#endif /* IOMANAGER_H */
Definition CFDSim.H:47
Definition IOManager.H:32
bool m_output_default_vars
Flag indicating whether default fields should be output.
Definition IOManager.H:152
const amrex::Vector< Field * > & checkpoint_fields() const
Definition IOManager.H:89
IOManager(const IOManager &)=delete
void write_plot_file()
Write all user-requested fields to disk.
Definition IOManager.cpp:132
void write_checkpoint_file(const int start_level=0, const int end_level=-1)
Write all necessary fields for restart.
Definition IOManager.cpp:189
std::set< std::string > m_pltvars_default
Default output variables registered automatically in the code.
Definition IOManager.H:116
IOManager(CFDSim &)
Definition IOManager.cpp:25
std::string m_chk_prefix
Prefix used for the restart file directories.
Definition IOManager.H:140
bool m_allow_missing_restart_fields
Flag indicating whether we should allow missing restart fields.
Definition IOManager.H:155
void write_info_file(const std::string &)
Definition IOManager.cpp:355
amrex::Vector< IntField * > m_int_plt_fields
Final list of integer fields to be output.
Definition IOManager.H:128
std::string m_restart_file
Restart file name.
Definition IOManager.H:146
std::string m_post_dir
Name for the post_processing directory.
Definition IOManager.H:143
void initialize_io()
Process user inputs and perform one-time initialization tasks.
Definition IOManager.cpp:31
std::unique_ptr< DerivedQtyMgr > m_derived_mgr
Definition IOManager.H:113
void register_output_var(const std::string &fname)
Register a variable for output.
Definition IOManager.H:59
std::string m_plt_prefix
Prefix used for the plot file directories.
Definition IOManager.H:137
void write_header(const std::string &, const int start_level, const int end_level)
Definition IOManager.cpp:305
void register_output_int_var(const std::string &fname)
Definition IOManager.H:64
const std::string & post_processing_directory()
Name of the post processing directory.
Definition IOManager.H:95
void read_checkpoint_fields(const std::string &restart_file, const amrex::Vector< amrex::BoxArray > &ba_chk, const amrex::Vector< amrex::DistributionMapping > &dm_chk, const amrex::IntVect &rep)
Read all necessary fields for a restart.
Definition IOManager.cpp:219
std::set< std::string > m_int_pltvars_default
Default output integer variables registered automatically in the code.
Definition IOManager.H:119
amrex::Vector< Field * > m_plt_fields
Final list of fields to be output.
Definition IOManager.H:125
const std::string & restart_file()
Name of the checkpoint file to be read during a restart.
Definition IOManager.H:83
int m_nfiles
Number of plot and checkpoint data files per write.
Definition IOManager.H:167
void register_io_var(const std::string &fname)
Convenience function to register a variable for both output and restart.
Definition IOManager.H:76
amrex::Vector< Field * > m_chk_fields
Final list of fields for restart.
Definition IOManager.H:131
bool is_restart() const
Definition IOManager.H:85
const amrex::Vector< Field * > & plot_fields() const
Definition IOManager.H:87
std::set< std::string > m_chkvars
Variables for output in checkpoint/restart files.
Definition IOManager.H:122
int m_plt_num_comp
Total number of variables (including components) output to plot file.
Definition IOManager.H:149
IOManager & operator=(const IOManager &)=delete
amrex::Vector< std::string > m_plt_var_names
Variable names (including components) for output.
Definition IOManager.H:134
CFDSim & m_sim
Definition IOManager.H:111
void register_restart_var(const std::string &fname)
Register a variable for restart file.
Definition IOManager.H:70
Definition BCInterface.cpp:7