Commit 481bbf8e authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Adding preIterate and postIterate methods.

parent 845b91de
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -76,12 +76,18 @@ class heatEquationSolver
   void bindAuxiliaryDofs( const MeshType& mesh,
                           DofVectorType& auxiliaryDofs );

   bool preIterate( const RealType& time,
                    const RealType& tau,
                    const MeshType& mesh,
                    DofVectorType& u );

   void getExplicitRHS( const RealType& time,
                        const RealType& tau,
                        const MeshType& mesh,
                        DofVectorType& _u,
                        DofVectorType& _fu );


   void assemblyLinearSystem( const RealType& time,
                              const RealType& tau,
                              const MeshType& mesh,
@@ -89,6 +95,12 @@ class heatEquationSolver
                              MatrixType& matrix,
                              DofVectorType& rightHandSide );

   bool postIterate( const RealType& time,
                     const RealType& tau,
                     const MeshType& mesh,
                     DofVectorType& u );


   tnlSolverMonitor< RealType, IndexType >* getSolverMonitor();
   
   protected:
+30 −0
Original line number Diff line number Diff line
@@ -183,6 +183,21 @@ makeSnapshot( const RealType& time,
   return true;
}

template< typename Mesh,
          typename DifferentialOperator,
          typename BoundaryCondition,
          typename RightHandSide >
bool
heatEquationSolver< Mesh, DifferentialOperator, BoundaryCondition, RightHandSide >::
preIterate( const RealType& time,
            const RealType& tau,
            const MeshType& mesh,
            DofVectorType& u )
{
   return true;
}


template< typename Mesh,
          typename DifferentialOperator,
          typename BoundaryCondition,
@@ -245,6 +260,21 @@ assemblyLinearSystem( const RealType& time,
   //abort();
}

template< typename Mesh,
          typename DifferentialOperator,
          typename BoundaryCondition,
          typename RightHandSide >
bool
heatEquationSolver< Mesh, DifferentialOperator, BoundaryCondition, RightHandSide >::
postIterate( const RealType& time,
             const RealType& tau,
             const MeshType& mesh,
             DofVectorType& u )
{
   return true;
}


template< typename Mesh,
          typename DifferentialOperator,
          typename BoundaryCondition,
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ setBoundaryConditions( const RealType& time,
                       DofVectorType& fu )
{
   fu[ index ] = 0;
   u[ index ] = function.getValue( mesh.getCellCenter( coordinates ), time );;
   u[ index ] = function.getValue( mesh.getCellCenter( coordinates ), time );
}

template< typename MeshReal,
+18 −0
Original line number Diff line number Diff line
@@ -112,7 +112,25 @@ void tnlExplicitTimeStepper< Problem, OdeSolver >::getExplicitRHS( const RealTyp
                                                                   DofVectorType& _u,
                                                                   DofVectorType& _fu )
{
   if( ! this->problem->preIterate( time,
                                    tau,
                                    *( this->mesh),
                                    _u ) )
   {
      cerr << endl << "Preiteration failed." << endl;
      return;
      //return false; // TODO: throw exception
   }
   this->problem->getExplicitRHS( time, tau, *( this->mesh ), _u, _fu );
   if( ! this->problem->postIterate( time,
                                     tau,
                                     *( this->mesh ),
                                     _u ) )
   {
      cerr << endl << "Postiteration failed." << endl;
      return;
      //return false; // TODO: throw exception
   }
}

#endif /* TNLEXPLICITTIMESTEPPER_IMPL_H_ */
+16 −0
Original line number Diff line number Diff line
@@ -139,6 +139,14 @@ solve( const RealType& time,
   {
      RealType currentTau = Min( this->timeStep, stopTime - t );

      if( ! this->problem->preIterate( t,
                                       currentTau,
                                       mesh,
                                       dofVector ) )
      {
         cerr << endl << "Preiteration failed." << endl;
         return false;
      }
      if( verbose )
         cout << "                                                                  Assembling the linear system ... \r" << flush;
      this->problem->assemblyLinearSystem( t,
@@ -154,6 +162,14 @@ solve( const RealType& time,
         cerr << "The linear system solver did not converge." << endl;
         return false;
      }
      if( ! this->problem->postIterate( t,
                                        currentTau,
                                        mesh,
                                        dofVector ) )
      {
         cerr << endl << "Postiteration failed." << endl;
         return false;
      }
      t += currentTau;
   }
   return true;