1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
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 Transient solver for inviscid shallow-water equations with rotation.
30 If the geometry is 3D then it is assumed to be one layers of cells and the
31 component of the velocity normal to gravity is removed.
33 \*---------------------------------------------------------------------------*/
36 #include "pimpleControl.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42 #include "setRootCase.H"
43 #include "createTime.H"
44 #include "createMesh.H"
45 #include "readGravitationalAcceleration.H"
46 #include "createFields.H"
48 pimpleControl pimple(mesh);
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 Info<< "\nStarting time loop\n" << endl;
54 while (runTime.loop())
56 Info<< "\n Time = " << runTime.timeName() << nl << endl;
58 #include "CourantNo.H"
60 // --- Pressure-velocity PIMPLE corrector loop
61 for (pimple.start(); pimple.loop(); pimple++)
63 surfaceScalarField phiv("phiv", phi/fvc::interpolate(h));
73 if (pimple.momentumPredictor())
77 solve(hUEqn + (F ^ hU) == -magg*h*fvc::grad(h + h0));
81 solve(hUEqn == -magg*h*fvc::grad(h + h0));
84 // Constrain the momentum to be in the geometry if 3D geometry
85 if (mesh.nGeometricD() == 3)
87 hU -= (gHat & hU)*gHat;
88 hU.correctBoundaryConditions();
93 for (int corr=0; corr<pimple.nCorr(); corr++)
95 volScalarField rAU(1.0/hUEqn.A());
96 surfaceScalarField ghrAUf(magg*fvc::interpolate(h*rAU));
98 surfaceScalarField phih0(ghrAUf*mesh.magSf()*fvc::snGrad(h0));
102 hU = rAU*(hUEqn.H() - (F ^ hU));
109 phi = (fvc::interpolate(hU) & mesh.Sf())
110 + fvc::ddtPhiCorr(rAU, h, hU, phi)
113 for (int nonOrth=0; nonOrth<=pimple.nNonOrthCorr(); nonOrth++)
119 - fvm::laplacian(ghrAUf, h)
126 h.select(pimple.finalInnerIter(corr, nonOrth))
130 if (nonOrth == pimple.nNonOrthCorr())
136 hU -= rAU*h*magg*fvc::grad(h + h0);
138 // Constrain the momentum to be in the geometry if 3D geometry
139 if (mesh.nGeometricD() == 3)
141 hU -= (gHat & hU)*gHat;
144 hU.correctBoundaryConditions();
153 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
154 << " ClockTime = " << runTime.elapsedClockTime() << " s"
158 Info<< "End\n" << endl;
164 // ************************************************************************* //