1#ifndef DUNE_FEM_SOLVER_RUNGEKUTTA_SEMIIMPLICIT_HH 
    2#define DUNE_FEM_SOLVER_RUNGEKUTTA_SEMIIMPLICIT_HH 
   13#include <dune/fem/solver/rungekutta/basicimplicit.hh> 
   14#include <dune/fem/solver/rungekutta/butchertable.hh> 
   15#include <dune/fem/solver/rungekutta/timestepcontrol.hh> 
   23  template< 
class ExplicitOperator >
 
   24  class SemiImplicitRungeKuttaSourceTerm
 
   26    typedef SemiImplicitRungeKuttaSourceTerm< ExplicitOperator > ThisType;
 
   29    typedef ExplicitOperator ExplicitOperatorType;
 
   31    typedef typename ExplicitOperatorType::DestinationType DestinationType;
 
   33    template< 
class ButcherTable >
 
   34    SemiImplicitRungeKuttaSourceTerm ( ExplicitOperatorType &explicitOp,
 
   35                                       const ButcherTable &butcherTable,
 
   37    : explicitOp_( explicitOp ),
 
   38      alpha_( butcherTable.A() ),
 
   39      gamma_( butcherTable.stages() ),
 
   40      c_( butcherTable.c() ),
 
   41      uex_( 
"SIRK u-explicit", explicitOp_.space() ),
 
   42      limiter_( explicitOp_.hasLimiter() )
 
   46      alpha_.rightmultiply( Ainv );
 
   48      for( 
int i = 0; i < butcherTable.stages(); ++i )
 
   51        for( 
int j = 0; j < i; ++j )
 
   52          gamma_[ i ] -= alpha_[ i ][ j ];
 
   56    bool operator() ( 
double time, 
double timeStepSize, 
int stage,
 
   57                      const DestinationType &u, 
const std::vector< DestinationType * > &update,
 
   58                      DestinationType &source )
 
   61      uex_ *= gamma_[ stage ];
 
   62      for( 
int k = 0; k < stage; ++k )
 
   63        uex_.axpy( alpha_[ stage ][ k ], *update[ k ] );
 
   64      explicitOp_.setTime( time + c_[ stage ]*timeStepSize );
 
   65      explicitOp_( uex_, source );
 
   70    void limit( DestinationType& update, 
const double time )
 
   75        explicitOp_.setTime( time );
 
   77        uex_.assign( update );
 
   79        explicitOp_.limit( uex_, update );
 
   83    double initialTimeStepEstimate ( 
double time, 
const DestinationType &u )
 const 
   85      explicitOp_.setTime( time );
 
   86      explicitOp_.initializeTimeStepSize( u );
 
   87      return explicitOp_.timeStepEstimate();
 
   90    double timeStepEstimate ()
 const 
   92      return explicitOp_.timeStepEstimate();
 
   96    ExplicitOperatorType &explicitOp_;
 
  100    const bool limiter_ ;
 
  109  template< 
class ExplicitOperator, 
class HelmholtzOperator, 
class NonlinearSolver >
 
  111  : 
public BasicImplicitRungeKuttaSolver< HelmholtzOperator, NonlinearSolver, ImplicitRungeKuttaTimeStepControl, SemiImplicitRungeKuttaSourceTerm< ExplicitOperator > >
 
  117    typedef ExplicitOperator ExplicitOperatorType;
 
  118    typedef HelmholtzOperator HelmholtzOperatorType;
 
  119    typedef typename BaseType::TimeStepControlType TimeStepControlType;
 
  120    typedef typename BaseType::SourceTermType SourceTermType;
 
  123    typedef typename BaseType::ParameterType                  ParameterType;
 
  124    typedef typename BaseType::NonlinearSolverParameterType   NonlinearSolverParameterType;
 
  136                                   HelmholtzOperatorType &helmholtzOp,
 
  138                                   const ParameterType& tscParams,
 
  139                                   const NonlinearSolverParameterType& nlsParams )
 
  141                defaultButcherTable( order, false ),
 
  142                TimeStepControlType( timeProvider, tscParams ),
 
  143                SourceTermType( explicitOp, defaultButcherTable( order, true ), defaultButcherTable( order, false ).A() ),
 
  148                                   HelmholtzOperatorType &helmholtzOp,
 
  149                                   TimeProviderType &timeProvider,
 
  151                                   const Dune::Fem::ParameterReader ¶meter = Dune::Fem::Parameter::container() )
 
  152    : BaseType( helmholtzOp,
 
  153                defaultButcherTable( order, false ),
 
  154                TimeStepControlType( timeProvider, parameter ),
 
  155                SourceTermType( explicitOp, defaultButcherTable( order, true ), defaultButcherTable( order, false ).A() ),
 
  156                NonlinearSolverParameterType( parameter ) )
 
  168                                   HelmholtzOperatorType &helmholtzOp,
 
  170                                   const ParameterType& tscParams,
 
  171                                   const NonlinearSolverParameterType& nlsParams )
 
  173                defaultButcherTable( 1, false ),
 
  174                TimeStepControlType( timeProvider, tscParams ),
 
  175                SourceTermType( explicitOp, defaultButcherTable( 1, true ), defaultButcherTable( 1, false ).A() ),
 
  180                                   HelmholtzOperatorType &helmholtzOp,
 
  181                                   TimeProviderType &timeProvider,
 
  182                                   const Dune::Fem::ParameterReader ¶meter = Dune::Fem::Parameter::container() )
 
  183    : BaseType( helmholtzOp,
 
  184                defaultButcherTable( 1, false ),
 
  185                TimeStepControlType( timeProvider, parameter ),
 
  186                SourceTermType( explicitOp, defaultButcherTable( 1, true ), defaultButcherTable( 1, false ).A() ),
 
  187                NonlinearSolverParameterType( parameter ) )
 
  192                                   HelmholtzOperatorType &helmholtzOp,
 
  193                                   TimeProviderType &timeProvider,
 
  194                                   const SimpleButcherTable< double >& explButcherTable,
 
  195                                   const SimpleButcherTable< double >& implButcherTable,
 
  196                                   const Dune::Fem::ParameterReader ¶meter = Dune::Fem::Parameter::container() )
 
  197    : BaseType( helmholtzOp,
 
  199                TimeStepControlType( timeProvider, parameter ),
 
  200                SourceTermType( explicitOp, explButcherTable, implButcherTable.A() ),
 
  201                NonlinearSolverParameterType( parameter ) )
 
  204    static SimpleButcherTable< double > defaultButcherTable ( 
int order, 
bool expl )
 
  209        return semiImplicitEulerButcherTable( expl );
 
  211        return semiImplicitSSP222ButcherTable( expl );
 
  213        return semiImplicit33ButcherTable( expl );
 
  215        return semiImplicitIERK45ButcherTable( expl );
 
  217        DUNE_THROW( NotImplemented, 
"Semi-implicit Runge-Kutta method of order " << order << 
" not implemented." );
 
Implicit RungeKutta ODE solver.
Definition: basicimplicit.hh:54
 
Implicit RungeKutta ODE solver.
Definition: semiimplicit.hh:112
 
SemiImplicitRungeKuttaSolver(ExplicitOperatorType &explicitOp, HelmholtzOperatorType &helmholtzOp, TimeProviderType &timeProvider, const ParameterType &tscParams, const NonlinearSolverParameterType &nlsParams)
constructor
Definition: semiimplicit.hh:167
 
SemiImplicitRungeKuttaSolver(ExplicitOperatorType &explicitOp, HelmholtzOperatorType &helmholtzOp, TimeProviderType &timeProvider, int order, const ParameterType &tscParams, const NonlinearSolverParameterType &nlsParams)
constructor
Definition: semiimplicit.hh:135
 
general base for time providers
Definition: timeprovider.hh:36
 
A few common exception classes.
 
This file implements a dense matrix with dynamic numbers of rows and columns.
 
This file implements a dense vector with a dynamic size.
 
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314