From bc9571491e284fcd74bb68ebeb0e0534a8985e3a Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Thu, 14 Jul 2016 10:43:46 +0200 Subject: [PATCH] Refactoring the fast sweeping method. --- .../hamilton-jacobi/tnlDirectEikonalProblem.h | 7 ++- .../tnlDirectEikonalProblem_impl.h | 19 +++++- .../hamilton-jacobi/tnlFastSweepingMethod.h | 58 +++++++++++++++++ .../tnlFastSweepingMethod2D_impl.h | 62 +++++++++++++++++++ 4 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 examples/hamilton-jacobi/tnlFastSweepingMethod.h create mode 100644 examples/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h diff --git a/examples/hamilton-jacobi/tnlDirectEikonalProblem.h b/examples/hamilton-jacobi/tnlDirectEikonalProblem.h index 7de0ceed4c..654c775ea9 100644 --- a/examples/hamilton-jacobi/tnlDirectEikonalProblem.h +++ b/examples/hamilton-jacobi/tnlDirectEikonalProblem.h @@ -15,6 +15,7 @@ #include <problems/tnlPDEProblem.h> #include <functions/tnlMeshFunction.h> +#include "tnlFastSweepingMethod.h" template< typename Mesh, typename Anisotropy, @@ -59,7 +60,7 @@ class tnlDirectEikonalProblem bool setInitialData( const tnlParameterContainer& parameters, const MeshType& mesh, DofVectorType& dofs, - MeshDependentData& meshdependentData ) + MeshDependentDataType& meshdependentData ); bool solve( const MeshType& mesh, DofVectorType& dosf ); @@ -68,7 +69,9 @@ class tnlDirectEikonalProblem protected: MeshFunctionType u; + + MeshFunctionType initialData; }; -#include "tnlDirectEikonalProblem_impl.h" \ No newline at end of file +#include "tnlDirectEikonalProblem_impl.h" diff --git a/examples/hamilton-jacobi/tnlDirectEikonalProblem_impl.h b/examples/hamilton-jacobi/tnlDirectEikonalProblem_impl.h index f3b2259c9c..1a9f7bcf46 100644 --- a/examples/hamilton-jacobi/tnlDirectEikonalProblem_impl.h +++ b/examples/hamilton-jacobi/tnlDirectEikonalProblem_impl.h @@ -77,7 +77,7 @@ Index tnlDirectEikonalProblem< Mesh, Anisotropy, Real, Index >:: getDofs( const MeshType& mesh ) const { - + return mesh.getEntitiesCount(); } template< typename Mesh, @@ -89,16 +89,31 @@ tnlDirectEikonalProblem< Mesh, Anisotropy, Real, Index >:: bindDofs( const MeshType& mesh, const DofVectorType& dofs ) { + this->u.bind( mesh, dofs ); +} + +bool +setInitialData( const tnlParameterContainer& parameters, + const MeshType& mesh, + DofVectorType& dofs, + MeshDependentDataType& meshdependentData ) +{ + tnlString inputFile = parameters.getParameter< tnlString >( "input-file" ); + this->initialData.setMesh( mesh ); + if( !this->initialData.boundLoad( inputFile ) ) + return false; } + template< typename Mesh, typename Anisotropy, typename Real, typename Index > bool tnlDirectEikonalProblem< Mesh, Anisotropy, Real, Index >:: -solve() +solve( const MeshType& mesh, + DofVectorType& dosf ) { } \ No newline at end of file diff --git a/examples/hamilton-jacobi/tnlFastSweepingMethod.h b/examples/hamilton-jacobi/tnlFastSweepingMethod.h new file mode 100644 index 0000000000..0234111ea5 --- /dev/null +++ b/examples/hamilton-jacobi/tnlFastSweepingMethod.h @@ -0,0 +1,58 @@ +/* + * 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 + */ + +#pragma once + +#include <mesh/tnlGrid.h> +#include <functions/tnlConstantFunction.h> + +template< typename Mesh, + typename Anisotropy = tnlConstantFunction< Mesh::getMeshDimensions(), typename Mesh::RealType > +class tnlFastSweepingMethod +{ +}; + +template< typename Real, + typename Device, + typename Index, + typename Anisotropy > +class tnlFastSweepingMethod< tnlGrid< 2, Real, Device, Index >, Anisotropy > +{ + static_assert( std::is_same< Device, tnlHost >::value, "The fast sweeping method works only on CPU." ); + + public: + + typedef tnlGrid< 2, Real, Device, Index > MeshType; + typedef Real RealType; + typedef tnlHost DeviceType; + typedef Index IndexType; + typedef Anisotropy AnisotropyType; + typedef tnlMeshFunction< MeshType > MeshFunctionType; + + tnlFastSweepingMethod(); + + const IndexType& getMaxIterations() const; + + void setMaxIterations( const IndexType& maxIterations ); + + void solve( const MeshType& mesh, + const AnisotropyType& anisotropy, + MeshFunctionType& u ); + + + protected: + + const IndexType maxIterations; +}; + +#include "tnlFastSweepingMethod2D_impl.h" diff --git a/examples/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h b/examples/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h new file mode 100644 index 0000000000..1959be39fa --- /dev/null +++ b/examples/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h @@ -0,0 +1,62 @@ +/* + * 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: tnlFastSweepingMethod2D_impl.h + * Author: oberhuber + * + * Created on July 14, 2016, 10:32 AM + */ + +#pragma once + +#include "tnlFastSweepingMethod.h" + +template< typename Real, + typename Device, + typename Index, + typename Anisotropy > +tnlFastSweepingMethod< tnlGrid< 2, Real, Device, Index >, Anisotropy >:: +tnlFastSweepingMethod() +{ + +} + +template< typename Real, + typename Device, + typename Index, + typename Anisotropy > +const Index& +tnlFastSweepingMethod< tnlGrid< 2, Real, Device, Index >, Anisotropy >:: +getMaxIterations() const +{ + +} + +template< typename Real, + typename Device, + typename Index, + typename Anisotropy > +void +tnlFastSweepingMethod< tnlGrid< 2, Real, Device, Index >, Anisotropy >:: +setMaxIterations( const IndexType& maxIterations ) +{ + +} + +template< typename Real, + typename Device, + typename Index, + typename Anisotropy > +void +tnlFastSweepingMethod< tnlGrid< 2, Real, Device, Index >, Anisotropy >:: +solve( const MeshType& mesh, + const AnisotropyType& anisotropy, + MeshFunctionType& u ) +{ + +} + -- GitLab