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

Refactorization of Timer and TimeDependentPDESolver.

Implementation of TimeIndependentPDESolver.
parent a02e42c4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#ADD_SUBDIRECTORY( hamilton-jacobi )
ADD_SUBDIRECTORY( hamilton-jacobi )

+4 −4
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ updateCell( MeshFunctionType& u,
      a = u[ neighborEntities.template getEntityIndex< -1,  0 >() ];
   else
   {
      a = ArgAbsMin( u[ neighborEntities.template getEntityIndex< -1,  0 >() ],
      a = argAbsMin( u[ neighborEntities.template getEntityIndex< -1,  0 >() ],
                     u[ neighborEntities.template getEntityIndex<  1,  0 >() ] );
   }

@@ -135,7 +135,7 @@ updateCell( MeshFunctionType& u,
      b = u[ neighborEntities.template getEntityIndex< 0,  -1 >() ];
   else
   {
      b = ArgAbsMin( u[ neighborEntities.template getEntityIndex< 0,  -1 >() ],
      b = argAbsMin( u[ neighborEntities.template getEntityIndex< 0,  -1 >() ],
                     u[ neighborEntities.template getEntityIndex< 0,   1 >() ] );
   }

@@ -146,7 +146,7 @@ updateCell( MeshFunctionType& u,
       fabs( b ) == TypeInfo< Real >::getMaxValue() ||
       fabs( a - b ) >= h )
   {
      tmp = ArgAbsMin( a, b ) + sign( value ) * h;
      tmp = argAbsMin( a, b ) + sign( value ) * h;
      /*   std::cerr << "a = " << a << " b = " << b << " h = " << h 
             << " ArgAbsMin( a, b ) = " << ArgAbsMin( a, b ) << " sign( value ) = " << sign( value )
             << " sign( value ) * h = " << sign( value ) * h
@@ -163,7 +163,7 @@ updateCell( MeshFunctionType& u,
   else
      tmp = 0.5 * ( a + b + sign( value ) * sqrt( 2.0 * h * h - ( a - b ) * ( a - b ) ) );

   u[ cell.getIndex() ] = ArgAbsMin( value, tmp );
   u[ cell.getIndex() ] = argAbsMin( value, tmp );
   //std::cerr << ArgAbsMin( value, tmp ) << " ";   
}

+8 −3
Original line number Diff line number Diff line
@@ -21,7 +21,11 @@ String
tnlDirectEikonalProblem< Mesh, Anisotropy, Real, Index >::
getTypeStatic()
{
   
   return String( "DirectEikonalProblem< " + 
                  Mesh::getTypeStatic() + ", " +
                  Anisotropy::getTypeStatic() + ", " +
                  Real::getTypeStatic() + ", " +
                  Index::getTypeStatic() + " >" );
}

template< typename Mesh,
@@ -122,6 +126,7 @@ tnlDirectEikonalProblem< Mesh, Anisotropy, Real, Index >::
solve( const MeshPointer& mesh,
       DofVectorPointer& dofs )
{
   tnlFastSweepingMethod< MeshType, AnisotropyType > fsm;
   //return fsm.solve( mesh, anisotropy, initialData );
   FastSweepingMethod< MeshType, AnisotropyType > fsm;
   fsm.solve( mesh, anisotropy, initialData );
   return true;
}
+22 −21
Original line number Diff line number Diff line
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   tnlFastSweepingMethod.h
 * Author: oberhuber
 *
 * Created on July 14, 2016, 10:04 AM
 */
/***************************************************************************
                          FastSweepingMethod.h  -  description
                             -------------------
    begin                : Jul 14, 2016
    copyright            : (C) 2017 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/* See Copyright Notice in tnl/Copyright */

#pragma once

#include <TNL/Meshes/Grid.h>
#include <TNL/Functions/Analytic/Constant.h>
#include <TNL/SharedPointer.h>
#include "tnlDirectEikonalMethodsBase.h"

template< typename Mesh,
          typename Anisotropy = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType > >
class tnlFastSweepingMethod
class FastSweepingMethod
{   
};

@@ -27,7 +25,7 @@ template< typename Real,
          typename Device,
          typename Index,
          typename Anisotropy >
class tnlFastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >
class FastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >
   : public tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >
{
   static_assert(  std::is_same< Device, TNL::Devices::Host >::value, "The fast sweeping method works only on CPU." );
@@ -40,17 +38,18 @@ class tnlFastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy
      typedef Index IndexType;
      typedef Anisotropy AnisotropyType;
      typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > > BaseType;
      using MeshPointer = SharedPointer< MeshType >;
      
      using typename BaseType::InterfaceMapType;
      using typename BaseType::MeshFunctionType;
      
      tnlFastSweepingMethod();
      FastSweepingMethod();
      
      const IndexType& getMaxIterations() const;
      
      void setMaxIterations( const IndexType& maxIterations );
      
      void solve( const MeshType& mesh,
      void solve( const MeshPointer& mesh,
                  const AnisotropyType& anisotropy,
                  MeshFunctionType& u );
      
@@ -64,7 +63,7 @@ template< typename Real,
          typename Device,
          typename Index,
          typename Anisotropy >
class tnlFastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >
class FastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >
   : public tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >
{
   static_assert(  std::is_same< Device, TNL::Devices::Host >::value, "The fast sweeping method works only on CPU." );
@@ -77,17 +76,18 @@ class tnlFastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy
      typedef Index IndexType;
      typedef Anisotropy AnisotropyType;
      typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > BaseType;
      using MeshPointer = SharedPointer< MeshType >;

      using typename BaseType::InterfaceMapType;
      using typename BaseType::MeshFunctionType;

      tnlFastSweepingMethod();
      FastSweepingMethod();
      
      const IndexType& getMaxIterations() const;
      
      void setMaxIterations( const IndexType& maxIterations );
      
      void solve( const MeshType& mesh,
      void solve( const MeshPointer& mesh,
                  const AnisotropyType& anisotropy,
                  MeshFunctionType& u );
      
@@ -101,7 +101,7 @@ template< typename Real,
          typename Device,
          typename Index,
          typename Anisotropy >
class tnlFastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >
class FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >
   : public tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >
{
   static_assert(  std::is_same< Device, TNL::Devices::Host >::value, "The fast sweeping method works only on CPU." );
@@ -114,17 +114,18 @@ class tnlFastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy
      typedef Index IndexType;
      typedef Anisotropy AnisotropyType;
      typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > BaseType;
      using MeshPointer = SharedPointer< MeshType >;
      
      using typename BaseType::InterfaceMapType;
      using typename BaseType::MeshFunctionType;
      
      tnlFastSweepingMethod();
      FastSweepingMethod();
      
      const IndexType& getMaxIterations() const;
      
      void setMaxIterations( const IndexType& maxIterations );
      
      void solve( const MeshType& mesh,
      void solve( const MeshPointer& mesh,
                  const AnisotropyType& anisotropy,
                  MeshFunctionType& u );
      
+6 −6
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ template< typename Real,
          typename Device,
          typename Index,
          typename Anisotropy >
tnlFastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
tnlFastSweepingMethod()
FastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
FastSweepingMethod()
: maxIterations( 1 )
{
   
@@ -31,7 +31,7 @@ template< typename Real,
          typename Index,
          typename Anisotropy >
const Index&
tnlFastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
FastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
getMaxIterations() const
{
   
@@ -42,7 +42,7 @@ template< typename Real,
          typename Index,
          typename Anisotropy >
void
tnlFastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
FastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
setMaxIterations( const IndexType& maxIterations )
{
   
@@ -53,8 +53,8 @@ template< typename Real,
          typename Index,
          typename Anisotropy >
void
tnlFastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
solve( const MeshType& mesh,
FastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >::
solve( const MeshPointer& mesh,
       const AnisotropyType& anisotropy,
       MeshFunctionType& u )
{
Loading