boundaryFoam.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-2021 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  boundaryFoam
26 
27 Description
28  Steady-state solver for incompressible, 1D turbulent flow, typically to
29  generate boundary layer conditions at an inlet, for use in a simulation.
30 
31  Boundary layer code to calculate the U, k and epsilon distributions.
32  Used to create inlet boundary conditions for experimental comparisons
33  for which U and k have not been measured.
34  Turbulence model is runtime selectable.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "fvCFD.H"
41 #include "fvModels.H"
42 #include "fvConstraints.H"
43 #include "wallFvPatch.H"
44 #include "makeGraph.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
50  argList::noParallel();
51 
52  #include "setRootCaseLists.H"
53 
54  #include "createTime.H"
55  #include "createMesh.H"
56  #include "createFields.H"
57  #include "interrogateWallPatches.H"
58 
59  turbulence->validate();
60 
61  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63  Info<< "\nStarting time loop\n" << endl;
64 
65  while (runTime.loop())
66  {
67  Info<< "Time = " << runTime.timeName() << nl << endl;
68 
69  fvModels.correct();
70 
71  fvVectorMatrix divR(turbulence->divDevSigma(U));
72  divR.source() = flowMask & divR.source();
73 
75  (
76  divR == gradP + fvModels.source(U)
77  );
78 
79  UEqn.relax();
80 
82 
83  UEqn.solve();
84 
86 
87 
88  // Correct driving force for a constant volume flow rate
89  dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V());
90 
91  U += (Ubar - UbarStar);
92  gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
93 
94  laminarTransport.correct();
95  turbulence->correct();
96 
97  Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())
98  << ", pressure gradient = " << (flowDirection & gradP.value())
99  << endl;
100 
101  #include "evaluateNearWall.H"
102 
103  if (runTime.writeTime())
104  {
105  #include "makeGraphs.H"
106  }
107 
108  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
109  << " ClockTime = " << runTime.elapsedClockTime() << " s"
110  << nl << endl;
111  }
112 
113  Info<< "End\n" << endl;
114 
115  return 0;
116 }
117 
118 
119 // ************************************************************************* //
vector flowDirection
Definition: createFields.H:41
virtual void correct()
Correct the fvModels.
Definition: fvModels.C:316
dimensionedVector gradP("gradP", dimensionSet(0, 1, -2, 0, 0), Zero)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
dynamicFvMesh & mesh
Foam::fvConstraints & fvConstraints
tensor flowMask
Definition: createFields.H:42
Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::momentumTransportModel > turbulence(compressible::momentumTransportModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
static const char nl
Definition: Ostream.H:260
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
Foam::fvModels & fvModels
U
Definition: pEqn.H:72
dimensionedVector Ubar("Ubar", dimVelocity, laminarTransport)
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
messageStream Info
singlePhaseTransportModel laminarTransport(U, phi)
fvVectorMatrix & UEqn
Definition: UEqn.H:13