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

Fixing tnl-quickstart.

parent 1520b3d8
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,9 @@ class {problemBaseName}Problem: ...@@ -20,6 +20,9 @@ class {problemBaseName}Problem:
typedef typename DifferentialOperator::IndexType IndexType; typedef typename DifferentialOperator::IndexType IndexType;
typedef TNL::Functions::MeshFunction< Mesh > MeshFunctionType; typedef TNL::Functions::MeshFunction< Mesh > MeshFunctionType;
typedef TNL::Problems::PDEProblem< Mesh, RealType, DeviceType, IndexType > BaseType; typedef TNL::Problems::PDEProblem< Mesh, RealType, DeviceType, IndexType > BaseType;
typedef TNL::SharedPointer< DifferentialOperator > DifferentialOperatorPointer;
typedef TNL::SharedPointer< BoundaryCondition > BoundaryConditionPointer;
typedef TNL::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer;
using typename BaseType::MeshType; using typename BaseType::MeshType;
using typename BaseType::MeshPointer; using typename BaseType::MeshPointer;
...@@ -42,17 +45,17 @@ class {problemBaseName}Problem: ...@@ -42,17 +45,17 @@ class {problemBaseName}Problem:
bool setInitialCondition( const TNL::Config::ParameterContainer& parameters, bool setInitialCondition( const TNL::Config::ParameterContainer& parameters,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& dofs, DofVectorPointer& dofs,
MeshDependentDataType& meshDependentData ); MeshDependentDataType& meshDependentData );
template< typename Matrix > template< typename MatrixPointer >
bool setupLinearSystem( const MeshPointer& mesh, bool setupLinearSystem( const MeshPointer& mesh,
Matrix& matrix ); MatrixPointer& matrixPointer );
bool makeSnapshot( const RealType& time, bool makeSnapshot( const RealType& time,
const IndexType& step, const IndexType& step,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& dofs, DofVectorPointer& dofs,
MeshDependentDataType& meshDependentData ); MeshDependentDataType& meshDependentData );
IndexType getDofs( const MeshPointer& mesh ) const; IndexType getDofs( const MeshPointer& mesh ) const;
...@@ -63,24 +66,24 @@ class {problemBaseName}Problem: ...@@ -63,24 +66,24 @@ class {problemBaseName}Problem:
void getExplicitRHS( const RealType& time, void getExplicitRHS( const RealType& time,
const RealType& tau, const RealType& tau,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& _u, DofVectorPointer& _u,
DofVectorType& _fu, DofVectorPointer& _fu,
MeshDependentDataType& meshDependentData ); MeshDependentDataType& meshDependentData );
template< typename Matrix > template< typename MatrixPointer >
void assemblyLinearSystem( const RealType& time, void assemblyLinearSystem( const RealType& time,
const RealType& tau, const RealType& tau,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& dofs, DofVectorPointer& dofs,
Matrix& matrix, MatrixPointer& matrixPointer,
DofVectorType& rightHandSide, DofVectorPointer& rightHandSide,
MeshDependentDataType& meshDependentData ); MeshDependentDataType& meshDependentData );
protected: protected:
DifferentialOperator differentialOperator; DifferentialOperatorPointer differentialOperator;
BoundaryCondition boundaryCondition; BoundaryConditionPointer boundaryCondition;
RightHandSide rightHandSide; RightHandSidePointer rightHandSide;
}}; }};
#include "{problemBaseName}Problem_impl.h" #include "{problemBaseName}Problem_impl.h"
...@@ -53,7 +53,7 @@ setup( const MeshPointer& meshPointer, ...@@ -53,7 +53,7 @@ setup( const MeshPointer& meshPointer,
const TNL::Config::ParameterContainer& parameters, const TNL::Config::ParameterContainer& parameters,
const TNL::String& prefix ) const TNL::String& prefix )
{{ {{
if( ! this->boundaryCondition.setup( parameters, "boundary-conditions-" ) || if( ! this->boundaryCondition.setup( meshPointer, parameters, "boundary-conditions-" ) ||
! this->rightHandSide.setup( parameters, "right-hand-side-" ) ) ! this->rightHandSide.setup( parameters, "right-hand-side-" ) )
return false; return false;
return true; return true;
...@@ -71,7 +71,7 @@ getDofs( const MeshPointer& mesh ) const ...@@ -71,7 +71,7 @@ getDofs( const MeshPointer& mesh ) const
* Return number of DOFs (degrees of freedom) i.e. number * Return number of DOFs (degrees of freedom) i.e. number
* of unknowns to be resolved by the main solver. * of unknowns to be resolved by the main solver.
*/ */
return mesh.template getEntitiesCount< typename MeshType::Cell >(); return mesh->template getEntitiesCount< typename MeshType::Cell >();
}} }}
template< typename Mesh, template< typename Mesh,
...@@ -93,7 +93,7 @@ bool ...@@ -93,7 +93,7 @@ bool
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
setInitialCondition( const TNL::Config::ParameterContainer& parameters, setInitialCondition( const TNL::Config::ParameterContainer& parameters,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& dofs, DofVectorPointer& dofs,
MeshDependentDataType& meshDependentData ) MeshDependentDataType& meshDependentData )
{{ {{
const TNL::String& initialConditionFile = parameters.getParameter< TNL::String >( "initial-condition" ); const TNL::String& initialConditionFile = parameters.getParameter< TNL::String >( "initial-condition" );
...@@ -110,24 +110,24 @@ template< typename Mesh, ...@@ -110,24 +110,24 @@ template< typename Mesh,
typename BoundaryCondition, typename BoundaryCondition,
typename RightHandSide, typename RightHandSide,
typename DifferentialOperator > typename DifferentialOperator >
template< typename Matrix > template< typename MatrixPointer >
bool bool
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
setupLinearSystem( const MeshPointer& mesh, setupLinearSystem( const MeshPointer& meshPointer,
Matrix& matrix ) MatrixPointer& matrixPointer )
{{ {{
const IndexType dofs = this->getDofs( mesh ); const IndexType dofs = this->getDofs( meshPointer );
typedef typename Matrix::CompressedRowsLengthsVector CompressedRowsLengthsVectorType; typedef typename MatrixPointer::ObjectType::CompressedRowsLengthsVector CompressedRowsLengthsVectorType;
CompressedRowsLengthsVectorType rowLengths; TNL::SharedPointer< CompressedRowsLengthsVectorType > rowLengthsPointer;
if( ! rowLengths.setSize( dofs ) ) if( ! rowLengthsPointer->setSize( dofs ) )
return false; return false;
TNL::Matrices::MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowsLengthsVectorType > matrixSetter; TNL::Matrices::MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowsLengthsVectorType > matrixSetter;
matrixSetter.template getCompressedRowsLengths< typename Mesh::Cell >( mesh, matrixSetter.template getCompressedRowsLengths< typename Mesh::Cell >( meshPointer,
differentialOperator, differentialOperator,
boundaryCondition, boundaryCondition,
rowLengths ); rowLengthsPointer );
matrix.setDimensions( dofs, dofs ); matrixPointer->setDimensions( dofs, dofs );
if( ! matrix.setCompressedRowsLengths( rowLengths ) ) if( ! matrixPointer->setCompressedRowsLengths( *rowLengthsPointer ) )
return false; return false;
return true; return true;
}} }}
...@@ -141,7 +141,7 @@ bool ...@@ -141,7 +141,7 @@ bool
makeSnapshot( const RealType& time, makeSnapshot( const RealType& time,
const IndexType& step, const IndexType& step,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& dofs, DofVectorPointer& dofs,
MeshDependentDataType& meshDependentData ) MeshDependentDataType& meshDependentData )
{{ {{
std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl;
...@@ -150,7 +150,7 @@ makeSnapshot( const RealType& time, ...@@ -150,7 +150,7 @@ makeSnapshot( const RealType& time,
fileName.setFileNameBase( "u-" ); fileName.setFileNameBase( "u-" );
fileName.setExtension( "tnl" ); fileName.setExtension( "tnl" );
fileName.setIndex( step ); fileName.setIndex( step );
if( ! dofs.save( fileName.getFileName() ) ) if( ! dofs->save( fileName.getFileName() ) )
return false; return false;
return true; return true;
}} }}
...@@ -164,8 +164,8 @@ void ...@@ -164,8 +164,8 @@ void
getExplicitRHS( const RealType& time, getExplicitRHS( const RealType& time,
const RealType& tau, const RealType& tau,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& _u, DofVectorPointer& _u,
DofVectorType& _fu, DofVectorPointer& _fu,
MeshDependentDataType& meshDependentData ) MeshDependentDataType& meshDependentData )
{{ {{
/**** /****
...@@ -199,15 +199,15 @@ template< typename Mesh, ...@@ -199,15 +199,15 @@ template< typename Mesh,
typename BoundaryCondition, typename BoundaryCondition,
typename RightHandSide, typename RightHandSide,
typename DifferentialOperator > typename DifferentialOperator >
template< typename Matrix > template< typename MatrixPointer >
void void
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
assemblyLinearSystem( const RealType& time, assemblyLinearSystem( const RealType& time,
const RealType& tau, const RealType& tau,
const MeshPointer& mesh, const MeshPointer& mesh,
DofVectorType& _u, DofVectorPointer& _u,
Matrix& matrix, MatrixPointer& matrixPointer,
DofVectorType& b, DofVectorPointer& b,
MeshDependentDataType& meshDependentData ) MeshDependentDataType& meshDependentData )
{{ {{
TNL::Solvers::PDE::LinearSystemAssembler< Mesh, TNL::Solvers::PDE::LinearSystemAssembler< Mesh,
...@@ -216,7 +216,7 @@ assemblyLinearSystem( const RealType& time, ...@@ -216,7 +216,7 @@ assemblyLinearSystem( const RealType& time,
BoundaryCondition, BoundaryCondition,
RightHandSide, RightHandSide,
TNL::Solvers::PDE::BackwardTimeDiscretisation, TNL::Solvers::PDE::BackwardTimeDiscretisation,
Matrix, typename MatrixPointer::ObjectType,
DofVectorType > systemAssembler; DofVectorType > systemAssembler;
TNL::Functions::MeshFunction< Mesh > u( mesh, _u ); TNL::Functions::MeshFunction< Mesh > u( mesh, _u );
...@@ -227,6 +227,6 @@ assemblyLinearSystem( const RealType& time, ...@@ -227,6 +227,6 @@ assemblyLinearSystem( const RealType& time,
this->boundaryCondition, this->boundaryCondition,
this->rightHandSide, this->rightHandSide,
u, u,
matrix, matrixPointer,
b ); b );
}} }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment