rhopSonicFoam.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 #include "fvCFD.H"
00034 #include "weighted.H"
00035 #include "gaussConvectionScheme.H"
00036 #include "multivariateGaussConvectionScheme.H"
00037 #include "MUSCL.H"
00038 #include "LimitedScheme.H"
00039 #include "boundaryTypes.H"
00040
00041
00042
00043 int main(int argc, char *argv[])
00044 {
00045 #include "setRootCase.H"
00046 #include "createTime.H"
00047 #include "createMesh.H"
00048 #include "readThermodynamicProperties.H"
00049 #include "createFields.H"
00050
00051
00052
00053 Info<< "\nStarting time loop\n" << endl;
00054
00055 while (runTime.loop())
00056 {
00057 Info<< "Time = " << runTime.value() << nl << endl;
00058
00059 #include "readPISOControls.H"
00060 scalar HbyAblend = readScalar(piso.lookup("HbyAblend"));
00061
00062 #include "readTimeControls.H"
00063
00064 scalar CoNum = max
00065 (
00066 mesh.surfaceInterpolation::deltaCoeffs()
00067 *mag(phiv)/mesh.magSf()
00068 ).value()*runTime.deltaT().value();
00069
00070 Info<< "Max Courant Number = " << CoNum << endl;
00071
00072 #include "setDeltaT.H"
00073
00074 for (int outerCorr=0; outerCorr<nOuterCorr; outerCorr++)
00075 {
00076 magRhoU = mag(rhoU);
00077 H = (rhoE + p)/rho;
00078
00079 fv::multivariateGaussConvectionScheme<scalar> mvConvection
00080 (
00081 mesh,
00082 fields,
00083 phiv,
00084 mesh.divScheme("div(phiv,rhoUH)")
00085 );
00086
00087 solve
00088 (
00089 fvm::ddt(rho)
00090 + mvConvection.fvmDiv(phiv, rho)
00091 );
00092
00093 surfaceScalarField rhoUWeights =
00094 mvConvection.interpolationScheme()()(magRhoU)()
00095 .weights(magRhoU);
00096
00097 weighted<vector> rhoUScheme(rhoUWeights);
00098
00099 fvVectorMatrix rhoUEqn
00100 (
00101 fvm::ddt(rhoU)
00102 + fv::gaussConvectionScheme<vector>(mesh, phiv, rhoUScheme)
00103 .fvmDiv(phiv, rhoU)
00104 );
00105
00106 solve(rhoUEqn == -fvc::grad(p));
00107
00108 solve
00109 (
00110 fvm::ddt(rhoE)
00111 + mvConvection.fvmDiv(phiv, rhoE)
00112 ==
00113 - mvConvection.fvcDiv(phiv, p)
00114 );
00115
00116 T = (rhoE - 0.5*rho*magSqr(rhoU/rho))/Cv/rho;
00117 psi = 1.0/(R*T);
00118 p = rho/psi;
00119
00120 for (int corr=0; corr<nCorr; corr++)
00121 {
00122 volScalarField rrhoUA = 1.0/rhoUEqn.A();
00123 surfaceScalarField rrhoUAf("rrhoUAf", fvc::interpolate(rrhoUA));
00124 volVectorField HbyA = rrhoUA*rhoUEqn.H();
00125
00126 surfaceScalarField HbyAWeights =
00127 HbyAblend*mesh.weights()
00128 + (1.0 - HbyAblend)*
00129 LimitedScheme
00130 <vector, MUSCLLimiter<NVDTVD>, limitFuncs::magSqr>
00131 (mesh, phi, IStringStream("HbyA")()).weights(HbyA);
00132
00133 phi =
00134 (
00135 surfaceInterpolationScheme<vector>::interpolate
00136 (HbyA, HbyAWeights) & mesh.Sf()
00137 )
00138 + HbyAblend*fvc::ddtPhiCorr(rrhoUA, rho, rhoU, phi);
00139
00140 p.boundaryField().updateCoeffs();
00141
00142 surfaceScalarField phiGradp =
00143 rrhoUAf*mesh.magSf()*fvc::snGrad(p);
00144
00145 phi -= phiGradp;
00146
00147 #include "resetPhiPatches.H"
00148
00149 surfaceScalarField rhof =
00150 mvConvection.interpolationScheme()()(rho)()
00151 .interpolate(rho);
00152
00153 phiv = phi/rhof;
00154
00155 fvScalarMatrix pEqn
00156 (
00157 fvm::ddt(psi, p)
00158 + mvConvection.fvcDiv(phiv, rho)
00159 + fvc::div(phiGradp)
00160 - fvm::laplacian(rrhoUAf, p)
00161 );
00162
00163 pEqn.solve();
00164
00165 phi += phiGradp + pEqn.flux();
00166 rho = psi*p;
00167 rhof =
00168 mvConvection.interpolationScheme()()(rho)()
00169 .interpolate(rho);
00170 phiv = phi/rhof;
00171
00172 rhoU = HbyA - rrhoUA*fvc::grad(p);
00173 rhoU.correctBoundaryConditions();
00174 }
00175 }
00176
00177 U = rhoU/rho;
00178
00179 runTime.write();
00180
00181 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00182 << " ClockTime = " << runTime.elapsedClockTime() << " s"
00183 << nl << endl;
00184 }
00185
00186 Info<< "End\n" << endl;
00187
00188 return 0;
00189 }
00190
00191
00192
Copyright © 2000-2009 OpenCFD Ltd