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