Skip to content
Snippets Groups Projects
Commit 481bbf8e authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Adding preIterate and postIterate methods.

parent 845b91de
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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,
......
......@@ -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,
......
......@@ -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_ */
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment