Loading examples/heat-equation/heatEquationSolver.h +12 −0 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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: Loading examples/heat-equation/heatEquationSolver_impl.h +30 −0 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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, Loading src/implementation/operators/tnlDirichletBoundaryConditions_impl.h +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading src/implementation/solvers/pde/tnlExplicitTimeStepper_impl.h +18 −0 Original line number Diff line number Diff line Loading @@ -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_ */ src/implementation/solvers/pde/tnlSemiImplicitTimeStepper_impl.h +16 −9 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -147,8 +155,6 @@ solve( const RealType& time, dofVector, this->matrix, this->rightHandSide ); cout << "u = " << dofVector << endl; cout << "b = " << this->rightHandSide << endl; if( verbose ) cout << " Solving the linear system for time " << t << " \r" << flush; if( ! this->linearSystemSolver->solve( this->rightHandSide, dofVector ) ) Loading @@ -156,13 +162,14 @@ solve( const RealType& time, cerr << "The linear system solver did not converge." << endl; return false; } DofVectorType aux; aux.setLike( dofVector ); this->matrix.vectorProduct( dofVector, aux ); cout << "tau = " << currentTau << endl; cout << "u = " << dofVector << endl; cout << "Ax = " << aux << endl; cout << "b = " << this->rightHandSide << endl; if( ! this->problem->postIterate( t, currentTau, mesh, dofVector ) ) { cerr << endl << "Postiteration failed." << endl; return false; } t += currentTau; } return true; Loading Loading
examples/heat-equation/heatEquationSolver.h +12 −0 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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: Loading
examples/heat-equation/heatEquationSolver_impl.h +30 −0 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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, Loading
src/implementation/operators/tnlDirichletBoundaryConditions_impl.h +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading
src/implementation/solvers/pde/tnlExplicitTimeStepper_impl.h +18 −0 Original line number Diff line number Diff line Loading @@ -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_ */
src/implementation/solvers/pde/tnlSemiImplicitTimeStepper_impl.h +16 −9 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -147,8 +155,6 @@ solve( const RealType& time, dofVector, this->matrix, this->rightHandSide ); cout << "u = " << dofVector << endl; cout << "b = " << this->rightHandSide << endl; if( verbose ) cout << " Solving the linear system for time " << t << " \r" << flush; if( ! this->linearSystemSolver->solve( this->rightHandSide, dofVector ) ) Loading @@ -156,13 +162,14 @@ solve( const RealType& time, cerr << "The linear system solver did not converge." << endl; return false; } DofVectorType aux; aux.setLike( dofVector ); this->matrix.vectorProduct( dofVector, aux ); cout << "tau = " << currentTau << endl; cout << "u = " << dofVector << endl; cout << "Ax = " << aux << endl; cout << "b = " << this->rightHandSide << endl; if( ! this->problem->postIterate( t, currentTau, mesh, dofVector ) ) { cerr << endl << "Postiteration failed." << endl; return false; } t += currentTau; } return true; Loading