From 6d78d9f99388d1ad9c996102d5bec3a4bb42dfe6 Mon Sep 17 00:00:00 2001
From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz>
Date: Mon, 26 Sep 2016 09:04:04 +0200
Subject: [PATCH] Fixing tnl-quickstart.

---
 src/Tools/tnl-quickstart/problem.h.in      | 29 +++++++------
 src/Tools/tnl-quickstart/problem_impl.h.in | 48 +++++++++++-----------
 2 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/src/Tools/tnl-quickstart/problem.h.in b/src/Tools/tnl-quickstart/problem.h.in
index d122e562f1..def92930e3 100644
--- a/src/Tools/tnl-quickstart/problem.h.in
+++ b/src/Tools/tnl-quickstart/problem.h.in
@@ -20,6 +20,9 @@ class {problemBaseName}Problem:
       typedef typename DifferentialOperator::IndexType IndexType;
       typedef TNL::Functions::MeshFunction< Mesh > MeshFunctionType;
       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::MeshPointer;
@@ -42,17 +45,17 @@ class {problemBaseName}Problem:
 
       bool setInitialCondition( const TNL::Config::ParameterContainer& parameters,
                                 const MeshPointer& mesh,
-                                DofVectorType& dofs,
+                                DofVectorPointer& dofs,
                                 MeshDependentDataType& meshDependentData );
 
-      template< typename Matrix >
+      template< typename MatrixPointer >
       bool setupLinearSystem( const MeshPointer& mesh,
-                              Matrix& matrix );
+                              MatrixPointer& matrixPointer );
 
       bool makeSnapshot( const RealType& time,
                          const IndexType& step,
                          const MeshPointer& mesh,
-                         DofVectorType& dofs,
+                         DofVectorPointer& dofs,
                          MeshDependentDataType& meshDependentData );
 
       IndexType getDofs( const MeshPointer& mesh ) const;
@@ -63,24 +66,24 @@ class {problemBaseName}Problem:
       void getExplicitRHS( const RealType& time,
                            const RealType& tau,
                            const MeshPointer& mesh,
-                           DofVectorType& _u,
-                           DofVectorType& _fu,
+                           DofVectorPointer& _u,
+                           DofVectorPointer& _fu,
                            MeshDependentDataType& meshDependentData );
 
-      template< typename Matrix >
+      template< typename MatrixPointer >
       void assemblyLinearSystem( const RealType& time,
                                  const RealType& tau,
                                  const MeshPointer& mesh,
-                                 DofVectorType& dofs,
-                                 Matrix& matrix,
-                                 DofVectorType& rightHandSide,
+                                 DofVectorPointer& dofs,
+                                 MatrixPointer& matrixPointer,
+                                 DofVectorPointer& rightHandSide,
                                  MeshDependentDataType& meshDependentData );
 
    protected:
     
-      DifferentialOperator differentialOperator;
-      BoundaryCondition boundaryCondition;
-      RightHandSide rightHandSide;
+      DifferentialOperatorPointer differentialOperator;
+      BoundaryConditionPointer boundaryCondition;
+      RightHandSidePointer rightHandSide;
 }};
 
 #include "{problemBaseName}Problem_impl.h"
diff --git a/src/Tools/tnl-quickstart/problem_impl.h.in b/src/Tools/tnl-quickstart/problem_impl.h.in
index 45727bc662..34aeb6dd6a 100644
--- a/src/Tools/tnl-quickstart/problem_impl.h.in
+++ b/src/Tools/tnl-quickstart/problem_impl.h.in
@@ -53,7 +53,7 @@ setup( const MeshPointer& meshPointer,
        const TNL::Config::ParameterContainer& parameters,
        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-" ) )
       return false;
    return true;
@@ -71,7 +71,7 @@ getDofs( const MeshPointer& mesh ) const
     * Return number of  DOFs (degrees of freedom) i.e. number
     * 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,
@@ -93,7 +93,7 @@ bool
 {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::            
 setInitialCondition( const TNL::Config::ParameterContainer& parameters,    
                      const MeshPointer& mesh,
-                     DofVectorType& dofs,
+                     DofVectorPointer& dofs,
                      MeshDependentDataType& meshDependentData )
 {{
    const TNL::String& initialConditionFile = parameters.getParameter< TNL::String >( "initial-condition" );
@@ -110,24 +110,24 @@ template< typename Mesh,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
-   template< typename Matrix >
+   template< typename MatrixPointer >
 bool
 {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::                
-setupLinearSystem( const MeshPointer& mesh,
-                   Matrix& matrix )
+setupLinearSystem( const MeshPointer& meshPointer,
+                   MatrixPointer& matrixPointer )
 {{
-   const IndexType dofs = this->getDofs( mesh );
-   typedef typename Matrix::CompressedRowsLengthsVector CompressedRowsLengthsVectorType;
-   CompressedRowsLengthsVectorType rowLengths;
-   if( ! rowLengths.setSize( dofs ) )
+   const IndexType dofs = this->getDofs( meshPointer );
+   typedef typename MatrixPointer::ObjectType::CompressedRowsLengthsVector CompressedRowsLengthsVectorType;
+   TNL::SharedPointer< CompressedRowsLengthsVectorType > rowLengthsPointer;
+   if( ! rowLengthsPointer->setSize( dofs ) )
       return false;
    TNL::Matrices::MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowsLengthsVectorType > matrixSetter;
-   matrixSetter.template getCompressedRowsLengths< typename Mesh::Cell >( mesh,
+   matrixSetter.template getCompressedRowsLengths< typename Mesh::Cell >( meshPointer,
                                                                           differentialOperator,
                                                                           boundaryCondition,
-                                                                          rowLengths );
-   matrix.setDimensions( dofs, dofs );
-   if( ! matrix.setCompressedRowsLengths( rowLengths ) )
+                                                                          rowLengthsPointer );
+   matrixPointer->setDimensions( dofs, dofs );
+   if( ! matrixPointer->setCompressedRowsLengths( *rowLengthsPointer ) )
       return false;
    return true;
 }}
@@ -141,7 +141,7 @@ bool
 makeSnapshot( const RealType& time,
               const IndexType& step,
               const MeshPointer& mesh,
-              DofVectorType& dofs,
+              DofVectorPointer& dofs,
               MeshDependentDataType& meshDependentData )
 {{
    std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl;
@@ -150,7 +150,7 @@ makeSnapshot( const RealType& time,
    fileName.setFileNameBase( "u-" );
    fileName.setExtension( "tnl" );
    fileName.setIndex( step );
-   if( ! dofs.save( fileName.getFileName() ) )
+   if( ! dofs->save( fileName.getFileName() ) )
       return false;
    return true;
 }}
@@ -164,8 +164,8 @@ void
 getExplicitRHS( const RealType& time,
                 const RealType& tau,
                 const MeshPointer& mesh,
-                DofVectorType& _u,
-                DofVectorType& _fu,
+                DofVectorPointer& _u,
+                DofVectorPointer& _fu,
                 MeshDependentDataType& meshDependentData )
 {{
    /****
@@ -199,15 +199,15 @@ template< typename Mesh,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
-   template< typename Matrix >
+   template< typename MatrixPointer >
 void
 {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::                
 assemblyLinearSystem( const RealType& time,
                       const RealType& tau,
                       const MeshPointer& mesh,
-                      DofVectorType& _u,
-                      Matrix& matrix,
-                      DofVectorType& b,
+                      DofVectorPointer& _u,
+                      MatrixPointer& matrixPointer,
+                      DofVectorPointer& b,
                       MeshDependentDataType& meshDependentData )
 {{
    TNL::Solvers::PDE::LinearSystemAssembler< Mesh,
@@ -216,7 +216,7 @@ assemblyLinearSystem( const RealType& time,
                              BoundaryCondition,
                              RightHandSide,
                              TNL::Solvers::PDE::BackwardTimeDiscretisation,
-                             Matrix,
+                             typename MatrixPointer::ObjectType,
                              DofVectorType > systemAssembler;
 
    TNL::Functions::MeshFunction< Mesh > u( mesh, _u );
@@ -227,6 +227,6 @@ assemblyLinearSystem( const RealType& time,
                                                              this->boundaryCondition,
                                                              this->rightHandSide,
                                                              u,
-                                                             matrix,
+                                                             matrixPointer,
                                                              b );
 }}
-- 
GitLab