dnsFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  dnsFoam
26 
27 Description
28  Direct numerical simulation solver for boxes of isotropic turbulence.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "fvCFD.H"
33 #include "Kmesh.H"
34 #include "UOprocess.H"
35 #include "fft.H"
36 #include "calcEk.H"
37 #include "graph.H"
38 #include "writeFile.H"
39 #include "pisoControl.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
45  #include "postProcess.H"
46 
47  #include "setRootCaseLists.H"
48  #include "createTime.H"
49  #include "createMeshNoClear.H"
50  #include "createControl.H"
51  #include "createFields.H"
52  #include "initContinuityErrs.H"
53 
54  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56  Info<< nl << "Starting time loop" << endl;
57 
58  while (runTime.loop())
59  {
60  Info<< "Time = " << runTime.timeName() << nl << endl;
61 
62  force.primitiveFieldRef() = ReImSum
63  (
64  fft::reverseTransform
65  (
66  K/(mag(K) + 1.0e-6) ^ forceGen.newField(), K.nn()
67  )
68  );
69 
70  #include "globalProperties.H"
71 
73  (
74  fvm::ddt(U)
75  + fvm::div(phi, U)
76  - fvm::laplacian(nu, U)
77  ==
78  force
79  );
80 
81  solve(UEqn == -fvc::grad(p));
82 
83 
84  // --- PISO loop
85  while (piso.correct())
86  {
87  volScalarField rAU(1.0/UEqn.A());
91  (
92  "phiHbyA",
95  );
96 
97  // Update the pressure BCs to ensure flux consistency
99 
100  fvScalarMatrix pEqn
101  (
103  );
104 
105  pEqn.solve();
106 
107  phi = phiHbyA - pEqn.flux();
108 
109  #include "continuityErrs.H"
110 
111  U = HbyA - rAU*fvc::grad(p);
112  U.correctBoundaryConditions();
113  }
114 
115  runTime.write();
116 
117  if (runTime.writeTime())
118  {
119  calcEk(U, K).write
120  (
121  runTime.path()
122  /functionObjects::writeFile::outputPrefix
123  /"graphs"
124  /runTime.timeName(),
125  "Ek",
126  runTime.graphFormat()
127  );
128  }
129 
130  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
131  << " ClockTime = " << runTime.elapsedClockTime() << " s"
132  << nl << endl;
133  }
134 
135  Info<< "End\n" << endl;
136 
137  return 0;
138 }
139 
140 
141 // ************************************************************************* //
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
void write(Ostream &, const word &format) const
Write graph to stream in given format.
Definition: graph.C:221
surfaceScalarField & phi
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
void constrainPressure(volScalarField &p, const RhoType &rho, const volVectorField &U, const surfaceScalarField &phiHbyA, const RAUType &rhorAU, const MRFType &MRF)
tmp< GeometricField< typename flux< Type >::type, fvsPatchField, surfaceMesh > > ddtCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const GeometricField< Type, fvsPatchField, surfaceMesh > &Uf)
Definition: fvcDdt.C:170
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
pisoControl piso(mesh)
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
graph calcEk(const volVectorField &U, const Kmesh &K)
Definition: calcEk.C:27
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcLaplacian.C:45
CGAL::Exact_predicates_exact_constructions_kernel K
HbyA
Definition: pcEqn.H:74
scalarField ReImSum(const UList< complex > &cf)
Definition: complexFields.C:84
phiHbyA
Definition: pcEqn.H:73
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
dimensionedScalar rAUf("rAUf", dimTime, 1.0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
volScalarField & e
Elementary charge.
Definition: createFields.H:11
rhoEqn solve()
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:33
static const char nl
Definition: Ostream.H:265
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
U
Definition: pEqn.H:72
fvVectorMatrix & UEqn
Definition: UEqn.H:13
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
tmp< volScalarField > rAU
Definition: initCorrectPhi.H:1
volScalarField & p
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Definition: fvcFlux.C:32
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Execute application functionObjects to post-process existing results.
volScalarField & nu