OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

estimateScalarError.C

Go 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     estimateScalarError
00027 
00028 Description
00029     Estimates the error in the solution for a scalar transport equation in the
00030     standard form
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #include "fvCFD.H"
00035 #include "errorEstimate.H"
00036 #include "resError.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 scalar transport 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 
00067     Info<< "Reading diffusivity DT\n" << endl;
00068 
00069     dimensionedScalar DT
00070     (
00071         transportProperties.lookup("DT")
00072     );
00073 
00074 
00075     forAll(timeDirs, timeI)
00076     {
00077         runTime.setTime(timeDirs[timeI], timeI);
00078 
00079         Info<< "Time = " << runTime.timeName() << endl;
00080 
00081         mesh.readUpdate();
00082 
00083         IOobject THeader
00084         (
00085             "T",
00086             runTime.timeName(),
00087             mesh,
00088             IOobject::MUST_READ
00089         );
00090 
00091         IOobject Uheader
00092         (
00093             "U",
00094             runTime.timeName(),
00095             mesh,
00096             IOobject::MUST_READ
00097         );
00098 
00099         if (THeader.headerOk() && Uheader.headerOk())
00100         {
00101             Info << "Reading T" << endl;
00102             volScalarField T(THeader, mesh);
00103 
00104             Info << "Reading U" << endl;
00105             volVectorField U(Uheader, mesh);
00106 
00107 #           include "createPhi.H"
00108 
00109             errorEstimate<scalar> ee
00110             (
00111                 resError::div(phi, T)
00112               - resError::laplacian(DT, T)
00113             );
00114 
00115             ee.residual()().write();
00116             volScalarField e = ee.error();
00117             e.write();
00118             mag(e)().write();
00119         }
00120         else
00121         {
00122             Info<< "    No T or U" << endl;
00123         }
00124 
00125         Info<< endl;
00126     }
00127 
00128     Info<< "End\n" << endl;
00129 
00130     return 0;
00131 }
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd