// License declaration at end of file #include #include #include #include #include #include "channelflow/flowfield.h" #include "channelflow/vector.h" #include "channelflow/chebyshev.h" #include "channelflow/tausolver.h" #include "channelflow/dns.h" #include "channelflow/utilfuncs.h" using namespace std; using namespace channelflow; void printdiagnostics(FlowField& u, const DNS& dns, Real t, const TimeStep& dt, Real nu, Real umin, bool vardt, bool pl2norm, bool pchnorm, bool pdissip, bool pforcing, bool pdiverge, bool pUbulk, bool pubulk, bool pdPdx, bool channel, bool pcfl); int main(int argc, char* argv[]) { string purpose("integrate plane Couette or channel flow from a given " "initial condition and save velocity fields to disk."); ArgList args(argc, argv, purpose); const Real T0 = args.getreal("-T0", "--T0", 0.0, "start time"); const Real T1 = args.getreal("-T1", "--T1", 100, "end time"); const bool vardt = args.getflag("-vdt", "--variabledt", "adjust dt to keep CFLmin<=CFL", "initial condition"); args.check(); args.save("./"); args.save(outdir); mkdir(outdir); cout << "Constructing u,q, and optimizing FFTW..." << endl; FlowField u(uname); u.optimizeFFTW(FFTW_PATIENT); const int Nx = u.Nx(); const int Ny = u.Ny(); const int Nz = u.Nz(); const Real Lx = u.Lx(); const Real Lz = u.Lz(); const Real a = u.a(); const Real b = u.b(); FlowField q(Nx,Ny,Nz,1,Lx,Lz,a,b); TimeStep dt(dtarg, dtmin, dtmax, dT, CFLmin, CFLmax, vardt); const bool inttime = (abs(dT - int(dT)) < 1e-12) ? true : false; const Real nu = 1.0/Reynolds; // Construct Navier-Stoke Integrator DNSFlags flags; flags.timestepping = s2stepmethod(stepstr); flags.dealiasing = DealiasXZ; flags.nonlinearity = s2nonlmethod(nonlstr); flags.constraint = bulkvel ? BulkVelocity : PressureGradient; flags.baseflow = channel ? Parabolic : PlaneCouette; flags.dPdx = dPdx; flags.Ubulk = Ubulk; cout << "constructing DNS..." << endl; DNS dns(u, nu, dt, flags, Real(T0)); for (Real t=T0; t<=T1; t += dT) { printdiagnostics(u, dns, t, dt, nu, umin, vardt, pl2norm, pchnorm, pdissip, pforcing, pdiverge, pUbulk, pubulk, pdPdx, channel, pcfl); u.binarySave(outdir + label + t2s(t, inttime)); dns.advance(u, q, dt.n()); if (dt.adjust(dns.CFL())) dns.reset_dt(dt); } cout << "done!" << endl; } void printdiagnostics(FlowField& u, const DNS& dns, Real t, const TimeStep& dt, Real nu, Real umin, bool vardt, bool pl2norm, bool pchnorm, bool pdissip, bool pforcing, bool pdiverge, bool pUbulk, bool pubulk, bool pdPdx, bool channel, bool pcfl) { // Printing diagnostics cout << " t == " << t << endl; if (vardt) cout << " dt == " << Real(dt) << endl; if (pl2norm) cout << " L2Norm(u) == " << L2Norm(u) << endl; if (pchnorm || umin !=0.0) { Real chnorm = chebyNorm(u); cout << "chebyNorm(u) == " << chnorm << endl; if (chnorm < umin) { cout << "Exiting: chebyNorm(u) < umin." << endl; exit(0); } } if (pdissip) { Complex U(1,0); u.cmplx(0,1,0,0) += U; cout << " dissip(u+U) == " << dissipation(u) << endl; u.cmplx(0,1,0,0) -= U; } if (pforcing) cout << " input(u+U) == " << 1 + forcing(u) << endl; if (pdiverge) cout << " divNorm(u) == " << divNorm(u) << endl; if (pUbulk) cout << " Ubulk == " << dns.Ubulk() << endl; if (pubulk) cout << " ubulk == " << Re(u.profile(0,0,0)).mean() << endl; if (pdPdx) cout << " dPdx == " << dns.dPdx() << endl; if (channel) { cout << " Ubulk*h/nu == " << dns.Ubulk()/nu << endl; cout << " Uparab*h/nu == " << 1.5*dns.Ubulk()/nu << endl; } cout << " CFL == " << dns.CFL() << endl; } /* couette.cpp: time-integration class for spectral Navier-Stokes simulator * channelflow-1.1 PCF-utils * * Copyright (C) 2001-2007 John F. Gibson * * gibson@cns.physics.gatech.edu jfg@member.fsf.org * * Center for Nonlinear Science * School of Physics * Georgia Institute of Technology * Atlanta, GA 30332-0430 * 404 385 2509 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation version 2 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U */