39 #ifndef NonLinearAitken_H 40 #define NonLinearAitken_H 46 #include <lifev/core/LifeV.hpp> 47 #include <lifev/core/util/LifeDebug.hpp> 62 template<
typename VectorType >
133 const bool& independentOmega =
false );
145 const UInt& blocksNumber = 1);
169 M_rangeOmega = omegaRange;
178 M_rangeOmega[0] = std::fabs ( omegaMin );
187 M_rangeOmega[1] = std::fabs ( omegaMax );
273 template <
class VectorType >
286 M_rangeOmega[0] = 0.;
287 M_rangeOmega[1] = 0.;
293 template <
class VectorType >
303 M_oldSolution.reset (
new vector_Type ( solution ) );
304 M_oldResidualSolid.reset (
new vector_Type ( residualSolid ) );
305 M_oldResidualFluid.reset (
new vector_Type ( residualFluid) );
307 #ifdef HAVE_LIFEV_DEBUG 308 debugStream (7020) <<
"NonLinearAitken: omegaFluid = " << M_defaultOmegaFluid <<
" omegaSolid = " << M_defaultOmegaSolid <<
"\n";
317 Real a11 = deltaRFluid * deltaRFluid;
318 Real a21 = deltaRFluid * deltaRSolid;
319 Real a22 = deltaRSolid * deltaRSolid;
321 Real b1 = deltaRFluid * ( solution - *M_oldSolution);
322 Real b2 = deltaRSolid * ( solution - *M_oldSolution);
324 Real det ( a22 * a11 - a21 * a21 );
329 if ( std::fabs ( det ) != 0. )
331 omegaFluid = - ( a22 * b1 - a21 * b2 ) / det;
332 omegaSolid = - ( a11 * b2 - a21 * b1 ) / det;
334 if ( omegaFluid == 0. )
339 if ( omegaSolid == 0. )
344 else if ( std::fabs ( a22 ) == 0. )
346 #ifdef HAVE_LIFEV_DEBUG 347 debugStream (7020) <<
"NonLinearAitken: a22 = " << std::fabs (a22) <<
"\n";
349 omegaFluid = -b1 / a11;
352 else if ( std::fabs (a11) == 0. )
354 #ifdef HAVE_LIFEV_DEBUG 355 debugStream (7020) <<
"NonLinearAitken: a11 = " << std::fabs (a11) <<
"\n";
358 omegaSolid = -b2 / a22;
360 #ifdef HAVE_LIFEV_DEBUG 363 debugStream (7020) <<
"NonLinearAitken: Failure: Det=0!!" << std::fabs (det) <<
"\n";
366 debugStream (7020) <<
" --------------- NonLinearAitken: \n";
367 debugStream (7020) <<
" omegaSolid = " << omegaSolid <<
" omegaFluid = " << omegaFluid <<
"\n";
370 *M_oldSolution = solution;
371 *M_oldResidualFluid = residualFluid;
372 *M_oldResidualSolid = residualSolid;
374 return omegaFluid * residualFluid + omegaSolid * residualSolid;
379 template <
class VectorType >
388 M_oldSolution.reset (
new vector_Type ( solution ) );
389 M_oldResidualFluid.reset (
new vector_Type ( residual ) );
391 #ifdef HAVE_LIFEV_DEBUG 392 debugStream (7020) <<
"NonLinearAitken: omega = " << M_defaultOmegaFluid <<
"\n";
401 deltaX -= *M_oldSolution;
402 deltaR -= *M_oldResidualFluid;
404 *M_oldSolution = solution;
405 *M_oldResidualFluid = residual;
411 omega = deltaX.dot ( deltaX );
412 norm = deltaR.dot ( deltaX );
417 omega = deltaX.dot ( deltaR );
418 norm = deltaR.dot ( deltaR );
421 omega = - omega / norm ;
426 #ifdef HAVE_LIFEV_DEBUG 427 debugStream (7020) <<
"NonLinearAitken: omega = " << omega <<
"\n";
430 return omega * residual;
433 template <
class VectorType >
437 const bool& independentOmega )
443 M_oldSolution.reset (
new vector_Type ( solution ) );
444 M_oldResidualFluid.reset (
new vector_Type ( residual ) );
446 #ifdef HAVE_LIFEV_DEBUG 447 debugStream (7020) <<
"NonLinearAitken: omega = " << M_defaultOmegaFluid <<
"\n";
456 deltaX -= *M_oldSolution;
457 deltaR -= *M_oldResidualFluid;
459 *M_oldSolution = solution;
460 *M_oldResidualFluid = residual;
464 if ( independentOmega )
472 norm = deltaR.dot ( deltaX );
477 norm = deltaR.dot ( deltaR );
483 for (
UInt i (0) ; i <
static_cast<
UInt> ( omega.size() ) ; ++i )
488 #ifdef HAVE_LIFEV_DEBUG 489 debugStream (7020) <<
"NonLinearAitken: omega = " <<
"\n";
498 template <
class VectorType >
503 const UInt& blocksNumber )
509 M_oldSolution.reset (
new vector_Type ( solution ) );
510 M_oldResidualFluid.reset (
new vector_Type ( residual ) );
512 #ifdef HAVE_LIFEV_DEBUG 513 debugStream (7020) <<
"NonLinearAitken: omega = " << M_defaultOmegaFluid <<
"\n";
522 deltaX -= *M_oldSolution;
523 deltaR -= *M_oldResidualFluid;
525 *M_oldSolution = solution;
526 *M_oldResidualFluid = residual;
536 for (
UInt i = 0 ; i < blocksNumber ; ++i )
538 tempVector = blocksVector - i;
539 tempVector = !tempVector;
542 tempDeltaX *= tempVector;
545 tempDeltaR *= tempVector;
550 tempOmega = - ( tempDeltaX.Dot ( tempDeltaX ) ) / ( tempDeltaR.Dot ( tempDeltaX ) );
555 tempOmega = - ( tempDeltaX.Dot ( tempDeltaR ) ) / ( tempDeltaR.Dot ( tempDeltaR ) );
561 omega += tempOmega * tempVector;
564 #ifdef HAVE_LIFEV_DEBUG 565 debugStream (7020) <<
"NonLinearAitken: omega = " <<
"\n";
569 return omega * residual;
575 template <
class VectorType >
591 template <
class VectorType >
598 if ( std::fabs (omega) < std::fabs (M_rangeOmega[0]) / 1024. )
602 omega = -M_rangeOmega[0];
606 omega = M_rangeOmega[0];
609 else if ( std::fabs (omega) > std::fabs (M_rangeOmega[1]) * 1024. )
613 omega = -M_rangeOmega[1];
617 omega = M_rangeOmega[1];
void setOmegaMin(const Real &omegaMin)
Set the minimum of Omega.
vectorPtr_Type M_oldSolution
NonLinearAitken()
Constructor.
virtual ~NonLinearAitken()
Destructor.
void restart()
Reinitialize Omega to the default value.
vector_Type computeDeltaLambdaVectorBlock(const vector_Type &solution, const vector_Type &residual, const vector_Type &blocksVector, const UInt &blocksNumber=1)
Compute Omega * residual - Paragraph 4.2.6 of S. Deparis PhD Thesis.
const Real & defaultOmegaFluid() const
Get the default value of omega fluid.
void setMinimizationType(const bool &inverseOmega)
Set minimization type.
vector_Type computeDeltaLambdaFSI(const vector_Type &solution, const vector_Type &residualFluid, const vector_Type &residualSolid)
Compute OmegaS * deltaRSolid + OmegaF * deltaRFluid.
std::array< Real, 2 > M_rangeOmega
void checkRange(Real &omega)
NonLinearAitken & operator=(const NonLinearAitken &aitken)
void useDefaultOmega(const bool useDefaultOmega=true)
Use default omega.
vector_Type computeDeltaLambdaVector(const vector_Type &solution, const vector_Type &residual, const bool &independentOmega=false)
Compute Omega * residual - Paragraph 4.2.6 of S. Deparis PhD Thesis.
vectorPtr_Type M_oldResidualFluid
NonLinearAitken - LifeV class for the non-linear generalized Aitken algorithm.
std::shared_ptr< vector_Type > vectorPtr_Type
double Real
Generic real data.
vector_Type computeDeltaLambdaScalar(const vector_Type &solution, const vector_Type &residual)
Compute Omega * residual - Paragraph 4.2.3 & 4.2.4 of S. Deparis PhD Thesis.
void setOmegaRange(const std::array< Real, 2 > &omegaRange)
Set the range of Omega.
NonLinearAitken(const NonLinearAitken &aitken)
const Real & defaultOmegaSolid() const
Get the default value of omega solid.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
void setDefaultOmega(const Real &defaultOmegaFluid=0.1, const Real &defaultOmegaSolid=0.1)
Set starting values for Omega.
vectorPtr_Type M_oldResidualSolid
void setOmegaMax(const Real &omegaMax)
Set the maximum of Omega.