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 ...@@ -76,12 +76,18 @@ class heatEquationSolver
void bindAuxiliaryDofs( const MeshType& mesh, void bindAuxiliaryDofs( const MeshType& mesh,
DofVectorType& auxiliaryDofs ); DofVectorType& auxiliaryDofs );
bool preIterate( const RealType& time,
const RealType& tau,
const MeshType& mesh,
DofVectorType& u );
void getExplicitRHS( const RealType& time, void getExplicitRHS( const RealType& time,
const RealType& tau, const RealType& tau,
const MeshType& mesh, const MeshType& mesh,
DofVectorType& _u, DofVectorType& _u,
DofVectorType& _fu ); DofVectorType& _fu );
void assemblyLinearSystem( const RealType& time, void assemblyLinearSystem( const RealType& time,
const RealType& tau, const RealType& tau,
const MeshType& mesh, const MeshType& mesh,
...@@ -89,6 +95,12 @@ class heatEquationSolver ...@@ -89,6 +95,12 @@ class heatEquationSolver
MatrixType& matrix, MatrixType& matrix,
DofVectorType& rightHandSide ); DofVectorType& rightHandSide );
bool postIterate( const RealType& time,
const RealType& tau,
const MeshType& mesh,
DofVectorType& u );
tnlSolverMonitor< RealType, IndexType >* getSolverMonitor(); tnlSolverMonitor< RealType, IndexType >* getSolverMonitor();
protected: protected:
......
...@@ -183,6 +183,21 @@ makeSnapshot( const RealType& time, ...@@ -183,6 +183,21 @@ makeSnapshot( const RealType& time,
return true; 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, template< typename Mesh,
typename DifferentialOperator, typename DifferentialOperator,
typename BoundaryCondition, typename BoundaryCondition,
...@@ -245,6 +260,21 @@ assemblyLinearSystem( const RealType& time, ...@@ -245,6 +260,21 @@ assemblyLinearSystem( const RealType& time,
//abort(); //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, template< typename Mesh,
typename DifferentialOperator, typename DifferentialOperator,
typename BoundaryCondition, typename BoundaryCondition,
......
...@@ -118,7 +118,7 @@ setBoundaryConditions( const RealType& time, ...@@ -118,7 +118,7 @@ setBoundaryConditions( const RealType& time,
DofVectorType& fu ) DofVectorType& fu )
{ {
fu[ index ] = 0; fu[ index ] = 0;
u[ index ] = function.getValue( mesh.getCellCenter( coordinates ), time );; u[ index ] = function.getValue( mesh.getCellCenter( coordinates ), time );
} }
template< typename MeshReal, template< typename MeshReal,
......
...@@ -112,7 +112,25 @@ void tnlExplicitTimeStepper< Problem, OdeSolver >::getExplicitRHS( const RealTyp ...@@ -112,7 +112,25 @@ void tnlExplicitTimeStepper< Problem, OdeSolver >::getExplicitRHS( const RealTyp
DofVectorType& _u, DofVectorType& _u,
DofVectorType& _fu ) 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 ); 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_ */ #endif /* TNLEXPLICITTIMESTEPPER_IMPL_H_ */
...@@ -139,6 +139,14 @@ solve( const RealType& time, ...@@ -139,6 +139,14 @@ solve( const RealType& time,
{ {
RealType currentTau = Min( this->timeStep, stopTime - t ); RealType currentTau = Min( this->timeStep, stopTime - t );
if( ! this->problem->preIterate( t,
currentTau,
mesh,
dofVector ) )
{
cerr << endl << "Preiteration failed." << endl;
return false;
}
if( verbose ) if( verbose )
cout << " Assembling the linear system ... \r" << flush; cout << " Assembling the linear system ... \r" << flush;
this->problem->assemblyLinearSystem( t, this->problem->assemblyLinearSystem( t,
...@@ -154,6 +162,14 @@ solve( const RealType& time, ...@@ -154,6 +162,14 @@ solve( const RealType& time,
cerr << "The linear system solver did not converge." << endl; cerr << "The linear system solver did not converge." << endl;
return false; return false;
} }
if( ! this->problem->postIterate( t,
currentTau,
mesh,
dofVector ) )
{
cerr << endl << "Postiteration failed." << endl;
return false;
}
t += currentTau; t += currentTau;
} }
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment