rhoCentralFoam.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 #include "fvCFD.H"
00035 #include "basicPsiThermo.H"
00036 #include "zeroGradientFvPatchFields.H"
00037 #include "fixedRhoFvPatchScalarField.H"
00038
00039
00040
00041 int main(int argc, char *argv[])
00042 {
00043 #include "setRootCase.H"
00044
00045 #include "createTime.H"
00046 #include "createMesh.H"
00047 #include "createFields.H"
00048 #include "readThermophysicalProperties.H"
00049 #include "readTimeControls.H"
00050
00051
00052
00053 #include "readFluxScheme.H"
00054
00055 dimensionedScalar v_zero("v_zero",dimVolume/dimTime, 0.0);
00056
00057 Info<< "\nStarting time loop\n" << endl;
00058
00059 while (runTime.run())
00060 {
00061
00062
00063 surfaceScalarField rho_pos =
00064 fvc::interpolate(rho, pos, "reconstruct(rho)");
00065 surfaceScalarField rho_neg =
00066 fvc::interpolate(rho, neg, "reconstruct(rho)");
00067
00068 surfaceVectorField rhoU_pos =
00069 fvc::interpolate(rhoU, pos, "reconstruct(U)");
00070 surfaceVectorField rhoU_neg =
00071 fvc::interpolate(rhoU, neg, "reconstruct(U)");
00072
00073 volScalarField rPsi = 1.0/psi;
00074 surfaceScalarField rPsi_pos =
00075 fvc::interpolate(rPsi, pos, "reconstruct(T)");
00076 surfaceScalarField rPsi_neg =
00077 fvc::interpolate(rPsi, neg, "reconstruct(T)");
00078
00079 surfaceScalarField e_pos =
00080 fvc::interpolate(e, pos, "reconstruct(T)");
00081 surfaceScalarField e_neg =
00082 fvc::interpolate(e, neg, "reconstruct(T)");
00083
00084 surfaceVectorField U_pos = rhoU_pos/rho_pos;
00085 surfaceVectorField U_neg = rhoU_neg/rho_neg;
00086
00087 surfaceScalarField p_pos = rho_pos*rPsi_pos;
00088 surfaceScalarField p_neg = rho_neg*rPsi_neg;
00089
00090 surfaceScalarField phiv_pos = U_pos & mesh.Sf();
00091 surfaceScalarField phiv_neg = U_neg & mesh.Sf();
00092
00093 volScalarField c = sqrt(thermo.Cp()/thermo.Cv()*rPsi);
00094 surfaceScalarField cSf_pos = fvc::interpolate(c, pos, "reconstruct(T)")*mesh.magSf();
00095 surfaceScalarField cSf_neg = fvc::interpolate(c, neg, "reconstruct(T)")*mesh.magSf();
00096
00097 surfaceScalarField ap = max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero);
00098 surfaceScalarField am = min(min(phiv_pos - cSf_pos, phiv_neg - cSf_neg), v_zero);
00099
00100 surfaceScalarField a_pos = ap/(ap - am);
00101
00102 surfaceScalarField amaxSf("amaxSf", max(mag(am), mag(ap)));
00103
00104 #include "compressibleCourantNo.H"
00105 #include "readTimeControls.H"
00106 #include "setDeltaT.H"
00107
00108 runTime++;
00109
00110 Info<< "Time = " << runTime.timeName() << nl << endl;
00111
00112 surfaceScalarField aSf = am*a_pos;
00113
00114 if (fluxScheme == "Tadmor")
00115 {
00116 aSf = -0.5*amaxSf;
00117 a_pos = 0.5;
00118 }
00119
00120 surfaceScalarField a_neg = (1.0 - a_pos);
00121
00122 phiv_pos *= a_pos;
00123 phiv_neg *= a_neg;
00124
00125 surfaceScalarField aphiv_pos = phiv_pos - aSf;
00126 surfaceScalarField aphiv_neg = phiv_neg + aSf;
00127
00128 surfaceScalarField phi("phi", aphiv_pos*rho_pos + aphiv_neg*rho_neg);
00129
00130 surfaceVectorField phiUp =
00131 (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg)
00132 + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf();
00133
00134 surfaceScalarField phiEp =
00135 aphiv_pos*(rho_pos*(e_pos + 0.5*magSqr(U_pos)) + p_pos)
00136 + aphiv_neg*(rho_neg*(e_neg + 0.5*magSqr(U_neg)) + p_neg)
00137 + aSf*p_pos - aSf*p_neg;
00138
00139 volTensorField tauMC("tauMC", mu*dev2(fvc::grad(U)().T()));
00140
00141
00142 solve(fvm::ddt(rho) + fvc::div(phi));
00143
00144
00145 solve(fvm::ddt(rhoU) + fvc::div(phiUp));
00146
00147 U.dimensionedInternalField() =
00148 rhoU.dimensionedInternalField()
00149 /rho.dimensionedInternalField();
00150 U.correctBoundaryConditions();
00151 rhoU.boundaryField() = rho.boundaryField()*U.boundaryField();
00152
00153 volScalarField rhoBydt(rho/runTime.deltaT());
00154
00155 if (!inviscid)
00156 {
00157 solve
00158 (
00159 fvm::ddt(rho, U) - fvc::ddt(rho, U)
00160 - fvm::laplacian(mu, U)
00161 - fvc::div(tauMC)
00162 );
00163 rhoU = rho*U;
00164 }
00165
00166
00167 surfaceScalarField sigmaDotU =
00168 (
00169 (
00170 fvc::interpolate(mu)*mesh.magSf()*fvc::snGrad(U)
00171 + (mesh.Sf() & fvc::interpolate(tauMC))
00172 )
00173 & (a_pos*U_pos + a_neg*U_neg)
00174 );
00175
00176 solve
00177 (
00178 fvm::ddt(rhoE)
00179 + fvc::div(phiEp)
00180 - fvc::div(sigmaDotU)
00181 );
00182
00183 e = rhoE/rho - 0.5*magSqr(U);
00184 e.correctBoundaryConditions();
00185 thermo.correct();
00186 rhoE.boundaryField() =
00187 rho.boundaryField()*
00188 (
00189 e.boundaryField() + 0.5*magSqr(U.boundaryField())
00190 );
00191
00192 if (!inviscid)
00193 {
00194 volScalarField k("k", thermo.Cp()*mu/Pr);
00195 solve
00196 (
00197 fvm::ddt(rho, e) - fvc::ddt(rho, e)
00198 - fvm::laplacian(thermo.alpha(), e)
00199 + fvc::laplacian(thermo.alpha(), e)
00200 - fvc::laplacian(k, T)
00201 );
00202 thermo.correct();
00203 rhoE = rho*(e + 0.5*magSqr(U));
00204 }
00205
00206 p.dimensionedInternalField() =
00207 rho.dimensionedInternalField()
00208 /psi.dimensionedInternalField();
00209 p.correctBoundaryConditions();
00210 rho.boundaryField() = psi.boundaryField()*p.boundaryField();
00211
00212 runTime.write();
00213
00214 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00215 << " ClockTime = " << runTime.elapsedClockTime() << " s"
00216 << nl << endl;
00217 }
00218
00219 Info<< "End\n" << endl;
00220
00221 return 0;
00222 }
00223
00224
Copyright © 2000-2009 OpenCFD Ltd