1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 #include "dictionary.H"
34 #include "scalarField.H"
35 #include "chemPoint.H"
36 #include "binaryNode.H"
40 // #define debugCheckSolution
47 const scalarField& v0,
49 const scalarField& tolerances,
50 const scalarField& tolerancesSolutions,
60 EOA_(tolerances.size()),
61 solutionsEOA_(tolerancesSolutions.size()),
72 if(tolerances[i] == 0)
78 EOA_[i] = absErr * tolerances[i];
82 forAll(tolerancesSolutions, i)
84 if(tolerances[i] == 0)
86 solutionsEOA_[i] = GREAT;
90 solutionsEOA_[i] = absErr * tolerancesSolutions[i];
99 const scalarField& v0,
100 const scalarField& r,
101 const scalarField& tolerances,
102 const scalarField& tolerancesSolutions,
103 const scalar& absErr,
105 const scalar& deltaT,
113 EOA_(tolerances.size()),
114 solutionsEOA_(tolerancesSolutions.size()),
121 forAll(tolerances, i)
123 if(tolerances[i] == 0)
129 EOA_[i] = absErr * tolerances[i];
133 forAll(tolerancesSolutions, i)
135 if(tolerancesSolutions[i] == 0)
137 solutionsEOA_[i] = 0.0;
141 solutionsEOA_[i] = absErr * tolerancesSolutions[i];
159 solutionsEOA_(p.solutionsEOA()),
163 timeEOA_(p.timeEOA())
176 solutionsEOA_(p.solutionsEOA()),
180 timeEOA_(p.timeEOA())
183 bool chemPoint::inEOA
185 const scalarField& point,
186 const scalarField& Wi,
188 const scalar& deltaT,
189 const scalarField& scaleFactor
198 label size = point.size();
202 for(label i=0; i < size; i++)
206 if(i == size-2 && logT_)
208 scalar diffAxis = sqr(Foam::scalar(mag(log(point[i])-log(v0_[i]))))/sqr(EOA_[i]) ;
211 else if(i == size-2 && !logT_)
213 scalar diffAxis = sqr(Foam::scalar(mag((point[i])-(v0_[i])))) / sqr(EOA_[i]) ;
218 scalar diffAxis = sqr(Foam::scalar(mag((point[i]-v0_[i])))) / sqr(EOA_[i]) ;
224 scalar diffAxis = sqr(Foam::scalar(mag((point[i]-v0_[i])))) / sqr(EOA_[i]) ;
243 const scalarField& v0,
244 const scalarField& Wi,
246 const scalarField& v,
251 label size = v.size();
253 for(label i=0; i < size-2; i++)
255 if(i == size-2 && logT_)
257 scalar diffAxis = Foam::scalar(mag(log(v0[i])-log(v0_[i]))) - EOA_[i] ;
259 if(diffAxis > Foam::VSMALL)
261 EOA_[i] = mag(log(v0[i])-log(v0_[i]));
264 else if(i == size-2 && !logT_)
266 scalar diffAxis = Foam::scalar(mag((v0[i])-(v0_[i]))) - EOA_[i] ;
268 if(diffAxis > Foam::VSMALL)
270 EOA_[i] = mag((v0[i])-(v0_[i]));
275 scalar diffAxis = Foam::scalar(mag((v0[i]-v0_[i]))) - EOA_[i] ;
277 if(diffAxis > Foam::VSMALL)
279 EOA_[i] = mag((v0[i]-v0_[i]));
285 timeEOA_ = Foam::scalar(mag(deltaT_ - deltaT));
289 bool chemPoint::checkSolution
291 const scalarField& v0,
292 const scalarField& v,
293 const scalarField& Wi,
297 const scalar& deltaT,
298 const scalarField& tolerances
302 label size = v.size();
318 for(label i=0; i < size; i++)
320 if(i == size-2 && logT_)
322 scalar diffAxis = (Foam::scalar(mag(log(s[i])-log(r_[i])))) / (solutionsEOA_[i]) ;
323 eps2 += sqr(diffAxis);
325 else if(i == size-2 && !logT_)
327 scalar diffAxis = (Foam::scalar(mag(s[i]-r_[i]))) / (solutionsEOA_[i]) ;
328 eps2 += sqr(diffAxis);
332 scalar diffAxis = (Foam::scalar(mag(s[i]-r_[i]))) / (solutionsEOA_[i]) ;
333 eps2 += sqr(diffAxis);
337 scalar diffAxis = (Foam::scalar(mag((s[i]*Wi[i]/rhoi-r_[i])))) / (solutionsEOA_[i]) ;
338 eps2 += sqr(diffAxis);
348 // if the solution is in the ellipsoid of accuracy, grow it!
349 grow(v0, Wi, rhoi, s, deltaT);
356 void chemPoint::setFree()
364 solutionsEOA_.clear();
372 void chemPoint::clearData()
375 // Info << "nUsed" << endl;
377 // Info << "v0.clear" << endl;
379 // Info << "r_.clear()" << endl;
381 // Info << "EOA_.clear()" << endl;
382 solutionsEOA_.clear();
383 // Info << "solutionsEOA_.clear()" << endl;
385 // Info << "absErr_ = 0" << endl;
387 // Info << "logT_ = 0" << endl;
389 // Info << "deltaT_ = 0;" << endl;
392 // Info << "chemPoint::clearData():: ENDDDDDD!" << endl;