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/>.
26 \*---------------------------------------------------------------------------*/
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 #include "dictionary.H"
33 #include "scalarField.H"
34 #include "chemPoint.H"
35 #include "binaryNode.H"
39 // #define debugCheckSolution
46 const scalarField& v0,
48 const scalarField& tolerances,
49 const scalarField& tolerancesSolutions,
59 EOA_(tolerances.size()),
60 solutionsEOA_(tolerancesSolutions.size()),
71 if(tolerances[i] == 0)
77 EOA_[i] = absErr * tolerances[i];
81 forAll(tolerancesSolutions, i)
83 if(tolerances[i] == 0)
85 solutionsEOA_[i] = GREAT;
89 solutionsEOA_[i] = absErr * tolerancesSolutions[i];
98 const scalarField& v0,
100 const scalarField& tolerances,
101 const scalarField& tolerancesSolutions,
102 const scalar& absErr,
104 const scalar& deltaT,
112 EOA_(tolerances.size()),
113 solutionsEOA_(tolerancesSolutions.size()),
120 forAll(tolerances, i)
122 if(tolerances[i] == 0)
128 EOA_[i] = absErr * tolerances[i];
132 forAll(tolerancesSolutions, i)
134 if(tolerancesSolutions[i] == 0)
136 solutionsEOA_[i] = 0.0;
140 solutionsEOA_[i] = absErr * tolerancesSolutions[i];
158 solutionsEOA_(p.solutionsEOA()),
162 timeEOA_(p.timeEOA())
175 solutionsEOA_(p.solutionsEOA()),
179 timeEOA_(p.timeEOA())
182 bool chemPoint::inEOA
184 const scalarField& point,
185 const scalarField& Wi,
187 const scalar& deltaT,
188 const scalarField& scaleFactor
197 label size = point.size();
201 for(label i=0; i < size; i++)
205 if(i == size-2 && logT_)
207 scalar diffAxis = sqr(Foam::scalar(mag(log(point[i])-log(v0_[i]))))/sqr(EOA_[i]) ;
210 else if(i == size-2 && !logT_)
212 scalar diffAxis = sqr(Foam::scalar(mag((point[i])-(v0_[i])))) / sqr(EOA_[i]) ;
217 scalar diffAxis = sqr(Foam::scalar(mag((point[i]-v0_[i])))) / sqr(EOA_[i]) ;
223 scalar diffAxis = sqr(Foam::scalar(mag((point[i]-v0_[i])))) / sqr(EOA_[i]) ;
242 const scalarField& v0,
243 const scalarField& Wi,
245 const scalarField& v,
250 label size = v.size();
252 for(label i=0; i < size-2; i++)
254 if(i == size-2 && logT_)
256 scalar diffAxis = Foam::scalar(mag(log(v0[i])-log(v0_[i]))) - EOA_[i] ;
258 if(diffAxis > Foam::VSMALL)
260 EOA_[i] = mag(log(v0[i])-log(v0_[i]));
263 else if(i == size-2 && !logT_)
265 scalar diffAxis = Foam::scalar(mag((v0[i])-(v0_[i]))) - EOA_[i] ;
267 if(diffAxis > Foam::VSMALL)
269 EOA_[i] = mag((v0[i])-(v0_[i]));
274 scalar diffAxis = Foam::scalar(mag((v0[i]-v0_[i]))) - EOA_[i] ;
276 if(diffAxis > Foam::VSMALL)
278 EOA_[i] = mag((v0[i]-v0_[i]));
284 timeEOA_ = Foam::scalar(mag(deltaT_ - deltaT));
288 bool chemPoint::checkSolution
290 const scalarField& v0,
291 const scalarField& v,
292 const scalarField& Wi,
296 const scalar& deltaT,
297 const scalarField& tolerances
301 label size = v.size();
317 for(label i=0; i < size; i++)
319 if(i == size-2 && logT_)
321 scalar diffAxis = (Foam::scalar(mag(log(s[i])-log(r_[i])))) / (solutionsEOA_[i]) ;
322 eps2 += sqr(diffAxis);
324 else if(i == size-2 && !logT_)
326 scalar diffAxis = (Foam::scalar(mag(s[i]-r_[i]))) / (solutionsEOA_[i]) ;
327 eps2 += sqr(diffAxis);
331 scalar diffAxis = (Foam::scalar(mag(s[i]-r_[i]))) / (solutionsEOA_[i]) ;
332 eps2 += sqr(diffAxis);
336 scalar diffAxis = (Foam::scalar(mag((s[i]*Wi[i]/rhoi-r_[i])))) / (solutionsEOA_[i]) ;
337 eps2 += sqr(diffAxis);
347 // if the solution is in the ellipsoid of accuracy, grow it!
348 grow(v0, Wi, rhoi, s, deltaT);
355 void chemPoint::setFree()
363 solutionsEOA_.clear();
371 void chemPoint::clearData()
374 // Info << "nUsed" << endl;
376 // Info << "v0.clear" << endl;
378 // Info << "r_.clear()" << endl;
380 // Info << "EOA_.clear()" << endl;
381 solutionsEOA_.clear();
382 // Info << "solutionsEOA_.clear()" << endl;
384 // Info << "absErr_ = 0" << endl;
386 // Info << "logT_ = 0" << endl;
388 // Info << "deltaT_ = 0;" << endl;
391 // Info << "chemPoint::clearData():: ENDDDDDD!" << endl;