icoMomentError.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 "linear.H"
00035 #include "gaussConvectionScheme.H"
00036 #include "gaussLaplacianScheme.H"
00037
00038
00039
00040 int main(int argc, char *argv[])
00041 {
00042 timeSelector::addOptions();
00043
00044 # include "setRootCase.H"
00045 # include "createTime.H"
00046
00047 instantList timeDirs = timeSelector::select0(runTime, args);
00048
00049 # include "createMesh.H"
00050
00051 Info<< "\nEstimating error in the incompressible momentum equation\n"
00052 << "Reading transportProperties\n" << endl;
00053
00054 IOdictionary transportProperties
00055 (
00056 IOobject
00057 (
00058 "transportProperties",
00059 runTime.constant(),
00060 mesh,
00061 IOobject::MUST_READ,
00062 IOobject::NO_WRITE
00063 )
00064 );
00065
00066 dimensionedScalar nu
00067 (
00068 transportProperties.lookup("nu")
00069 );
00070
00071 forAll(timeDirs, timeI)
00072 {
00073 runTime.setTime(timeDirs[timeI], timeI);
00074
00075 Info<< "Time = " << runTime.timeName() << endl;
00076
00077 mesh.readUpdate();
00078
00079 IOobject pHeader
00080 (
00081 "p",
00082 runTime.timeName(),
00083 mesh,
00084 IOobject::MUST_READ
00085 );
00086
00087 IOobject Uheader
00088 (
00089 "U",
00090 runTime.timeName(),
00091 mesh,
00092 IOobject::MUST_READ
00093 );
00094
00095 if (pHeader.headerOk() && Uheader.headerOk())
00096 {
00097 Info << "Reading p" << endl;
00098 volScalarField p(pHeader, mesh);
00099
00100 Info << "Reading U" << endl;
00101 volVectorField U(Uheader, mesh);
00102
00103 # include "createPhi.H"
00104
00105 volScalarField ek = 0.5*magSqr(U);
00106 volTensorField gradU = fvc::grad(U);
00107
00108
00109
00110 volScalarField L
00111 (
00112 IOobject
00113 (
00114 "L",
00115 mesh.time().timeName(),
00116 mesh,
00117 IOobject::NO_READ,
00118 IOobject::NO_WRITE
00119 ),
00120 mesh,
00121 dimensionedScalar("one", dimLength, 1.0)
00122 );
00123
00124 L.internalField() =
00125 mesh.V()/fvc::surfaceSum(mesh.magSf())().internalField();
00126
00127
00128
00129
00130 volScalarField momError
00131 (
00132 IOobject
00133 (
00134 "momErrorL" + U.name(),
00135 mesh.time().timeName(),
00136 mesh,
00137 IOobject::NO_READ,
00138 IOobject::NO_WRITE
00139 ),
00140 sqrt
00141 (
00142 2.0*mag
00143 (
00144 (
00145 fv::gaussConvectionScheme<scalar>
00146 (
00147 mesh,
00148 phi,
00149 tmp<surfaceInterpolationScheme<scalar> >
00150 (
00151 new linear<scalar>(mesh)
00152 )
00153 ).fvcDiv(phi, ek)
00154
00155 - nu*
00156 fv::gaussLaplacianScheme<scalar, scalar>(mesh)
00157 .fvcLaplacian
00158 (
00159 ek
00160 )
00161 - (U & fvc::grad(p))
00162
00163 + 0.5*nu*
00164 (
00165 gradU && (gradU + gradU.T())
00166 )
00167 )*L/(mag(U) + nu/L)
00168 )
00169 )
00170 );
00171
00172 momError.boundaryField() = 0.0;
00173 momError.write();
00174 }
00175 else
00176 {
00177 Info<< " No p or U" << endl;
00178 }
00179
00180 Info<< endl;
00181 }
00182
00183 Info<< "End\n" << endl;
00184
00185 return 0;
00186 }
00187
00188
00189
Copyright © 2000-2009 OpenCFD Ltd