1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Simple potential flow solver which can be used to generate starting fields
29 for full Navier-Stokes codes.
31 \*---------------------------------------------------------------------------*/
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 int main(int argc, char *argv[])
40 argList::addBoolOption("writep", "write the final pressure field");
41 argList::addBoolOption
44 "initialise U boundary conditions"
47 #include "setRootCase.H"
48 #include "createTime.H"
49 #include "createMesh.H"
50 #include "readControls.H"
51 #include "createFields.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 Info<< nl << "Calculating potential flow" << endl;
57 // Since solver contains no time loop it would never execute
58 // function objects so do it ourselves.
59 runTime.functionObjects().start();
63 for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
72 dimTime/p.dimensions()*dimensionSet(0, 2, -2, 0, 0),
81 pEqn.setReference(pRefCell, pRefValue);
84 if (nonOrth == nNonOrthCorr)
90 Info<< "continuity error = "
91 << mag(fvc::div(phi))().weightedAverage(mesh.V()).value()
94 U = fvc::reconstruct(phi);
95 U.correctBoundaryConditions();
97 Info<< "Interpolated U error = "
98 << (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi)))
99 /sum(mesh.magSf())).value()
106 if (args.optionFound("writep"))
111 runTime.functionObjects().end();
113 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
114 << " ClockTime = " << runTime.elapsedClockTime() << " s"
117 Info<< "End\n" << endl;
123 // ************************************************************************* //