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

Function WriteFab

Tools/Postprocessing/C_Src/PlotfileToMatLab.cpp:93–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93static
94void
95WriteFab (std::ostream& os,
96 const FArrayBox& fab,
97 const char* name)
98
99{
100 int nx = fab.box().length(0);
101 int ny = fab.box().length(1);
102 int dim = BL_SPACEDIM;
103
104
105#if (BL_SPACEDIM == 2)
106 for (int i = 0; i < nx; i++)
107 for (int j = 0; j < ny; j++)
108 {
109 int index = j*nx + i;
110 const Real * ptr = fab.dataPtr();
111 os.write((char*)(ptr+index),sizeof(Real));
112 }
113
114#elif (BL_SPACEDIM == 3)
115 int nz = fab.box().length(2);
116 os.write((char*)&nz,sizeof(int));
117
118 for (int k = 0; k < nz; k++)
119 for (int i = 0; i < nx; i++)
120 for (int j = 0; j < ny; j++)
121 {
122 int index = k*(nx*ny) + j*nx + i;
123 const Real * ptr = fab.dataPtr();
124 os.write((char*)(ptr+index),sizeof(Real));
125 }
126#endif
127}
128
129static
130void

Callers 1

WriteFunction · 0.70

Calls 4

lengthMethod · 0.45
boxMethod · 0.45
dataPtrMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected