Commit b10b293b authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Refactroing the mena-curvature flow.

parent bebd40c3
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ class meanCurvatureFlowEocConfig
      static void configSetup( tnlConfigDescription& config )
      {
         config.addDelimiter( "Mean Curvature Flow EOC settings:" );         
         config.addEntry< tnlString >( "numerical-scheme", "Numerical scheme for the solution approximation.", "fvm" );
            config.addEntryEnum< tnlString >( "fdm" );
            config.addEntryEnum< tnlString >( "fvm" );

         config.addEntry< double >( "eps", "This sets a eps in operator Q.", 1.0 );
         config.addDelimiter( "Tests setting::" );         
         tnlTestFunction< 3, double >::configSetup( config );
@@ -66,10 +70,11 @@ class meanCurvatureFlowEocSetter
   typedef Index IndexType;

   typedef typename MeshType::VertexType Vertex;
   enum { Dimensions = MeshType::meshDimensions };

   static bool run( const tnlParameterContainer& parameters )
   {
      enum { Dimensions = MeshType::meshDimensions };

      typedef tnlFiniteVolumeOperatorQ<MeshType, Real, Index, 0> OperatorQ;
      typedef tnlFiniteVolumeNonlinearOperator<MeshType, OperatorQ, Real, Index > NonlinearOperator;
      typedef tnlNonlinearDiffusion< MeshType, NonlinearOperator, Real, Index > ApproximateOperator;
+34 −6
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@
#include <problems/tnlMeanCurvatureFlowProblem.h>
#include <operators/diffusion/tnlNonlinearDiffusion.h>
#include <operators/operator-Q/tnlOneSideDiffOperatorQ.h>
#include <operators/operator-Q/tnlFiniteVolumeOperatorQ.h>
#include <operators/diffusion/nonlinear-diffusion-operators/tnlOneSideDiffNonlinearOperator.h>
#include <operators/diffusion/nonlinear-diffusion-operators/tnlFiniteVolumeNonlinearOperator.h>
#include <functions/tnlMeshFunction.h>

//typedef tnlDefaultConfigTag BuildConfig;
@@ -40,6 +42,9 @@ class meanCurvatureFlowConfig
      static void configSetup( tnlConfigDescription& config )
      {
         config.addDelimiter( "Mean Curvature Flow settings:" );
         config.addEntry< tnlString >( "numerical-scheme", "Numerical scheme for the solution approximation.", "fvm" );
            config.addEntryEnum< tnlString >( "fdm" );
            config.addEntryEnum< tnlString >( "fvm" );
         config.addEntry< tnlString >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet");
            config.addEntryEnum< tnlString >( "dirichlet" );
            config.addEntryEnum< tnlString >( "neumann" );
@@ -66,13 +71,36 @@ class meanCurvatureFlowSetter
   typedef Device DeviceType;
   typedef Index IndexType;

   typedef tnlStaticVector< MeshType::meshDimensions, Real > Vertex;
   typedef typename MeshType::VertexType Vertex;
   enum { Dimensions = MeshType::meshDimensions };

   static bool run( const tnlParameterContainer& parameters )
   {
      enum { Dimensions = MeshType::meshDimensions };
      typedef tnlOneSideDiffOperatorQ<MeshType, Real, Index, 0> OperatorQ;
      typedef tnlOneSideDiffNonlinearOperator<MeshType, OperatorQ, Real, Index > NonlinearOperator;
      return setNumericalScheme( parameters );
   }
   
   static bool setNumericalScheme( const tnlParameterContainer& parameters )
   {
      const tnlString& numericalScheme = parameters.getParameter< tnlString >( "numerical-scheme" );
      if( numericalScheme == "fdm" )
      {
         typedef tnlOneSideDiffOperatorQ<MeshType, Real, Index, 0> QOperator;
         typedef tnlOneSideDiffNonlinearOperator<MeshType, QOperator, Real, Index > NonlinearOperator;         
         return setBoundaryConditions< NonlinearOperator, QOperator >( parameters );
      }
      if( numericalScheme == "fvm" )
      {
         typedef tnlFiniteVolumeOperatorQ<MeshType, Real, Index, 0> QOperator;
         typedef tnlFiniteVolumeNonlinearOperator<MeshType, QOperator, Real, Index > NonlinearOperator;         
         return setBoundaryConditions< NonlinearOperator, QOperator >( parameters );
      }
      return false;
   }
   
   template< typename NonlinearOperator,
             typename QOperator >
   static bool setBoundaryConditions( const tnlParameterContainer& parameters )
   {
      typedef tnlNonlinearDiffusion< MeshType, NonlinearOperator, Real, Index > ApproximateOperator;
      typedef tnlConstantFunction< Dimensions, Real > RightHandSide;
      typedef tnlStaticVector< MeshType::meshDimensions, Real > Vertex;
+9 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ class tnlSparseMatrixRow
                       const Index& column,
                       const Real& value );
      
      void print( ostream& str ) const;

   protected:

      Real* values;
@@ -53,6 +55,13 @@ class tnlSparseMatrixRow
      Index length, step;
};

template< typename Real, typename Index >
ostream& operator << ( ostream& str, const tnlSparseMatrixRow< Real, Index >& row )
{
   row.print( str );
   return str;
}

#include <matrices/tnlSparseMatrixRow_impl.h>

#endif /* TNLSPARSEMATRIXROW_H_ */
+13 −0
Original line number Diff line number Diff line
@@ -77,4 +77,17 @@ setElement( const Index& elementIndex,
   this->values[ elementIndex * step ] = value;
}

template< typename Real, typename Index >
void
tnlSparseMatrixRow< Real, Index >::
print( ostream& str ) const
{
   Index pos( 0 );
   for( Index i = 0; i < length; i++ )
   {
      str << " [ " << columns[ pos ] << " ] = " << values[ pos ] << ", ";
      pos += step;   
   }
}

#endif /* TNLSPARSEMATRIXROW_IMPL_H_ */
+12 −6
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ processBoundaryEntities( const GridType& grid,
    * Boundary cells
    */
   const int CellDimensions = GridType::meshDimensions;
   typename GridType::template GridEntity< CellDimensions > entity( grid );
   //typename GridType::template GridEntity< CellDimensions > entity( grid );
   GridEntity entity( grid );

   CoordinatesType& coordinates = entity.getCoordinates();
   const IndexType& xSize = grid.getDimensions().x();   
@@ -58,7 +59,8 @@ processInteriorEntities( const GridType& grid,
    * Interior cells
    */
   const int CellDimensions = GridType::meshDimensions;
   typename GridType::template GridEntity< CellDimensions > cell( grid );
   //typename GridType::template GridEntity< CellDimensions > cell( grid );
   GridEntity cell( grid );

   const IndexType& xSize = grid.getDimensions().x();
   for( cell.getCoordinates().x() = 1;
@@ -84,7 +86,8 @@ processBoundaryEntities( const GridType& grid,
    * Boundary vertices
    */
   const int VerticesDimensions = 0;
   typename GridType::template GridEntity< VerticesDimensions > entity( grid );
   //typename GridType::template GridEntity< VerticesDimensions > entity( grid );
   GridEntity entity( grid );
   
   CoordinatesType& coordinates = entity.getCoordinates();
   const IndexType& xSize = grid.getDimensions().x();
@@ -110,7 +113,8 @@ processInteriorEntities( const GridType& grid,
    * Interior vertices
    */
   const int VerticesDimensions = 0;
   typename GridType::template GridEntity< VerticesDimensions > entity( grid );
   //typename GridType::template GridEntity< VerticesDimensions > entity( grid );
   GridEntity entity( grid );
   
   CoordinatesType& coordinates = entity.getCoordinates();
   const IndexType& xSize = grid.getDimensions().x();
@@ -140,7 +144,8 @@ __global__ void tnlTraverserGrid1DCells( const tnlGrid< 1, Real, tnlCuda, Index
{
   typedef tnlGrid< 1, Real, tnlCuda, Index > GridType;
   const int CellDimensions = GridType::meshDimensions;
   typename GridType::template GridEntity< CellDimensions > entity( *grid );
   //typename GridType::template GridEntity< CellDimensions > entity( *grid );
   GridEntity entity( *grid );
   typedef typename GridType::CoordinatesType CoordinatesType;
   CoordinatesType& coordinates = entity.getCoordinates();

@@ -247,7 +252,8 @@ __global__ void tnlTraverserGrid1DVertices( const tnlGrid< 1, Real, tnlCuda, Ind
                                            Index gridXIdx )
{
   typedef tnlGrid< 1, Real, tnlCuda, Index > GridType;
   typename GridType::template GridEntity< GridType::Vertices > vertex;
   //typename GridType::template GridEntity< GridType::Vertices > vertex;
   GridEntity vertex( *grid );

   const Index& xSize = grid->getDimensions().x();

Loading