43 #ifndef TIMEADVANCEBDF_H 44 #define TIMEADVANCEBDF_H 1
49 #include <lifev/core/fem/TimeAdvance.hpp> 139 template<
typename feVectorType = VectorEpetra >
141 public TimeAdvance < feVectorType >
149 typedef TimeAdvance< feVectorType >
super;
218 void setup (
const UInt& order,
const UInt& orderDerivative = 1 );
226 ERROR_MSG (
"use setup for TimeAdvanceNewmark but the time advance scheme is BDF");
240 ERROR_MSG (
"this method is not yet implemented" );
246 ERROR_MSG (
"this method is not yet implemented" );
303 template<
typename feVectorType>
312 template<
typename feVectorType>
316 ASSERT (
this->M_unknowns.size() ==
this->M_size,
317 "M_unknowns.size() and M_size must be equal" );
325 for ( ; it != itb; --it )
335 template<
typename feVectorType>
340 rhsContribution *= (
this->M_alpha[ 1 ] / timeStep);
342 for (
UInt i = 1; i <
this->M_order; ++i )
344 rhsContribution += (
this->M_alpha[ i + 1 ] / timeStep) * *
this->M_unknowns[ i ];
349 template<
typename feVectorType>
353 ASSERT (
this->M_orderDerivative == 2 ,
354 " M_orderDerivative must be equal two" );
360 ** it *=
this->M_xi[ 1 ] / (timeStep * timeStep);
362 for (
UInt i = 1; i <
this->M_order + 1; ++i )
364 **it += (
this->M_xi[ i + 1 ] / (timeStep * timeStep) ) * *
this->M_unknowns[ i ];
368 template<
typename feVectorType>
372 output <<
"*** BDF Time discretization of order " <<
this->M_order <<
" maximum order of derivate " <<
this->M_orderDerivative <<
" ***" 374 output <<
" Coefficients: " << std::endl;
375 for ( UInt i = 0; i <
this->M_order + 1; ++i )
376 output <<
" alpha(" << i <<
") = " <<
this->M_alpha[ i ]
378 for ( UInt i = 0; i <
this->M_order; ++i )
379 output <<
" beta (" << i <<
") = " <<
this->M_beta[ i ]
381 if (
this->M_orderDerivative == 2)
383 for (
UInt i = 0; i <
this->M_order +
this->M_orderDerivative; ++i )
385 output <<
" xi(" << i <<
") = " <<
this->M_xi[ i ] << std::endl;
387 for ( UInt i = 0; i <
this->M_order + 1; ++i )
388 output <<
" beta of the extrapolation of the first derivative (" 389 << i <<
") = " <<
this->M_betaFirstDerivative[ i ]
392 output <<
"Delta Time : " <<
this->M_timeStep <<
"\n";
393 output <<
"*************************************\n";
401 template<
typename feVectorType>
407 std::ostringstream __ex;
408 __ex <<
"Error: wrong BDF order\n" 409 <<
" you want to use BDF order " << order <<
"\n" 410 <<
" we support BDF order from 1 to " << BDF_MAX_ORDER <<
"\n";
411 throw std::invalid_argument ( __ex.str() );
414 this->M_order = order ;
415 this->M_orderDerivative = orderDerivative ;
416 this->M_size = order ;
417 this->M_alpha.resize ( order + 1 );
418 this->M_xi.resize ( order + 2 );
419 this->M_beta.resize ( order );
420 this->M_betaFirstDerivative.resize ( order + 1 );
421 this->M_coefficientsSize = order + orderDerivative;
426 this->M_alpha[ 0 ] = 1.;
427 this->M_alpha[ 1 ] = 1.;
428 this->M_beta[ 0 ] = 1.;
429 this->M_xi[ 0 ] = 1.;
430 this->M_xi[ 1 ] = 2.;
431 this->M_xi[ 2 ] = -1.;
432 this->M_betaFirstDerivative[0] = 2.;
433 this->M_betaFirstDerivative[0] = -1.;
436 this->M_alpha[ 0 ] = 3. / 2.;
437 this->M_alpha[ 1 ] = 2.;
438 this->M_alpha[ 2 ] = -1. / 2.;
439 this->M_beta[ 0 ] = 2.;
440 this->M_beta[ 1 ] = -1.;
441 this->M_xi[ 0 ] = 2.;
442 this->M_xi[ 1 ] = 5.;
443 this->M_xi[ 2 ] = -4.;
444 this->M_xi[ 3 ] = 1.;
445 this->M_betaFirstDerivative[0] = 3.;
446 this->M_betaFirstDerivative[1] = -3.;
447 this->M_betaFirstDerivative[2] = 1.;
450 this->M_alpha[ 0 ] = 11. / 6.;
451 this->M_alpha[ 1 ] = 3.;
452 this->M_alpha[ 2 ] = -3. / 2.;
453 this->M_alpha[ 3 ] = 1. / 3.;
454 this->M_beta[ 0 ] = 3.;
455 this->M_beta[ 1 ] = -3.;
456 this->M_beta[ 2 ] = 1.;
457 this->M_xi[ 0 ] = 35. / 12.;
458 this->M_xi[ 1 ] = 26. / 3.;
459 this->M_xi[ 2 ] = -19. / 2;
460 this->M_xi[ 3 ] = 14. / 3.;
461 this->M_xi[ 4 ] = -11. / 12.;
462 this->M_betaFirstDerivative[0] = 4.;
463 this->M_betaFirstDerivative[ 1 ] = -6.;
464 this->M_betaFirstDerivative[ 2 ] = 4.;
465 this->M_betaFirstDerivative[ 3 ] = -1.;
468 this->M_alpha[ 0 ] = 25. / 12.;
469 this->M_alpha[ 1 ] = 4.;
470 this->M_alpha[ 2 ] = -3. ;
471 this->M_alpha[ 3 ] = 4. / 3.;
472 this->M_alpha[ 4 ] = - 1 / 4.;
473 this->M_beta[ 0 ] = 4.;
474 this->M_beta[ 1 ] = -6.;
475 this->M_beta[ 2 ] = 4.;
476 this->M_beta[ 3 ] = -1;
477 this->M_xi[ 0 ] = 15. / 4.;
478 this->M_xi[ 1 ] = 77. / 6.;
479 this->M_xi[ 2 ] = -107. / 6.;
480 this->M_xi[ 3 ] = 13.;
481 this->M_xi[ 4 ] = -61. / 12.;
482 this->M_xi[ 5 ] = 5. / 6.;
483 this->M_betaFirstDerivative[ 0 ] = 5.;
484 this->M_betaFirstDerivative[ 1 ] = -10.;
485 this->M_betaFirstDerivative[ 2 ] = 10.;
486 this->M_betaFirstDerivative[ 3 ] = -5.;
487 this->M_betaFirstDerivative[ 4 ] = 1.;
490 this->M_alpha[ 0 ] = 137. / 60.;
491 this->M_alpha[ 1 ] = 5.;
492 this->M_alpha[ 2 ] = -5. ;
493 this->M_alpha[ 3 ] = 10. / 3.;
494 this->M_alpha[ 4 ] = -5. / 4.;
495 this->M_alpha[ 5 ] = 1. / 5.;
496 this->M_beta[ 0 ] = 5.;
497 this->M_beta[ 1 ] = -10.;
498 this->M_beta[ 2 ] = 10.;
499 this->M_beta[ 3 ] = -5.;
500 this->M_beta[ 4 ] = 1.;
501 this->M_xi[ 0 ] = 203. / 45.;
502 this->M_xi[ 1 ] = 87. / 5.;
503 this->M_xi[ 2 ] = -117. / 4.;
504 this->M_xi[ 3 ] = 254. / 9.;
505 this->M_xi[ 4 ] = -33. / 2.;
506 this->M_xi[ 5 ] = 27. / 5.;
507 this->M_xi[ 6 ] = -137. / 180.;
508 this->M_betaFirstDerivative[ 0 ] = 6.;
509 this->M_betaFirstDerivative[ 1 ] = -15. / 2.;
510 this->M_betaFirstDerivative[ 2 ] = 20. / 3.;
511 this->M_betaFirstDerivative[ 3 ] = -15. / 4.;
512 this->M_betaFirstDerivative[ 4 ] = 6. / 5.;
513 this->M_betaFirstDerivative[ 5 ] = -1.;
517 if (
this->M_orderDerivative == 2 )
521 this->M_unknowns.reserve (
this->M_size);
522 this->M_rhsContribution.reserve (2);
525 template<
typename feVectorType>
531 for ( ; iter != iter_end; iter++ )
537 for (
UInt i (
this->M_unknowns.size() ) ; i <
this->M_order; i++ )
544 this->setInitialRHS (zero);
546 ASSERT (
this->M_unknowns.size() ==
this->M_order,
547 "M_unknowns.size() and M_order must be equal" );
550 template<
typename feVectorType>
555 ASSERT ( n0 != 0,
"Initial data are not enough for the selected BDF" );
562 for ( ; iter != iter_end && i < n0 ; ++iter, ++i )
568 for ( i =
this->M_unknowns.size() ; i <
this->M_order && i < n0; ++i )
573 if (
this->M_orderDerivative == 1)
575 for ( i =
this->M_unknowns.size() ; i <
this->M_order; ++i )
577 this->M_unknowns.push_back (
new feVector_Type (*x0[n0 - 1]) );
580 ASSERT (
this->M_unknowns.size() ==
this->M_order,
581 "M_unknowns.size() and M_order must be equal" );
583 if (
this->M_orderDerivative == 2)
585 for ( i =
this->M_unknowns.size() ; i <
this->M_order + 1; ++i )
587 this->M_unknowns.push_back (
new feVector_Type (*x0[n0 - 1]) );
590 ASSERT (
this->M_unknowns.size() ==
this->M_order + 1,
591 "M_unknowns.size() and M_order must be equal" );
597 this->setInitialRHS (zero);
604 template<
typename feVectorType>
609 ASSERT ( i <
this->M_order,
610 "Error in specification of the time derivative coefficient for the BDF formula (out of range error)" );
611 return this->M_beta[ i ];
614 template<
typename feVectorType>
619 ASSERT ( i <
this->M_order,
620 "Error in specification of the time derivative coefficient for the BDF formula (out of range error)" );
621 return this->M_betaFirstDerivative[ i ];
624 template<
typename feVectorType>
628 extrapolation =
this->M_beta[ 0 ] * (*
this->M_unknowns[ 0 ]);
630 for (
UInt i = 1; i <
this->M_order; ++i )
632 extrapolation +=
this->M_beta[ i ] * (*
this->M_unknowns[ i ]);
636 template<
typename feVectorType>
640 ASSERT (
this->M_orderDerivative == 2,
641 "extrapolationFirstDerivative: this method must be used with the second order problem." )
643 extrapolation =
this->M_betaFirstDerivative[ 0 ] * (*
this->M_unknowns[ 0 ]);
645 for (
UInt i = 1; i <
this->M_order; ++i )
647 extrapolation +=
this->M_betaFirstDerivative[ i ] * (*
this->M_unknowns[ i ]);
651 template<
typename feVectorType>
675 return *
this->M_unknowns[0] *
this->M_alpha[ 0 ] /
this->M_timeStep
676 - ( *
this->M_rhsContribution[0] );
679 template<
typename feVectorType>
683 return (*
this->M_unknowns[0]) *
this->M_xi[ 0 ] / (
this->M_timeStep *
this->M_timeStep) - ( *
this->M_rhsContribution[1] );
695 return new TimeAdvanceBDF<VectorEpetra>();
feVectorType firstDerivative() const
Return the current velocity.
void extrapolationFirstDerivative(feVector_Type &extrapolation) const
Compute the polynomial extrapolation of velocity.
void updateRHSSecondDerivative(const Real &timeStep=1)
Update the right hand side of the time derivative formula.
super::feVectorContainerPtr_Type feVectorContainerPtr_Type
container of pointer of feVector;
void setInitialCondition(const feVectorSharedPtrContainer_Type &x0)
Initialize all the entries of the unknown vector to be derived with a.
super::feVectorContainer_Type feVectorContainer_Type
container of feVector
void setInitialCondition(const feVector_Type &x0)
Initialize the StateVector.
static const LifeV::UInt elm_nodes_num[]
TimeAdvance< feVectorType > super
class super
feVectorContainerPtr_Type::iterator feVectorContainerPtrIterate_Type
iterator;
Real coefficientExtrapolationFirstDerivative(const UInt &i) const
Return the -th coefficient of the velocity's extrapolation.
class TimeAdvanceBDF - Backward differencing formula time discretization for the first and the second...
void extrapolation(feVector_Type &extrapolation) const
Compute the polynomial extrapolation of solution.
Real coefficientExtrapolation(const UInt &i) const
Return the -th coefficient of the unk's extrapolation.
void setInitialCondition(const feVector_Type &, const feVector_Type &, const feVector_Type &)
Initialize the StateVector used in TimeAdvanceNewmark.
void showMe(std::ostream &output=std::cout) const
Show the properties of temporal scheme.
void setup(const UInt &order, const UInt &orderDerivative=1)
Initialize the parameters of time advance scheme.
super::feVectorSharedPtrContainer_Type feVectorSharedPtrContainer_Type
container of pointer of feVector;
double Real
Generic real data.
void RHSFirstDerivative(const Real &timeStep, feVectorType &rhsContribution) const
Update the right hand side of the time derivative formula.
TimeAdvanceBDF()
Empty Constructor.
void shiftRight(const feVector_Type &solution)
Update the state vector.
virtual ~TimeAdvanceBDF()
Destructor.
feVectorType secondDerivative() const
Return the current acceleration.
super::feVector_Type feVector_Type
type of template
TimeAdvance< VectorEpetra > * createBDF()
define the BDF factory; this class runs only the default template parameter.
void setup(const std::vector< Real > &, const UInt &)
Initialize the parameters of time advance scheme used in TimeAdvanceNewmark.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
void setInitialCondition(const feVector_Type &, const feVector_Type &)
Initialize the StateVector used in TimeAdvanceNewmark.