|
|
|
channelFoam.CGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Application 00026 channelFoam 00027 00028 Description 00029 Incompressible LES solver for flow in a channel. 00030 00031 \*---------------------------------------------------------------------------*/ 00032 00033 #include "fvCFD.H" 00034 #include "singlePhaseTransportModel.H" 00035 #include "LESModel.H" 00036 #include "IFstream.H" 00037 #include "OFstream.H" 00038 #include "Random.H" 00039 00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00041 00042 int main(int argc, char *argv[]) 00043 { 00044 #include "setRootCase.H" 00045 #include "createTime.H" 00046 #include "createMesh.H" 00047 #include "readTransportProperties.H" 00048 #include "createFields.H" 00049 #include "initContinuityErrs.H" 00050 #include "createGradP.H" 00051 00052 Info<< "\nStarting time loop\n" << endl; 00053 00054 while (runTime.loop()) 00055 { 00056 Info<< "Time = " << runTime.timeName() << nl << endl; 00057 00058 #include "readPISOControls.H" 00059 00060 #include "CourantNo.H" 00061 00062 sgsModel->correct(); 00063 00064 fvVectorMatrix UEqn 00065 ( 00066 fvm::ddt(U) 00067 + fvm::div(phi, U) 00068 + sgsModel->divDevBeff(U) 00069 == 00070 flowDirection*gradP 00071 ); 00072 00073 if (momentumPredictor) 00074 { 00075 solve(UEqn == -fvc::grad(p)); 00076 } 00077 00078 00079 // --- PISO loop 00080 00081 volScalarField rUA = 1.0/UEqn.A(); 00082 00083 for (int corr=0; corr<nCorr; corr++) 00084 { 00085 U = rUA*UEqn.H(); 00086 phi = (fvc::interpolate(U) & mesh.Sf()) 00087 + fvc::ddtPhiCorr(rUA, U, phi); 00088 00089 adjustPhi(phi, U, p); 00090 00091 for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) 00092 { 00093 fvScalarMatrix pEqn 00094 ( 00095 fvm::laplacian(rUA, p) == fvc::div(phi) 00096 ); 00097 00098 pEqn.setReference(pRefCell, pRefValue); 00099 00100 if (corr == nCorr-1 && nonOrth == nNonOrthCorr) 00101 { 00102 pEqn.solve(mesh.solver(p.name() + "Final")); 00103 } 00104 else 00105 { 00106 pEqn.solve(mesh.solver(p.name())); 00107 } 00108 00109 if (nonOrth == nNonOrthCorr) 00110 { 00111 phi -= pEqn.flux(); 00112 } 00113 } 00114 00115 #include "continuityErrs.H" 00116 00117 U -= rUA*fvc::grad(p); 00118 U.correctBoundaryConditions(); 00119 } 00120 00121 00122 // Correct driving force for a constant mass flow rate 00123 00124 // Extract the velocity in the flow direction 00125 dimensionedScalar magUbarStar = 00126 (flowDirection & U)().weightedAverage(mesh.V()); 00127 00128 // Calculate the pressure gradient increment needed to 00129 // adjust the average flow-rate to the correct value 00130 dimensionedScalar gragPplus = 00131 (magUbar - magUbarStar)/rUA.weightedAverage(mesh.V()); 00132 00133 U += flowDirection*rUA*gragPplus; 00134 00135 gradP += gragPplus; 00136 00137 Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab 00138 << "pressure gradient = " << gradP.value() << endl; 00139 00140 runTime.write(); 00141 00142 #include "writeGradP.H" 00143 00144 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 00145 << " ClockTime = " << runTime.elapsedClockTime() << " s" 00146 << nl << endl; 00147 } 00148 00149 Info<< "End\n" << endl; 00150 00151 return 0; 00152 } 00153 00154 00155 // ************************************************************************* // |