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

Refactoring the parabolic hamilton-jacobi solver.

parent accf0746
Loading
Loading
Loading
Loading
+3 −25
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <solvers/tnlSolverMonitor.h>
#include <core/tnlLogger.h>
#include <core/vectors/tnlVector.h>
#include <core/vectors/tnlSharedVector.h>
#include <solvers/pde/tnlExplicitUpdater.h>
#include <solvers/pde/tnlLinearSystemAssembler.h>
#include <functions/tnlMeshFunction.h>
@@ -71,14 +70,9 @@ class HamiltonJacobiProblem : public tnlPDEProblem< Mesh,

   IndexType getDofs( const MeshType& mesh ) const;

   IndexType getAuxiliaryDofs( const MeshType& mesh ) const;

   void bindDofs( const MeshType& mesh,
                  DofVectorType& dofs );

   void bindAuxiliaryDofs( const MeshType& mesh,
                           DofVectorType& auxiliaryDofs );

   void getExplicitRHS( const RealType& time,
                        const RealType& tau,
                        const MeshType& mesh,
@@ -86,25 +80,9 @@ class HamiltonJacobiProblem : public tnlPDEProblem< Mesh,
                        DofVectorType& _fu,
                        MeshDependentDataType& meshDependentData );

   bool preIterate( const RealType& time,
                    const RealType& tau,
                    const MeshType& mesh,
                    DofVectorType& u,
                    MeshDependentDataType& meshDependentData );
   
   bool postIterate( const RealType& time,
                     const RealType& tau,
                     const MeshType& mesh,
                     DofVectorType& u,
                     MeshDependentDataType& meshDependentData );


   tnlSolverMonitor< RealType, IndexType >* getSolverMonitor();


   protected:

   tnlSharedVector< RealType, DeviceType, IndexType > solution;
   MeshFunctionType solution;

   tnlExplicitUpdater< Mesh, MeshFunctionType, DifferentialOperator, BoundaryCondition, RightHandSide  > explicitUpdater;

@@ -114,8 +92,8 @@ class HamiltonJacobiProblem : public tnlPDEProblem< Mesh,

   RightHandSide rightHandSide;

   bool schemeTest;
   bool tested;
   //bool schemeTest;
   //bool tested;
};

#include "HamiltonJacobiProblem_impl.h"
+13 −86
Original line number Diff line number Diff line
@@ -55,9 +55,8 @@ template< typename Mesh,
		  typename RightHandSide>
bool HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide > :: setup( const tnlParameterContainer& parameters )
{
	   if( ! boundaryCondition.setup( parameters ) ||
	       ! rightHandSide.setup( parameters ) )
      return false;
   this->boundaryCondition.getFunction().setConstant( 1.0 );
   //this->rightHandSide.getFunction().setConstant( 0.0 );
   //return true;
/*
   const tnlString& problemName = parameters. GetParameter< tnlString >( "problem-name" );
@@ -97,18 +96,6 @@ typename HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandS
   return mesh.template getEntitiesCount< typename MeshType::Cell >();
}

template< typename Mesh,
          typename HamiltonJacobi,
          typename BoundaryCondition,
          typename RightHandSide>
typename HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide >::IndexType
         HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide >::getAuxiliaryDofs( const MeshType& mesh ) const
{
   /****
    * Set-up DOFs and supporting grid functions which will not appear in the discrete solver
    */
}

template< typename Mesh,
          typename HamiltonJacobi,
          typename BoundaryCondition,
@@ -117,19 +104,8 @@ void HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide
bindDofs( const MeshType& mesh,
          DofVectorType& dofVector )
{
   const IndexType dofs = mesh.template getEntitiesCount< typename MeshType::Cell >();
   this->solution.bind( dofVector.getData(), dofs );
}


template< typename Mesh,
          typename HamiltonJacobi,
          typename BoundaryCondition,
          typename RightHandSide>
void HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide >::
bindAuxiliaryDofs( const MeshType& mesh,
                   DofVectorType& auxiliaryDofVector )
{
   //const IndexType dofs = mesh.template getEntitiesCount< typename MeshType::Cell >();
   this->solution.bind( mesh, dofVector );
}

template< typename Mesh,
@@ -151,7 +127,6 @@ setInitialCondition( const tnlParameterContainer& parameters,
      return false;
   }
   return true;

}

template< typename Mesh,
@@ -166,8 +141,6 @@ makeSnapshot( const RealType& time,
              DofVectorType& dofs,
              MeshDependentDataType& meshDependentData  )
{


   cout << endl << "Writing output at time " << time << " step " << step << "." << endl;

   tnlString fileName;
@@ -219,49 +192,3 @@ getExplicitRHS( const RealType& time,
	                                                            u,
	                                                            fu );
}
 No newline at end of file

template< typename Mesh,
		  typename HamiltonJacobi,
		  typename BoundaryCondition,
		  typename RightHandSide>
tnlSolverMonitor< typename HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide > :: RealType,
                  typename HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide > ::  IndexType >*
                  HamiltonJacobiProblem< Mesh,HamiltonJacobi,BoundaryCondition,RightHandSide >
::  getSolverMonitor()
{
   return 0;
}




template< typename Mesh,
          typename HamiltonJacobi,
          typename BoundaryCondition,
          typename RightHandSide >
bool
HamiltonJacobiProblem< Mesh, HamiltonJacobi, BoundaryCondition, RightHandSide >::
preIterate( const RealType& time,
             const RealType& tau,
             const MeshType& mesh,
             DofVectorType& u,
             MeshDependentDataType& meshDependentData )
{
   return true;
}

template< typename Mesh,
          typename HamiltonJacobi,
          typename BoundaryCondition,
          typename RightHandSide >
bool
HamiltonJacobiProblem< Mesh, HamiltonJacobi, BoundaryCondition, RightHandSide >::
postIterate( const RealType& time,
             const RealType& tau,
             const MeshType& mesh,
             DofVectorType& u,
             MeshDependentDataType& meshDependentData )
{
   return true;
}
+12 −12
Original line number Diff line number Diff line
@@ -8,11 +8,11 @@ sizes1D="16 32 64 128 256 512"
sizes2D="16 32 64 128 256 512"
#sizes2D="8"
sizes3D="16 32 64 128"
testFunctions="sin-bumps"
testFunctions="sin-wave"
snapshotPeriod=0.1
finalTime=1.5
solverName="tnl-hamilton-jacobi"
#solverName="gdb --args tnl-heat-equation-eoc-test-dbg"
#solverName="gdb --args tnl-hamilton-jacobi-dbg"
#

setupTestFunction()
@@ -23,15 +23,15 @@ setupTestFunction()
      origin=-1.0
      proportions=2.0
      amplitude=1.0
      waveLength=1.0
      waveLengthX=1.0
      waveLengthY=1.0
      waveLengthZ=1.0
      wavesNumber=0.0
      wavesNumberX=0.0
      wavesNumberY=0.0
      wavesNumberZ=0.0
      phase=0.0
      waveLength=0.25
      waveLengthX=0.2
      waveLengthY=0.2
      waveLengthZ=0.2
      wavesNumber=3.0
      wavesNumberX=0.5
      wavesNumberY=2.0
      wavesNumberZ=3.0
      phase=0.1
      phaseX=0.0
      phaseY=0.0
      phaseZ=0.0
@@ -75,7 +75,7 @@ setInitialCondition()
            --phase-z ${phaseZ} \
            --sigma ${sigma} 
   
    tnl-init --test-function sdf-${testFunction} \
    tnl-init --test-function ${testFunction}-sdf \
            --output-file final-u.tnl \
            --amplitude ${amplitude} \
            --wave-length ${waveLength} \
+2 −4
Original line number Diff line number Diff line
@@ -26,16 +26,14 @@ SET( headers tnlConstantFunction.h
             tnlTestFunction.h             
             tnlTestFunction_impl.h 
             tnlSinBumpsFunctionSDF.h
             tnlSDFSinWaveFunction.h 
	     tnlSDFSinWaveFunctionSDF.h
	     tnlSinWaveFunctionSDF.h
	     tnlParaboloid.h 
	     tnlParaboloidSDF.h
	     tnlSDFSchemeTest.h
	     tnlSDFSign.h
	     tnlSDFGridValue.h
	     tnlSinBumpsFunctionSDF_impl.h
             tnlSDFSinWaveFunction_impl.h 
	     tnlSDFSinWaveFunctionSDF_impl.h
	     tnlSinWaveFunctionSDF_impl.h
	     tnlParaboloid_impl.h
	     tnlParaboloidSDF_impl.h
	     tnlSDFSchemeTest_impl.h
+0 −173
Original line number Diff line number Diff line
/***************************************************************************
                          tnlSDFSinBumpsFunction.h  -  description
                             -------------------
    begin                : Oct 13, 2014
    copyright            : (C) 2014 by Tomas Sobotik

 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TNLSDFSINBUMPSFUNCTION_H_
#define TNLSDFSINBUMPSFUNCTION_H_

#include <config/tnlParameterContainer.h>
#include <core/vectors/tnlStaticVector.h>
#include <functions/tnlDomain.h>

template< typename Vertex >
class tnlSDFSinBumpsFunctionBase : public tnlDomain< Vertex::size, SpaceDomain >
{
   public:

      typedef Vertex VertexType;
      typedef typename Vertex::RealType RealType;
      enum { Dimensions = VertexType::size };

      void setWaveLength( const VertexType& waveLength );

      const VertexType& getWaveLength() const;

      void setAmplitude( const RealType& amplitude );

      const RealType& getAmplitude() const;

      void setPhase( const VertexType& phase );

      const VertexType& getPhase() const;

      void setWavesNumber( const VertexType& wavesNumber );

      const VertexType& getWavesNumber() const;

   protected:

      RealType amplitude;

      VertexType waveLength, phase, wavesNumber;
};

template< int Dimensions, typename Real >
class tnlSDFSinBumpsFunction
{
};

template< typename Real >
class tnlSDFSinBumpsFunction< 1, Real  > : public tnlSDFSinBumpsFunctionBase< tnlStaticVector< 1, Real > >
{
   public:

      typedef Real RealType;
      typedef tnlStaticVector< 1, RealType > VertexType;


      tnlSDFSinBumpsFunction();

      bool setup( const tnlParameterContainer& parameters,
                  const tnlString& prefix = "" );

#ifdef HAVE_NOT_CXX11
      template< int XDiffOrder,
                int YDiffOrder,
                int ZDiffOrder >
#else
      template< int XDiffOrder = 0,
                int YDiffOrder = 0,
                int ZDiffOrder = 0 >
#endif
      __cuda_callable__
      RealType getPartialDerivative( const VertexType& v,
                                     const Real& time = 0.0 ) const;

   __cuda_callable__
   RealType operator()( const VertexType& v,
                        const Real& time = 0.0 ) const;

};

template< typename Real >
class tnlSDFSinBumpsFunction< 2, Real > : public tnlSDFSinBumpsFunctionBase< tnlStaticVector< 2, Real > >
{
   public:

      typedef Real RealType;
      typedef tnlStaticVector< 2, RealType > VertexType;


      tnlSDFSinBumpsFunction();

      bool setup( const tnlParameterContainer& parameters,
                 const tnlString& prefix = "" );

#ifdef HAVE_NOT_CXX11
      template< int XDiffOrder,
                int YDiffOrder,
                int ZDiffOrder >
#else
      template< int XDiffOrder = 0,
                int YDiffOrder = 0,
                int ZDiffOrder = 0 >
#endif
      __cuda_callable__
      RealType getPartialDerivative( const VertexType& v,
                                     const Real& time = 0.0 ) const;

   __cuda_callable__
   RealType operator()( const VertexType& v,
                        const Real& time = 0.0 ) const;

};

template< typename Real >
class tnlSDFSinBumpsFunction< 3, Real > : public tnlSDFSinBumpsFunctionBase< tnlStaticVector< 3, Real > >
{
   public:

      typedef Real RealType;
      typedef tnlStaticVector< 3, RealType > VertexType;

      tnlSDFSinBumpsFunction();

      bool setup( const tnlParameterContainer& parameters,
                  const tnlString& prefix = "" );

#ifdef HAVE_NOT_CXX11
      template< int XDiffOrder,
                int YDiffOrder,
                int ZDiffOrder >
#else
      template< int XDiffOrder = 0,
                int YDiffOrder = 0,
                int ZDiffOrder = 0 >
#endif
      __cuda_callable__
      RealType getPartialDerivative( const VertexType& v,
                         const Real& time = 0.0 ) const;

   __cuda_callable__
   RealType operator()( const VertexType& v,
                        const Real& time = 0.0 ) const;

};

template< int Dimensions,
          typename Real >
ostream& operator << ( ostream& str, const tnlSDFSinBumpsFunction< Dimensions, Real >& f )
{
   str << "SDF Sin Bumps. function: amplitude = " << f.getAmplitude()
       << " wavelength = " << f.getWaveLength()
       << " phase = " << f.getPhase();
   return str;
}

#include <functions/tnlSDFSinBumpsFunction_impl.h>


#endif /* TNLSDFSINBUMPSFUNCTION_H_ */
Loading