FreeFOAM The Cross-Platform CFD Toolkit
estimateScalarError.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  estimateScalarError
26 
27 Description
28  Estimates the error in the solution for a scalar transport equation in the
29  standard form
30 
31 Usage
32 
33  - estimateScalarError [OPTIONS]
34 
35  @param -noZero \n
36  Ignore timestep 0.
37 
38  @param -constant \n
39  Include the constant directory.
40 
41  @param -time <time>\n
42  Apply only to specific time.
43 
44  @param -latestTime \n
45  Only apply to latest time step.
46 
47  @param -case <dir>\n
48  Case directory.
49 
50  @param -parallel \n
51  Run in parallel.
52 
53  @param -help \n
54  Display help message.
55 
56  @param -doc \n
57  Display Doxygen API documentation page for this application.
58 
59  @param -srcDoc \n
60  Display Doxygen source documentation page for this application.
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #include <finiteVolume/fvCFD.H>
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 int main(int argc, char *argv[])
71 {
72  timeSelector::addOptions();
73 
74 # include <OpenFOAM/setRootCase.H>
75 # include <OpenFOAM/createTime.H>
76 
77  instantList timeDirs = timeSelector::select0(runTime, args);
78 
79 # include <OpenFOAM/createMesh.H>
80 
81  Info<< "\nEstimating error in scalar transport equation\n"
82  << "Reading transportProperties\n" << endl;
83 
85  (
86  IOobject
87  (
88  "transportProperties",
89  runTime.constant(),
90  mesh,
91  IOobject::MUST_READ,
92  IOobject::NO_WRITE
93  )
94  );
95 
96 
97  Info<< "Reading diffusivity DT\n" << endl;
98 
100  (
102  );
103 
104 
105  forAll(timeDirs, timeI)
106  {
107  runTime.setTime(timeDirs[timeI], timeI);
108 
109  Info<< "Time = " << runTime.timeName() << endl;
110 
111  mesh.readUpdate();
112 
113  IOobject THeader
114  (
115  "T",
116  runTime.timeName(),
117  mesh,
118  IOobject::MUST_READ
119  );
120 
121  IOobject Uheader
122  (
123  "U",
124  runTime.timeName(),
125  mesh,
126  IOobject::MUST_READ
127  );
128 
129  if (THeader.headerOk() && Uheader.headerOk())
130  {
131  Info << "Reading T" << endl;
132  volScalarField T(THeader, mesh);
133 
134  Info << "Reading U" << endl;
135  volVectorField U(Uheader, mesh);
136 
137 # include <finiteVolume/createPhi.H>
138 
140  (
142  - resError::laplacian(DT, T)
143  );
144 
145  ee.residual()().write();
146  volScalarField e = ee.error();
147  e.write();
148  mag(e)().write();
149  }
150  else
151  {
152  Info<< " No T or U" << endl;
153  }
154 
155  Info<< endl;
156  }
157 
158  Info<< "End\n" << endl;
159 
160  return 0;
161 }
162 
163 
164 // ************************ vim: set sw=4 sts=4 et: ************************ //