FreeFOAM The Cross-Platform CFD Toolkit
icoErrorEstimate.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  icoErrorEstimate
26 
27 Description
28  Estimates error for the incompressible laminar CFD application icoFoam.
29 
30 Usage
31 
32  - icoErrorEstimate [OPTIONS]
33 
34  @param -noZero \n
35  Ignore timestep 0.
36 
37  @param -constant \n
38  Include the constant directory.
39 
40  @param -time <time>\n
41  Apply only to specific time.
42 
43  @param -latestTime \n
44  Only apply to latest time step.
45 
46  @param -case <dir>\n
47  Case directory.
48 
49  @param -parallel \n
50  Run in parallel.
51 
52  @param -help \n
53  Display help message.
54 
55  @param -doc \n
56  Display Doxygen API documentation page for this application.
57 
58  @param -srcDoc \n
59  Display Doxygen source documentation page for this application.
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #include <finiteVolume/fvCFD.H>
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 int main(int argc, char *argv[])
70 {
71  timeSelector::addOptions();
72 
73 # include <OpenFOAM/setRootCase.H>
74 # include <OpenFOAM/createTime.H>
75 
76  instantList timeDirs = timeSelector::select0(runTime, args);
77 
78 # include <OpenFOAM/createMesh.H>
79 
80  Info<< "\nEstimating error in the incompressible momentum equation\n"
81  << "Reading transportProperties\n" << endl;
82 
84  (
85  IOobject
86  (
87  "transportProperties",
88  runTime.constant(),
89  mesh,
90  IOobject::MUST_READ,
91  IOobject::NO_WRITE
92  )
93  );
94 
96  (
98  );
99 
100  forAll(timeDirs, timeI)
101  {
102  runTime.setTime(timeDirs[timeI], timeI);
103 
104  Info<< "Time = " << runTime.timeName() << endl;
105 
106  mesh.readUpdate();
107 
108  IOobject pHeader
109  (
110  "p",
111  runTime.timeName(),
112  mesh,
113  IOobject::MUST_READ
114  );
115 
116  IOobject Uheader
117  (
118  "U",
119  runTime.timeName(),
120  mesh,
121  IOobject::MUST_READ
122  );
123 
124  if (pHeader.headerOk() && Uheader.headerOk())
125  {
126  Info << "Reading p" << endl;
127  volScalarField p(pHeader, mesh);
128 
129  Info << "Reading U" << endl;
130  volVectorField U(Uheader, mesh);
131 
132 # include <finiteVolume/createPhi.H>
133 
135  (
138  ==
139  -fvc::grad(p)
140  );
141 
142  volVectorField e = ee.error();
143  e.write();
144  mag(e)().write();
145  }
146  else
147  {
148  Info<< " No p or U" << endl;
149  }
150 
151  Info<< endl;
152  }
153 
154  Info<< "End\n" << endl;
155 
156  return 0;
157 }
158 
159 
160 // ************************ vim: set sw=4 sts=4 et: ************************ //