Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / solvers / DNS / dnsFoam / dnsFoam.C
blob84e2f0fbbecda3a93db3f69a81ab28f254a252ed
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     dnsFoam
27 Description
28     Direct numerical simulation solver for boxes of isotropic turbulence
30 \*---------------------------------------------------------------------------*/
32 #include "fvCFD.H"
33 #include "Kmesh.H"
34 #include "UOprocess.H"
35 #include "fft.H"
36 #include "calcEk.H"
37 #include "graph.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 int main(int argc, char *argv[])
43     #include "setRootCase.H"
45     #include "createTime.H"
46     #include "createMeshNoClear.H"
47     #include "readTransportProperties.H"
48     #include "createFields.H"
49     #include "readTurbulenceProperties.H"
50     #include "initContinuityErrs.H"
52     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54     Info<< nl << "Starting time loop" << endl;
56     while (runTime.loop())
57     {
58         Info<< "Time = " << runTime.timeName() << nl << endl;
60         #include "readPISOControls.H"
62         force.internalField() = ReImSum
63         (
64             fft::reverseTransform
65             (
66                 K/(mag(K) + 1.0e-6) ^ forceGen.newField(), K.nn()
67             )
68         );
70         #include "globalProperties.H"
72         fvVectorMatrix UEqn
73         (
74             fvm::ddt(U)
75           + fvm::div(phi, U)
76           - fvm::laplacian(nu, U)
77          ==
78             force
79         );
81         solve(UEqn == -fvc::grad(p));
84         // --- PISO loop
86         for (int corr=1; corr<=1; corr++)
87         {
88             volScalarField rUA = 1.0/UEqn.A();
90             U = rUA*UEqn.H();
91             phi = (fvc::interpolate(U) & mesh.Sf())
92                 + fvc::ddtPhiCorr(rUA, U, phi);
94             fvScalarMatrix pEqn
95             (
96                 fvm::laplacian(rUA, p) == fvc::div(phi)
97             );
99             pEqn.solve();
101             phi -= pEqn.flux();
103 #           include "continuityErrs.H"
105             U -= rUA*fvc::grad(p);
106             U.correctBoundaryConditions();
107         }
109         runTime.write();
111         if (runTime.outputTime())
112         {
113             calcEk(U, K).write(runTime.timePath()/"Ek", runTime.graphFormat());
114         }
116         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
117             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
118             << nl << endl;
119     }
121     Info<< "End\n" << endl;
123     return 0;
127 // ************************************************************************* //