shallowWaterFoam.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "fvCFD.H"
00037
00038
00039
00040 int main(int argc, char *argv[])
00041 {
00042 #include "setRootCase.H"
00043 #include "createTime.H"
00044 #include "createMesh.H"
00045 #include "readGravitationalAcceleration.H"
00046 #include "createFields.H"
00047
00048
00049
00050 Info<< "\nStarting time loop\n" << endl;
00051
00052 while (runTime.loop())
00053 {
00054 Info<< "\n Time = " << runTime.timeName() << nl << endl;
00055
00056 #include "readPISOControls.H"
00057 #include "CourantNo.H"
00058
00059 for (int ucorr=0; ucorr<nOuterCorr; ucorr++)
00060 {
00061 surfaceScalarField phiv("phiv", phi/fvc::interpolate(h));
00062
00063 fvVectorMatrix hUEqn
00064 (
00065 fvm::ddt(hU)
00066 + fvm::div(phiv, hU)
00067 );
00068
00069 hUEqn.relax();
00070
00071 if (momentumPredictor)
00072 {
00073 if (rotating)
00074 {
00075 solve(hUEqn + (F ^ hU) == -magg*h*fvc::grad(h + h0));
00076 }
00077 else
00078 {
00079 solve(hUEqn == -magg*h*fvc::grad(h + h0));
00080 }
00081
00082
00083 if (mesh.nGeometricD() == 3)
00084 {
00085 hU -= (gHat & hU)*gHat;
00086 hU.correctBoundaryConditions();
00087 }
00088 }
00089
00090
00091 for (int corr=0; corr<nCorr; corr++)
00092 {
00093 surfaceScalarField hf = fvc::interpolate(h);
00094 volScalarField rUA = 1.0/hUEqn.A();
00095 surfaceScalarField ghrUAf = magg*fvc::interpolate(h*rUA);
00096
00097 surfaceScalarField phih0 = ghrUAf*mesh.magSf()*fvc::snGrad(h0);
00098
00099 if (rotating)
00100 {
00101 hU = rUA*(hUEqn.H() - (F ^ hU));
00102 }
00103 else
00104 {
00105 hU = rUA*hUEqn.H();
00106 }
00107
00108 phi = (fvc::interpolate(hU) & mesh.Sf())
00109 + fvc::ddtPhiCorr(rUA, h, hU, phi)
00110 - phih0;
00111
00112 for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00113 {
00114 fvScalarMatrix hEqn
00115 (
00116 fvm::ddt(h)
00117 + fvc::div(phi)
00118 - fvm::laplacian(ghrUAf, h)
00119 );
00120
00121 if (ucorr < nOuterCorr-1 || corr < nCorr-1)
00122 {
00123 hEqn.solve();
00124 }
00125 else
00126 {
00127 hEqn.solve(mesh.solver(h.name() + "Final"));
00128 }
00129
00130 if (nonOrth == nNonOrthCorr)
00131 {
00132 phi += hEqn.flux();
00133 }
00134 }
00135
00136 hU -= rUA*h*magg*fvc::grad(h + h0);
00137
00138
00139 if (mesh.nGeometricD() == 3)
00140 {
00141 hU -= (gHat & hU)*gHat;
00142 }
00143
00144 hU.correctBoundaryConditions();
00145 }
00146 }
00147
00148 U == hU/h;
00149 hTotal == h + h0;
00150
00151 runTime.write();
00152
00153 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00154 << " ClockTime = " << runTime.elapsedClockTime() << " s"
00155 << nl << endl;
00156 }
00157
00158 Info<< "End\n" << endl;
00159
00160 return 0;
00161 }
00162
00163
00164
Copyright © 2000-2009 OpenCFD Ltd