1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 \*---------------------------------------------------------------------------*/
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 int main(int argc, char *argv[])
41 #include "setRootCase.H"
42 #include "createTime.H"
43 #include "createMesh.H"
44 #include "readGravitationalAcceleration.H"
45 #include "createFields.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 Info<< "\nStarting time loop\n" << endl;
51 while (runTime.loop())
53 Info<< "\n Time = " << runTime.timeName() << nl << endl;
55 #include "readPISOControls.H"
56 #include "CourantNo.H"
58 for (int ucorr=0; ucorr<nOuterCorr; ucorr++)
60 surfaceScalarField phiv("phiv", phi/fvc::interpolate(h));
70 if (momentumPredictor)
74 solve(hUEqn + (F ^ hU) == -magg*h*fvc::grad(h + h0));
78 solve(hUEqn == -magg*h*fvc::grad(h + h0));
81 // Constrain the momentum to be in the geometry if 3D geometry
82 if (mesh.nGeometricD() == 3)
84 hU -= (gHat & hU)*gHat;
85 hU.correctBoundaryConditions();
90 for (int corr = 0; corr < nCorr; corr++)
92 surfaceScalarField hf = fvc::interpolate(h);
93 volScalarField rUA = 1.0/hUEqn.A();
94 surfaceScalarField ghrUAf = magg*fvc::interpolate(h*rUA);
96 surfaceScalarField phih0 = ghrUAf*mesh.magSf()*fvc::snGrad(h0);
100 hU = rUA*(hUEqn.H() - (F ^ hU));
107 phi = (fvc::interpolate(hU) & mesh.Sf())
108 + fvc::ddtPhiCorr(rUA, h, hU, phi)
111 for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
117 - fvm::laplacian(ghrUAf, h)
120 if (ucorr < nOuterCorr - 1 || corr < nCorr - 1)
128 mesh.solutionDict().solver(h.name() + "Final")
132 if (nonOrth == nNonOrthCorr)
138 hU -= rUA*h*magg*fvc::grad(h + h0);
140 // Constrain the momentum to be in the geometry if 3D geometry
141 if (mesh.nGeometricD() == 3)
143 hU -= (gHat & hU)*gHat;
146 hU.correctBoundaryConditions();
155 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
156 << " ClockTime = " << runTime.elapsedClockTime() << " s"
160 Info<< "End\n" << endl;
166 // ************************************************************************* //