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"
39 #include "viscosityModel.H"
41 #include "fvModels.H"
42 #include "fvConstraints.H"
43 #include "wallFvPatch.H"
44 #include "setWriter.H"
45 #include "writeFile.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 int main(int argc, char *argv[])
50 {
51  argList::noParallel();
52 
53  #include "setRootCaseLists.H"
54 
55  #include "createTime.H"
56  #include "createMesh.H"
57  #include "createFields.H"
58  #include "interrogateWallPatches.H"
59 
60  turbulence->validate();
61 
62  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64  Info<< "\nStarting time loop\n" << endl;
65 
66  while (runTime.loop())
67  {
68  Info<< "Time = " << runTime.userTimeName() << nl << endl;
69 
70  fvModels.correct();
71 
72  fvVectorMatrix divR(turbulence->divDevSigma(U));
73  divR.source() = flowMask & divR.source();
74 
76  (
77  divR == gradP + fvModels.source(U)
78  );
79 
80  UEqn.relax();
81 
83 
84  UEqn.solve();
85 
87 
88 
89  // Correct driving force for a constant volume flow rate
90  dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V());
91 
92  U += (Ubar - UbarStar);
93  gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V());
94 
95  viscosity->correct();
96  turbulence->correct();
97 
98  Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())
99  << ", pressure gradient = " << (flowDirection & gradP.value())
100  << endl;
101 
102  #include "evaluateNearWall.H"
103 
104  if (runTime.writeTime())
105  {
106  #include "makeGraphs.H"
107  }
108 
109  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
110  << " ClockTime = " << runTime.elapsedClockTime() << " s"
111  << nl << endl;
112  }
113 
114  Info<< "End\n" << endl;
115 
116  return 0;
117 }
118 
119 
120 // ************************************************************************* //
U
Definition: pEqn.H:72
vector flowDirection
Definition: createFields.H:41
virtual void correct()
Correct the fvModels.
Definition: fvModels.C:353
dimensionedVector gradP("gradP", dimensionSet(0, 1, -2, 0, 0), Zero)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvMesh & mesh
dimensionedVector Ubar("Ubar", dimVelocity, viscosity)
Foam::fvConstraints & fvConstraints
tensor flowMask
Definition: createFields.H:42
Info<< "Reading field p\"<< endl;volScalarField p(IOobject("p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, simple.dict());mesh.schemes().setFluxRequired(p.name());Info<< "Reading field pa\"<< endl;volScalarField pa(IOobject("pa", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field Ua\"<< endl;volVectorField Ua(IOobject("Ua", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);# 65 "/home/ubuntu/OpenFOAM-10/applications/solvers/incompressible/adjointShapeOptimisationFoam/createFields.H" 2label paRefCell=0;scalar paRefValue=0.0;setRefCell(pa, simple.dict(), paRefCell, paRefValue);mesh.schemes().setFluxRequired(pa.name());autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))
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
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
messageStream Info
fvVectorMatrix & UEqn
Definition: UEqn.H:13