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

icoErrorEstimate.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     icoErrorEstimate
00027 
00028 Description
00029     Estimates error for the incompressible laminar CFD application icoFoam.
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #include "fvCFD.H"
00034 #include "errorEstimate.H"
00035 #include "resError.H"
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 int main(int argc, char *argv[])
00040 {
00041     timeSelector::addOptions();
00042 
00043 #   include "setRootCase.H"
00044 #   include "createTime.H"
00045 
00046     instantList timeDirs = timeSelector::select0(runTime, args);
00047 
00048 #   include "createMesh.H"
00049 
00050     Info<< "\nEstimating error in the incompressible momentum equation\n"
00051         << "Reading transportProperties\n" << endl;
00052 
00053     IOdictionary transportProperties
00054     (
00055         IOobject
00056         (
00057             "transportProperties",
00058             runTime.constant(),
00059             mesh,
00060             IOobject::MUST_READ,
00061             IOobject::NO_WRITE
00062         )
00063     );
00064 
00065     dimensionedScalar nu
00066     (
00067         transportProperties.lookup("nu")
00068     );
00069 
00070     forAll(timeDirs, timeI)
00071     {
00072         runTime.setTime(timeDirs[timeI], timeI);
00073 
00074         Info<< "Time = " << runTime.timeName() << endl;
00075 
00076         mesh.readUpdate();
00077 
00078         IOobject pHeader
00079         (
00080             "p",
00081             runTime.timeName(),
00082             mesh,
00083             IOobject::MUST_READ
00084         );
00085 
00086         IOobject Uheader
00087         (
00088             "U",
00089             runTime.timeName(),
00090             mesh,
00091             IOobject::MUST_READ
00092         );
00093 
00094         if (pHeader.headerOk() && Uheader.headerOk())
00095         {
00096             Info << "Reading p" << endl;
00097             volScalarField p(pHeader, mesh);
00098 
00099             Info << "Reading U" << endl;
00100             volVectorField U(Uheader, mesh);
00101 
00102 #           include "createPhi.H"
00103 
00104             errorEstimate<vector> ee
00105             (
00106                 resError::div(phi, U)
00107               - resError::laplacian(nu, U)
00108              ==
00109                -fvc::grad(p)
00110             );
00111 
00112             volVectorField e = ee.error();
00113             e.write();
00114             mag(e)().write();
00115         }
00116         else
00117         {
00118             Info<< "    No p or U" << endl;
00119         }
00120 
00121         Info<< endl;
00122     }
00123 
00124     Info<< "End\n" << endl;
00125 
00126     return 0;
00127 }
00128 
00129 
00130 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd