<code> #include <iostream> #include <fstream> #include <iomanip> #include "channelflow/flowfield.h" #include "channelflow/dns.h" #include "channelflow/utilfuncs.h" #include "channelflow/vector.h" #include "channelflow/turbstats.h" using namespace std; using namespace channelflow; int main(int argc, char* argv[]) { string purpose("take input Flowfield and write a file with energy density\n" "as a function of y, averaged over x and z"); ArgList args(argc, argv, purpose); const string uname = args.getstr(2, "<fieldname>", "flowfield input file"); const string afile = args.getstr(1, "<asciifile>", "ascii output file"); args.check(); FlowField u(uname); u.makeState(Physical, Physical); const int Nx = u.Nx(); const int Ny = u.Ny(); const int Nz = u.Nz(); const int Nd = u.Nd(); int p = 16; Vector e(Ny); int count = 0; for (int ny=0; ny<Ny; ++ny) { e[ny]=0; for (int nx=0; nx<Nx; ++nx) { for (int nz=0; nz<Nz; ++nz) { count++; for (int i=0; i<Nd; ++i) { e[ny]+=u(nx,ny,nz,i)*u(nx,ny,nz,i); } } } } ofstream os(appendSuffix(afile, ".asc").c_str()); os << setprecision(p) << scientific; for (int ny_=0; ny_<Ny;++ny_) { e[ny_]=e[ny_]/(2*count); os << e[ny_] << '\n'; } } </code>