MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / Write

Function Write

Tools/Postprocessing/C_Src/PlotfileToMatLab.cpp:146–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146static
147void
148Write (AmrData& amrData,
149 const std::string& iFile_name,
150 const std::list<std::string> plot_vars)
151{
152 int finest_level = amrData.FinestLevel();
153
154 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
155
156 char buf[128];
157
158 for (int icomp = 0; icomp < amrData.NComp(); icomp++)
159 {
160 //
161 // Write one component per file.
162 //
163 const std::string& CompName = amrData.PlotVarNames()[icomp];
164 if (isPlotVar(CompName))
165 {
166
167 std::string file = iFile_name;
168 file += '_';
169 file += CompName;
170 file += ".mat";
171
172 std::ofstream os;
173
174 os.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
175
176 os.open(file.c_str(), std::ios::out|std::ios::binary);
177
178 if (os.fail()) {
179 amrex::FileOpenFailed(file);
180 }
181
182 int dim = BL_SPACEDIM;
183 os.write((char*)&dim,sizeof(int));
184
185 int num_levels = finest_level+1;
186 os.write((char*)&num_levels,sizeof(int));
187
188// Write the number of grids at each level
189 for (int iLevel = 0; iLevel <= finest_level; ++iLevel)
190 {
191 MultiFab& mf = amrData.GetGrids(iLevel,icomp);
192 const BoxArray& ba = mf.boxArray();
193 int num_grids = ba.size();
194 os.write((char*)&num_grids,sizeof(int));
195 }
196
197// Write the (Real) physical locations of each grid at each level
198 for (int iLevel = 0; iLevel <= finest_level; ++iLevel)
199 {
200 MultiFab& mf = amrData.GetGrids(iLevel,icomp);
201 const BoxArray& ba = mf.boxArray();
202 int num_grids = ba.size();
203 for (int i = 0; i < num_grids; ++i)

Callers 12

mainFunction · 0.70
solveMethod · 0.50
writePlotfileMethod · 0.50
solveMethod · 0.50
solveMethod · 0.50
solveMethod · 0.50
solveMethod · 0.50
MFdiffFunction · 0.50
AMREX_D_TERMFunction · 0.50
WriteCheckpointFileMethod · 0.50
main_mainFunction · 0.50
mainFunction · 0.50

Calls 9

isPlotVarFunction · 0.85
NCompMethod · 0.80
WriteFabFunction · 0.70
FinestLevelMethod · 0.45
dataPtrMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
boxArrayMethod · 0.45
lengthMethod · 0.45

Tested by 6

solveMethod · 0.40
writePlotfileMethod · 0.40
solveMethod · 0.40
solveMethod · 0.40
solveMethod · 0.40
solveMethod · 0.40