1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Estimates error for the incompressible laminar CFD application icoFoam.
30 \*---------------------------------------------------------------------------*/
34 #include "gaussConvectionScheme.H"
35 #include "gaussLaplacianScheme.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 int main(int argc, char *argv[])
41 timeSelector::addOptions();
43 # include "setRootCase.H"
44 # include "createTime.H"
46 instantList timeDirs = timeSelector::select0(runTime, args);
48 # include "createMesh.H"
50 Info<< "\nEstimating error in the incompressible momentum equation\n"
51 << "Reading transportProperties\n" << endl;
53 IOdictionary transportProperties
57 "transportProperties",
67 transportProperties.lookup("nu")
70 forAll(timeDirs, timeI)
72 runTime.setTime(timeDirs[timeI], timeI);
74 Info<< "Time = " << runTime.timeName() << endl;
94 if (pHeader.headerOk() && Uheader.headerOk())
96 Info << "Reading p" << endl;
97 volScalarField p(pHeader, mesh);
99 Info << "Reading U" << endl;
100 volVectorField U(Uheader, mesh);
102 # include "createPhi.H"
104 volScalarField ek = 0.5*magSqr(U);
105 volTensorField gradU = fvc::grad(U);
107 // Divergence of the error in U squared
114 mesh.time().timeName(),
120 dimensionedScalar("one", dimLength, 1.0)
124 mesh.V()/fvc::surfaceSum(mesh.magSf())().internalField();
126 // Warning: 4th row of this equation specially modified
127 // for the momentum equation. The "real" formulation would
128 // have diffusivity*(gradV && gradV)
129 volScalarField momError
133 "momErrorL" + U.name(),
134 mesh.time().timeName(),
144 fv::gaussConvectionScheme<scalar>
148 tmp<surfaceInterpolationScheme<scalar> >
150 new linear<scalar>(mesh)
155 fv::gaussLaplacianScheme<scalar, scalar>(mesh)
161 // + nu*(gradU && gradU)
164 gradU && (gradU + gradU.T())
171 momError.boundaryField() = 0.0;
176 Info<< " No p or U" << endl;
182 Info<< "End\n" << endl;
188 // ************************************************************************* //