diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 157374d4c7c1224768332810c40103f6aea4646c..9670a1ed73767ac132db7268e6169e9da17038fe 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -60,12 +60,11 @@ stages:
                 -DWITH_EXAMPLES=${WITH_EXAMPLES}
                 -DWITH_TOOLS=${WITH_TOOLS}
                 -DWITH_PYTHON=${WITH_PYTHON}
-#        - make
-#        - make test
+        # "install" implies the "all" target
 #        - make install
-        - ninja ${NINJAFLAGS}
+#        - make test
+        - ninja ${NINJAFLAGS} install
         - ninja test
-        - ninja install
         - popd
     variables:
         <<: *default_cmake_flags
@@ -73,15 +72,23 @@ stages:
 
 # Cuda builds are specified first because they take more time than host-only builds,
 # which can be allocated on hosts whitout GPUs.
+# Similarly, release builds are launched first to avoid the tail effect (they take
+# significantly more time than debug builds).
 
-cuda_base_Debug:
+cuda_full_Release:
     <<: *build_template
     tags:
+        - openmp
         - gpu
     variables:
         <<: *default_cmake_flags
+        WITH_OPENMP: "yes"
         WITH_CUDA: "yes"
-        BUILD_TYPE: Debug
+        BUILD_TYPE: Release
+        WITH_BENCHMARKS: "yes"
+        WITH_EXAMPLES: "yes"
+        WITH_TOOLS: "yes"
+        WITH_PYTHON: "yes"
 
 cuda_base_Release:
     <<: *build_template
@@ -92,19 +99,6 @@ cuda_base_Release:
         WITH_CUDA: "yes"
         BUILD_TYPE: Release
 
-cuda_mpi_Debug:
-    <<: *build_template
-    tags:
-        - openmp
-        - gpu
-        - mpi
-    variables:
-        <<: *default_cmake_flags
-        WITH_OPENMP: "yes"
-        WITH_CUDA: "yes"
-        WITH_MPI: "yes"
-        BUILD_TYPE: Debug
-
 cuda_mpi_Release:
     <<: *build_template
     tags:
@@ -133,20 +127,28 @@ cuda_full_Debug:
         WITH_TOOLS: "yes"
         WITH_PYTHON: "yes"
 
-cuda_full_Release:
+cuda_base_Debug:
+    <<: *build_template
+    tags:
+        - gpu
+    variables:
+        <<: *default_cmake_flags
+        WITH_CUDA: "yes"
+        BUILD_TYPE: Debug
+
+cuda_mpi_Debug:
     <<: *build_template
     tags:
         - openmp
         - gpu
+        - mpi
     variables:
         <<: *default_cmake_flags
         WITH_OPENMP: "yes"
         WITH_CUDA: "yes"
-        BUILD_TYPE: Release
-        WITH_BENCHMARKS: "yes"
-        WITH_EXAMPLES: "yes"
-        WITH_TOOLS: "yes"
-        WITH_PYTHON: "yes"
+        WITH_MPI: "yes"
+        BUILD_TYPE: Debug
+
 
 default_base_Debug:
     <<: *build_template
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000000000000000000000000000000000..21c479a2cdf65ff588bbc82077baf11c1825cb22
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,79 @@
+## How to configure git
+
+It is important to [configure your git username and email address](
+https://mmg-gitlab.fjfi.cvut.cz/gitlab/help/gitlab-basics/start-using-git.md#add-your-git-username-and-set-your-email),
+since every git commit will use this information to identify you as the author:
+
+    git config --global user.name "John Doe"
+    git config --global user.email "john.doe@example.com"
+
+In the TNL project, this username should be your real name (given name and
+family name) and the email address should be the email address used in the
+Gitlab profile. You should use the same configuration on all computers where
+you make commits. If you have made some commits with a different email address
+in the past, you can also add secondary email addresses to the Gitlab profile.
+
+## How to write good commit messages
+
+Begin with a short summary line a.k.a. message subject:
+
+- Use up to 50 characters; this is the git official preference.
+- Finish without a sentence-ending period.
+
+Continue with a longer description a.k.a. message body:
+
+- Add a blank line after the summary line, then write as much as you want.
+- Use up to 72 characters per line for typical text for word wrap.
+- Use as many characters as needed for atypical text, such as URLs, terminal
+  output, formatted messages, etc.
+- Include any kind of notes, links, examples, etc. as you want.
+
+See [5 Useful Tips For A Better Commit Message](
+https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message) and
+[How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/)
+for examples and reasoning.
+
+## How to split commits
+
+Extensive changes should be split into multiple commits so that only related
+changes are made in each commit. All changes made in a commit should be
+described in its commit message. If describing all changes would not result in
+a good commit message, you should probably make multiple separate commits.
+
+Multiple small commits are better than one big commit, because later they can be
+easily [squashed](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History)
+together, whereas splitting a big commit into logical parts is significantly
+more difficult.
+
+> __Tip:__ Use `git add -p` to stage only part of your working tree for the next
+> commit. See [git add -p: The most powerful git feature you're not using yet](
+https://johnkary.net/blog/git-add-p-the-most-powerful-git-feature-youre-not-using-yet/).
+
+## Rebase-based workflow
+
+The development of new features should follow the rebase-based workflow:
+
+- Create a new _feature_ branch based on the main branch (`develop`).
+- Make commits with your work in the feature branch.
+- When there are other new commits in the `develop` branch, you should do a
+  [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to rewind your
+  commits on top of the current develop branch.
+    - If there are conflicts, you will need to resolve them manually. Hence, it
+      is a good practice to rebase as often as possible (generally as soon as
+      the changes appear in the `develop` branch) and to split commits into
+      logical parts.
+- When your work is ready for review, you can open a [merge request](
+  https://mmg-gitlab.fjfi.cvut.cz/gitlab/tnl/tnl-dev/merge_requests/new).
+    - If the branch is not ready for merge yet, prepend `[WIP]` to the merge
+      request title to indicate _work in progress_ and to prevent a premature
+      merge.
+    - This is also a good time to squash small commits (e.g. typos, forgotten
+      changes or trivial corrections) with relevant bigger commits to make the
+      review easier.
+- When reviewed, the feature branch can be merged into the develop branch.
+
+The main advantages of this workflow are linear history, clear commits and
+reduction of merge conflicts. See [A rebase-based workflow](
+https://brokenco.de/2010/04/02/a-rebase-based-workflow.html) and
+[Why is rebase-then-merge better than just merge](https://stackoverflow.com/a/457988)
+([complement](https://stackoverflow.com/a/804178)) for reference.
\ No newline at end of file
diff --git a/build b/build
index 0f6723d604797c38dff9a95a3c99843ee9a86904..f11dbffbc1ed3b23bfb1ef514cc21755ed0283d8 100755
--- a/build
+++ b/build
@@ -111,6 +111,9 @@ fi
 if [[ ${WITH_CLANG} == "yes" ]]; then
    export CXX=clang++
    export CC=clang
+else
+   export CXX=g++
+   export CC=gcc
 fi
 
 if [[ ${WITH_MPI} == "yes" ]]; then
@@ -124,8 +127,9 @@ if [[ ${WITH_MPI} == "yes" ]]; then
 #       if [ -n "$CXX" ]; then
 #          export OMPI_CXX="$CXX"
 #       fi
-       export CXX=mpicxx
+       export CUDA_ARCH_HOST_COMPILER="$CXX"
        export CUDA_HOST_COMPILER=mpicxx
+       export CXX=mpicxx
     fi
     if [[ ! -x  "$(command -v mpicc)" ]]; then
        echo "Warning: mpicc is not installed on this system." 
diff --git a/src/Benchmarks/BLAS/array-operations.h b/src/Benchmarks/BLAS/array-operations.h
index 724869c92fd0593bd6eb3338e340b2a2726a37c8..5134dafe04db9115f2743ad81a830ca6349e5df0 100644
--- a/src/Benchmarks/BLAS/array-operations.h
+++ b/src/Benchmarks/BLAS/array-operations.h
@@ -30,7 +30,7 @@ benchmarkArrayOperations( Benchmark & benchmark,
    typedef Containers::Array< Real, Devices::Cuda, Index > CudaArray;
    using namespace std;
 
-   double datasetSize = ( double ) ( loops * size ) * sizeof( Real ) / oneGB;
+   double datasetSize = (double) size * sizeof( Real ) / oneGB;
 
    HostArray hostArray, hostArray2;
    CudaArray deviceArray, deviceArray2;
diff --git a/src/Benchmarks/BLAS/spmv.h b/src/Benchmarks/BLAS/spmv.h
index a6840af9f8c1f1dedeee876fd2bca258a55c64ba..4421076a6c14d9f247fd50b3cd92530579526cdf 100644
--- a/src/Benchmarks/BLAS/spmv.h
+++ b/src/Benchmarks/BLAS/spmv.h
@@ -139,7 +139,7 @@ benchmarkSpMV( Benchmark & benchmark,
 
    const int elements = setHostTestMatrix< HostMatrix >( hostMatrix, elementsPerRow );
    setCudaTestMatrix< DeviceMatrix >( deviceMatrix, elementsPerRow );
-   const double datasetSize = ( double ) loops * elements * ( 2 * sizeof( Real ) + sizeof( int ) ) / oneGB;
+   const double datasetSize = (double) elements * ( 2 * sizeof( Real ) + sizeof( int ) ) / oneGB;
 
    // reset function
    auto reset = [&]() {
diff --git a/src/Benchmarks/BLAS/tnl-benchmark-blas.h b/src/Benchmarks/BLAS/tnl-benchmark-blas.h
index 4f6d63022db3302c71a145a0d78a96c0016e726d..6419087a93b393fe1ee0d4ad56c5bbba6252ce56 100644
--- a/src/Benchmarks/BLAS/tnl-benchmark-blas.h
+++ b/src/Benchmarks/BLAS/tnl-benchmark-blas.h
@@ -43,7 +43,7 @@ runBlasBenchmarks( Benchmark & benchmark,
                            metadata );
    for( std::size_t size = minSize; size <= maxSize; size *= 2 ) {
       benchmark.setMetadataColumns( Benchmark::MetadataColumns({
-         {"size", size},
+         {"size", String( size ) },
       } ));
       benchmarkArrayOperations< Real >( benchmark, loops, size );
    }
@@ -53,7 +53,7 @@ runBlasBenchmarks( Benchmark & benchmark,
                            metadata );
    for( std::size_t size = minSize; size <= maxSize; size *= sizeStepFactor ) {
       benchmark.setMetadataColumns( Benchmark::MetadataColumns({
-         {"size", size},
+         { "size", String( size ) },
       } ));
       benchmarkVectorOperations< Real >( benchmark, loops, size );
    }
@@ -63,9 +63,9 @@ runBlasBenchmarks( Benchmark & benchmark,
                            metadata );
    for( std::size_t size = minSize; size <= maxSize; size *= 2 ) {
       benchmark.setMetadataColumns( Benchmark::MetadataColumns({
-         {"rows", size},
-         {"columns", size},
-         {"elements per row", elementsPerRow},
+         {"rows", String( size ) },
+         {"columns", String( size ) },
+         {"elements per row", String( elementsPerRow ) },
       } ));
       benchmarkSpmvSynthetic< Real >( benchmark, loops, size, elementsPerRow );
    }
diff --git a/src/Benchmarks/BLAS/vector-operations.h b/src/Benchmarks/BLAS/vector-operations.h
index e5b6f5aee648ac89f1ec44656a3ce67b8043c24d..40f392ebd49d6fb0397345adf0939f504193c6fd 100644
--- a/src/Benchmarks/BLAS/vector-operations.h
+++ b/src/Benchmarks/BLAS/vector-operations.h
@@ -36,7 +36,7 @@ benchmarkVectorOperations( Benchmark & benchmark,
    typedef Containers::Vector< Real, Devices::Cuda, Index > CudaVector;
    using namespace std;
 
-   double datasetSize = ( double ) ( loops * size ) * sizeof( Real ) / oneGB;
+   double datasetSize = (double) size * sizeof( Real ) / oneGB;
 
    HostVector hostVector, hostVector2;
    CudaVector deviceVector, deviceVector2;
@@ -252,7 +252,7 @@ benchmarkVectorOperations( Benchmark & benchmark,
    hostVector.computePrefixSum();
    timer.stop();
    timeHost = timer.getTime();
-   bandwidth = 2 * datasetSize / loops / timer.getTime();
+   bandwidth = 2 * datasetSize / timer.getTime();
    std::cout << "  CPU: bandwidth: " << bandwidth << " GB/sec, time: " << timer.getTime() << " sec." << std::endl;
 
    timer.reset();
@@ -260,7 +260,7 @@ benchmarkVectorOperations( Benchmark & benchmark,
    deviceVector.computePrefixSum();
    timer.stop();
    timeDevice = timer.getTime();
-   bandwidth = 2 * datasetSize / loops / timer.getTime();
+   bandwidth = 2 * datasetSize / timer.getTime();
    std::cout << "  GPU: bandwidth: " << bandwidth << " GB/sec, time: " << timer.getTime() << " sec." << std::endl;
    std::cout << "  CPU/GPU speedup: " << timeHost / timeDevice << std::endl;
 
diff --git a/src/Benchmarks/Benchmarks.h b/src/Benchmarks/Benchmarks.h
index 4b0c622714293cfaa496f49ac695f619d78f8f5b..2b8b28b892b1c8f2332e0d9e702b8b74228578aa 100644
--- a/src/Benchmarks/Benchmarks.h
+++ b/src/Benchmarks/Benchmarks.h
@@ -504,7 +504,9 @@ Benchmark::MetadataMap getHardwareMetadata()
        { "system release", Devices::SystemInfo::getSystemRelease() },
        { "start time", Devices::SystemInfo::getCurrentTime() },
 #ifdef HAVE_MPI
-       { "number of MPI processes", Communicators::MpiCommunicator::GetSize( Communicators::MpiCommunicator::AllGroup ) },
+       { "number of MPI processes", (Communicators::MpiCommunicator::IsInitialized())
+                                       ? Communicators::MpiCommunicator::GetSize( Communicators::MpiCommunicator::AllGroup )
+                                       : 1 },
 #endif
        { "OpenMP enabled", Devices::Host::isOMPEnabled() },
        { "OpenMP threads", Devices::Host::getMaxThreadsCount() },
diff --git a/src/Benchmarks/LinearSolvers/benchmarks.h b/src/Benchmarks/LinearSolvers/benchmarks.h
index 032ed74ed2f708d65063e2356411ccfd39e51d23..e9811003d3d3b0f045c29a20acb88baf646d0e57 100644
--- a/src/Benchmarks/LinearSolvers/benchmarks.h
+++ b/src/Benchmarks/LinearSolvers/benchmarks.h
@@ -39,12 +39,29 @@ void barrier( const DistributedContainers::DistributedMatrix< Matrix, Communicat
    Communicator::Barrier( matrix.getCommunicationGroup() );
 }
 
+template< typename Device >
+bool checkDevice( const Config::ParameterContainer& parameters )
+{
+   const String device = parameters.getParameter< String >( "devices" );
+   if( device == "all" )
+      return true;
+   if( std::is_same< Device, Devices::Host >::value && device == "host" )
+      return true;
+   if( std::is_same< Device, Devices::Cuda >::value && device == "cuda" )
+      return true;
+   return false;
+}
+
 template< template<typename> class Preconditioner, typename Matrix >
 void
 benchmarkPreconditionerUpdate( Benchmark& benchmark,
                                const Config::ParameterContainer& parameters,
                                const SharedPointer< Matrix >& matrix )
 {
+   // skip benchmarks on devices which the user did not select
+   if( ! checkDevice< typename Matrix::DeviceType >( parameters ) )
+      return;
+
    barrier( matrix );
    const char* performer = getPerformer< typename Matrix::DeviceType >();
    Preconditioner< Matrix > preconditioner;
@@ -67,6 +84,10 @@ benchmarkSolver( Benchmark& benchmark,
                  const Vector& x0,
                  const Vector& b )
 {
+   // skip benchmarks on devices which the user did not select
+   if( ! checkDevice< typename Matrix::DeviceType >( parameters ) )
+      return;
+
    barrier( matrix );
    const char* performer = getPerformer< typename Matrix::DeviceType >();
 
diff --git a/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h b/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h
index 555e6bd3b2cdf34f842e2d60643ae82e824c7a29..a898f156b4e2e25915e20ece50539991b25f47b2 100644
--- a/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h
+++ b/src/Benchmarks/LinearSolvers/tnl-benchmark-linear-solvers.h
@@ -497,6 +497,12 @@ configSetup( Config::ConfigDescription& config )
    config.addEntry< String >( "solvers", "Comma-separated list of solvers to run benchmarks for. Options: gmres, cwygmres, tfqmr, bicgstab, bicgstab-ell.", "all" );
    config.addEntry< String >( "preconditioners", "Comma-separated list of preconditioners to run benchmarks for. Options: jacobi, ilu0, ilut.", "all" );
    config.addEntry< bool >( "with-preconditioner-update", "Run benchmark for the preconditioner update.", true );
+   config.addEntry< String >( "devices", "Run benchmarks on these devices.", "all" );
+   config.addEntryEnum( "all" );
+   config.addEntryEnum( "host" );
+   #ifdef HAVE_CUDA
+   config.addEntryEnum( "cuda" );
+   #endif
 
    config.addDelimiter( "Device settings:" );
    Devices::Host::configSetup( config );
diff --git a/src/Examples/narrow-band/CMakeLists.txt b/src/Examples/narrow-band/CMakeLists.txt
deleted file mode 100644
index 158cd20132ed4f499228cda7400ba18776dc1503..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-set( tnl_narrow_band_SOURCES
-#     MainBuildConfig.h
-#     tnlNarrowBand2D_impl.h
-#     tnlNarrowBand.h
-#     narrowBandConfig.h 
-     main.cpp)
-
-
-IF(  BUILD_CUDA ) 
-	CUDA_ADD_EXECUTABLE(narrow-band main.cu)
-ELSE(  BUILD_CUDA )                
-	ADD_EXECUTABLE(narrow-band main.cpp)
-ENDIF( BUILD_CUDA )
-target_link_libraries (narrow-band tnl )
-
-
-INSTALL( TARGETS narrow-band
-         RUNTIME DESTINATION bin
-         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
-        
-#INSTALL( FILES ${tnl_narrow_band_SOURCES}
-#         DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/narrow-band )
diff --git a/src/Examples/narrow-band/MainBuildConfig.h b/src/Examples/narrow-band/MainBuildConfig.h
deleted file mode 100644
index ed3d686eb99379af1589d734eac9b5812cccdedf..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/MainBuildConfig.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
-                          MainBuildConfig.h  -  description
-                             -------------------
-    begin                : Jul 7, 2014
-    copyright            : (C) 2014 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 MAINBUILDCONFIG_H_
-#define MAINBUILDCONFIG_H_
-
-#include <solvers/tnlBuildConfigTags.h>
-
-class MainBuildConfig
-{
-   public:
-
-      static void print() {std::cerr << "MainBuildConfig" <<std::endl; }
-};
-
-/****
- * Turn off support for float and long double.
- */
-template<> struct tnlConfigTagReal< MainBuildConfig, float > { enum { enabled = false }; };
-template<> struct tnlConfigTagReal< MainBuildConfig, long double > { enum { enabled = false }; };
-
-/****
- * Turn off support for short int and long int indexing.
- */
-template<> struct tnlConfigTagIndex< MainBuildConfig, short int >{ enum { enabled = false }; };
-template<> struct tnlConfigTagIndex< MainBuildConfig, long int >{ enum { enabled = false }; };
-
-/****
- * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.
- */
-template< int Dimensions, typename Real, typename Device, typename Index >
-   struct tnlConfigTagMesh< MainBuildConfig, tnlGrid< Dimensions, Real, Device, Index > >
-      { enum { enabled = tnlConfigTagDimensions< MainBuildConfig, Dimensions >::enabled  &&
-                         tnlConfigTagReal< MainBuildConfig, Real >::enabled &&
-                         tnlConfigTagDevice< MainBuildConfig, Device >::enabled &&
-                         tnlConfigTagIndex< MainBuildConfig, Index >::enabled }; };
-
-/****
- * Please, chose your preferred time discretisation  here.
- */
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = false}; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };
-
-/****
- * Only the Runge-Kutta-Merson solver is enabled by default.
- */
-template<> struct tnlConfigTagExplicitSolver< MainBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };
-
-#endif /* MAINBUILDCONFIG_H_ */
diff --git a/src/Examples/narrow-band/main.cpp b/src/Examples/narrow-band/main.cpp
deleted file mode 100644
index 8849008ff630db0400a6d7d98e789099e5fbb5d9..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/Examples/narrow-band/main.cu b/src/Examples/narrow-band/main.cu
deleted file mode 100644
index 8849008ff630db0400a6d7d98e789099e5fbb5d9..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/main.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/Examples/narrow-band/main.h b/src/Examples/narrow-band/main.h
deleted file mode 100644
index 51dbdac37cfc5ff76b5ad03b826bf3a4642b17b4..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/main.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-                          main.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-
-#include "MainBuildConfig.h"
-	//for HOST versions:
-//#include "tnlNarrowBand.h"
-	//for DEVICE versions:
-#include "tnlNarrowBand_CUDA.h"
-#include "narrowBandConfig.h"
-#include <solvers/tnlBuildConfigTags.h>
-
-#include <mesh/tnlGrid.h>
-#include <core/tnlDevice.h>
-#include <time.h>
-#include <ctime>
-
-typedef MainBuildConfig BuildConfig;
-
-int main( int argc, char* argv[] )
-{
-	time_t start;
-	time_t stop;
-	time(&start);
-	std::clock_t start2= std::clock();
-   Config::ParameterContainer parameters;
-   tnlConfigDescription configDescription;
-   narrowBandConfig< BuildConfig >::configSetup( configDescription );
-
-   if( ! parseCommandLine( argc, argv, configDescription, parameters ) )
-      return false;
-
-   const int& dim = parameters.getParameter< int >( "dim" );
-
-   if(dim == 2)
-   {
-		tnlNarrowBand<tnlGrid<2,double,TNL::Devices::Host, int>, double, int> solver;
-		if(!solver.init(parameters))
-	   {
-			cerr << "Solver failed to initialize." <<std::endl;
-			return EXIT_FAILURE;
-	   }
-		TNL_CHECK_CUDA_DEVICE;
-	  std::cout << "-------------------------------------------------------------" <<std::endl;
-	  std::cout << "Starting solver..." <<std::endl;
-	   solver.run();
-   }
-//   else if(dim == 3)
-//   {
-//		tnlNarrowBand<tnlGrid<3,double,TNL::Devices::Host, int>, double, int> solver;
-//		if(!solver.init(parameters))
-//	   {
-//			cerr << "Solver failed to initialize." <<std::endl;
-//			return EXIT_FAILURE;
-//	   }
-//		TNL_CHECK_CUDA_DEVICE;
-//	  std::cout << "-------------------------------------------------------------" <<std::endl;
-//	  std::cout << "Starting solver..." <<std::endl;
-//	   solver.run();
-//   }
-   else
-   {
-	  std::cerr << "Unsupported number of dimensions: " << dim << "!" <<std::endl;
-	   return EXIT_FAILURE;
-   }
-
-
-   time(&stop);
-  std::cout << "Solver stopped..." <<std::endl;
-  std::cout <<std::endl;
-  std::cout << "Running time was: " << difftime(stop,start) << " .... " << (std::clock() - start2) / (double)(CLOCKS_PER_SEC) <<std::endl;
-   return EXIT_SUCCESS;
-}
-
-
diff --git a/src/Examples/narrow-band/narrowBandConfig.h b/src/Examples/narrow-band/narrowBandConfig.h
deleted file mode 100644
index bab58ceac46bf9c766b697ed79c2c676111323a2..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/narrowBandConfig.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/***************************************************************************
-                          narrowBandConfig.h  -  description
-                             -------------------
-    begin                : Oct 15, 2015
-    copyright            : (C) 2015 by Tomas Sobotik
-    email                :
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 NARROWBANDCONFIG_H_
-#define NARROWBANDCONFIG_H_
-
-#include <config/tnlConfigDescription.h>
-
-template< typename ConfigTag >
-class narrowBandConfig
-{
-   public:
-      static void configSetup( tnlConfigDescription& config )
-      {
-         config.addDelimiter( "Narrow Band Solver solver settings:" );
-         config.addEntry        < String > ( "problem-name", "This defines particular problem.", "fast-sweeping" );
-         config.addRequiredEntry        < String > ( "initial-condition", "Initial condition for solver");
-         config.addRequiredEntry        < int > ( "dim", "Dimension of problem.");
-         config.addRequiredEntry        < double > ( "tau", "Time step.");
-         config.addRequiredEntry        < double > ( "final-time", "Final time.");
-         config.addEntry       < String > ( "mesh", "Name of mesh.", "mesh.tnl" );
-         config.addEntry       < String > ( "exact-input", "Are the function values near the curve equal to the SDF? (yes/no)", "no" );
-      }
-};
-
-#endif /* NARROWBANDCONFIG_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand.h b/src/Examples/narrow-band/tnlNarrowBand.h
deleted file mode 100644
index 7d3d19bc03b43247f735cf04c5c82368360a748d..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND_H_
-#define TNLNARROWBAND_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <functions/tnlMeshFunction.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-#include <ctime>
-#ifdef HAVE_OPENMP
-#include <omp.h>
-#endif
-
-
-
-
-template< typename Mesh,
-		  typename Real,
-		  typename Index >
-class tnlNarrowBand
-{};
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 2, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-
-	tnlNarrowBand();
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-
-	bool initGrid();
-	bool run();
-
-	//for single core version use this implementation:
-	void updateValue(const Index i, const Index j);
-	//for parallel version use this one instead:
-//	void updateValue(const Index i, const Index j, DofVectorType* grid);
-
-
-	void setupSquare1000(Index i, Index j);
-	void setupSquare1100(Index i, Index j);
-	void setupSquare1010(Index i, Index j);
-	void setupSquare1001(Index i, Index j);
-	void setupSquare1110(Index i, Index j);
-	void setupSquare1101(Index i, Index j);
-	void setupSquare1011(Index i, Index j);
-	void setupSquare1111(Index i, Index j);
-	void setupSquare0000(Index i, Index j);
-	void setupSquare0100(Index i, Index j);
-	void setupSquare0010(Index i, Index j);
-	void setupSquare0001(Index i, Index j);
-	void setupSquare0110(Index i, Index j);
-	void setupSquare0101(Index i, Index j);
-	void setupSquare0011(Index i, Index j);
-	void setupSquare0111(Index i, Index j);
-
-	Real fabsMin(const Real x, const Real y);
-
-
-protected:
-
-	MeshType Mesh;
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector, dofVector2;
-	DofVectorType data;
-
-	RealType h;
-
-	tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage > Entity;
-
-
-#ifdef HAVE_OPENMP
-//	omp_lock_t* gridLock;
-#endif
-
-
-};
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 3, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-	tnlNarrowBand();
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-
-	bool initGrid();
-	bool run();
-
-	//for single core version use this implementation:
-	void updateValue(const Index i, const Index j, const Index k);
-	//for parallel version use this one instead:
-//	void updateValue(const Index i, const Index j, DofVectorType* grid);
-
-	Real fabsMin(const Real x, const Real y);
-
-
-protected:
-
-	MeshType Mesh;
-
-	bool exactInput;
-
-
-	tnlMeshFunction<MeshType> dofVector, dofVector2;
-	DofVectorType data;
-
-	RealType h;
-
-	tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage > Entity;
-
-#ifdef HAVE_OPENMP
-//	omp_lock_t* gridLock;
-#endif
-
-
-};
-
-
-	//for single core version use this implementation:
-#include "tnlNarrowBand2D_impl.h"
-	//for parallel version use this one instead:
-// #include "tnlNarrowBand2D_openMP_impl.h"
-
-#include "tnlNarrowBand3D_impl.h"
-
-#endif /* TNLNARROWBAND_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand2D_CUDA_v4_impl.h b/src/Examples/narrow-band/tnlNarrowBand2D_CUDA_v4_impl.h
deleted file mode 100644
index dff0b48c8d69cc6fa6ec932e24446a8c3b1b1417..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand2D_CUDA_v4_impl.h
+++ /dev/null
@@ -1,1317 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand2D_CUDA_v4_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND2D_IMPL_H_
-#define TNLNARROWBAND2D_IMPL_H_
-
-#define NARROWBAND_SUBGRID_SIZE 32
-
-#include "tnlNarrowBand.h"
-
-#ifdef HAVE_CUDA
-__device__
-double fabsMin( double x, double y)
-{
-	double fx = abs(x);
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__device__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(__longlong_as_double(assumed),val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-#endif
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-#ifdef HAVE_CUDA
-   __device__ __host__
-#endif
-Real tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >:: positivePart(const Real arg) const
-{
-	if(arg > 0.0)
-		return arg;
-	return 0.0;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-#ifdef HAVE_CUDA
-   __device__ __host__
-#endif
-Real  tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: negativePart(const Real arg) const
-{
-	if(arg < 0.0)
-		return -arg;
-	return 0.0;
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlNarrowBand< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlNarrowBand()
-:dofVector(Mesh)
-{
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	//Entity.refresh();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-	tau = parameters.getParameter< double >( "tau" );
-
-	finalTime = parameters.getParameter< double >( "final-time" );
-
-	statusGridSize = ((Mesh.getDimensions().x() + NARROWBAND_SUBGRID_SIZE-1 ) / NARROWBAND_SUBGRID_SIZE);
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaStatusVector),  statusGridSize*statusGridSize*sizeof(int));
-//	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(),  statusGridSize*statusGridSize* sizeof(int)), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&reinitialize, sizeof(int));
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-#endif
-
-	int n = Mesh.getDimensions().x();
-
-	dim3 threadsPerBlock2(NARROWBAND_SUBGRID_SIZE, NARROWBAND_SUBGRID_SIZE);
-	dim3 numBlocks2(statusGridSize ,statusGridSize);
-	initSetupGridCUDA<<<numBlocks2,threadsPerBlock2>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	initSetupGrid2CUDA<<<numBlocks2,1>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-
-	/*dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);*/
-	initCUDA<<<numBlocks2,threadsPerBlock2>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-
-	cout << "Solver initialized." <<std::endl;
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlockFS(1, 512);
-	dim3 numBlocksFS(4,1);
-	dim3 threadsPerBlockNB(NARROWBAND_SUBGRID_SIZE, NARROWBAND_SUBGRID_SIZE);
-	dim3 numBlocksNB(n/NARROWBAND_SUBGRID_SIZE + 1,n/NARROWBAND_SUBGRID_SIZE + 1);
-
-	double time = 0.0;
-	int reinit = 0;
-
-	cout << "Hi!" <<std::endl;
-	runCUDA<<<numBlocksFS,threadsPerBlockFS>>>(this->cudaSolver,0,0);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	cout << "Hi2!" <<std::endl;
-	while(time < finalTime)
-	{
-		if(tau+time > finalTime)
-			tau=finalTime-time;
-
-		runNarrowBandCUDA<<<numBlocksNB,threadsPerBlockNB>>>(this->cudaSolver,tau);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		time += tau;
-
-
-		cudaMemcpy(&reinit, this->reinitialize, sizeof(int), cudaMemcpyDeviceToHost);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		if(reinit != 0 /*&& time != finalTime */)
-		{
-			cout << time <<std::endl;
-
-			initSetupGridCUDA<<<numBlocksNB,threadsPerBlockNB>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			initSetupGrid2CUDA<<<numBlocksNB,1>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			initCUDA<<<numBlocksNB,threadsPerBlockNB>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			runCUDA<<<numBlocksFS,threadsPerBlockFS>>>(this->cudaSolver,0,0);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-		}
-	}
-
-	//data.setLike(dofVector.getData());
-	//cudaMemcpy(data.getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaMemcpy(dofVector.getData().getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	//data.save("u-00001.tnl");
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	//			1 - with curve,  	2 - to the north of curve, 	4  - to the south of curve,
-	//								8 - to the east of curve, 	16 - to the west of curve.
-	int subgridID = i/NARROWBAND_SUBGRID_SIZE + (j/NARROWBAND_SUBGRID_SIZE) * statusGridSize;
-	if(cudaStatusVector[subgridID] != 0 && i<Mesh.getDimensions().x() && j < Mesh.getDimensions().y())
-	{
-		tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-		Entity.setCoordinates(CoordinatesType(i,j));
-		Entity.refresh();
-		tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-		Real value = cudaDofVector2[Entity.getIndex()];
-		Real a,b, tmp;
-
-		if( i == 0 /*|| (i/NARROWBAND_SUBGRID_SIZE == 0 && !(cudaStatusVector[subgridID] & 9))*/ )
-			a = cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-		else if( i == Mesh.getDimensions().x() - 1 /*|| (i/NARROWBAND_SUBGRID_SIZE == NARROWBAND_SUBGRID_SIZE - 1 && !(cudaStatusVector[subgridID] & 17))*/ )
-			a = cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-		else
-		{
-			a = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-					 cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-		}
-
-		if( j == 0 /*|| (j/NARROWBAND_SUBGRID_SIZE == 0 && !(cudaStatusVector[subgridID] & 3))*/ )
-			b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-		else if( j == Mesh.getDimensions().y() - 1 /* || (j/NARROWBAND_SUBGRID_SIZE == NARROWBAND_SUBGRID_SIZE - 1 && !(cudaStatusVector[subgridID] & 5)) */)
-			b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-		else
-		{
-			b = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-					 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-		}
-
-
-		if(abs(a-b) >= h)
-			tmp = fabsMin(a,b) + sign(value)*h;
-		else
-			tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-	//	cudaDofVector2[Entity.getIndex()]  = fabsMin(value, tmp);
-		atomicFabsMin(&(cudaDofVector2[Entity.getIndex()]), tmp);
-	}
-
-}
-
-
-__global__ void initCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-
-
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-
-	if(solver->Mesh.getDimensions().x() > gx  && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int i = threadIdx.x + blockDim.x*blockIdx.x;
-	int j = blockDim.y*blockIdx.y + threadIdx.y;
-
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	int gid = Entity.getIndex();
-
-	if(abs(cudaDofVector2[gid]) > 1.5*h)
-		cudaDofVector2[gid] = INT_MAX*sign(cudaDofVector2[gid]);
-
-//	if (i >0 && j > 0 && i+1 < Mesh.getDimensions().x() && j+1 < Mesh.getDimensions().y())
-//	{
-//		if(cudaDofVector2[gid]*cudaDofVector2[gid+1] <= 0 )
-//		{
-//			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-//			cudaDofVector2[gid+1] = sign(cudaDofVector2[gid+1])*0.5*h;
-//		}
-//		if( cudaDofVector2[gid]*cudaDofVector2[gid+Mesh.getDimensions().x()] <= 0 )
-//		{
-//			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-//			cudaDofVector2[gid+Mesh.getDimensions().x()] = sign(cudaDofVector2[gid+Mesh.getDimensions().x()])*0.5*h;
-//		}
-//
-//		if(cudaDofVector2[gid]*cudaDofVector2[gid-1] <= 0 )
-//		{
-//			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-//			cudaDofVector2[gid-1] = sign(cudaDofVector2[gid-1])*0.5*h;
-//		}
-//		if( cudaDofVector2[gid]*cudaDofVector2[gid-Mesh.getDimensions().x()] <= 0 )
-//		{
-//			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-//			cudaDofVector2[gid-Mesh.getDimensions().x()] = sign(cudaDofVector2[gid-Mesh.getDimensions().x()])*0.5*h;
-//		}
-//	}
-
-
-//
-
-
-
-
-
-
-//	if(i+1 < Mesh.getDimensions().x() && j+1 < Mesh.getDimensions().y() )
-//	{
-//		if(cudaDofVector[Entity.getIndex()] > 0)
-//		{
-//			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1111(i,j);
-//					else
-//						setupSquare1110(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1101(i,j);
-//					else
-//						setupSquare1100(i,j);
-//				}
-//			}
-//			else
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1011(i,j);
-//					else
-//						setupSquare1010(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1001(i,j);
-//					else
-//						setupSquare1000(i,j);
-//				}
-//			}
-//		}
-//		else
-//		{
-//			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0111(i,j);
-//					else
-//						setupSquare0110(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0101(i,j);
-//					else
-//						setupSquare0100(i,j);
-//				}
-//			}
-//			else
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0011(i,j);
-//					else
-//						setupSquare0010(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0001(i,j);
-//					else
-//						setupSquare0000(i,j);
-//				}
-//			}
-//		}
-//
-//	}
-
-	return true;
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	//Real fy = abs(y);
-
-	//Real tmpMin = Min(fx,abs(y));
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-
-	int gx = 0;
-	int gy = threadIdx.y;
-	//if(solver->Mesh.getDimensions().x() <= gx || solver->Mesh.getDimensions().y() <= gy)
-	//	return;
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-	//int gid = solver->Mesh.getDimensions().x() * gy + gx;
-	//int max = solver->Mesh.getDimensions().x()*solver->Mesh.getDimensions().x();
-
-	//int id1 = gx+gy;
-	//int id2 = (solver->Mesh.getDimensions().x() - gx - 1) + gy;
-
-	if(blockIdx.x==0)
-	{
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==1)
-	{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==2)
-	{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==3)
-	{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-
-}
-
-
-
-
-__global__ void initSetupGridCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	__shared__ double u0;
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-
-//		printf("Hello from  block = %d, thread = %d, x = %d, y = %d\n", blockIdx.x + gridDim.x*blockIdx.y,(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x, threadIdx.x, threadIdx.y);
-		if(threadIdx.x+threadIdx.y == 0)
-		{
-//			printf("Hello from  block = %d, thread = %d, x = %d, y = %d\n", blockIdx.x + gridDim.x*blockIdx.y,(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x, threadIdx.x, threadIdx.y);
-
-			if(blockIdx.x+blockIdx.y == 0)
-				*(solver->reinitialize) = 0;
-
-			solver->cudaStatusVector[blockIdx.x + gridDim.x*blockIdx.y] = 0;
-
-			u0 = solver->cudaDofVector2[(blockDim.y*blockIdx.y + 0)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + 0];
-		}
-		__syncthreads();
-
-		double u = solver->cudaDofVector2[(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x];
-
-		if(u*u0 <=0.0)
-			atomicMax(&(solver->cudaStatusVector[blockIdx.x + gridDim.x*blockIdx.y]),1);
-	}
-//	if(threadIdx.x+threadIdx.y == 0)
-
-//	printf("Bye from  block = %d, thread = %d, x = %d, y = %d\n", blockIdx.x + gridDim.x*blockIdx.y,(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x, threadIdx.x, threadIdx.y);
-
-
-}
-
-
-
-// run this with one thread per block
-__global__ void initSetupGrid2CUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-//	printf("Hello\n");
-	if(solver->cudaStatusVector[blockIdx.x + gridDim.x*blockIdx.y] == 1)
-	{
-//			1 - with curve,  	2 - to the north of curve, 	4  - to the south of curve,
-//								8 - to the east of curve, 	16 - to the west of curve.
-			if(blockIdx.x > 0)
-			{
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x - 1 + gridDim.x*blockIdx.y]), 16);
-			}
-
-			if(blockIdx.x < gridDim.x - 1)
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x + 1 + gridDim.x*blockIdx.y]), 8);
-
-			if(blockIdx.y > 0 )
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x + gridDim.x*(blockIdx.y - 1)]), 4);
-
-			if(blockIdx.y < gridDim.y - 1)
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x + gridDim.x*(blockIdx.y + 1)]), 2);
-	}
-
-
-}
-
-
-
-
-
-__global__ void runNarrowBandCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, double tau)
-{
-	int gid = (blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x()+ threadIdx.x;
-	int i = threadIdx.x + blockIdx.x*blockDim.x;
-	int j = threadIdx.y + blockIdx.y*blockDim.y;
-
-//	if(i+j == 0)
-//		printf("Hello\n");
-
-	int blockID = blockIdx.x + blockIdx.y*gridDim.x; /*i/NARROWBAND_SUBGRID_SIZE + (j/NARROWBAND_SUBGRID_SIZE) * ((Mesh.getDimensions().x() + NARROWBAND_SUBGRID_SIZE-1 ) / NARROWBAND_SUBGRID_SIZE);*/
-
-	int status = solver->cudaStatusVector[blockID];
-
-	if(solver->Mesh.getDimensions().x() > i && solver->Mesh.getDimensions().y() > j)
-	{
-
-		if(status != 0)
-		{
-			tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(solver->Mesh);
-			Entity.setCoordinates(Containers::StaticVector<2,double>(i,j));
-			Entity.refresh();
-			tnlNeighborGridEntityGetter<tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-			double value = solver->cudaDofVector2[Entity.getIndex()];
-			double xf,xb,yf,yb, grad, fu, a,b;
-			a = b = 0.0;
-
-			if( i == 0 || (threadIdx.x == 0 && !(status & 9)) )
-			{
-				xb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-				xf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] - value;
-			}
-			else if( i == solver->Mesh.getDimensions().x() - 1 || (threadIdx.x == blockDim.x - 1 && !(status & 17)) )
-			{
-				xb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-				xf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()] - value;
-			}
-			else
-			{
-				xb =  value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-				xf = solver-> cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] - value;
-			}
-
-			if( j == 0 || (threadIdx.y == 0 && !(status & 3)) )
-			{
-				yb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] ;
-				yf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] - value;
-			}
-			else if( j == solver->Mesh.getDimensions().y() - 1  || (threadIdx.y == blockDim.y - 1 && !(status & 5)) )
-			{
-				yb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-				yf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()] - value;
-			}
-			else
-			{
-				yb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0, -1 >()];
-				yf = solver-> cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] - value;
-			}
-			__syncthreads();
-
-
-
-
-
-			   if(sign(value) >= 0.0)
-			   {
-				   xf = solver->negativePart(xf);
-
-				   xb = solver->positivePart(xb);
-
-				   yf = solver->negativePart(yf);
-
-				   yb = solver->positivePart(yb);
-
-			   }
-			   else
-			   {
-
-				   xb = solver->negativePart(xb);
-
-				   xf = solver->positivePart(xf);
-
-				   yb = solver->negativePart(yb);
-
-				   yf = solver->positivePart(yf);
-			   }
-
-
-			   if(xb > xf)
-				   a = xb*solver->Mesh.template getSpaceStepsProducts< -1, 0 >();
-			   else
-				   a = xf*solver->Mesh.template getSpaceStepsProducts< -1, 0 >();
-
-			   if(yb > yf)
-				   b = yb*solver->Mesh.template getSpaceStepsProducts< 0, -1 >();
-			   else
-				   b = yf*solver->Mesh.template getSpaceStepsProducts< 0, -1 >();
-
-
-
-//			grad = sqrt(0.5 * (xf*xf + xb*xb    +   yf*yf + yb*yb ) )*solver->Mesh.template getSpaceStepsProducts< -1, 0 >();
-
-			grad = sqrt(/*0.5 **/ (a*a    +   b*b ) );
-
-			fu = -1.0 * grad;
-
-			if((tau*fu+value)*value <=0 )
-			{
-				//			1 - with curve,  	2 - to the north of curve, 	4  - to the south of curve,
-				//								8 - to the east of curve, 	16 - to the west of curve.
-
-				if((threadIdx.x == 6 && !(status & 9)) && (blockIdx.x > 0) )
-					atomicMax(solver->reinitialize,1);
-				else if((threadIdx.x == blockDim.x - 7 && !(status & 17)) && (blockIdx.x < gridDim.x - 1) )
-					atomicMax(solver->reinitialize,1);
-				else if((threadIdx.y == 6 && !(status & 3)) && (blockIdx.y > 0) )
-					atomicMax(solver->reinitialize,1);
-				else if((threadIdx.y == blockDim.y - 7 && !(status & 5)) && (blockIdx.y < gridDim.y - 1) )
-					atomicMax(solver->reinitialize,1);
-			}
-
-			solver->cudaDofVector2[Entity.getIndex()]  += tau*fu;
-		}
-	}
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(INT_MAX,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-#endif
-
-
-
-
-#endif /* TNLNARROWBAND_IMPL_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand2D_CUDA_v5_impl.h b/src/Examples/narrow-band/tnlNarrowBand2D_CUDA_v5_impl.h
deleted file mode 100644
index c92810490069164d9f170249c328304576773d20..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand2D_CUDA_v5_impl.h
+++ /dev/null
@@ -1,1313 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand2D_CUDA_v4_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND2D_IMPL_H_
-#define TNLNARROWBAND2D_IMPL_H_
-
-#define NARROWBAND_SUBGRID_SIZE 32
-
-#include "tnlNarrowBand.h"
-
-__device__
-double fabsMin( double x, double y)
-{
-	double fx = abs(x);
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__device__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(__longlong_as_double(assumed),val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-#ifdef HAVE_CUDA
-   __device__ __host__
-#endif
-Real tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >:: positivePart(const Real arg) const
-{
-	if(arg > 0.0)
-		return arg;
-	return 0.0;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-#ifdef HAVE_CUDA
-   __device__ __host__
-#endif
-Real  tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: negativePart(const Real arg) const
-{
-	if(arg < 0.0)
-		return -arg;
-	return 0.0;
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlNarrowBand< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlNarrowBand()
-:dofVector(Mesh)
-{
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	//Entity.refresh();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-	tau = parameters.getParameter< double >( "tau" );
-
-	finalTime = parameters.getParameter< double >( "final-time" );
-
-	statusGridSize = ((Mesh.getDimensions().x() + NARROWBAND_SUBGRID_SIZE-1 ) / NARROWBAND_SUBGRID_SIZE);
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaStatusVector),  statusGridSize*statusGridSize*sizeof(int));
-//	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(),  statusGridSize*statusGridSize* sizeof(int)), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&reinitialize, sizeof(int));
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-#endif
-
-	int n = Mesh.getDimensions().x();
-
-	dim3 threadsPerBlock2(NARROWBAND_SUBGRID_SIZE, NARROWBAND_SUBGRID_SIZE);
-	dim3 numBlocks2(statusGridSize ,statusGridSize);
-	initSetupGridCUDA<<<numBlocks2,threadsPerBlock2>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	initSetupGrid2CUDA<<<numBlocks2,1>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-
-	/*dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);*/
-	initCUDA<<<numBlocks2,threadsPerBlock2>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-
-	cout << "Solver initialized." <<std::endl;
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlockFS(1, 512);
-	dim3 numBlocksFS(4,1);
-	dim3 threadsPerBlockNB(NARROWBAND_SUBGRID_SIZE, NARROWBAND_SUBGRID_SIZE);
-	dim3 numBlocksNB(n/NARROWBAND_SUBGRID_SIZE + 1,n/NARROWBAND_SUBGRID_SIZE + 1);
-
-	double time = 0.0;
-	int reinit = 0;
-
-	cout << "Hi!" <<std::endl;
-	runCUDA<<<numBlocksFS,threadsPerBlockFS>>>(this->cudaSolver,0,0);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	cout << "Hi2!" <<std::endl;
-	while(time < finalTime)
-	{
-		if(tau+time > finalTime)
-			tau=finalTime-time;
-
-		runNarrowBandCUDA<<<numBlocksNB,threadsPerBlockNB>>>(this->cudaSolver,tau);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		time += tau;
-
-
-		cudaMemcpy(&reinit, this->reinitialize, sizeof(int), cudaMemcpyDeviceToHost);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		if(reinit != 0 /*&& time != finalTime */)
-		{
-			cout << time <<std::endl;
-
-			initSetupGridCUDA<<<numBlocksNB,threadsPerBlockNB>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			initSetupGrid2CUDA<<<numBlocksNB,1>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			initCUDA<<<numBlocksNB,threadsPerBlockNB>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			runCUDA<<<numBlocksFS,threadsPerBlockFS>>>(this->cudaSolver,0,0);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-		}
-	}
-
-	//data.setLike(dofVector.getData());
-	//cudaMemcpy(data.getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaMemcpy(dofVector.getData().getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	//data.save("u-00001.tnl");
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	//			1 - with curve,  	2 - to the north of curve, 	4  - to the south of curve,
-	//								8 - to the east of curve, 	16 - to the west of curve.
-	int subgridID = i/NARROWBAND_SUBGRID_SIZE + (j/NARROWBAND_SUBGRID_SIZE) * ((Mesh.getDimensions().x() + NARROWBAND_SUBGRID_SIZE-1 ) / NARROWBAND_SUBGRID_SIZE);
-	if(/*cudaStatusVector[subgridID] != 0 &&*/ i<Mesh.getDimensions().x() && Mesh.getDimensions().y())
-	{
-		tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-		Entity.setCoordinates(CoordinatesType(i,j));
-		Entity.refresh();
-		tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-		Real value = cudaDofVector2[Entity.getIndex()];
-		Real a,b, tmp;
-
-		if( i == 0 /*|| (i/NARROWBAND_SUBGRID_SIZE == 0 && !(cudaStatusVector[subgridID] & 9)) */)
-			a = cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-		else if( i == Mesh.getDimensions().x() - 1 /*|| (i/NARROWBAND_SUBGRID_SIZE == NARROWBAND_SUBGRID_SIZE - 1 && !(cudaStatusVector[subgridID] & 17)) */)
-			a = cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-		else
-		{
-			a = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-					 cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-		}
-
-		if( j == 0/* || (j/NARROWBAND_SUBGRID_SIZE == 0 && !(cudaStatusVector[subgridID] & 3)) */)
-			b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-		else if( j == Mesh.getDimensions().y() - 1 /* || (j/NARROWBAND_SUBGRID_SIZE == NARROWBAND_SUBGRID_SIZE - 1 && !(cudaStatusVector[subgridID] & 5))*/ )
-			b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-		else
-		{
-			b = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-					 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-		}
-
-
-		if(abs(a-b) >= h)
-			tmp = fabsMin(a,b) + sign(value)*h;
-		else
-			tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-	//	cudaDofVector2[Entity.getIndex()]  = fabsMin(value, tmp);
-		atomicFabsMin(&(cudaDofVector2[Entity.getIndex()]), tmp);
-	}
-
-}
-
-
-__global__ void initCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-
-
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-
-	if(solver->Mesh.getDimensions().x() > gx  && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int i = threadIdx.x + blockDim.x*blockIdx.x;
-	int j = blockDim.y*blockIdx.y + threadIdx.y;
-
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	int gid = Entity.getIndex();
-
-	cudaDofVector2[gid] = INT_MAX*sign(cudaDofVector2[gid]);
-
-	if (i >0 && j > 0 && i+1 < Mesh.getDimensions().x() && j+1 < Mesh.getDimensions().y())
-	{
-		if(cudaDofVector2[gid]*cudaDofVector2[gid+1] <= 0 )
-		{
-			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-			cudaDofVector2[gid+1] = sign(cudaDofVector2[gid+1])*0.5*h;
-		}
-		if( cudaDofVector2[gid]*cudaDofVector2[gid+Mesh.getDimensions().x()] <= 0 )
-		{
-			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-			cudaDofVector2[gid+Mesh.getDimensions().x()] = sign(cudaDofVector2[gid+Mesh.getDimensions().x()])*0.5*h;
-		}
-
-		if(cudaDofVector2[gid]*cudaDofVector2[gid-1] <= 0 )
-		{
-			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-			cudaDofVector2[gid-1] = sign(cudaDofVector2[gid-1])*0.5*h;
-		}
-		if( cudaDofVector2[gid]*cudaDofVector2[gid-Mesh.getDimensions().x()] <= 0 )
-		{
-			cudaDofVector2[gid] = sign(cudaDofVector2[gid])*0.5*h;
-			cudaDofVector2[gid-Mesh.getDimensions().x()] = sign(cudaDofVector2[gid-Mesh.getDimensions().x()])*0.5*h;
-		}
-	}
-
-
-//
-
-
-
-
-
-
-//	if(i+1 < Mesh.getDimensions().x() && j+1 < Mesh.getDimensions().y() )
-//	{
-//		if(cudaDofVector[Entity.getIndex()] > 0)
-//		{
-//			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1111(i,j);
-//					else
-//						setupSquare1110(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1101(i,j);
-//					else
-//						setupSquare1100(i,j);
-//				}
-//			}
-//			else
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1011(i,j);
-//					else
-//						setupSquare1010(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1001(i,j);
-//					else
-//						setupSquare1000(i,j);
-//				}
-//			}
-//		}
-//		else
-//		{
-//			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0111(i,j);
-//					else
-//						setupSquare0110(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0101(i,j);
-//					else
-//						setupSquare0100(i,j);
-//				}
-//			}
-//			else
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0011(i,j);
-//					else
-//						setupSquare0010(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0001(i,j);
-//					else
-//						setupSquare0000(i,j);
-//				}
-//			}
-//		}
-//
-//	}
-
-	return true;
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	//Real fy = abs(y);
-
-	//Real tmpMin = Min(fx,abs(y));
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-
-	int gx = 0;
-	int gy = threadIdx.y;
-	//if(solver->Mesh.getDimensions().x() <= gx || solver->Mesh.getDimensions().y() <= gy)
-	//	return;
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-	//int gid = solver->Mesh.getDimensions().x() * gy + gx;
-	//int max = solver->Mesh.getDimensions().x()*solver->Mesh.getDimensions().x();
-
-	//int id1 = gx+gy;
-	//int id2 = (solver->Mesh.getDimensions().x() - gx - 1) + gy;
-
-	if(blockIdx.x==0)
-	{
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==1)
-	{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==2)
-	{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==3)
-	{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-
-}
-
-
-
-
-__global__ void initSetupGridCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	__shared__ double u0;
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-
-//		printf("Hello from  block = %d, thread = %d, x = %d, y = %d\n", blockIdx.x + gridDim.x*blockIdx.y,(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x, threadIdx.x, threadIdx.y);
-		if(threadIdx.x+threadIdx.y == 0)
-		{
-//			printf("Hello from  block = %d, thread = %d, x = %d, y = %d\n", blockIdx.x + gridDim.x*blockIdx.y,(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x, threadIdx.x, threadIdx.y);
-
-			if(blockIdx.x+blockIdx.y == 0)
-				*(solver->reinitialize) = 0;
-
-			solver->cudaStatusVector[blockIdx.x + gridDim.x*blockIdx.y] = 0;
-
-			u0 = solver->cudaDofVector2[(blockDim.y*blockIdx.y + 0)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + 0];
-		}
-		__syncthreads();
-
-		double u = solver->cudaDofVector2[(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x];
-
-		if(u*u0 <=0.0)
-			atomicMax(&(solver->cudaStatusVector[blockIdx.x + gridDim.x*blockIdx.y]),1);
-	}
-//	if(threadIdx.x+threadIdx.y == 0)
-
-//	printf("Bye from  block = %d, thread = %d, x = %d, y = %d\n", blockIdx.x + gridDim.x*blockIdx.y,(blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x() + blockDim.x*blockIdx.x + threadIdx.x, threadIdx.x, threadIdx.y);
-
-
-}
-
-
-
-// run this with one thread per block
-__global__ void initSetupGrid2CUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-//	printf("Hello\n");
-	if(solver->cudaStatusVector[blockIdx.x + gridDim.x*blockIdx.y] == 1)
-	{
-//			1 - with curve,  	2 - to the north of curve, 	4  - to the south of curve,
-//								8 - to the east of curve, 	16 - to the west of curve.
-			if(blockIdx.x > 0)
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x - 1 + gridDim.x*blockIdx.y]), 16);
-
-			if(blockIdx.x < gridDim.x - 1)
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x + 1 + gridDim.x*blockIdx.y]), 8);
-
-			if(blockIdx.y > 0 )
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x + gridDim.x*(blockIdx.y - 1)]), 4);
-
-			if(blockIdx.y < gridDim.y - 1)
-				atomicAdd(&(solver->cudaStatusVector[blockIdx.x + gridDim.x*(blockIdx.y + 1)]), 2);
-	}
-
-
-}
-
-
-
-
-
-__global__ void runNarrowBandCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, double tau)
-{
-	int gid = (blockDim.y*blockIdx.y + threadIdx.y)*solver->Mesh.getDimensions().x()+ threadIdx.x;
-	int i = threadIdx.x + blockIdx.x*blockDim.x;
-	int j = threadIdx.y + blockIdx.y*blockDim.y;
-
-//	if(i+j == 0)
-//		printf("Hello\n");
-
-	int blockID = blockIdx.x + blockIdx.y*gridDim.x; /*i/NARROWBAND_SUBGRID_SIZE + (j/NARROWBAND_SUBGRID_SIZE) * ((Mesh.getDimensions().x() + NARROWBAND_SUBGRID_SIZE-1 ) / NARROWBAND_SUBGRID_SIZE);*/
-
-	int status = solver->cudaStatusVector[blockID];
-
-	if(solver->Mesh.getDimensions().x() > i && solver->Mesh.getDimensions().y() > j)
-	{
-
-//		if(status != 0)
-		{
-			tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(solver->Mesh);
-			Entity.setCoordinates(Containers::StaticVector<2,double>(i,j));
-			Entity.refresh();
-			tnlNeighborGridEntityGetter<tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-			double value = solver->cudaDofVector2[Entity.getIndex()];
-			double xf,xb,yf,yb, grad, fu, a,b;
-			a = b = 0.0;
-
-			if( i == 0 /*|| (threadIdx.x == 0 && !(status & 9)) */)
-			{
-				xb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-				xf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] - value;
-			}
-			else if( i == solver->Mesh.getDimensions().x() - 1 /*|| (threadIdx.x == blockDim.x - 1 && !(status & 17)) */)
-			{
-				xb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-				xf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()] - value;
-			}
-			else
-			{
-				xb =  value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-				xf = solver-> cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] - value;
-			}
-
-			if( j == 0/* || (threadIdx.y == 0 && !(status & 3))*/ )
-			{
-				yb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] ;
-				yf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] - value;
-			}
-			else if( j == solver->Mesh.getDimensions().y() - 1  /*|| (threadIdx.y == blockDim.y - 1 && !(status & 5)) */)
-			{
-				yb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-				yf = solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()] - value;
-			}
-			else
-			{
-				yb = value - solver->cudaDofVector2[neighborEntities.template getEntityIndex< 0, -1 >()];
-				yf = solver-> cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] - value;
-			}
-			__syncthreads();
-
-
-
-
-
-			   if(sign(value) > 0.0)
-			   {
-				   xf = solver->negativePart(xf);
-
-				   xb = solver->positivePart(xb);
-
-				   yf = solver->negativePart(yf);
-
-				   yb = solver->positivePart(yb);
-
-			   }
-			   else
-			   {
-
-				   xb = solver->negativePart(xb);
-
-				   xf = solver->positivePart(xf);
-
-				   yb = solver->negativePart(yb);
-
-				   yf = solver->positivePart(yf);
-			   }
-
-
-			   if(xb > xf)
-				   a = xb*solver->Mesh.template getSpaceStepsProducts< -1, 0 >();
-			   else
-				   a = xf*solver->Mesh.template getSpaceStepsProducts< -1, 0 >();
-
-			   if(yb > yf)
-				   b = yb*solver->Mesh.template getSpaceStepsProducts< 0, -1 >();
-			   else
-				   b = yf*solver->Mesh.template getSpaceStepsProducts< 0, -1 >();
-
-
-
-//			grad = sqrt(0.5 * (xf*xf + xb*xb    +   yf*yf + yb*yb ) )*solver->Mesh.template getSpaceStepsProducts< -1, 0 >();
-
-			grad = sqrt(/*0.5 **/ (a*a    +   b*b ) );
-
-			fu = -1.0 * grad;
-
-//			if((tau*fu+value)*value <=0 )
-//			{
-//				//			1 - with curve,  	2 - to the north of curve, 	4  - to the south of curve,
-//				//								8 - to the east of curve, 	16 - to the west of curve.
-//
-//				if((threadIdx.x == 1 && !(status & 9)) && (blockIdx.x > 0) )
-//					atomicMax(solver->reinitialize,1);
-//				else if((threadIdx.x == blockDim.x - 2 && !(status & 17)) && (blockIdx.x < gridDim.x - 1) )
-//					atomicMax(solver->reinitialize,1);
-//				else if((threadIdx.y == 1 && !(status & 3)) && (blockIdx.y > 0) )
-//					atomicMax(solver->reinitialize,1);
-//				else if((threadIdx.y == blockDim.y - 2 && !(status & 5)) && (blockIdx.y < gridDim.y - 1) )
-//					atomicMax(solver->reinitialize,1);
-//			}
-
-			solver->cudaDofVector2[Entity.getIndex()]  += tau*fu;
-		}
-	}
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(INT_MAX,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-#endif
-
-
-
-
-#endif /* TNLNARROWBAND_IMPL_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand2D_impl.h b/src/Examples/narrow-band/tnlNarrowBand2D_impl.h
deleted file mode 100644
index d42bc2a7610d5bb02a94031d446a61ac5a2e6579..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand2D_impl.h
+++ /dev/null
@@ -1,927 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand2D_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND2D_IMPL_H_
-#define TNLNARROWBAND2D_IMPL_H_
-
-#include "tnlNarrowBand.h"
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlNarrowBand< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlNarrowBand()
-:Entity(Mesh),
- dofVector(Mesh),
- dofVector2(Mesh)
-{
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-	dofVector2.load(initialCondition);
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	Entity.refresh();
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-	cout << "a" <<std::endl;
-	return initGrid();
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	for(int i=0; i< Mesh.getDimensions().x()*Mesh.getDimensions().x();i++)
-	{
-		dofVector2[i]=INT_MAX*sign(dofVector[i]);
-	}
-
-	for(int i = 0 ; i < Mesh.getDimensions().x()-1; i++)
-	{
-		for(int j = 0 ; j < Mesh.getDimensions().x()-1; j++)
-			{
-			this->Entity.setCoordinates(CoordinatesType(i,j));
-			this->Entity.refresh();
-			neighborEntities.refresh(Mesh,Entity.getIndex());
-
-				if(dofVector[this->Entity.getIndex()] > 0)
-				{
-					if(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1111(i,j);
-							else
-								setupSquare1110(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1101(i,j);
-							else
-								setupSquare1100(i,j);
-						}
-					}
-					else
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1011(i,j);
-							else
-								setupSquare1010(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1001(i,j);
-							else
-								setupSquare1000(i,j);
-						}
-					}
-				}
-				else
-				{
-					if(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0111(i,j);
-							else
-								setupSquare0110(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0101(i,j);
-							else
-								setupSquare0100(i,j);
-						}
-					}
-					else
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0011(i,j);
-							else
-								setupSquare0010(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0001(i,j);
-							else
-								setupSquare0000(i,j);
-						}
-					}
-				}
-
-			}
-	}
-	cout << "a" <<std::endl;
-
-//	Real tmp = 0.0;
-//	Real ax=0.5/sqrt(2.0);
-//
-//	if(!exactInput)
-//	{
-//		for(Index i = 0; i < Mesh.getDimensions().x()*Mesh.getDimensions().y(); i++)
-//				dofVector[i]=0.5*h*sign(dofVector[i]);
-//	}
-//
-//
-//	for(Index i = 1; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		for(Index j = 1; j < Mesh.getDimensions().y()-1; j++)
-//		{
-//			 tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//			if(tmp == 0.0)
-//			{}
-//			else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//					dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//					dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-//					dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//			{}
-//			else
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//		}
-//	}
-//
-//
-//
-//	for(int i = 1; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		Index j = 0;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//	for(int i = 1; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		Index j = Mesh.getDimensions().y() - 1;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//	for(int j = 1; j < Mesh.getDimensions().y()-1; j++)
-//	{
-//		Index i = 0;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//	for(int j = 1; j < Mesh.getDimensions().y()-1; j++)
-//	{
-//		Index i = Mesh.getDimensions().x() - 1;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//
-//	Index i = Mesh.getDimensions().x() - 1;
-//	Index j = Mesh.getDimensions().y() - 1;
-//
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//
-//
-//
-//	j = 0;
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//
-//
-//
-//	i = 0;
-//	j = Mesh.getDimensions().y() -1;
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//
-//
-//
-//	j = 0;
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-
-	//data.setLike(dofVector2.getData());
-	//data=dofVector2.getData();
-	//cout << data.getType() <<std::endl;
-	dofVector2.save("u-00000.tnl");
-	//dofVector2.getData().save("u-00000.tnl");
-
-	return true;
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-	{
-		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-//	data.setLike(dofVector2.getData());
-//	data = dofVector2.getData();
-//	cout << data.getType() <<std::endl;
-	dofVector2.save("u-00001.tnl");
-	//dofVector2.getData().save("u-00001.tnl");
-
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	Real value = dofVector2[Entity.getIndex()];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = dofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-	else
-	{
-		a = fabsMin( dofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-				 dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-	}
-
-	if( j == 0 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-	else
-	{
-		b = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-				 dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-	}
-
-
-	if(fabs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-
-	dofVector2[Entity.getIndex()] = fabsMin(value, tmp);
-
-//	if(dofVector2[Entity.getIndex()] > 1.0)
-//		cout << value << "    " << tmp << " " << dofVector2[Entity.getIndex()] <<std::endl;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-Real tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = fabs(x);
-	Real fy = fabs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-//	this->Entity.setCoordinates(CoordinatesType(i,j));
-//	this->Entity.refresh();
-//	auto neighborEntities =  Entity.getNeighborEntities();
-//	dofVector2[Entity.getIndex()]=fabsMin(INT_MAX,dofVector2[Entity.getIndex()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-//	this->Entity.setCoordinates(CoordinatesType(i,j));
-//	this->Entity.refresh();
-//	auto neighborEntities =  Entity.getNeighborEntities();
-//	dofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,dofVector2[(Entity.getIndex())]);
-//	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	dofVector2[Entity.getIndex()]=fabsMin(dofVector[Entity.getIndex()],dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	dofVector2[Entity.getIndex()]=fabsMin(dofVector[Entity.getIndex()],dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-
-
-
-
-#endif /* TNLNARROWBAND_IMPL_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand3D_CUDA_impl.h b/src/Examples/narrow-band/tnlNarrowBand3D_CUDA_impl.h
deleted file mode 100644
index d362f249a79112aa9b902f86cd1a304702292423..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand3D_CUDA_impl.h
+++ /dev/null
@@ -1,961 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand2D_CUDA_v4_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND3D_IMPL_H_
-#define TNLNARROWBAND3D_IMPL_H_
-
-#include "tnlNarrowBand.h"
-
-//__device__
-//double fabsMin( double x, double y)
-//{
-//	double fx = abs(x);
-//
-//	if(Min(fx,abs(y)) == fx)
-//		return x;
-//	else
-//		return y;
-//}
-//
-//__device__
-//double atomicFabsMin(double* address, double val)
-//{
-//	unsigned long long int* address_as_ull =
-//						  (unsigned long long int*)address;
-//	unsigned long long int old = *address_as_ull, assumed;
-//	do {
-//		assumed = old;
-//			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(assumed,val) ));
-//	} while (assumed != old);
-//	return __longlong_as_double(old);
-//}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlNarrowBand< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	this->h = Mesh.template getSpaceStepsProducts< 1, 0, 0 >();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(8, 8,8);
-	dim3 numBlocks(n/8 + 1, n/8 +1, n/8 +1);
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(1, 512);
-	dim3 numBlocks(8,1);
-
-
-	runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,0,0);
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	cudaMemcpy(this->dofVector.getData().getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, Index k)
-{
-	tnlGridEntity< tnlGrid< 3,double, TNL::Devices::Host, int >, 3, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j,k));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage >,3> neighborEntities(Entity);
-	Real value = cudaDofVector2[Entity.getIndex()];
-	Real a,b,c, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0,  0 >()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0,  0 >()];
-	else
-	{
-		a = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0,  0 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0,  0 >()] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1,  0 >()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0 >()];
-	else
-	{
-		b = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1,  0 >()] );
-	}
-
-	if( k == 0 )
-		c = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  1 >()];
-	else if( k == Mesh.getDimensions().z() - 1 )
-		c = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1 >()];
-	else
-	{
-		c = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  1 >()] );
-	}
-
-	Real hD = 3.0*h*h - 2.0*(a*a + b*b + c*c - a*b - a*c - b*c);
-
-	if(hD < 0.0)
-		tmp = fabsMin(a,fabsMin(b,c)) + sign(value)*h;
-	else
-		tmp = (1.0/3.0) * ( a + b + c + sign(value)*sqrt(hD) );
-
-	atomicFabsMin(&cudaDofVector2[Entity.getIndex()],tmp);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid(int i, int j, int k)
-{
-	tnlGridEntity< tnlGrid< 3,double, TNL::Devices::Host, int >, 3, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j,k));
-	Entity.refresh();
-	int gid = Entity.getIndex();
-
-	if(abs(cudaDofVector[gid]) < 1.8*h)
-		cudaDofVector2[gid] = cudaDofVector[gid];
-	else
-		cudaDofVector2[gid] = INT_MAX*sign(cudaDofVector[gid]);
-
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlNarrowBand< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-	int gx = 0;
-	int gy = threadIdx.y;
-
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-
-	if(blockIdx.x==0)
-	{
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx = 0;
-		gy = threadIdx.y;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		__syncthreads();
-		}
-	}
-	else if(blockIdx.x==1)
-	{
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==2)
-	{
-
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==3)
-	{
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-
-
-
-
-	else if(blockIdx.x==4)
-	{
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx = 0;
-		gy = threadIdx.y;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==5)
-	{
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==6)
-	{
-
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==7)
-	{
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlNarrowBand< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	int gz = blockDim.z*blockIdx.z + threadIdx.z;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy && solver->Mesh.getDimensions().z() > gz)
-	{
-		solver->initGrid(gx,gy,gz);
-	}
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(INT_MAX,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(-INT_MAX,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-al;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(cudaDofVector[index],cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//
-//
-//
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-al;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(cudaDofVector[index],cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//}
-#endif
-
-
-
-
-#endif /* TNLNARROWBAND_IMPL_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand3D_impl.h b/src/Examples/narrow-band/tnlNarrowBand3D_impl.h
deleted file mode 100644
index 6e63d527b92e0b5c7907a5a2e8b24cba7ed432f2..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand3D_impl.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand2D_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND3D_IMPL_H_
-#define TNLNARROWBAND3D_IMPL_H_
-
-#include "tnlNarrowBand.h"
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlNarrowBand< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: tnlNarrowBand()
-:Entity(Mesh),
- dofVector(Mesh),
- dofVector2(Mesh)
-{
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-	dofVector2.load(initialCondition);
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0, 0 >();
-	Entity.refresh();
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-//	cout << "bla "<<endl;
-	return initGrid();
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	for(int i=0; i< Mesh.getDimensions().x()*Mesh.getDimensions().y()*Mesh.getDimensions().z();i++)
-	{
-
-		if (abs(dofVector[i]) < 1.8*h)
-			dofVector2[i]=dofVector[i];
-		else
-			dofVector2[i]=INT_MAX*sign(dofVector[i]);
-	}
-
-	return true;
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-
-
-
-
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-	dofVector2.save("u-00001.tnl");
-
-	cout << "bla 3"<<endl;
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, Index k)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j,k));
-	this->Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage >,3> neighborEntities(Entity);
-	Real value = dofVector2[Entity.getIndex()];
-	Real a,b,c, tmp;
-
-	if( i == 0 )
-		a = dofVector2[neighborEntities.template getEntityIndex< 1,  0,  0>()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = dofVector2[neighborEntities.template getEntityIndex< -1,  0,  0 >()];
-	else
-	{
-		a = fabsMin( dofVector2[neighborEntities.template getEntityIndex< -1,  0,  0>()],
-				 dofVector2[neighborEntities.template getEntityIndex< 1,  0,  0>()] );
-	}
-
-	if( j == 0 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  1,  0>()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0>()];
-	else
-	{
-		b = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0>()],
-				 dofVector2[neighborEntities.template getEntityIndex< 0,  1,  0>()] );
-	}
-
-	if( k == 0 )
-		c = dofVector2[neighborEntities.template getEntityIndex< 0,  0,  1>()];
-	else if( k == Mesh.getDimensions().z() - 1 )
-		c = dofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1>()];
-	else
-	{
-		c = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1>()],
-				 dofVector2[neighborEntities.template getEntityIndex< 0,  0,  1>()] );
-	}
-
-	Real hD = 3.0*h*h - 2.0*(a*a+b*b+c*c-a*b-a*c-b*c);
-
-	if(hD < 0.0)
-		tmp = fabsMin(a,fabsMin(b,c)) + sign(value)*h;
-	else
-		tmp = (1.0/3.0) * ( a + b + c + sign(value)*sqrt(hD) );
-
-
-	dofVector2[Entity.getIndex()]  = fabsMin(value, tmp);
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-Real tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = fabs(x);
-	Real fy = fabs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-}
-
-
-
-#endif /* TNLNARROWBAND_IMPL_H_ */
diff --git a/src/Examples/narrow-band/tnlNarrowBand_CUDA.h b/src/Examples/narrow-band/tnlNarrowBand_CUDA.h
deleted file mode 100644
index ca9b1da2cc6e26b14bc003532b6eea75e89d907d..0000000000000000000000000000000000000000
--- a/src/Examples/narrow-band/tnlNarrowBand_CUDA.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/***************************************************************************
-                          tnlNarrowBand_CUDA.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLNARROWBAND_H_
-#define TNLNARROWBAND_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-
-#include <functions/tnlMeshFunction.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-#include <ctime>
-
-
-
-
-
-template< typename Mesh,
-		  typename Real,
-		  typename Index >
-class tnlNarrowBand
-{};
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 2, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-	tnlNarrowBand();
-
-        static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-	bool run();
-#ifdef HAVE_CUDA
-   __device__ __host__
-#endif
-	RealType positivePart(const RealType arg) const;
-#ifdef HAVE_CUDA
-   __device__ __host__
-#endif
-	RealType negativePart(const RealType arg) const;
-
-#ifdef HAVE_CUDA
-	__device__ bool initGrid();
-	__device__ void updateValue(const Index i, const Index j);
-	__device__ void updateValue(const Index i, const Index j, double** sharedMem, const int k3);
-	__device__ Real fabsMin(const Real x, const Real y);
-
-	tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >* cudaSolver;
-	double* cudaDofVector;
-	double* cudaDofVector2;
-	int* cudaStatusVector;
-	int counter;
-	int* reinitialize;
-	__device__ void setupSquare1000(Index i, Index j);
-	__device__ void setupSquare1100(Index i, Index j);
-	__device__ void setupSquare1010(Index i, Index j);
-	__device__ void setupSquare1001(Index i, Index j);
-	__device__ void setupSquare1110(Index i, Index j);
-	__device__ void setupSquare1101(Index i, Index j);
-	__device__ void setupSquare1011(Index i, Index j);
-	__device__ void setupSquare1111(Index i, Index j);
-	__device__ void setupSquare0000(Index i, Index j);
-	__device__ void setupSquare0100(Index i, Index j);
-	__device__ void setupSquare0010(Index i, Index j);
-	__device__ void setupSquare0001(Index i, Index j);
-	__device__ void setupSquare0110(Index i, Index j);
-	__device__ void setupSquare0101(Index i, Index j);
-	__device__ void setupSquare0011(Index i, Index j);
-	__device__ void setupSquare0111(Index i, Index j);
-#endif
-
-	MeshType Mesh;
-
-protected:
-
-	int statusGridSize;
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector;
-	DofVectorType data;
-
-
-	RealType h, tau, finalTime;
-
-
-};
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 3, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-	bool run();
-
-#ifdef HAVE_CUDA
-	__device__ bool initGrid(int i, int j, int k);
-	__device__ void updateValue(const Index i, const Index j, const Index k);
-	__device__ void updateValue(const Index i, const Index j, const Index k, double** sharedMem, const int k3);
-	__device__ Real fabsMin(const Real x, const Real y);
-
-	tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >* cudaSolver;
-	double* cudaDofVector;
-	double* cudaDofVector2;
-	int counter;
-#endif
-
-	MeshType Mesh;
-
-protected:
-
-
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector;
-	DofVectorType data;
-
-	RealType h;
-
-
-};
-
-
-
-
-
-
-
-#ifdef HAVE_CUDA
-//template<int sweep_t>
-__global__ void runCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i);
-//__global__ void runCUDA(tnlNarrowBand< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i);
-
-__global__ void initCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver);
-
-__global__ void initSetupGridCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver);
-__global__ void initSetupGrid2CUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver);
-__global__ void initSetupGrid1_2CUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver);
-__global__ void runNarrowBandCUDA(tnlNarrowBand< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, double tau);
-//__global__ void initCUDA(tnlNarrowBand< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver);
-#endif
-
-
-
-#include "tnlNarrowBand2D_CUDA_v4_impl.h"
-//											#include "tnlNarrowBand3D_CUDA_impl.h"
-
-#endif /* TNLNARROWBAND_H_ */
diff --git a/src/TNL/CMakeLists.txt b/src/TNL/CMakeLists.txt
index 306bd82a3c5c6633c893beafa90aa768f0e83bee..3c1a88f48a3d61d3755965c0db8ae0024c24b9f4 100644
--- a/src/TNL/CMakeLists.txt
+++ b/src/TNL/CMakeLists.txt
@@ -1,5 +1,6 @@
 ADD_SUBDIRECTORY( Config )
 ADD_SUBDIRECTORY( Containers )
+ADD_SUBDIRECTORY( DistributedContainers )
 ADD_SUBDIRECTORY( Communicators )
 ADD_SUBDIRECTORY( Debugging )
 ADD_SUBDIRECTORY( Devices )
@@ -24,6 +25,7 @@ set( headers
      File.h
      File_impl.h
      FileName.h
+     FileName.hpp
      Object.h
      Logger.h
      Logger_impl.h
diff --git a/src/TNL/Communicators/MpiCommunicator.h b/src/TNL/Communicators/MpiCommunicator.h
index 1ad8a6e088445fe76a0aeab3bc0bf68cd00c6943..9c277a3b607a5940987648c083863579d4967945 100644
--- a/src/TNL/Communicators/MpiCommunicator.h
+++ b/src/TNL/Communicators/MpiCommunicator.h
@@ -89,7 +89,7 @@ class MpiCommunicator
 #ifdef HAVE_MPI
          config.addEntry< bool >( "redirect-mpi-output", "Only process with rank 0 prints to console. Other processes are redirected to files.", true );
          config.addEntry< bool >( "mpi-gdb-debug", "Wait for GDB to attach the master MPI process.", false );
-         config.addEntry< int >( "mpi-process-to-attach", "Number of the MPI process to be attached by GDB.", 0 );
+         config.addEntry< int >( "mpi-process-to-attach", "Number of the MPI process to be attached by GDB. Set -1 for all processes.", 0 );
 #endif
       }
 
@@ -276,13 +276,13 @@ class MpiCommunicator
         }
 
          template <typename T>
-         static Request ISend( const T* data, int count, int dest, CommunicationGroup group)
+         static Request ISend( const T* data, int count, int dest, int tag, CommunicationGroup group)
          {
 #ifdef HAVE_MPI
             TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not initialized");
             TNL_ASSERT_NE(group, NullGroup, "ISend cannot be called with NullGroup");
             Request req;
-            MPI_Isend((const void*) data, count, MPIDataType(data) , dest, 0, group, &req);
+            MPI_Isend( const_cast< void* >( ( const void* ) data ), count, MPIDataType(data) , dest, tag, group, &req);
             return req;
 #else
             throw Exceptions::MPISupportMissing();
@@ -290,13 +290,13 @@ class MpiCommunicator
         }
 
          template <typename T>
-         static Request IRecv( T* data, int count, int src, CommunicationGroup group)
+         static Request IRecv( T* data, int count, int src, int tag, CommunicationGroup group)
          {
 #ifdef HAVE_MPI
             TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not initialized");
             TNL_ASSERT_NE(group, NullGroup, "IRecv cannot be called with NullGroup");
             Request req;
-            MPI_Irecv((void*) data, count, MPIDataType(data) , src, 0, group, &req);
+            MPI_Irecv((void*) data, count, MPIDataType(data) , src, tag, group, &req);
             return req;
 #else
             throw Exceptions::MPISupportMissing();
@@ -334,7 +334,7 @@ class MpiCommunicator
         {
 #ifdef HAVE_MPI
             TNL_ASSERT_NE(group, NullGroup, "Allreduce cannot be called with NullGroup");
-            MPI_Allreduce( (const void*) data, (void*) reduced_data,count,MPIDataType(data),op,group);
+            MPI_Allreduce( const_cast< void* >( ( void* ) data ), (void*) reduced_data,count,MPIDataType(data),op,group);
 #else
             throw Exceptions::MPISupportMissing();
 #endif
@@ -366,7 +366,7 @@ class MpiCommunicator
          {
 #ifdef HAVE_MPI
             TNL_ASSERT_NE(group, NullGroup, "Reduce cannot be called with NullGroup");
-            MPI_Reduce( (const void*) data, (void*) reduced_data,count,MPIDataType(data),op,root,group);
+            MPI_Reduce( const_cast< void* >( ( void*) data ), (void*) reduced_data,count,MPIDataType(data),op,root,group);
 #else
             throw Exceptions::MPISupportMissing();
 #endif
@@ -386,7 +386,7 @@ class MpiCommunicator
 #ifdef HAVE_MPI
             TNL_ASSERT_NE(group, NullGroup, "SendReceive cannot be called with NullGroup");
             MPI_Status status;
-            MPI_Sendrecv( ( const void* ) sendData,
+            MPI_Sendrecv( const_cast< void* >( ( void* ) sendData ),
                           sendCount,
                           MPIDataType( sendData ),
                           destination,
@@ -412,7 +412,7 @@ class MpiCommunicator
          {
 #ifdef HAVE_MPI
             TNL_ASSERT_NE(group, NullGroup, "SendReceive cannot be called with NullGroup");
-            MPI_Alltoall( ( const void* ) sendData,
+            MPI_Alltoall( const_cast< void* >( ( void* ) sendData ),
                           sendCount,
                           MPIDataType( sendData ),
                           ( void* ) receiveData,
@@ -433,7 +433,7 @@ class MpiCommunicator
          }
       }
 
-      static void CreateNewGroup(bool meToo,int myRank, CommunicationGroup &oldGroup, CommunicationGroup &newGroup)
+      static void CreateNewGroup( bool meToo, int myRank, CommunicationGroup &oldGroup, CommunicationGroup &newGroup )
       {
 #ifdef HAVE_MPI
         if(meToo)
diff --git a/src/TNL/Communicators/NoDistrCommunicator.h b/src/TNL/Communicators/NoDistrCommunicator.h
index 33bbe01a0d289a74d74af23195ee4d7a60c87366..5b2fb9049f8a9209c05d3af5a4789e6063055718 100644
--- a/src/TNL/Communicators/NoDistrCommunicator.h
+++ b/src/TNL/Communicators/NoDistrCommunicator.h
@@ -78,13 +78,13 @@ class NoDistrCommunicator
       };
 
       template <typename T>
-      static Request ISend( const T *data, int count, int dest, CommunicationGroup group)
+      static Request ISend( const T *data, int count, int dest, int tag, CommunicationGroup group)
       {
           return 1;
       }
 
       template <typename T>
-      static Request IRecv( const T *data, int count, int src, CommunicationGroup group)
+      static Request IRecv( const T *data, int count, int src, int tag, CommunicationGroup group)
       {
           return 1;
       }
diff --git a/src/TNL/Config/ParameterContainer.cpp b/src/TNL/Config/ParameterContainer.cpp
index 946a1842be25ef92930586a7099b348649f5945a..1f01dfcf52b9112b65085ecf4d1aaa952b2d107a 100644
--- a/src/TNL/Config/ParameterContainer.cpp
+++ b/src/TNL/Config/ParameterContainer.cpp
@@ -206,7 +206,7 @@ parseCommandLine( int argc, char* argv[],
             std::cerr << "Internal error: Unknown config entry type " << entryType << "." << std::endl;
             return false;
          }
-         if( parsedEntryType[ 0 ] == "List" )
+         if( parsedEntryType[ 0 ] == "Containers::List" )
          {
             Containers::List< String >* string_list( 0 );
             Containers::List< bool >* bool_list( 0 );
diff --git a/src/TNL/Containers/List_impl.h b/src/TNL/Containers/List_impl.h
index 136f4cc986a35063a8be9f52ab4fa4e705b6c273..e67be136cd19e28db2f3f2da1183e8b2d7bf3236 100644
--- a/src/TNL/Containers/List_impl.h
+++ b/src/TNL/Containers/List_impl.h
@@ -38,7 +38,7 @@ List< T >::~List()
 template< typename T >
 String List< T >::getType()
 {
-   return String( "List< " ) + TNL::getType< T >() +  String( " >" );
+   return String( "Containers::List< " ) + TNL::getType< T >() +  String( " >" );
 }
 
 template< typename T >
diff --git a/src/TNL/Devices/Cuda.cpp b/src/TNL/Devices/Cuda.cpp
index 1bc85e3c829ff4a2f44518f4016c7ef90a447b27..9dc2ff9d00b035154195d4ef81dc39a94a36345a 100644
--- a/src/TNL/Devices/Cuda.cpp
+++ b/src/TNL/Devices/Cuda.cpp
@@ -23,7 +23,7 @@ Timer Cuda::smartPointersSynchronizationTimer;
 
 String Cuda::getDeviceType()
 {
-   return String( "Cuda" );
+   return String( "Devices::Cuda" );
 }
 
 int Cuda::getNumberOfBlocks( const int threads,
diff --git a/src/TNL/Devices/MIC.h b/src/TNL/Devices/MIC.h
index 776b7c36fe7a44fd0063142708fd0789f350c45c..5b6a9a4f8c40adf1b26bfdc687254db1d1241872 100644
--- a/src/TNL/Devices/MIC.h
+++ b/src/TNL/Devices/MIC.h
@@ -71,7 +71,7 @@ class MIC
    
         static String getDeviceType()
         {
-            return String( "MIC" );
+            return String( "Devices::MIC" );
         };
         
 #ifdef HAVE_MIC  
diff --git a/src/TNL/Devices/SystemInfo.cpp b/src/TNL/Devices/SystemInfo.cpp
index ad853a5d41ee60d899d2339a5e1c148ca07b5203..490f65f101c762c96dc0c6a5bf281a1ef232d7e5 100644
--- a/src/TNL/Devices/SystemInfo.cpp
+++ b/src/TNL/Devices/SystemInfo.cpp
@@ -173,7 +173,7 @@ writeDeviceInfo( Logger& logger )
    logger.writeParameter< String >( "Model name:", getCPUModelName( cpu_id ), 1 );
    logger.writeParameter< int >( "Cores:", cores, 1 );
    logger.writeParameter< int >( "Threads per core:", threadsPerCore, 1 );
-   logger.writeParameter< String >( "Max clock rate (in MHz):", getCPUMaxFrequency( cpu_id ) / 1000, 1 );
+   logger.writeParameter< float >( "Max clock rate (in MHz):", getCPUMaxFrequency( cpu_id ) / 1000, 1 );
    CacheSizes cacheSizes = getCPUCacheSizes( cpu_id );
    String cacheInfo = String( cacheSizes.L1data ) + ", "
                        + String( cacheSizes.L1instruction ) + ", "
diff --git a/src/TNL/DistributedContainers/CMakeLists.txt b/src/TNL/DistributedContainers/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..7aa8b2cde74b43c23641157e906c6632260c405e
--- /dev/null
+++ b/src/TNL/DistributedContainers/CMakeLists.txt
@@ -0,0 +1,16 @@
+SET( headers DistributedArray.h
+             DistributedArray_impl.h
+             DistributedArrayView.h
+             DistributedArrayView_impl.h
+             DistributedMatrix.h
+             DistributedMatrix_impl.h
+             DistributedSpMV.h
+             DistributedVector.h
+             DistributedVector_impl.h
+             DistributedVectorView.h
+             DistributedVectorView_impl.h
+             Partitioner.h
+             Subrange.h
+    )
+
+INSTALL( FILES ${headers} DESTINATION ${TNL_TARGET_INCLUDE_DIRECTORY}/DistributedContainers )
diff --git a/src/TNL/DistributedContainers/DistributedSpMV.h b/src/TNL/DistributedContainers/DistributedSpMV.h
index 9bc47d73910dfac2894c3469b9853ad63ed12de4..afaef299e11f6e884f6d13c3df93dba7edd21bc5 100644
--- a/src/TNL/DistributedContainers/DistributedSpMV.h
+++ b/src/TNL/DistributedContainers/DistributedSpMV.h
@@ -145,7 +145,7 @@ public:
             commRequests.push_back( CommunicatorType::ISend(
                      inVector.getLocalVectorView().getData(),
                      inVector.getLocalVectorView().getSize(),
-                     i, group ) );
+                     i, 0, group ) );
 
       // receive data that we need
       for( int j = 0; j < commPattern.getRows(); j++ )
@@ -153,7 +153,7 @@ public:
             commRequests.push_back( CommunicatorType::IRecv(
                      &globalBuffer[ Partitioner::getOffset( globalBuffer.getSize(), j, nproc ) ],
                      Partitioner::getSizeForRank( globalBuffer.getSize(), j, nproc ),
-                     j, group ) );
+                     j, 0, group ) );
 
       // general variant
       if( localOnlySpan.first >= localOnlySpan.second ) {
diff --git a/src/TNL/DistributedContainers/Subrange.h b/src/TNL/DistributedContainers/Subrange.h
index 8cff45b495e280080252a496c76b69a32705932f..e581c9a4fc103ff352fe9b73fa9a612279063084 100644
--- a/src/TNL/DistributedContainers/Subrange.h
+++ b/src/TNL/DistributedContainers/Subrange.h
@@ -12,6 +12,7 @@
 
 #pragma once
 
+#include <ostream>
 #include <TNL/Assert.h>
 #include <TNL/String.h>
 #include <TNL/param-types.h>
@@ -119,5 +120,12 @@ protected:
    Index end = 0;
 };
 
+// due to formatting in TNL::Assert
+template< typename Index >
+std::ostream& operator<<( std::ostream& str, const Subrange< Index >& range )
+{
+   return str << Subrange< Index >::getType() << "( " << range.getBegin() << ", " << range.getEnd() << " )";
+}
+
 } // namespace DistributedContainers
 } // namespace TNL
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/CMakeLists.txt b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/CMakeLists.txt
deleted file mode 100644
index 3f9db0da04526a8d5fc935f4079cc0bca91b3e56..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-set( tnl_fast_sweeping_map_SOURCES
-#     MainBuildConfig.h
-#     tnlFastSweepingMap2D_impl.h
-#     tnlFastSweepingMap.h
-#     fastSweepingMapConfig.h 
-     main.cpp)
-
-
-IF(  BUILD_CUDA ) 
-	CUDA_ADD_EXECUTABLE(fast-sweeping-map main.cu)
-ELSE(  BUILD_CUDA )                
-	ADD_EXECUTABLE(fast-sweeping-map main.cpp)
-ENDIF( BUILD_CUDA )
-target_link_libraries (fast-sweeping-map tnl )
-
-
-INSTALL( TARGETS fast-sweeping-map
-         RUNTIME DESTINATION bin
-         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
-        
-#INSTALL( FILES ${tnl_fast_sweeping_map_SOURCES}
-#         DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/fast-sweeping-map )
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/MainBuildConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/MainBuildConfig.h
deleted file mode 100644
index ed3d686eb99379af1589d734eac9b5812cccdedf..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/MainBuildConfig.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
-                          MainBuildConfig.h  -  description
-                             -------------------
-    begin                : Jul 7, 2014
-    copyright            : (C) 2014 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 MAINBUILDCONFIG_H_
-#define MAINBUILDCONFIG_H_
-
-#include <solvers/tnlBuildConfigTags.h>
-
-class MainBuildConfig
-{
-   public:
-
-      static void print() {std::cerr << "MainBuildConfig" <<std::endl; }
-};
-
-/****
- * Turn off support for float and long double.
- */
-template<> struct tnlConfigTagReal< MainBuildConfig, float > { enum { enabled = false }; };
-template<> struct tnlConfigTagReal< MainBuildConfig, long double > { enum { enabled = false }; };
-
-/****
- * Turn off support for short int and long int indexing.
- */
-template<> struct tnlConfigTagIndex< MainBuildConfig, short int >{ enum { enabled = false }; };
-template<> struct tnlConfigTagIndex< MainBuildConfig, long int >{ enum { enabled = false }; };
-
-/****
- * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.
- */
-template< int Dimensions, typename Real, typename Device, typename Index >
-   struct tnlConfigTagMesh< MainBuildConfig, tnlGrid< Dimensions, Real, Device, Index > >
-      { enum { enabled = tnlConfigTagDimensions< MainBuildConfig, Dimensions >::enabled  &&
-                         tnlConfigTagReal< MainBuildConfig, Real >::enabled &&
-                         tnlConfigTagDevice< MainBuildConfig, Device >::enabled &&
-                         tnlConfigTagIndex< MainBuildConfig, Index >::enabled }; };
-
-/****
- * Please, chose your preferred time discretisation  here.
- */
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = false}; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };
-
-/****
- * Only the Runge-Kutta-Merson solver is enabled by default.
- */
-template<> struct tnlConfigTagExplicitSolver< MainBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };
-
-#endif /* MAINBUILDCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/fastSweepingMapConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/fastSweepingMapConfig.h
deleted file mode 100644
index 9251deca876e821dace59682ca1a151555095c69..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/fastSweepingMapConfig.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/***************************************************************************
-                          fastSweepingConfig.h  -  description
-                             -------------------
-    begin                : Oct 15, 2015
-    copyright            : (C) 2015 by Tomas Sobotik
-    email                :
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 FASTSWEEPINGCONFIG_H_
-#define FASTSWEEPINGCONFIG_H_
-
-#include <config/tnlConfigDescription.h>
-
-template< typename ConfigTag >
-class fastSweepingMapConfig
-{
-   public:
-      static void configSetup( tnlConfigDescription& config )
-      {
-         config.addDelimiter( "Parallel Eikonal solver settings:" );
-         config.addEntry        < String > ( "problem-name", "This defines particular problem.", "fast-sweeping" );
-         config.addRequiredEntry        < String > ( "initial-condition", "Initial condition for solver");
-         config.addRequiredEntry        < int > ( "dim", "Dimension of problem.");
-         config.addEntry       < String > ( "mesh", "Name of mesh.", "mesh.tnl" );
-         config.addEntry       < String > ( "exact-input", "Are the function values near the curve equal to the SDF? (yes/no)", "no" );
-         config.addRequiredEntry        < String > ( "map", "Gradient map for solver");
-      }
-};
-
-#endif /* FASTSWEEPINGCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.cpp b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.cpp
deleted file mode 100644
index 8849008ff630db0400a6d7d98e789099e5fbb5d9..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.cu b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.cu
deleted file mode 100644
index 8849008ff630db0400a6d7d98e789099e5fbb5d9..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.h
deleted file mode 100644
index 6f23851c2ea111712b9d65cfdbb613b04c1e1cdd..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/main.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-                          main.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-
-#include "MainBuildConfig.h"
-	//for HOST versions:
-#include "tnlFastSweepingMap.h"
-	//for DEVICE versions:
-//#include "tnlFastSweepingMap_CUDA.h"
-#include "fastSweepingMapConfig.h"
-#include <solvers/tnlBuildConfigTags.h>
-
-#include <mesh/tnlGrid.h>
-#include <core/tnlDevice.h>
-#include <time.h>
-#include <ctime>
-
-typedef MainBuildConfig BuildConfig;
-
-int main( int argc, char* argv[] )
-{
-	time_t start;
-	time_t stop;
-	time(&start);
-	std::clock_t start2= std::clock();
-   Config::ParameterContainer parameters;
-   tnlConfigDescription configDescription;
-   fastSweepingMapConfig< BuildConfig >::configSetup( configDescription );
-
-   if( ! parseCommandLine( argc, argv, configDescription, parameters ) )
-      return false;
-
-   const int& dim = parameters.getParameter< int >( "dim" );
-
-   if(dim == 2)
-   {
-		tnlFastSweepingMap<tnlGrid<2,double,TNL::Devices::Host, int>, double, int> solver;
-		if(!solver.init(parameters))
-	   {
-			cerr << "Solver failed to initialize." <<std::endl;
-			return EXIT_FAILURE;
-	   }
-		TNL_CHECK_CUDA_DEVICE;
-	  std::cout << "-------------------------------------------------------------" <<std::endl;
-	  std::cout << "Starting solver..." <<std::endl;
-	   solver.run();
-   }
-//   else if(dim == 3)
-//   {
-//		tnlFastSweepingMap<tnlGrid<3,double,TNL::Devices::Host, int>, double, int> solver;
-//		if(!solver.init(parameters))
-//	   {
-//			cerr << "Solver failed to initialize." <<std::endl;
-//			return EXIT_FAILURE;
-//	   }
-//		TNL_CHECK_CUDA_DEVICE;
-//	  std::cout << "-------------------------------------------------------------" <<std::endl;
-//	  std::cout << "Starting solver..." <<std::endl;
-//	   solver.run();
-//   }
-   else
-   {
-	  std::cerr << "Unsupported number of dimensions: " << dim << "!" <<std::endl;
-	   return EXIT_FAILURE;
-   }
-
-
-   time(&stop);
-  std::cout << "Solver stopped..." <<std::endl;
-  std::cout <<std::endl;
-  std::cout << "Running time was: " << difftime(stop,start) << " .... " << (std::clock() - start2) / (double)(CLOCKS_PER_SEC) <<std::endl;
-   return EXIT_SUCCESS;
-}
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap.h
deleted file mode 100644
index c568329ba2aa5fdb8fed303d43b25e73f210c014..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/***************************************************************************
-                          tnlFastSweepingMap.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING_H_
-#define TNLFASTSWEEPING_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <functions/tnlMeshFunction.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-#include <ctime>
-#ifdef HAVE_OPENMP
-#include <omp.h>
-#endif
-
-
-
-
-template< typename Mesh,
-		  typename Real,
-		  typename Index >
-class tnlFastSweepingMap
-{};
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 2, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-
-	tnlFastSweepingMap();
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-
-	bool initGrid();
-	bool run();
-
-	//for single core version use this implementation:
-	void updateValue(const Index i, const Index j);
-	//for parallel version use this one instead:
-//	void updateValue(const Index i, const Index j, DofVectorType* grid);
-
-
-	void setupSquare1000(Index i, Index j);
-	void setupSquare1100(Index i, Index j);
-	void setupSquare1010(Index i, Index j);
-	void setupSquare1001(Index i, Index j);
-	void setupSquare1110(Index i, Index j);
-	void setupSquare1101(Index i, Index j);
-	void setupSquare1011(Index i, Index j);
-	void setupSquare1111(Index i, Index j);
-	void setupSquare0000(Index i, Index j);
-	void setupSquare0100(Index i, Index j);
-	void setupSquare0010(Index i, Index j);
-	void setupSquare0001(Index i, Index j);
-	void setupSquare0110(Index i, Index j);
-	void setupSquare0101(Index i, Index j);
-	void setupSquare0011(Index i, Index j);
-	void setupSquare0111(Index i, Index j);
-
-	Real fabsMin(const Real x, const Real y);
-
-
-protected:
-
-	MeshType Mesh;
-
-	bool exactInput;
-
-	int something_changed;
-
-	tnlMeshFunction<MeshType> dofVector, dofVector2;
-	DofVectorType data,map;
-
-	RealType h;
-
-	tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage > Entity;
-
-
-#ifdef HAVE_OPENMP
-//	omp_lock_t* gridLock;
-#endif
-
-
-};
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweepingMap< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 3, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-	tnlFastSweepingMap();
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-
-	bool initGrid();
-	bool run();
-
-	//for single core version use this implementation:
-	void updateValue(const Index i, const Index j, const Index k);
-	//for parallel version use this one instead:
-//	void updateValue(const Index i, const Index j, DofVectorType* grid);
-
-	Real fabsMin(const Real x, const Real y);
-
-
-protected:
-
-	MeshType Mesh;
-
-	bool exactInput;
-
-
-	tnlMeshFunction<MeshType> dofVector, dofVector2;
-	DofVectorType data;
-
-	RealType h;
-
-	tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage > Entity;
-
-#ifdef HAVE_OPENMP
-//	omp_lock_t* gridLock;
-#endif
-
-
-};
-
-
-	//for single core version use this implementation:
-#include "tnlFastSweepingMap2D_impl.h"
-	//for parallel version use this one instead:
-// #include "tnlFastSweepingMap2D_openMP_impl.h"
-
-//											#include "tnlFastSweepingMap3D_impl.h"
-
-#endif /* TNLFASTSWEEPING_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap2D_CUDA_v4_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap2D_CUDA_v4_impl.h
deleted file mode 100644
index d02b8d6c5d40f8f581e160201c952777ba15aefe..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap2D_CUDA_v4_impl.h
+++ /dev/null
@@ -1,1051 +0,0 @@
-/***************************************************************************
-                          tnlFastSweepingMap2D_CUDA_v4_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweepingMap.h"
-
-#define MAP_SOLVER_MAX_VALUE 3
-
-__device__
-double fabsMin( double x, double y)
-{
-	double fx = abs(x);
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__device__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(__longlong_as_double(assumed),val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweepingMap< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlFastSweepingMap()
-:dofVector(Mesh)
-{
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	const String& mapFile = parameters.getParameter <String>("map");
-	if(! this->map.load( mapFile ))
-		cout << "Failed to load map file : " << mapFile <<std::endl;
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	//Entity.refresh();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(map_cuda), this->map.getSize()*sizeof(double));
-	cudaMemcpy(map_cuda, this->map.getData(), this->map.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(changed), sizeof(int));
-	//counter == 0 --> setting changed to 0
-	cudaMemcpy(changed, &counter, sizeof(int), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);
-
-
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(1, 1024);
-	dim3 numBlocks(4,1);
-
-	int run = 1;
-	int zero = 0;
-	int cntr = 0;
-
-	while(run != 0)
-	{
-		cudaMemcpy(this->changed, &zero, sizeof(int), cudaMemcpyHostToDevice);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,0,0, this->changed);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		cudaMemcpy(&run, this->changed,sizeof(int), cudaMemcpyDeviceToHost);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		cntr++;
-		cout << "Finished set of sweeps #" << cntr << "           " << run <<std::endl;
-	}
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	//data.setLike(dofVector.getData());
-	//cudaMemcpy(data.getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaMemcpy(dofVector.getData().getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	//data.save("u-00001.tnl");
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, Index* something_changed)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-
-	if(map_cuda[Entity.getIndex()] != 0.0)
-	{
-		tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-		Real value = cudaDofVector2[Entity.getIndex()];
-		Real im = abs(1.0/map_cuda[Entity.getIndex()]);
-		Real a,b, tmp;
-
-		if( i == 0 )
-			a = cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-		else if( i == Mesh.getDimensions().x() - 1 )
-			a = cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-		else
-		{
-			a = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-					 cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-		}
-
-		if( j == 0 )
-			b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-		else if( j == Mesh.getDimensions().y() - 1 )
-			b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-		else
-		{
-			b = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-					 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-		}
-
-
-		if(abs(a-b) >= im*h)
-			tmp = fabsMin(a,b) + sign(value)*im*h;
-		else
-			tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * im * h * im * h - (a - b) * (a - b) ) );
-
-	//	cudaDofVector2[Entity.getIndex()]  = fabsMin(value, tmp);
-		atomicFabsMin(&(cudaDofVector2[Entity.getIndex()]), tmp);
-
-		if(abs(value)-abs(tmp) > 0.0)
-			atomicMax(something_changed,1);
-	}
-	else
-	{
-		atomicFabsMin(&(cudaDofVector2[Entity.getIndex()]), MAP_SOLVER_MAX_VALUE);
-	}
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int i = threadIdx.x + blockDim.x*blockIdx.x;
-	int j = blockDim.y*blockIdx.y + threadIdx.y;
-
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	int gid = Entity.getIndex();
-
-	cudaDofVector2[gid] = INT_MAX*sign(cudaDofVector[gid]);
-
-	if(abs(cudaDofVector[gid]) < 1.01*h)
-	{
-		cudaDofVector2[gid] = cudaDofVector[gid];
-		if(map_cuda[gid] != 0.0)
-			cudaDofVector2[gid] /=map_cuda[gid];
-	}
-
-
-
-
-
-//	if(i+1 < Mesh.getDimensions().x() && j+1 < Mesh.getDimensions().y() )
-//	{
-//		if(cudaDofVector[Entity.getIndex()] > 0)
-//		{
-//			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1111(i,j);
-//					else
-//						setupSquare1110(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1101(i,j);
-//					else
-//						setupSquare1100(i,j);
-//				}
-//			}
-//			else
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1011(i,j);
-//					else
-//						setupSquare1010(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare1001(i,j);
-//					else
-//						setupSquare1000(i,j);
-//				}
-//			}
-//		}
-//		else
-//		{
-//			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0111(i,j);
-//					else
-//						setupSquare0110(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0101(i,j);
-//					else
-//						setupSquare0100(i,j);
-//				}
-//			}
-//			else
-//			{
-//				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0011(i,j);
-//					else
-//						setupSquare0010(i,j);
-//				}
-//				else
-//				{
-//					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//						setupSquare0001(i,j);
-//					else
-//						setupSquare0000(i,j);
-//				}
-//			}
-//		}
-//
-//	}
-
-	return true;
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	//Real fy = abs(y);
-
-	//Real tmpMin = Min(fx,abs(y));
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlFastSweepingMap< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i, int* changed)
-{
-
-	__shared__ int something_changed;
-	if(threadIdx.x+threadIdx.y == 0)
-		something_changed = 0;
-
-	int gx = 0;
-	int gy = threadIdx.y;
-	//if(solver->Mesh.getDimensions().x() <= gx || solver->Mesh.getDimensions().y() <= gy)
-	//	return;
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-	//int gid = solver->Mesh.getDimensions().x() * gy + gx;
-	//int max = solver->Mesh.getDimensions().x()*solver->Mesh.getDimensions().x();
-
-	//int id1 = gx+gy;
-	//int id2 = (solver->Mesh.getDimensions().x() - gx - 1) + gy;
-
-	__syncthreads();
-	if(blockIdx.x==0)
-	{
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,&something_changed);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==1)
-	{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,&something_changed);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==2)
-	{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,&something_changed);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==3)
-	{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,&something_changed);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-
-
-	if(threadIdx.x+threadIdx.y == 0)
-		atomicMax(changed, something_changed);
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlFastSweepingMap< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-
-
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(INT_MAX,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-#endif
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap2D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap2D_impl.h
deleted file mode 100644
index 4bd9e17c5626c7fcbbe0b747a2011d0d74ac9809..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap2D_impl.h
+++ /dev/null
@@ -1,823 +0,0 @@
-/***************************************************************************
-                          tnlFastSweepingMap2D_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-
-#define MAP_SOLVER_MAX_VALUE 3
-
-
-#include "tnlFastSweepingMap.h"
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweepingMap< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlFastSweepingMap()
-:Entity(Mesh),
- dofVector(Mesh),
- dofVector2(Mesh)
-{
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-	dofVector2.load(initialCondition);
-
-	const String& mapFile = parameters.getParameter <String>("map");
-	if(! this->map.load( mapFile ))
-		cout << "Failed to load map file : " << mapFile <<std::endl;
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	Entity.refresh();
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-	cout << "a" <<std::endl;
-
-	something_changed = 1;
-	return initGrid();
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	for(int i=0; i< Mesh.getDimensions().x()*Mesh.getDimensions().x();i++)
-	{
-		dofVector2[i]=INT_MAX*sign(dofVector[i]);
-
-		if(abs(dofVector[i]) < 1.01*h)
-		{
-			dofVector2[i] = dofVector[i];
-			if(map[i] != 0.0)
-				dofVector2[i] /= map[i];
-		}
-	}
-
-//	for(int i = 0 ; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		for(int j = 0 ; j < Mesh.getDimensions().x()-1; j++)
-//			{
-//			this->Entity.setCoordinates(CoordinatesType(i,j));
-//			this->Entity.refresh();
-//			neighborEntities.refresh(Mesh,Entity.getIndex());
-//
-//				if(dofVector[this->Entity.getIndex()] > 0)
-//				{
-//					if(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//					{
-//						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare1111(i,j);
-//							else
-//								setupSquare1110(i,j);
-//						}
-//						else
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare1101(i,j);
-//							else
-//								setupSquare1100(i,j);
-//						}
-//					}
-//					else
-//					{
-//						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare1011(i,j);
-//							else
-//								setupSquare1010(i,j);
-//						}
-//						else
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare1001(i,j);
-//							else
-//								setupSquare1000(i,j);
-//						}
-//					}
-//				}
-//				else
-//				{
-//					if(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-//					{
-//						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare0111(i,j);
-//							else
-//								setupSquare0110(i,j);
-//						}
-//						else
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare0101(i,j);
-//							else
-//								setupSquare0100(i,j);
-//						}
-//					}
-//					else
-//					{
-//						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare0011(i,j);
-//							else
-//								setupSquare0010(i,j);
-//						}
-//						else
-//						{
-//							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-//								setupSquare0001(i,j);
-//							else
-//								setupSquare0000(i,j);
-//						}
-//					}
-//				}
-//
-//			}
-//	}
-	cout << "a" <<std::endl;
-
-	//data.setLike(dofVector2.getData());
-	//data=dofVector2.getData();
-	//cout << data.getType() <<std::endl;
-	dofVector2.save("u-00000.tnl");
-	//dofVector2.getData().save("u-00000.tnl");
-
-	return true;
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-	int cntr = 0;
-	while(something_changed != 0)
-	{
-		something_changed = 0;
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j);
-			}
-		}
-
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j);
-			}
-		}
-
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j);
-			}
-		}
-
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j);
-			}
-		}
-
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-		cntr++;
-		cout << "Finished set of sweeps #" << cntr << "           " << something_changed <<std::endl;
-	}
-
-
-
-	dofVector2.save("u-00001.tnl");
-
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	if(map[Entity.getIndex()] != 0.0)
-	{
-		tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-		Real value = dofVector2[Entity.getIndex()];
-		Real im = abs(1.0/map[Entity.getIndex()]);
-		Real a,b, tmp;
-
-		if( i == 0 )
-			a = dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-		else if( i == Mesh.getDimensions().x() - 1 )
-			a = dofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-		else
-		{
-			a = fabsMin( dofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-					 dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-		}
-
-		if( j == 0 )
-			b = dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-		else if( j == Mesh.getDimensions().y() - 1 )
-			b = dofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-		else
-		{
-			b = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-					 dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-		}
-
-
-		if(fabs(a-b) >= im*h)
-			tmp = fabsMin(a,b) + sign(value)*im*h;
-		else
-			tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * im * h * im * h - (a - b) * (a - b) ) );
-
-		if(abs(value)-abs(tmp) > 0.0)
-			something_changed = 1;
-
-		dofVector2[Entity.getIndex()] = fabsMin(value, tmp);
-
-	}
-	else
-	{
-		dofVector2[Entity.getIndex()] = MAP_SOLVER_MAX_VALUE;
-	}
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-Real tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = fabs(x);
-	Real fy = fabs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-//	this->Entity.setCoordinates(CoordinatesType(i,j));
-//	this->Entity.refresh();
-//	auto neighborEntities =  Entity.getNeighborEntities();
-//	dofVector2[Entity.getIndex()]=fabsMin(INT_MAX,dofVector2[Entity.getIndex()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-//	this->Entity.setCoordinates(CoordinatesType(i,j));
-//	this->Entity.refresh();
-//	auto neighborEntities =  Entity.getNeighborEntities();
-//	dofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,dofVector2[(Entity.getIndex())]);
-//	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	dofVector2[Entity.getIndex()]=fabsMin(dofVector[Entity.getIndex()],dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	dofVector2[Entity.getIndex()]=fabsMin(dofVector[Entity.getIndex()],dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap_CUDA.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap_CUDA.h
deleted file mode 100644
index a23057e78c745e74467db4c4190d6f217024bc5a..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping-map/tnlFastSweepingMap_CUDA.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/***************************************************************************
-                          tnlFastSweepingMap_CUDA.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING_H_
-#define TNLFASTSWEEPING_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-
-#include <functions/tnlMeshFunction.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-#include <ctime>
-
-
-
-
-
-template< typename Mesh,
-		  typename Real,
-		  typename Index >
-class tnlFastSweepingMap
-{};
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 2, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-	tnlFastSweepingMap();
-
-	__host__ static String getType();
-	__host__ bool init( const Config::ParameterContainer& parameters );
-	__host__ bool run();
-
-#ifdef HAVE_CUDA
-	__device__ bool initGrid();
-	__device__ void updateValue(const Index i, const Index j, Index* something_changed);
-	__device__ void updateValue(const Index i, const Index j, double** sharedMem, const int k3);
-	__device__ Real fabsMin(const Real x, const Real y);
-
-	tnlFastSweepingMap< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >* cudaSolver;
-	double* cudaDofVector;
-	double* cudaDofVector2;
-	double* map_cuda;
-	int counter;
-	int* changed;
-	__device__ void setupSquare1000(Index i, Index j);
-	__device__ void setupSquare1100(Index i, Index j);
-	__device__ void setupSquare1010(Index i, Index j);
-	__device__ void setupSquare1001(Index i, Index j);
-	__device__ void setupSquare1110(Index i, Index j);
-	__device__ void setupSquare1101(Index i, Index j);
-	__device__ void setupSquare1011(Index i, Index j);
-	__device__ void setupSquare1111(Index i, Index j);
-	__device__ void setupSquare0000(Index i, Index j);
-	__device__ void setupSquare0100(Index i, Index j);
-	__device__ void setupSquare0010(Index i, Index j);
-	__device__ void setupSquare0001(Index i, Index j);
-	__device__ void setupSquare0110(Index i, Index j);
-	__device__ void setupSquare0101(Index i, Index j);
-	__device__ void setupSquare0011(Index i, Index j);
-	__device__ void setupSquare0111(Index i, Index j);
-#endif
-
-	MeshType Mesh;
-
-protected:
-
-
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector;
-	DofVectorType data, map;
-
-
-	RealType h;
-
-
-};
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweepingMap< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 3, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-
-
-	__host__ static String getType();
-	__host__ bool init( const Config::ParameterContainer& parameters );
-	__host__ bool run();
-
-#ifdef HAVE_CUDA
-	__device__ bool initGrid(int i, int j, int k);
-	__device__ void updateValue(const Index i, const Index j, const Index k);
-	__device__ void updateValue(const Index i, const Index j, const Index k, double** sharedMem, const int k3);
-	__device__ Real fabsMin(const Real x, const Real y);
-
-	tnlFastSweepingMap< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >* cudaSolver;
-	double* cudaDofVector;
-	double* cudaDofVector2;
-	int counter;
-#endif
-
-	MeshType Mesh;
-
-protected:
-
-
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector;
-	DofVectorType data;
-
-	RealType h;
-
-
-};
-
-
-
-
-
-
-
-#ifdef HAVE_CUDA
-//template<int sweep_t>
-__global__ void runCUDA(tnlFastSweepingMap< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i, int* changed);
-//__global__ void runCUDA(tnlFastSweepingMap< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i);
-
-__global__ void initCUDA(tnlFastSweepingMap< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver);
-//__global__ void initCUDA(tnlFastSweepingMap< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver);
-#endif
-
-/*various implementtions.... choose one*/
-//#include "tnlFastSweepingMap2D_CUDA_impl.h"
-//#include "tnlFastSweepingMap2D_CUDA_v2_impl.h"
-//#include "tnlFastSweepingMap2D_CUDA_v3_impl.h"
-#include "tnlFastSweepingMap2D_CUDA_v4_impl.h"
-//#include "tnlFastSweepingMap2D_CUDA_v5_impl.h"
-
-
-//															#include "tnlFastSweepingMap3D_CUDA_impl.h"
-
-#endif /* TNLFASTSWEEPING_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/CMakeLists.txt b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/CMakeLists.txt
deleted file mode 100644
index 1a23d646a43090c0a63216b43c317c14ab0903d3..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-set( tnl_fast_sweeping_SOURCES
-#     MainBuildConfig.h
-#     tnlFastSweeping2D_impl.h
-#     tnlFastSweeping.h
-#     fastSweepingConfig.h 
-     main.cpp)
-
-
-IF(  BUILD_CUDA ) 
-	CUDA_ADD_EXECUTABLE(fast-sweeping main.cu)
-ELSE(  BUILD_CUDA )                
-	ADD_EXECUTABLE(fast-sweeping main.cpp)
-ENDIF( BUILD_CUDA )
-target_link_libraries (fast-sweeping tnl )
-
-
-INSTALL( TARGETS fast-sweeping
-         RUNTIME DESTINATION bin
-         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
-        
-#INSTALL( FILES ${tnl_fast_sweeping_SOURCES}
-#         DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/fast-sweeping )
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/MainBuildConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/MainBuildConfig.h
deleted file mode 100644
index ed3d686eb99379af1589d734eac9b5812cccdedf..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/MainBuildConfig.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
-                          MainBuildConfig.h  -  description
-                             -------------------
-    begin                : Jul 7, 2014
-    copyright            : (C) 2014 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 MAINBUILDCONFIG_H_
-#define MAINBUILDCONFIG_H_
-
-#include <solvers/tnlBuildConfigTags.h>
-
-class MainBuildConfig
-{
-   public:
-
-      static void print() {std::cerr << "MainBuildConfig" <<std::endl; }
-};
-
-/****
- * Turn off support for float and long double.
- */
-template<> struct tnlConfigTagReal< MainBuildConfig, float > { enum { enabled = false }; };
-template<> struct tnlConfigTagReal< MainBuildConfig, long double > { enum { enabled = false }; };
-
-/****
- * Turn off support for short int and long int indexing.
- */
-template<> struct tnlConfigTagIndex< MainBuildConfig, short int >{ enum { enabled = false }; };
-template<> struct tnlConfigTagIndex< MainBuildConfig, long int >{ enum { enabled = false }; };
-
-/****
- * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.
- */
-template< int Dimensions, typename Real, typename Device, typename Index >
-   struct tnlConfigTagMesh< MainBuildConfig, tnlGrid< Dimensions, Real, Device, Index > >
-      { enum { enabled = tnlConfigTagDimensions< MainBuildConfig, Dimensions >::enabled  &&
-                         tnlConfigTagReal< MainBuildConfig, Real >::enabled &&
-                         tnlConfigTagDevice< MainBuildConfig, Device >::enabled &&
-                         tnlConfigTagIndex< MainBuildConfig, Index >::enabled }; };
-
-/****
- * Please, chose your preferred time discretisation  here.
- */
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = false}; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };
-
-/****
- * Only the Runge-Kutta-Merson solver is enabled by default.
- */
-template<> struct tnlConfigTagExplicitSolver< MainBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };
-
-#endif /* MAINBUILDCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/fastSweepingConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/fastSweepingConfig.h
deleted file mode 100644
index 3df2c1e889050448fc07baf7dcd0e32feab3f778..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/fastSweepingConfig.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/***************************************************************************
-                          fastSweepingConfig.h  -  description
-                             -------------------
-    begin                : Oct 15, 2015
-    copyright            : (C) 2015 by Tomas Sobotik
-    email                :
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 FASTSWEEPINGCONFIG_H_
-#define FASTSWEEPINGCONFIG_H_
-
-#include <config/tnlConfigDescription.h>
-
-template< typename ConfigTag >
-class fastSweepingConfig
-{
-   public:
-      static void configSetup( tnlConfigDescription& config )
-      {
-         config.addDelimiter( "Parallel Eikonal solver settings:" );
-         config.addEntry        < String > ( "problem-name", "This defines particular problem.", "fast-sweeping" );
-         config.addRequiredEntry        < String > ( "initial-condition", "Initial condition for solver");
-         config.addRequiredEntry        < int > ( "dim", "Dimension of problem.");
-         config.addEntry       < String > ( "mesh", "Name of mesh.", "mesh.tnl" );
-         config.addEntry       < String > ( "exact-input", "Are the function values near the curve equal to the SDF? (yes/no)", "no" );
-      }
-};
-
-#endif /* FASTSWEEPINGCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.cpp b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.cpp
deleted file mode 100644
index 8849008ff630db0400a6d7d98e789099e5fbb5d9..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.cu b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.cu
deleted file mode 100644
index 8849008ff630db0400a6d7d98e789099e5fbb5d9..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.h
deleted file mode 100644
index e5ac15fede2281abbd31320985de93671d63d178..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/main.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-                          main.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-
-#include "MainBuildConfig.h"
-	//for HOST versions:
-#include "tnlFastSweeping.h"
-	//for DEVICE versions:
-//#include "tnlFastSweeping_CUDA.h"
-#include "fastSweepingConfig.h"
-#include <solvers/tnlBuildConfigTags.h>
-
-#include <mesh/tnlGrid.h>
-#include <core/tnlDevice.h>
-#include <time.h>
-#include <ctime>
-
-typedef MainBuildConfig BuildConfig;
-
-int main( int argc, char* argv[] )
-{
-	time_t start;
-	time_t stop;
-	time(&start);
-	std::clock_t start2= std::clock();
-   Config::ParameterContainer parameters;
-   tnlConfigDescription configDescription;
-   fastSweepingConfig< BuildConfig >::configSetup( configDescription );
-
-   if( ! parseCommandLine( argc, argv, configDescription, parameters ) )
-      return false;
-
-   const int& dim = parameters.getParameter< int >( "dim" );
-
-   if(dim == 2)
-   {
-		tnlFastSweeping<tnlGrid<2,double,TNL::Devices::Host, int>, double, int> solver;
-		if(!solver.init(parameters))
-	   {
-			cerr << "Solver failed to initialize." <<std::endl;
-			return EXIT_FAILURE;
-	   }
-		TNL_CHECK_CUDA_DEVICE;
-	  std::cout << "-------------------------------------------------------------" <<std::endl;
-	  std::cout << "Starting solver..." <<std::endl;
-	   solver.run();
-   }
-   else if(dim == 3)
-   {
-		tnlFastSweeping<tnlGrid<3,double,TNL::Devices::Host, int>, double, int> solver;
-		if(!solver.init(parameters))
-	   {
-			cerr << "Solver failed to initialize." <<std::endl;
-			return EXIT_FAILURE;
-	   }
-		TNL_CHECK_CUDA_DEVICE;
-	  std::cout << "-------------------------------------------------------------" <<std::endl;
-	  std::cout << "Starting solver..." <<std::endl;
-	   solver.run();
-   }
-   else
-   {
-	  std::cerr << "Unsupported number of dimensions: " << dim << "!" <<std::endl;
-	   return EXIT_FAILURE;
-   }
-
-
-   time(&stop);
-  std::cout << "Solver stopped..." <<std::endl;
-  std::cout <<std::endl;
-  std::cout << "Running time was: " << difftime(stop,start) << " .... " << (std::clock() - start2) / (double)(CLOCKS_PER_SEC) <<std::endl;
-   return EXIT_SUCCESS;
-}
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping.h
deleted file mode 100644
index 96d26db7b5a2077d8e2199292f0e888b0171a5c2..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING_H_
-#define TNLFASTSWEEPING_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <functions/tnlMeshFunction.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-#include <ctime>
-#ifdef HAVE_OPENMP
-#include <omp.h>
-#endif
-
-
-
-
-template< typename Mesh,
-		  typename Real,
-		  typename Index >
-class tnlFastSweeping
-{};
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 2, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-
-	tnlFastSweeping();
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-
-	bool initGrid();
-	bool run();
-
-	//for single core version use this implementation:
-	void updateValue(const Index i, const Index j);
-	//for parallel version use this one instead:
-//	void updateValue(const Index i, const Index j, DofVectorType* grid);
-
-
-	void setupSquare1000(Index i, Index j);
-	void setupSquare1100(Index i, Index j);
-	void setupSquare1010(Index i, Index j);
-	void setupSquare1001(Index i, Index j);
-	void setupSquare1110(Index i, Index j);
-	void setupSquare1101(Index i, Index j);
-	void setupSquare1011(Index i, Index j);
-	void setupSquare1111(Index i, Index j);
-	void setupSquare0000(Index i, Index j);
-	void setupSquare0100(Index i, Index j);
-	void setupSquare0010(Index i, Index j);
-	void setupSquare0001(Index i, Index j);
-	void setupSquare0110(Index i, Index j);
-	void setupSquare0101(Index i, Index j);
-	void setupSquare0011(Index i, Index j);
-	void setupSquare0111(Index i, Index j);
-
-	Real fabsMin(const Real x, const Real y);
-
-
-protected:
-
-	MeshType Mesh;
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector, dofVector2;
-	DofVectorType data;
-
-	RealType h;
-
-	tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage > Entity;
-
-
-#ifdef HAVE_OPENMP
-//	omp_lock_t* gridLock;
-#endif
-
-
-};
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 3, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-	tnlFastSweeping();
-
-	static String getType();
-	bool init( const Config::ParameterContainer& parameters );
-
-	bool initGrid();
-	bool run();
-
-	//for single core version use this implementation:
-	void updateValue(const Index i, const Index j, const Index k);
-	//for parallel version use this one instead:
-//	void updateValue(const Index i, const Index j, DofVectorType* grid);
-
-	Real fabsMin(const Real x, const Real y);
-
-
-protected:
-
-	MeshType Mesh;
-
-	bool exactInput;
-
-
-	tnlMeshFunction<MeshType> dofVector, dofVector2;
-	DofVectorType data;
-
-	RealType h;
-
-	tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage > Entity;
-
-#ifdef HAVE_OPENMP
-//	omp_lock_t* gridLock;
-#endif
-
-
-};
-
-
-	//for single core version use this implementation:
-#include "tnlFastSweeping2D_impl.h"
-	//for parallel version use this one instead:
-// #include "tnlFastSweeping2D_openMP_impl.h"
-
-#include "tnlFastSweeping3D_impl.h"
-
-#endif /* TNLFASTSWEEPING_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_impl.h
deleted file mode 100644
index bc1da169c01466a69c00b24e450e5eba09aacd1a..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_impl.h
+++ /dev/null
@@ -1,522 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_CUDA_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.getSpaceSteps().x();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);
-
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-//
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//
-//	dofVector.save("u-00001.tnl");
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(32, 32);
-	dim3 numBlocks(n/32 + 1 ,n/32 +1);
-
-	for(int i = 2*n - 1; i > -1; i--)
-	{
-		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,4,i);
-		cudaDeviceSynchronize();
-	}
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	for(int i = 0; i < 2*n ; i++)
-	{
-		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,1,i);
-		cudaDeviceSynchronize();
-	}
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	for(int i = 0; i < 2*n ; i++)
-	{
-		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,2,i);
-		cudaDeviceSynchronize();
-	}
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	for(int i = 2*n - 1; i > -1; i--)
-	{
-		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,3,i);
-		cudaDeviceSynchronize();
-	}
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	cudaMemcpy(this->dofVector.getData(), cudaDofVector, this->dofVector.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-	Real value = cudaDofVector[index];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)];
-	else
-	{
-		a = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)];
-	else
-	{
-		b = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)] );
-	}
-
-
-	if(abs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-	cudaDofVector[index]  = fabsMin(value, tmp);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	int gid = Mesh.getCellIndex(CoordinatesType(gx,gy));
-
-	int total = blockDim.x*gridDim.x;
-
-
-
-	Real tmp = 0.0;
-	int flag = 0;
-	counter = 0;
-	tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-
-
-	if(!exactInput)
-	{
-		cudaDofVector[gid]=cudaDofVector[gid]=0.5*h*sign(cudaDofVector[gid]);
-	}
-	__threadfence();
-//	printf("-----------------------------------------------------------------------------------\n");
-
-	__threadfence();
-
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1)
-	{
-		if(gy > 0 && gy < Mesh.getDimensions().y()-1)
-		{
-
-			Index j = gy;
-			Index i = gx;
-//			 tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-			if(tmp == 0.0)
-			{}
-			else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-			{}
-			else
-				flag=1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-		}
-	}
-
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-//	printf("****************************************************************\n");
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == 0)
-	{
-//		printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-		Index j = 0;
-		Index i = gx;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == Mesh.getDimensions().y() - 1)
-	{
-		Index i = gx;
-		Index j = Mesh.getDimensions().y() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1 && gx == 0)
-	{
-		Index j = gy;
-		Index i = 0;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-//	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1  && gx == Mesh.getDimensions().x() - 1)
-	{
-		Index j = gy;
-		Index i = Mesh.getDimensions().x() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("##################################################################################################\n");
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == 0)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-//	printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
-	if(gx == 0 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == 0 &&
-	   gy == 0)
-	{
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-
-	__threadfence();
-
-	if(flag==1)
-		cudaDofVector[gid] =  tmp*3;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	Real fy = abs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	if(solver->Mesh.getDimensions().x() <= gx || solver->Mesh.getDimensions().y() <= gy)
-		return;
-	int total = solver->Mesh.getDimensions().x();
-	//int gid = solver->Mesh.getDimensions().x() * gy + gx;
-	int max = solver->Mesh.getDimensions().x()*solver->Mesh.getDimensions().x();
-
-	int id1 = gx+gy;
-	int id2 = (solver->Mesh.getDimensions().x() - gx - 1) + gy;
-
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-	if(sweep == 1)
-//	for(int i = 0; i < 2*total - 1; i++)
-	{
-		if(id1 == i)
-		{
-			solver->updateValue(gx,gy);
-			return;
-		}
-
-	}
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-	else if(sweep == 2)
-//	for(int i = 0; i < 2*total - 1; i++)
-	{
-		if(id2 == i)
-		{
-			solver->updateValue(gx,gy);
-			return;
-		}
-	}
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-	else if(sweep == 3)
-//	for(int i = 2*total - 2; i > -1; i--)
-	{
-		if(id1 == i)
-		{
-			solver->updateValue(gx,gy);
-			return;
-		}
-	}
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-	else if(sweep == 4)
-//	for(int i = 2*total - 2; i > -1; i--)
-	{
-		if(id2 == i)
-		{
-			solver->updateValue(gx,gy);
-			return;
-		}
-	}
-	/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-#endif
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v2_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v2_impl.h
deleted file mode 100644
index 3ad5b7944f839f794f695240e7abba59e23d16b4..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v2_impl.h
+++ /dev/null
@@ -1,588 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_CUDA_v2_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.getSpaceSteps().x();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);
-
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-//
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//
-//	dofVector.save("u-00001.tnl");
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(27, 27);
-	dim3 numBlocks(1 ,1);
-
-//	for(int i = 2*n - 1; i > -1; i--)
-	{
-		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,4,0);
-		cudaDeviceSynchronize();
-	}
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-////	for(int i = 0; i < 2*n ; i++)
-//	{
-//		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,1,0);
-//		cudaDeviceSynchronize();
-//	}
-//	cudaDeviceSynchronize();
-//	TNL_CHECK_CUDA_DEVICE;
-////	for(int i = 0; i < 2*n ; i++)
-//	{
-//		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,2,0);
-//		cudaDeviceSynchronize();
-//	}
-//	cudaDeviceSynchronize();
-//	TNL_CHECK_CUDA_DEVICE;
-////	for(int i = 2*n - 1; i > -1; i--)
-//	{
-//		runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,3,0);
-//		cudaDeviceSynchronize();
-//	}
-//
-//	cudaDeviceSynchronize();
-//	TNL_CHECK_CUDA_DEVICE;
-
-	cudaMemcpy(this->dofVector.getData(), cudaDofVector, this->dofVector.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-	Real value = cudaDofVector[index];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)];
-	else
-	{
-		a = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)];
-	else
-	{
-		b = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)] );
-	}
-
-
-	if(abs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-	cudaDofVector[index]  = fabsMin(value, tmp);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	int gid = Mesh.getCellIndex(CoordinatesType(gx,gy));
-
-	int total = blockDim.x*gridDim.x;
-
-
-
-	Real tmp = 0.0;
-	int flag = 0;
-	counter = 0;
-	tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-
-
-	if(!exactInput)
-	{
-		cudaDofVector[gid]=cudaDofVector[gid]=0.5*h*sign(cudaDofVector[gid]);
-	}
-	__threadfence();
-//	printf("-----------------------------------------------------------------------------------\n");
-
-	__threadfence();
-
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1)
-	{
-		if(gy > 0 && gy < Mesh.getDimensions().y()-1)
-		{
-
-			Index j = gy;
-			Index i = gx;
-//			 tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-			if(tmp == 0.0)
-			{}
-			else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-			{}
-			else
-				flag=1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-		}
-	}
-
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-//	printf("****************************************************************\n");
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == 0)
-	{
-//		printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-		Index j = 0;
-		Index i = gx;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == Mesh.getDimensions().y() - 1)
-	{
-		Index i = gx;
-		Index j = Mesh.getDimensions().y() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1 && gx == 0)
-	{
-		Index j = gy;
-		Index i = 0;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-//	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1  && gx == Mesh.getDimensions().x() - 1)
-	{
-		Index j = gy;
-		Index i = Mesh.getDimensions().x() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("##################################################################################################\n");
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == 0)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-//	printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
-	if(gx == 0 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == 0 &&
-	   gy == 0)
-	{
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-
-	__threadfence();
-
-	if(flag==1)
-		cudaDofVector[gid] =  tmp*3;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-
-	Real tmpMin = Min(fx,abs(y));
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-{
-
-	//int gx = threadIdx.x;
-	//int gy = threadIdx.y;
-	int id1,id2;
-	int nx = solver->Mesh.getDimensions().x()+ threadIdx.x;
-	int ny = solver->Mesh.getDimensions().y()+ threadIdx.y;
-
-	int blockCount = solver->Mesh.getDimensions().x()/blockDim.x + 1;
-
-	for(int gy = threadIdx.y; gy < ny;gy+=blockDim.y)
-	{
-		for(int gx = threadIdx.x; gx < nx;gx+=blockDim.x)
-		{
-//			if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy && gy > -1&& gx > -1)
-			{
-				id1 = threadIdx.x+threadIdx.y;
-
-				for(int l = 0; l < 2*blockDim.x - 1; l++)
-				{
-					if(id1 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-					}
-					__syncthreads();
-				}
-
-			}
-			//gx+=blockDim.x;
-			//__syncthreads();
-		}
-		//gx = threadIdx.x;
-		//gy+=blockDim.y;
-		//__syncthreads();
-	}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-//	gx = blockDim.x*(blockCount-1) + threadIdx.x;
-//	gy = threadIdx.y;
-	for(int gy = threadIdx.y; gy < ny;gy+=blockDim.y)
-	{
-		for(int gx = blockDim.x*(blockCount-1) + threadIdx.x; gx >- 1;gx-=blockDim.x)
-		{
-//			if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy && gy > -1&& gx > -1)
-			{
-				id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-				for(int l = 0; l < 2*blockDim.x - 1; l++)
-				{
-					if(id2 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-					}
-					__syncthreads();
-				}
-			}
-			//gx-=blockDim.x;
-			//__syncthreads();
-		}
-		//gx = blockDim.x*(blockCount-1) + threadIdx.x;
-		//gy+=blockDim.y;
-		//__syncthreads();
-	}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-//	gx = blockDim.x*(blockCount-1) + threadIdx.x;
-//	gy = blockDim.x*(blockCount-1) + threadIdx.y;
-	for(int gy = blockDim.x*(blockCount-1) +threadIdx.y; gy >- 1;gy-=blockDim.y)
-	{
-		for(int gx = blockDim.x*(blockCount-1) + threadIdx.x; gx >- 1;gx-=blockDim.x)
-		{
-//			if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy && gy > -1&& gx > -1)
-			{
-				id1 = threadIdx.x+threadIdx.y;
-
-				for(int l = 2*blockDim.x - 2; l > -1; l--)
-				{
-					if(id1 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-					}
-					__syncthreads();
-				}
-			}
-			//gx-=blockDim.x;
-			//__syncthreads();
-		}
-		//gx = blockDim.x*(blockCount-1) + threadIdx.x;
-		//gy-=blockDim.y;
-		//__syncthreads();
-	}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-	//gx = threadIdx.x;
-	//gy = blockDim.x*(blockCount-1) +threadIdx.y;
-	for(int gy = blockDim.x*(blockCount-1) +threadIdx.y; gy >- 1;gy-=blockDim.y)
-	{
-		for(int gx = threadIdx.x; gx < nx;gx+=blockDim.x)
-		{
-//			if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy && gy > -1&& gx > -1)
-			{
-				id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-				for(int l = 2*blockDim.x - 2; l > -1; l--)
-				{
-					if(id2 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-					}
-					__syncthreads();
-				}
-			}
-			//gx+=blockDim.x;
-			//__syncthreads();
-		}
-		//gx = threadIdx.x;
-		//gy-=blockDim.y;
-		///__syncthreads();
-	}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-#endif
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v3_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v3_impl.h
deleted file mode 100644
index ff36d3f8e0a73e5a0987b06f81be2650b277fa25..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v3_impl.h
+++ /dev/null
@@ -1,920 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_CUDA_v3_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-
-
-
-__device__ double atomicSet(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong(val ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.getSpaceSteps().x();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);
-
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-//
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//
-//	dofVector.save("u-00001.tnl");
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 +1 ,n/16 +1);
-	int m =n/16 +1;
-
-	for(int i = 0; i < 2*m -1; i++)
-	{
-		runCUDA<15><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,1,i);
-		//cudaDeviceSynchronize();
-	}
-//	cudaDeviceSynchronize();
-//	TNL_CHECK_CUDA_DEVICE;
-//	for(int i = 0; i < 2*m -1; i++)
-//	{
-//		runCUDA<2><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,2,i);
-//		cudaDeviceSynchronize();
-//	}
-//	cudaDeviceSynchronize();
-//	TNL_CHECK_CUDA_DEVICE;
-//	for(int i = 0; i < 2*m -1; i++)
-//	{
-//		runCUDA<4><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,4,i);
-//		cudaDeviceSynchronize();
-//	}
-//	cudaDeviceSynchronize();
-//	TNL_CHECK_CUDA_DEVICE;
-//	for(int i = 0; i < 2*m -1; i++)
-//	{
-//		runCUDA<8><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,8,i);
-//		cudaDeviceSynchronize();
-//	}
-
-
-
-
-//	for(int i = 0; i < (2*m -1)/4 -1; i++)
-//	{
-//		runCUDA<15><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,15,i);//all
-//		cudaDeviceSynchronize();
-//	}
-//	for(int i = (2*m -1)/4 -1; i < (2*m -1)/2 -1; i++)
-//	{
-//		runCUDA<5><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,5,i); //two
-//		cudaDeviceSynchronize();
-//		runCUDA<10><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,10,i); //two
-//		cudaDeviceSynchronize();
-//	}
-//	for(int i = (2*m -1)/2 -1; i < (2*m -1)/2 +1; i++)
-//	{
-//		runCUDA<1><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,1,i); //separate
-//		cudaDeviceSynchronize();
-//		runCUDA<2><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,2,i); //separate
-//		cudaDeviceSynchronize();
-//		runCUDA<4><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,4,i); //separate
-//		cudaDeviceSynchronize();
-//		runCUDA<8><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,8,i); //separate
-//		cudaDeviceSynchronize();
-//	}
-//	for(int i = (2*m -1)/2 +1; i < (2*m -1/4)*3 +1; i++)
-//	{
-//		runCUDA<5><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,5,i); //two
-//		cudaDeviceSynchronize();
-//		runCUDA<10><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,10,i); //two
-//		cudaDeviceSynchronize();
-//	}
-//	for(int i = (2*m -1/4)*3 +1; i < 2*m -1; i++)
-//	{
-//		runCUDA<15><<<numBlocks,threadsPerBlock>>>(this->cudaSolver,15,i);//all
-//		cudaDeviceSynchronize();
-//	}
-cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	cudaMemcpy(this->dofVector.getData(), cudaDofVector, this->dofVector.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-	Real value = cudaDofVector[index];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)];
-	else
-	{
-		a = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)];
-	else
-	{
-		b = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)] );
-	}
-
-
-	if(abs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-	atomicSet(&cudaDofVector[index],fabsMin(value, tmp));
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	int gid = Mesh.getCellIndex(CoordinatesType(gx,gy));
-
-	int total = blockDim.x*gridDim.x;
-
-
-
-	Real tmp = 0.0;
-	int flag = 0;
-	counter = 0;
-	tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-
-
-	if(!exactInput)
-	{
-		cudaDofVector[gid]=cudaDofVector[gid]=0.5*h*sign(cudaDofVector[gid]);
-	}
-	__threadfence();
-//	printf("-----------------------------------------------------------------------------------\n");
-
-	__threadfence();
-
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1)
-	{
-		if(gy > 0 && gy < Mesh.getDimensions().y()-1)
-		{
-
-			Index j = gy;
-			Index i = gx;
-//			 tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-			if(tmp == 0.0)
-			{}
-			else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-			{}
-			else
-				flag=1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-		}
-	}
-
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-//	printf("****************************************************************\n");
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == 0)
-	{
-//		printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-		Index j = 0;
-		Index i = gx;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == Mesh.getDimensions().y() - 1)
-	{
-		Index i = gx;
-		Index j = Mesh.getDimensions().y() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1 && gx == 0)
-	{
-		Index j = gy;
-		Index i = 0;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-//	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1  && gx == Mesh.getDimensions().x() - 1)
-	{
-		Index j = gy;
-		Index i = Mesh.getDimensions().x() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("##################################################################################################\n");
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == 0)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-//	printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
-	if(gx == 0 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == 0 &&
-	   gy == 0)
-	{
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-
-	__threadfence();
-
-	if(flag==1)
-		cudaDofVector[gid] =  tmp*3;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-//	Real fx = abs(x);
-//
-//	Real tmpMin = Min(fx,abs(y));
-
-	if(abs(y) > abs(x))
-		return x;
-	else
-		return y;
-
-
-}
-
-
-template<>
-__global__ void runCUDA<1>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-{
-
-	if(blockIdx.x+blockIdx.y == k)
-	{
-		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-		int id1 = threadIdx.x+threadIdx.y;
-
-						for(int l = 0; l < 2*blockDim.x - 1; l++)
-						{
-							if(id1 == l)
-							{
-								if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-								solver->updateValue(gx,gy);
-							}
-							__syncthreads();
-						}
-
-	}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-}
-	template<>
-	__global__ void runCUDA<2>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-	{
-	if((gridDim.x - blockIdx.x - 1)+blockIdx.y == k)
-	{
-		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-		int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-				for(int l = 0; l < 2*blockDim.x - 1; l++)
-				{
-					if(id2 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-					}
-					__syncthreads();
-				}
-
-	}
-	}			/*---------------------------------------------------------------------------------------------------------------------------*/
-	template<>
-	__global__ void runCUDA<4>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-	{
-	if(blockIdx.x+blockIdx.y == gridDim.x+gridDim.y-k-2)
-		{
-		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-		int id1 = threadIdx.x+threadIdx.y;
-
-				for(int l = 2*blockDim.x - 2; l > -1; l--)
-				{
-					if(id1 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-						return;
-					}
-					__syncthreads();
-				}
-
-		}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	}
-
-	template<>
-	__global__ void runCUDA<8>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-	{
-	if((gridDim.x - blockIdx.x - 1)+blockIdx.y == gridDim.x+gridDim.y-k-2)
-		{
-		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-		int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-				for(int l = 2*blockDim.x - 2; l > -1; l--)
-				{
-					if(id2 == l)
-					{
-						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-						solver->updateValue(gx,gy);
-						return;
-					}
-					__syncthreads();
-				}
-
-		}
-			/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-
-}
-
-
-	template<>
-		__global__ void runCUDA<5>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-		{
-
-			if(blockIdx.x+blockIdx.y == k)
-			{
-				int gx = threadIdx.x + blockDim.x*blockIdx.x;
-				int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-				int id1 = threadIdx.x+threadIdx.y;
-
-								for(int l = 0; l < 2*blockDim.x - 1; l++)
-								{
-									if(id1 == l)
-									{
-										if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-										solver->updateValue(gx,gy);
-										return;
-									}
-									__syncthreads();
-								}
-
-			}
-			else if(blockIdx.x+blockIdx.y == gridDim.x+gridDim.y-k-2)
-				{
-				int gx = threadIdx.x + blockDim.x*blockIdx.x;
-				int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-				int id1 = threadIdx.x+threadIdx.y;
-
-						for(int l = 2*blockDim.x - 2; l > -1; l--)
-						{
-							if(id1 == l)
-							{
-								if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-								solver->updateValue(gx,gy);
-								return;
-							}
-							__syncthreads();
-						}
-
-				}
-		}
-
-
-	template<>
-		__global__ void runCUDA<10>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-		{
-			if((gridDim.x - blockIdx.x - 1)+blockIdx.y == k)
-			{
-				int gx = threadIdx.x + blockDim.x*blockIdx.x;
-				int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-				int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-						for(int l = 0; l < 2*blockDim.x - 1; l++)
-						{
-							if(id2 == l)
-							{
-								if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-								solver->updateValue(gx,gy);
-								return;
-							}
-							__syncthreads();
-						}
-
-			}
-
-			else if((gridDim.x - blockIdx.x - 1)+blockIdx.y == gridDim.x+gridDim.y-k-2)
-				{
-				int gx = threadIdx.x + blockDim.x*blockIdx.x;
-				int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-				int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-						for(int l = 2*blockDim.x - 2; l > -1; l--)
-						{
-							if(id2 == l)
-							{
-								if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-								solver->updateValue(gx,gy);
-								return;
-							}
-							__syncthreads();
-						}
-
-				}
-
-		}
-
-
-
-	template<>
-	__global__ void runCUDA<15>(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-	{
-
-		if(blockIdx.x+blockIdx.y == k)
-		{
-			int gx = threadIdx.x + blockDim.x*blockIdx.x;
-			int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-			int id1 = threadIdx.x+threadIdx.y;
-
-							for(int l = 0; l < 2*blockDim.x - 1; l++)
-							{
-								if(id1 == l)
-								{
-									if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-									solver->updateValue(gx,gy);
-									return;
-								}
-								__syncthreads();
-							}
-
-		}
-				/*---------------------------------------------------------------------------------------------------------------------------*/
-
-		if((gridDim.x - blockIdx.x - 1)+blockIdx.y == k)
-		{
-			int gx = threadIdx.x + blockDim.x*blockIdx.x;
-			int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-			int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-					for(int l = 0; l < 2*blockDim.x - 1; l++)
-					{
-						if(id2 == l)
-						{
-							if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-							solver->updateValue(gx,gy);
-							return;
-						}
-						__syncthreads();
-					}
-
-		}
-				/*---------------------------------------------------------------------------------------------------------------------------*/
-
-		if(blockIdx.x+blockIdx.y == gridDim.x+gridDim.y-k-2)
-			{
-			int gx = threadIdx.x + blockDim.x*blockIdx.x;
-			int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-			int id1 = threadIdx.x+threadIdx.y;
-
-					for(int l = 2*blockDim.x - 2; l > -1; l--)
-					{
-						if(id1 == l)
-						{
-							if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-							solver->updateValue(gx,gy);
-							return;
-						}
-						__syncthreads();
-					}
-
-			}
-				/*---------------------------------------------------------------------------------------------------------------------------*/
-
-		if((gridDim.x - blockIdx.x - 1)+blockIdx.y == gridDim.x+gridDim.y-k-2)
-			{
-			int gx = threadIdx.x + blockDim.x*blockIdx.x;
-			int gy = threadIdx.y + blockDim.y*blockIdx.y;
-
-			int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-
-					for(int l = 2*blockDim.x - 2; l > -1; l--)
-					{
-						if(id2 == l)
-						{
-							if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-							solver->updateValue(gx,gy);
-							return;
-						}
-						__syncthreads();
-					}
-
-			}
-				/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-
-	}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-#endif
-
-
-
-
-
-
-//__global__ void runCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int k)
-//{
-//
-//	if(sweep==1 && blockIdx.x+blockIdx.y == k)
-//	{
-//		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-//		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-//
-//		int id1 = threadIdx.x+threadIdx.y;
-//
-//						for(int l = 0; l < 2*blockDim.x - 1; l++)
-//						{
-//							if(id1 == l)
-//							{
-//								if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-//								solver->updateValue(gx,gy);
-//							}
-//							__syncthreads();
-//						}
-//
-//	}
-//			/*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	else if(sweep==2 && (gridDim.x - blockIdx.x - 1)+blockIdx.y == k)
-//	{
-//		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-//		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-//
-//		int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-//
-//				for(int l = 0; l < 2*blockDim.x - 1; l++)
-//				{
-//					if(id2 == l)
-//					{
-//						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-//						solver->updateValue(gx,gy);
-//					}
-//					__syncthreads();
-//				}
-//
-//	}
-//			/*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	else if(sweep==4 && blockIdx.x+blockIdx.y == gridDim.x+gridDim.y-k-2)
-//		{
-//		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-//		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-//
-//		int id1 = threadIdx.x+threadIdx.y;
-//
-//				for(int l = 2*blockDim.x - 2; l > -1; l--)
-//				{
-//					if(id1 == l)
-//					{
-//						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-//						solver->updateValue(gx,gy);
-//						return;
-//					}
-//					__syncthreads();
-//				}
-//
-//		}
-//			/*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	else if(sweep==8 && (gridDim.x - blockIdx.x - 1)+blockIdx.y == gridDim.x+gridDim.y-k-2)
-//		{
-//		int gx = threadIdx.x + blockDim.x*blockIdx.x;
-//		int gy = threadIdx.y + blockDim.y*blockIdx.y;
-//
-//		int id2 = (blockDim.x - threadIdx.x - 1) + threadIdx.y;
-//
-//				for(int l = 2*blockDim.x - 2; l > -1; l--)
-//				{
-//					if(id2 == l)
-//					{
-//						if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy /*&& gy > -1&& gx > -1*/)
-//						solver->updateValue(gx,gy);
-//						return;
-//					}
-//					__syncthreads();
-//				}
-//
-//		}
-//			/*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//
-//
-//
-//
-//}
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v4_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v4_impl.h
deleted file mode 100644
index e0a9697c2e5ea4097232b4d4a8f3c6da6fa41e50..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v4_impl.h
+++ /dev/null
@@ -1,1003 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_CUDA_v4_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-__device__
-double fabsMin( double x, double y)
-{
-	double fx = abs(x);
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__device__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(__longlong_as_double(assumed),val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlFastSweeping()
-:dofVector(Mesh)
-{
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	//Entity.refresh();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);
-
-
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(1, 1024);
-	dim3 numBlocks(4,1);
-
-
-	runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,0,0);
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	//data.setLike(dofVector.getData());
-	//cudaMemcpy(data.getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaMemcpy(dofVector.getData().getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	//data.save("u-00001.tnl");
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	Real value = cudaDofVector2[Entity.getIndex()];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-	else
-	{
-		a = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-	else
-	{
-		b = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-	}
-
-
-	if(abs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-//	cudaDofVector2[Entity.getIndex()]  = fabsMin(value, tmp);
-	atomicFabsMin(&(cudaDofVector2[Entity.getIndex()]), tmp);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int i = threadIdx.x + blockDim.x*blockIdx.x;
-	int j = blockDim.y*blockIdx.y + threadIdx.y;
-
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	int gid = Entity.getIndex();
-
-	cudaDofVector2[gid] = INT_MAX*sign(cudaDofVector[gid]);
-//
-//	if(abs(cudaDofVector[gid]) < 1.01*h)
-//		cudaDofVector2[gid] = cudaDofVector[gid];
-
-
-
-
-
-	if(i+1 < Mesh.getDimensions().x() && j+1 < Mesh.getDimensions().y() && !exactInput)
-	{
-		if(cudaDofVector[Entity.getIndex()] > 0)
-		{
-			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-			{
-				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare1111(i,j);
-					else
-						setupSquare1110(i,j);
-				}
-				else
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare1101(i,j);
-					else
-						setupSquare1100(i,j);
-				}
-			}
-			else
-			{
-				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare1011(i,j);
-					else
-						setupSquare1010(i,j);
-				}
-				else
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare1001(i,j);
-					else
-						setupSquare1000(i,j);
-				}
-			}
-		}
-		else
-		{
-			if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-			{
-				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare0111(i,j);
-					else
-						setupSquare0110(i,j);
-				}
-				else
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare0101(i,j);
-					else
-						setupSquare0100(i,j);
-				}
-			}
-			else
-			{
-				if(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare0011(i,j);
-					else
-						setupSquare0010(i,j);
-				}
-				else
-				{
-					if(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-						setupSquare0001(i,j);
-					else
-						setupSquare0000(i,j);
-				}
-			}
-		}
-
-	}
-	if(exactInput)
-	{
-		if(abs(cudaDofVector[gid]) < 1.5*h)
-			cudaDofVector2[gid] = cudaDofVector[gid];
-	}
-
-
-	return true;
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	//Real fy = abs(y);
-
-	//Real tmpMin = Min(fx,abs(y));
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-	int gx = 0;
-	int gy = threadIdx.y;
-	//if(solver->Mesh.getDimensions().x() <= gx || solver->Mesh.getDimensions().y() <= gy)
-	//	return;
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-	//int gid = solver->Mesh.getDimensions().x() * gy + gx;
-	//int max = solver->Mesh.getDimensions().x()*solver->Mesh.getDimensions().x();
-
-	//int id1 = gx+gy;
-	//int id2 = (solver->Mesh.getDimensions().x() - gx - 1) + gy;
-
-	if(blockIdx.x==0)
-	{
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==1)
-	{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==2)
-	{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-	else if(blockIdx.x==3)
-	{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-
-
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-//	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-//	Entity.setCoordinates(CoordinatesType(i,j));
-//	Entity.refresh();
-//	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-//	cudaDofVector2[Entity.getIndex()]=fabsMin(INT_MAX,cudaDofVector2[Entity.getIndex()]);
-//	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-//	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-//	Entity.setCoordinates(CoordinatesType(i,j));
-//	Entity.refresh();
-//	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-//	cudaDofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,cudaDofVector2[Entity.getIndex()]);
-//	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=INT_MAX;	//fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-0.5*h;	//fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=0.5*h;	//fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=0.5*h;	//fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=0.5*h;	//fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=INT_MAX;	//fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=0.5*h;	//fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=INT_MAX;	//fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-0.5*h;	//fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=-0.5*h;	//fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=INT_MAX;	//fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=0.5*h;	//fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=-INT_MAX;	//fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=-0.5*h;	//fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=0.5*h;	//fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=-0.5*h;	//fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-INT_MAX;	//fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[Entity.getIndex()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=-0.5*h;	//fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=INT_MAX;	//fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-0.5*h;	//fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=0.5*h;	//fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=0.5*h;	//fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-INT_MAX;	//fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-0.5*h;	//fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=0.5*h;	//fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=-0.5*h;	//fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=0.5*h;	//fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=0.5*h;	//fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-0.5*h;	//fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=0.5*h;	//fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=-0.5*h;	//fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=0.5*h;	//fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-0.5*h;	//fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=-0.5*h;	//fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=0.5*h;	//fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	Real al,be, a,b,c,s;
-	al=abs(cudaDofVector[Entity.getIndex()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 cudaDofVector[Entity.getIndex()]));
-
-	be=abs(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b = 1.0;
-	c = -be;
-	s = h/sqrt(a*a+b*b);
-
-
-	cudaDofVector2[Entity.getIndex()]=-0.5*h;	//fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=-0.5*h;	//fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=0.5*h;	//fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=0.5*h;	//fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	tnlGridEntity< tnlGrid< 2,double, TNL::Devices::Host, int >, 2, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	cudaDofVector2[Entity.getIndex()]=-0.5*h;	//fabsMin(cudaDofVector[Entity.getIndex()],cudaDofVector2[Entity.getIndex()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=0.5*h;	//fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 0,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=-0.5*h;	//fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  1 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=0.5*h;	//fabsMin(cudaDofVector[neighborEntities.template getEntityIndex< 1,  0 >()],cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-#endif
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v5_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v5_impl.h
deleted file mode 100644
index 1591bb6137007b88e636a83bb113030ecd529f9c..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_CUDA_v5_impl.h
+++ /dev/null
@@ -1,697 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_CUDA_v5_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-__device__
-double fabsMin( double x, double y)
-{
-	double fx = abs(x);
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__device__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(assumed,val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.getSpaceSteps().x();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData(), this->dofVector.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(16, 16);
-	dim3 numBlocks(n/16 + 1 ,n/16 +1);
-
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-//
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-//	{
-//		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-//		{
-//			updateValue(i,j);
-//		}
-//	}
-//
-///*---------------------------------------------------------------------------------------------------------------------------*/
-//
-//
-//	dofVector.save("u-00001.tnl");
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(1, 512);
-	dim3 numBlocks(4,1);
-
-
-	runCUDA<<<numBlocks,threadsPerBlock,3*(512+1)*sizeof(double)>>>(this->cudaSolver,0,0);
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	cudaMemcpy(this->dofVector.getData(), cudaDofVector, this->dofVector.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-	Real value = cudaDofVector[index];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)];
-	else
-	{
-		a = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<-1,0>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)];
-	else
-	{
-		b = fabsMin( cudaDofVector[Mesh.template getCellNextToCell<0,-1>(index)],
-				 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)] );
-	}
-
-
-	if(abs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-	cudaDofVector[index]  = fabsMin(value, tmp);
-
-}
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, double** sharedMem, int k3)
-{
-	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-	Real value = sharedMem[k3+1][threadIdx.y];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = sharedMem[k3][threadIdx.y];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = sharedMem[k3+2][threadIdx.y];
-	else
-	{
-		a = fabsMin( sharedMem[k3][threadIdx.y],
-				sharedMem[k3+2][threadIdx.y] );
-	}
-
-	if( j == 0 )
-		b = sharedMem[k3][threadIdx.y+1];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = sharedMem[k3+2][threadIdx.y-1];
-	else
-	{
-		b = fabsMin( sharedMem[k3][threadIdx.y+1],
-				sharedMem[k3+2][threadIdx.y-1] );
-	}
-
-
-	if(abs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-//	sharedMem[k3+1][threadIdx.y] = this->fabsMin(value, tmp);
-//	atomicFabsMin(&(cudaDofVector[index]), tmp);
-	cudaDofVector[index]  = tmp;
-	this->fabsMin(value, tmp);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	int gid = Mesh.getCellIndex(CoordinatesType(gx,gy));
-
-	int total = blockDim.x*gridDim.x;
-
-
-
-	Real tmp = 0.0;
-	int flag = 0;
-	counter = 0;
-	tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-
-
-	if(!exactInput)
-	{
-		cudaDofVector[gid]=cudaDofVector[gid]=0.5*h*sign(cudaDofVector[gid]);
-	}
-	__threadfence();
-//	printf("-----------------------------------------------------------------------------------\n");
-
-	__threadfence();
-
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1)
-	{
-		if(gy > 0 && gy < Mesh.getDimensions().y()-1)
-		{
-
-			Index j = gy;
-			Index i = gx;
-//			 tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-			if(tmp == 0.0)
-			{}
-			else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-					cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-			{}
-			else
-				flag=1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-		}
-	}
-
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-//	printf("****************************************************************\n");
-//	printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == 0)
-	{
-//		printf("gx: %d, gy: %d, gid: %d \n", gx, gy,gid);
-		Index j = 0;
-		Index i = gx;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-	if(gx > 0 && gx < Mesh.getDimensions().x()-1 && gy == Mesh.getDimensions().y() - 1)
-	{
-		Index i = gx;
-		Index j = Mesh.getDimensions().y() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1 && gx == 0)
-	{
-		Index j = gy;
-		Index i = 0;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-//	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
-	if(gy > 0 && gy < Mesh.getDimensions().y()-1  && gx == Mesh.getDimensions().x() - 1)
-	{
-		Index j = gy;
-		Index i = Mesh.getDimensions().x() - 1;
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-//	printf("##################################################################################################\n");
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == Mesh.getDimensions().x() - 1 &&
-	   gy == 0)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx-1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-//	printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
-	if(gx == 0 &&
-	   gy == Mesh.getDimensions().y() - 1)
-	{
-
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy-1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-	if(gx == 0 &&
-	   gy == 0)
-	{
-//		tmp = sign(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))]);
-		if(cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx+1,gy))]*tmp > 0.0 &&
-				cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy+1))]*tmp > 0.0)
-
-			flag = 1;//cudaDofVector[Mesh.getCellIndex(CoordinatesType(gx,gy))] = tmp*INT_MAX;
-	}
-
-	__threadfence();
-
-	if(flag==1)
-		cudaDofVector[gid] =  tmp*3;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	//Real fy = abs(y);
-
-	//Real tmpMin = Min(fx,abs(y));
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-	extern __shared__ double u[];
-	double* sharedMem[5];
-	sharedMem[0] = u;
-	sharedMem[1] = &(u[blockDim.y+1]);
-	sharedMem[2] = &(sharedMem[1][blockDim.y+1]);
-	sharedMem[3] = sharedMem[1];
-	sharedMem[4] = sharedMem[2];
-
-	int gx = 0;
-	int gy = threadIdx.y;
-	//if(solver->Mesh.getDimensions().x() <= gx || solver->Mesh.getDimensions().y() <= gy)
-	//	return;
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-	//int gid = solver->Mesh.getDimensions().x() * gy + gx;
-	//int max = solver->Mesh.getDimensions().x()*solver->Mesh.getDimensions().x();
-
-	//int id1 = gx+gy;
-	//int id2 = (solver->Mesh.getDimensions().x() - gx - 1) + gy;
-
-
-	if(blockIdx.x==0)
-	{
-		if(threadIdx.y==0)
-			sharedMem[1][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(0,0))];
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				int k3=k%3;
-
-				if(threadIdx.y==0)
-				{
-					if(gx==n-1)
-						sharedMem[k3][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(0,gy+blockDim.y))];
-					else
-						sharedMem[k3][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx+1,gy))];
-				}
-//				else
-//					solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy-1))]=sharedMem[k3+2][threadIdx.y-1];
-
-				if(gy<n-1)
-					sharedMem[k3][threadIdx.y+1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy+1))];
-
-				solver->updateValue(gx,gy,sharedMem,k3);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-	}
-//	else if(blockIdx.x==1)
-//	{
-//		gx=n-1;
-//		gy=threadIdx.y;
-//
-//		if(threadIdx.y==0)
-//					sharedMem[1][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(n-1,0))];
-//
-//		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-//		{
-//			if(threadIdx.y  < k+1 && gy < n)
-//			{
-//				int k3=k%3;
-//
-//				if(threadIdx.y==0)
-//					if(gx==0)
-//						sharedMem[k3+2][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(n-1,gy+blockDim.y))];
-//					else
-//						sharedMem[k3+2][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx-1,gy))];
-//				else
-//					solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy-1))]=sharedMem[k3][threadIdx.y-1];
-//
-//				if(gy<n-1)
-//					sharedMem[k3+2][threadIdx.y+1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy+1))];
-//
-//
-//				solver->updateValue(gx,gy,sharedMem,k3);
-//				gx--;
-//				if(gx==-1)
-//				{
-//					gx=n-1;
-//					gy+=blockDim.y;
-//				}
-//			}
-//
-//
-//			__syncthreads();
-//		}
-//	}
-//	else if(blockIdx.x==2)
-//	{
-//		gx=0;
-//		gy=n-blockDim.y-1+threadIdx.y;
-//
-//		if(threadIdx.y==0)
-//					sharedMem[1][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(0,n-1))];
-//
-//		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-//		{
-//			if(blockDim.y-threadIdx.y  < k+1 && gy > -1)
-//			{
-//				int k3=k%3;
-//
-//				if(threadIdx.y==blockDim.y-1)
-//					if(gx==n-1)
-//						sharedMem[k3][n-1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(0,gy-blockDim.y))];
-//					else
-//						sharedMem[k3][n-1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx+1,gy))];
-//				else
-//					solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy-1))]=sharedMem[k3+2][threadIdx.y-1];
-//
-//				if(gy<n-1)
-//					sharedMem[k3][threadIdx.y+1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy+1))];
-//
-//
-//				solver->updateValue(gx,gy,sharedMem,k3);
-//				gx++;
-//				if(gx==n)
-//				{
-//					gx=0;
-//					gy-=blockDim.y;
-//				}
-//			}
-//
-//
-//			__syncthreads();
-//		}
-//	}
-//	else if(blockIdx.x==3)
-//	{
-//		gx=n-1;
-//		gy=n-blockDim.y-1+threadIdx.y;
-//
-//		if(threadIdx.y==0)
-//					sharedMem[1][0]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(n-1,n-1))];
-//
-//
-//		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-//		{
-//			if(blockDim.y-threadIdx.y  < k+1 && gy > -1)
-//			{
-//				int k3=k%3;
-//
-//				if(threadIdx.y==blockDim.y-1)
-//					if(gx==n-1)
-//						sharedMem[k3+2][n-1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(n-1,gy-blockDim.y))];
-//					else
-//						sharedMem[k3+2][n-1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx+1,gy))];
-//				else
-//					solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy-1))]=sharedMem[k3][threadIdx.y-1];
-//
-//				if(gy<n-1)
-//					sharedMem[k3+2][threadIdx.y+1]=solver->cudaDofVector[solver->Mesh.getCellIndex(Containers::StaticVector<2,int>(gx,gy+1))];
-//
-//
-//				solver->updateValue(gx,gy,sharedMem,k3);
-//				gx--;
-//				if(gx==-1)
-//				{
-//					gx=n-1;
-//					gy-=blockDim.y;
-//				}
-//			}
-//
-//
-//			__syncthreads();
-//		}
-//	}
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy)
-	{
-		solver->initGrid();
-	}
-
-
-}
-#endif
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_impl.h
deleted file mode 100644
index c4ce8fe6b2ee80131c0bc2a945bc8cef4377f106..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_impl.h
+++ /dev/null
@@ -1,927 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: tnlFastSweeping()
-:Entity(Mesh),
- dofVector(Mesh),
- dofVector2(Mesh)
-{
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-	dofVector2.load(initialCondition);
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0 >();
-	Entity.refresh();
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-	cout << "a" <<std::endl;
-	return initGrid();
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-	for(int i=0; i< Mesh.getDimensions().x()*Mesh.getDimensions().x();i++)
-	{
-		dofVector2[i]=INT_MAX*sign(dofVector[i]);
-	}
-
-	for(int i = 0 ; i < Mesh.getDimensions().x()-1; i++)
-	{
-		for(int j = 0 ; j < Mesh.getDimensions().x()-1; j++)
-			{
-			this->Entity.setCoordinates(CoordinatesType(i,j));
-			this->Entity.refresh();
-			neighborEntities.refresh(Mesh,Entity.getIndex());
-
-				if(dofVector[this->Entity.getIndex()] > 0)
-				{
-					if(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1111(i,j);
-							else
-								setupSquare1110(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1101(i,j);
-							else
-								setupSquare1100(i,j);
-						}
-					}
-					else
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1011(i,j);
-							else
-								setupSquare1010(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare1001(i,j);
-							else
-								setupSquare1000(i,j);
-						}
-					}
-				}
-				else
-				{
-					if(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()] > 0)
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0111(i,j);
-							else
-								setupSquare0110(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0101(i,j);
-							else
-								setupSquare0100(i,j);
-						}
-					}
-					else
-					{
-						if(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()] > 0)
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0011(i,j);
-							else
-								setupSquare0010(i,j);
-						}
-						else
-						{
-							if(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()] > 0)
-								setupSquare0001(i,j);
-							else
-								setupSquare0000(i,j);
-						}
-					}
-				}
-
-			}
-	}
-	cout << "a" <<std::endl;
-
-//	Real tmp = 0.0;
-//	Real ax=0.5/sqrt(2.0);
-//
-//	if(!exactInput)
-//	{
-//		for(Index i = 0; i < Mesh.getDimensions().x()*Mesh.getDimensions().y(); i++)
-//				dofVector[i]=0.5*h*sign(dofVector[i]);
-//	}
-//
-//
-//	for(Index i = 1; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		for(Index j = 1; j < Mesh.getDimensions().y()-1; j++)
-//		{
-//			 tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//			if(tmp == 0.0)
-//			{}
-//			else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//					dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//					dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-//					dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//			{}
-//			else
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//		}
-//	}
-//
-//
-//
-//	for(int i = 1; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		Index j = 0;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//	for(int i = 1; i < Mesh.getDimensions().x()-1; i++)
-//	{
-//		Index j = Mesh.getDimensions().y() - 1;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//	for(int j = 1; j < Mesh.getDimensions().y()-1; j++)
-//	{
-//		Index i = 0;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//	for(int j = 1; j < Mesh.getDimensions().y()-1; j++)
-//	{
-//		Index i = Mesh.getDimensions().x() - 1;
-//		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//
-//
-//		if(tmp == 0.0)
-//		{}
-//		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-//				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-//		{}
-//		else
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//	}
-//
-//
-//	Index i = Mesh.getDimensions().x() - 1;
-//	Index j = Mesh.getDimensions().y() - 1;
-//
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//
-//
-//
-//	j = 0;
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//
-//
-//
-//	i = 0;
-//	j = Mesh.getDimensions().y() -1;
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-//
-//
-//
-//	j = 0;
-//	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-//	if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp > 0.0 &&
-//			dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp > 0.0)
-//
-//		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-
-	//data.setLike(dofVector2.getData());
-	//data=dofVector2.getData();
-	//cout << data.getType() <<std::endl;
-	dofVector2.save("u-00000.tnl");
-	//dofVector2.getData().save("u-00000.tnl");
-
-	return true;
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-	{
-		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			updateValue(i,j);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-//	data.setLike(dofVector2.getData());
-//	data = dofVector2.getData();
-//	cout << data.getType() <<std::endl;
-	dofVector2.save("u-00001.tnl");
-	//dofVector2.getData().save("u-00001.tnl");
-
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j)
-{
-
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-	Real value = dofVector2[Entity.getIndex()];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = dofVector2[neighborEntities.template getEntityIndex< -1,  0 >()];
-	else
-	{
-		a = fabsMin( dofVector2[neighborEntities.template getEntityIndex< -1,  0 >()],
-				 dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()] );
-	}
-
-	if( j == 0 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()];
-	else
-	{
-		b = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  -1 >()],
-				 dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()] );
-	}
-
-
-	if(fabs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-
-	dofVector2[Entity.getIndex()] = fabsMin(value, tmp);
-
-//	if(dofVector2[Entity.getIndex()] > 1.0)
-//		cout << value << "    " << tmp << " " << dofVector2[Entity.getIndex()] <<std::endl;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = fabs(x);
-	Real fy = fabs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-{
-//	this->Entity.setCoordinates(CoordinatesType(i,j));
-//	this->Entity.refresh();
-//	auto neighborEntities =  Entity.getNeighborEntities();
-//	dofVector2[Entity.getIndex()]=fabsMin(INT_MAX,dofVector2[Entity.getIndex()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-{
-//	this->Entity.setCoordinates(CoordinatesType(i,j));
-//	this->Entity.refresh();
-//	auto neighborEntities =  Entity.getNeighborEntities();
-//	dofVector2[Entity.getIndex()]=fabsMin(-INT_MAX,dofVector2[(Entity.getIndex())]);
-//	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-//	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-INT_MAX,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[Entity.getIndex()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	a = be/al;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(-abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	dofVector2[Entity.getIndex()]=fabsMin(dofVector[Entity.getIndex()],dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-al;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	Real al,be, a,b,c,s;
-	al=abs(dofVector[Entity.getIndex()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()]-
-			 dofVector[Entity.getIndex()]));
-
-	be=abs(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]/
-			(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()]-
-			 dofVector[neighborEntities.template getEntityIndex< 0,  1 >()]));
-
-	a = al-be;
-	b=1.0;
-	c=-be;
-	s= h/sqrt(a*a+b*b);
-
-
-	dofVector2[Entity.getIndex()]=fabsMin(-abs(a*0+b*0+c)*s,dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(-abs(a*1+b*0+c)*s,dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(abs(a*1+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(abs(a*0+b*1+c)*s,dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j));
-	this->Entity.refresh();
-	auto neighborEntities =  Entity.getNeighborEntities();
-	dofVector2[Entity.getIndex()]=fabsMin(dofVector[Entity.getIndex()],dofVector2[(Entity.getIndex())]);
-	dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 0,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 0,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  1 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  1 >()]);
-	dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]=fabsMin(dofVector[neighborEntities.template getEntityIndex< 1,  0 >()],dofVector2[neighborEntities.template getEntityIndex< 1,  0 >()]);
-}
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_openMP_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_openMP_impl.h
deleted file mode 100644
index 54bbe931e0ae305ac300027d7da850d705b4c309..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping2D_openMP_impl.h
+++ /dev/null
@@ -1,399 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING2D_IMPL_H_
-#define TNLFASTSWEEPING2D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	h = Mesh.getSpaceSteps().x();
-
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-#ifdef HAVE_OPENMP
-//	gridLock = (omp_lock_t*) malloc(sizeof(omp_lock_t)*Mesh.getDimensions().x()*Mesh.getDimensions().y());
-//
-//	for(int i = 0; i < Mesh.getDimensions().x()*Mesh.getDimensions().y(); i++)
-//			omp_init_lock(&gridLock[i]);
-#endif
-
-	return initGrid();
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-
-	Real tmp = 0.0;
-
-	if(!exactInput)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x()*Mesh.getDimensions().y(); i++)
-				dofVector[i]=0.5*h*sign(dofVector[i]);
-	}
-
-
-	for(Index i = 1; i < Mesh.getDimensions().x()-1; i++)
-	{
-		for(Index j = 1; j < Mesh.getDimensions().y()-1; j++)
-		{
-			 tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-			if(tmp == 0.0)
-			{}
-			else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-					dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-					dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-					dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-			{}
-			else
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-		}
-	}
-
-
-
-	for(int i = 1; i < Mesh.getDimensions().x()-1; i++)
-	{
-		Index j = 0;
-		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 )
-		{}
-		else
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-	for(int i = 1; i < Mesh.getDimensions().x()-1; i++)
-	{
-		Index j = Mesh.getDimensions().y() - 1;
-		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-	for(int j = 1; j < Mesh.getDimensions().y()-1; j++)
-	{
-		Index i = 0;
-		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-	for(int j = 1; j < Mesh.getDimensions().y()-1; j++)
-	{
-		Index i = Mesh.getDimensions().x() - 1;
-		tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-
-
-		if(tmp == 0.0)
-		{}
-		else if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp < 0.0 ||
-				dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp < 0.0 )
-		{}
-		else
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-	}
-
-
-	Index i = Mesh.getDimensions().x() - 1;
-	Index j = Mesh.getDimensions().y() - 1;
-
-	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-	if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp > 0.0 &&
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp > 0.0)
-
-		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-
-
-
-	j = 0;
-	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-	if(dofVector[Mesh.getCellIndex(CoordinatesType(i-1,j))]*tmp > 0.0 &&
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp > 0.0)
-
-		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-
-
-
-	i = 0;
-	j = Mesh.getDimensions().y() -1;
-	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-	if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp > 0.0 &&
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j-1))]*tmp > 0.0)
-
-		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-
-
-
-	j = 0;
-	tmp = sign(dofVector[Mesh.getCellIndex(CoordinatesType(i,j))]);
-	if(dofVector[Mesh.getCellIndex(CoordinatesType(i+1,j))]*tmp > 0.0 &&
-			dofVector[Mesh.getCellIndex(CoordinatesType(i,j+1))]*tmp > 0.0)
-
-		dofVector[Mesh.getCellIndex(CoordinatesType(i,j))] = tmp*INT_MAX;
-
-
-	dofVector.save("u-00000.tnl");
-
-	return true;
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	DofVectorType d2,d3,d4;
-	d2.setLike(dofVector);
-	d2=dofVector;
-	d3.setLike(dofVector);
-	d3=dofVector;
-	d4.setLike(dofVector);
-	d4=dofVector;
-
-
-#ifdef HAVE_OPENMP
-#pragma omp parallel sections num_threads(4)
-	{
-	{
-#endif
-
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-		{
-			updateValue(i,j,&dofVector);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-#ifdef HAVE_OPENMP
-	}
-#pragma omp section
-	{
-#endif
-	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-	{
-		for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-		{
-			updateValue(i,j,&d2);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-#ifdef HAVE_OPENMP
-	}
-#pragma omp section
-	{
-#endif
-	for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			updateValue(i,j, &d3);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-#ifdef HAVE_OPENMP
-	}
-#pragma omp section
-	{
-#endif
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			updateValue(i,j, &d4);
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-#ifdef HAVE_OPENMP
-	}
-	}
-#endif
-
-
-#ifdef HAVE_OPENMP
-#pragma omp parallel for num_threads(4) schedule(dynamic)
-#endif
-	for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-	{
-		for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-		{
-			int index = Mesh.getCellIndex(CoordinatesType(i,j));
-			dofVector[index] = fabsMin(dofVector[index], d2[index]);
-			dofVector[index] = fabsMin(dofVector[index], d3[index]);
-			dofVector[index] = fabsMin(dofVector[index], d4[index]);
-		}
-	}
-
-	dofVector.save("u-00001.tnl");
-
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, DofVectorType* grid)
-{
-	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-	Real value = (*grid)[index];
-	Real a,b, tmp;
-
-	if( i == 0 )
-		a = (*grid)[Mesh.template getCellNextToCell<1,0>(index)];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = (*grid)[Mesh.template getCellNextToCell<-1,0>(index)];
-	else
-	{
-		a = fabsMin( (*grid)[Mesh.template getCellNextToCell<-1,0>(index)],
-				 (*grid)[Mesh.template getCellNextToCell<1,0>(index)] );
-	}
-
-	if( j == 0 )
-		b = (*grid)[Mesh.template getCellNextToCell<0,1>(index)];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = (*grid)[Mesh.template getCellNextToCell<0,-1>(index)];
-	else
-	{
-		b = fabsMin( (*grid)[Mesh.template getCellNextToCell<0,-1>(index)],
-				 (*grid)[Mesh.template getCellNextToCell<0,1>(index)] );
-	}
-
-
-	if(fabs(a-b) >= h)
-		tmp = fabsMin(a,b) + sign(value)*h;
-	else
-		tmp = 0.5 * (a + b + sign(value)*sqrt(2.0 * h * h - (a - b) * (a - b) ) );
-
-#ifdef HAVE_OPENMP
-//	omp_set_lock(&gridLock[index]);
-#endif
-	(*grid)[index]  = fabsMin(value, tmp);
-#ifdef HAVE_OPENMP
-//	omp_unset_lock(&gridLock[index]);
-#endif
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-Real tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = fabs(x);
-	Real fy = fabs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping3D_CUDA_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping3D_CUDA_impl.h
deleted file mode 100644
index 6a5195cfe4edda5754b8826158d6d9faa5701fa0..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping3D_CUDA_impl.h
+++ /dev/null
@@ -1,961 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_CUDA_v4_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING3D_IMPL_H_
-#define TNLFASTSWEEPING3D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-//__device__
-//double fabsMin( double x, double y)
-//{
-//	double fx = abs(x);
-//
-//	if(Min(fx,abs(y)) == fx)
-//		return x;
-//	else
-//		return y;
-//}
-//
-//__device__
-//double atomicFabsMin(double* address, double val)
-//{
-//	unsigned long long int* address_as_ull =
-//						  (unsigned long long int*)address;
-//	unsigned long long int old = *address_as_ull, assumed;
-//	do {
-//		assumed = old;
-//			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(assumed,val) ));
-//	} while (assumed != old);
-//	return __longlong_as_double(old);
-//}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-	this->h = Mesh.template getSpaceStepsProducts< 1, 0, 0 >();
-	counter = 0;
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-
-
-#ifdef HAVE_CUDA
-
-	cudaMalloc(&(cudaDofVector), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-	cudaMalloc(&(cudaDofVector2), this->dofVector.getData().getSize()*sizeof(double));
-	cudaMemcpy(cudaDofVector2, this->dofVector.getData().getData(), this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyHostToDevice);
-
-
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >));
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >), cudaMemcpyHostToDevice);
-
-#endif
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(8, 8,8);
-	dim3 numBlocks(n/8 + 1, n/8 +1, n/8 +1);
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	initCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	return true;
-}
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	int n = Mesh.getDimensions().x();
-	dim3 threadsPerBlock(1, 1024);
-	dim3 numBlocks(8,1);
-
-
-	runCUDA<<<numBlocks,threadsPerBlock>>>(this->cudaSolver,0,0);
-
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-
-	cudaMemcpy(this->dofVector.getData().getData(), cudaDofVector2, this->dofVector.getData().getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-	cudaDeviceSynchronize();
-	cudaFree(cudaDofVector);
-	cudaFree(cudaDofVector2);
-	cudaFree(cudaSolver);
-	dofVector.save("u-00001.tnl");
-	cudaDeviceSynchronize();
-	return true;
-}
-
-
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, Index k)
-{
-	tnlGridEntity< tnlGrid< 3,double, TNL::Devices::Host, int >, 3, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j,k));
-	Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage >,3> neighborEntities(Entity);
-	Real value = cudaDofVector2[Entity.getIndex()];
-	Real a,b,c, tmp;
-
-	if( i == 0 )
-		a = cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0,  0 >()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0,  0 >()];
-	else
-	{
-		a = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< -1,  0,  0 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 1,  0,  0 >()] );
-	}
-
-	if( j == 0 )
-		b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1,  0 >()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0 >()];
-	else
-	{
-		b = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  1,  0 >()] );
-	}
-
-	if( k == 0 )
-		c = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  1 >()];
-	else if( k == Mesh.getDimensions().z() - 1 )
-		c = cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1 >()];
-	else
-	{
-		c = fabsMin( cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1 >()],
-				 cudaDofVector2[neighborEntities.template getEntityIndex< 0,  0,  1 >()] );
-	}
-
-	Real hD = 3.0*h*h - 2.0*(a*a + b*b + c*c - a*b - a*c - b*c);
-
-	if(hD < 0.0)
-		tmp = fabsMin(a,fabsMin(b,c)) + sign(value)*h;
-	else
-		tmp = (1.0/3.0) * ( a + b + c + sign(value)*sqrt(hD) );
-
-	atomicFabsMin(&cudaDofVector2[Entity.getIndex()],tmp);
-
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-bool tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid(int i, int j, int k)
-{
-	tnlGridEntity< tnlGrid< 3,double, TNL::Devices::Host, int >, 3, tnlGridEntityNoStencilStorage > Entity(Mesh);
-	Entity.setCoordinates(CoordinatesType(i,j,k));
-	Entity.refresh();
-	int gid = Entity.getIndex();
-
-	if(abs(cudaDofVector[gid]) < 1.0*h)
-		cudaDofVector2[gid] = 0.5*h;//cudaDofVector[gid];
-	else
-		cudaDofVector2[gid] = INT_MAX*sign(cudaDofVector[gid]);
-
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-__device__
-Real tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = abs(x);
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-
-
-}
-
-
-
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i)
-{
-
-	int gx = 0;
-	int gy = threadIdx.y;
-
-	int n = solver->Mesh.getDimensions().x();
-	int blockCount = n/blockDim.y +1;
-
-	if(blockIdx.x==0)
-	{
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx = 0;
-		gy = threadIdx.y;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		__syncthreads();
-		}
-	}
-	else if(blockIdx.x==1)
-	{
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==2)
-	{
-
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==3)
-	{
-		for(int gz = 0; gz < n;gz++)
-		{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-
-
-
-
-	else if(blockIdx.x==4)
-	{
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx = 0;
-		gy = threadIdx.y;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==5)
-	{
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx=n-1;
-		gy=threadIdx.y;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy < n)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy+=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==6)
-	{
-
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx=0;
-		gy=n-threadIdx.y-1;
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx++;
-				if(gx==n)
-				{
-					gx=0;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-	else if(blockIdx.x==7)
-	{
-		for(int gz = n-1; gz > -1;gz--)
-		{
-		gx=n-1;
-		gy=n-threadIdx.y-1;
-
-		for(int k = 0; k < n*blockCount + blockDim.y; k++)
-		{
-			if(threadIdx.y  < k+1 && gy > -1)
-			{
-				solver->updateValue(gx,gy,gz);
-				gx--;
-				if(gx==-1)
-				{
-					gx=n-1;
-					gy-=blockDim.y;
-				}
-			}
-
-
-			__syncthreads();
-		}
-		}
-	}
-
-
-
-
-}
-
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver)
-{
-	int gx = threadIdx.x + blockDim.x*blockIdx.x;
-	int gy = blockDim.y*blockIdx.y + threadIdx.y;
-	int gz = blockDim.z*blockIdx.z + threadIdx.z;
-
-	if(solver->Mesh.getDimensions().x() > gx && solver->Mesh.getDimensions().y() > gy && solver->Mesh.getDimensions().z() > gz)
-	{
-		solver->initGrid(gx,gy,gz);
-	}
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1111( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(INT_MAX,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0000( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(-INT_MAX,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-INT_MAX,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1110( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1101( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1011( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0111( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0001( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0010( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0100( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1000( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	a = be/al;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1100( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-al;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1010( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(-abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare1001( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(cudaDofVector[index],cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//
-//
-//
-//
-//
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0011( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-al;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0101( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	Real al,be, a,b,c,s;
-//	al=abs(cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,0>(index)]));
-//
-//	be=abs(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]/
-//			(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)]-
-//			 cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)]));
-//
-//	a = al-be;
-//	b=1.0;
-//	c=-be;
-//	s= h/sqrt(a*a+b*b);
-//
-//
-//	cudaDofVector2[index]=fabsMin(-abs(a*0+b*0+c)*s,cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(-abs(a*1+b*0+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(abs(a*1+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(abs(a*0+b*1+c)*s,cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//
-//}
-//
-//template< typename MeshReal,
-//          typename Device,
-//          typename MeshIndex,
-//          typename Real,
-//          typename Index >
-//void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: setupSquare0110( Index i, Index j)
-//{
-//	Index index = Mesh.getCellIndex(CoordinatesType(i,j));
-//	cudaDofVector2[index]=fabsMin(cudaDofVector[index],cudaDofVector2[(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<0,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<0,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,1>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,1>(index)]);
-//	cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]=fabsMin(cudaDofVector[Mesh.template getCellNextToCell<1,0>(index)],cudaDofVector2[Mesh.template getCellNextToCell<1,0>(index)]);
-//}
-#endif
-
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping3D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping3D_impl.h
deleted file mode 100644
index e22de0ab85f3814004b072ef0ebdb403b7f970c7..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping3D_impl.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping2D_impl.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING3D_IMPL_H_
-#define TNLFASTSWEEPING3D_IMPL_H_
-
-#include "tnlFastSweeping.h"
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-String tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: getType()
-{
-	   return String( "tnlFastSweeping< " ) +
-	          MeshType::getType() + ", " +
-	          ::getType< Real >() + ", " +
-	          ::getType< Index >() + " >";
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: tnlFastSweeping()
-:Entity(Mesh),
- dofVector(Mesh),
- dofVector2(Mesh)
-{
-}
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: init( const Config::ParameterContainer& parameters )
-{
-	const String& meshFile = parameters.getParameter< String >( "mesh" );
-
-	if( ! Mesh.load( meshFile ) )
-	{
-		  std::cerr << "I am not able to load the mesh from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	if( ! dofVector.load( initialCondition ) )
-	{
-		  std::cerr << "I am not able to load the initial condition from the file " << meshFile << "." <<std::endl;
-		   return false;
-	}
-	dofVector2.load(initialCondition);
-
-	h = Mesh.template getSpaceStepsProducts< 1, 0, 0 >();
-	Entity.refresh();
-
-	const String& exact_input = parameters.getParameter< String >( "exact-input" );
-
-	if(exact_input == "no")
-		exactInput=false;
-	else
-		exactInput=true;
-//	cout << "bla "<<endl;
-	return initGrid();
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: initGrid()
-{
-	for(int i=0; i< Mesh.getDimensions().x()*Mesh.getDimensions().y()*Mesh.getDimensions().z();i++)
-	{
-
-		if (abs(dofVector[i]) < 1.8*h)
-			dofVector2[i]=dofVector[i];
-		else
-			dofVector2[i]=INT_MAX*sign(dofVector[i]);
-	}
-
-	return true;
-}
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-bool tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: run()
-{
-
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-	for(Index k = 0; k < Mesh.getDimensions().z(); k++)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-
-
-
-
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = 0; j < Mesh.getDimensions().y(); j++)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = Mesh.getDimensions().x() - 1; i > -1; i--)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-	for(Index k = Mesh.getDimensions().z() -1; k > -1; k--)
-	{
-		for(Index i = 0; i < Mesh.getDimensions().x(); i++)
-		{
-			for(Index j = Mesh.getDimensions().y() - 1; j > -1; j--)
-			{
-				updateValue(i,j,k);
-			}
-		}
-	}
-
-/*---------------------------------------------------------------------------------------------------------------------------*/
-
-
-	dofVector2.save("u-00001.tnl");
-
-	cout << "bla 3"<<endl;
-	return true;
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-void tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: updateValue( Index i, Index j, Index k)
-{
-	this->Entity.setCoordinates(CoordinatesType(i,j,k));
-	this->Entity.refresh();
-	tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage >,3> neighborEntities(Entity);
-	Real value = dofVector2[Entity.getIndex()];
-	Real a,b,c, tmp;
-
-	if( i == 0 )
-		a = dofVector2[neighborEntities.template getEntityIndex< 1,  0,  0>()];
-	else if( i == Mesh.getDimensions().x() - 1 )
-		a = dofVector2[neighborEntities.template getEntityIndex< -1,  0,  0 >()];
-	else
-	{
-		a = fabsMin( dofVector2[neighborEntities.template getEntityIndex< -1,  0,  0>()],
-				 dofVector2[neighborEntities.template getEntityIndex< 1,  0,  0>()] );
-	}
-
-	if( j == 0 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  1,  0>()];
-	else if( j == Mesh.getDimensions().y() - 1 )
-		b = dofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0>()];
-	else
-	{
-		b = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  -1,  0>()],
-				 dofVector2[neighborEntities.template getEntityIndex< 0,  1,  0>()] );
-	}
-
-	if( k == 0 )
-		c = dofVector2[neighborEntities.template getEntityIndex< 0,  0,  1>()];
-	else if( k == Mesh.getDimensions().z() - 1 )
-		c = dofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1>()];
-	else
-	{
-		c = fabsMin( dofVector2[neighborEntities.template getEntityIndex< 0,  0,  -1>()],
-				 dofVector2[neighborEntities.template getEntityIndex< 0,  0,  1>()] );
-	}
-
-	Real hD = 3.0*h*h - 2.0*(a*a+b*b+c*c-a*b-a*c-b*c);
-
-	if(hD < 0.0)
-		tmp = fabsMin(a,fabsMin(b,c)) + sign(value)*h;
-	else
-		tmp = (1.0/3.0) * ( a + b + c + sign(value)*sqrt(hD) );
-
-
-	dofVector2[Entity.getIndex()]  = fabsMin(value, tmp);
-}
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-Real tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > :: fabsMin( Real x, Real y)
-{
-	Real fx = fabs(x);
-	Real fy = fabs(y);
-
-	Real tmpMin = Min(fx,fy);
-
-	if(tmpMin == fx)
-		return x;
-	else
-		return y;
-
-}
-
-
-
-#endif /* TNLFASTSWEEPING_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweepingSolver.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweepingSolver.h
deleted file mode 100644
index fc9eb545987dfa14bb17b28f4d104d4c6e6fa2e7..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweepingSolver.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 
- * File:   tnlFastSweepingSolver.h
- * Author: oberhuber
- *
- * Created on July 12, 2016, 6:04 PM
- */
-
-#pragma once
-
-#include <functions/tnlConstantFunction.h>
-#include <problems/tnlPDEProblem.h>
-
-template< typename Mesh,
-          typename Communicator,
-          typename Anisotropy = tnlConstanstFunction< Mesh > >
-class tnlFastSweepingSolver  : public tnlPDEProblem< Mesh,
-                                                     Communicator,
-                                                     typename Mesh::RealType,
-                                                     typename Mesh::DeviceType,
-                                                     typename Mesh::IndexType  >
-{
-   public:
-
-      typedef typename DifferentialOperator::RealType RealType;
-      typedef typename Mesh::DeviceType DeviceType;
-      typedef typename DifferentialOperator::IndexType IndexType;
-
-      typedef tnlMeshFunction< Mesh > MeshFunctionType;
-      typedef tnlPDEProblem< Mesh, TimeDependentProblem, RealType, DeviceType, IndexType > BaseType;
-
-      using typename BaseType::MeshType;
-      using typename BaseType::DofVectorType;
-      using typename BaseType::MeshDependentDataType;
-};
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping_CUDA.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping_CUDA.h
deleted file mode 100644
index f531da431bfec5d16da8ea7deabe6595031a0873..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/fast-sweeping/tnlFastSweeping_CUDA.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/***************************************************************************
-                          tnlFastSweeping_CUDA.h  -  description
-                             -------------------
-    begin                : Oct 15 , 2015
-    copyright            : (C) 2015 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 TNLFASTSWEEPING_H_
-#define TNLFASTSWEEPING_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-
-#include <functions/tnlMeshFunction.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-#include <ctime>
-
-
-
-
-
-template< typename Mesh,
-		  typename Real,
-		  typename Index >
-class tnlFastSweeping
-{};
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 2, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-	tnlFastSweeping();
-
-	__host__ static String getType();
-	__host__ bool init( const Config::ParameterContainer& parameters );
-	__host__ bool run();
-
-#ifdef HAVE_CUDA
-	__device__ bool initGrid();
-	__device__ void updateValue(const Index i, const Index j);
-	__device__ void updateValue(const Index i, const Index j, double** sharedMem, const int k3);
-	__device__ Real fabsMin(const Real x, const Real y);
-
-	tnlFastSweeping< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >* cudaSolver;
-	double* cudaDofVector;
-	double* cudaDofVector2;
-	int counter;
-	__device__ void setupSquare1000(Index i, Index j);
-	__device__ void setupSquare1100(Index i, Index j);
-	__device__ void setupSquare1010(Index i, Index j);
-	__device__ void setupSquare1001(Index i, Index j);
-	__device__ void setupSquare1110(Index i, Index j);
-	__device__ void setupSquare1101(Index i, Index j);
-	__device__ void setupSquare1011(Index i, Index j);
-	__device__ void setupSquare1111(Index i, Index j);
-	__device__ void setupSquare0000(Index i, Index j);
-	__device__ void setupSquare0100(Index i, Index j);
-	__device__ void setupSquare0010(Index i, Index j);
-	__device__ void setupSquare0001(Index i, Index j);
-	__device__ void setupSquare0110(Index i, Index j);
-	__device__ void setupSquare0101(Index i, Index j);
-	__device__ void setupSquare0011(Index i, Index j);
-	__device__ void setupSquare0111(Index i, Index j);
-#endif
-
-	MeshType Mesh;
-
-protected:
-
-
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector;
-	DofVectorType data;
-
-
-	RealType h;
-
-
-};
-
-
-
-
-
-
-
-
-
-template< typename MeshReal,
-          typename Device,
-          typename MeshIndex,
-          typename Real,
-          typename Index >
-class tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
-{
-
-public:
-	typedef Real RealType;
-	typedef Device DeviceType;
-	typedef Index IndexType;
-	typedef tnlGrid< 3, Real, Device, Index > MeshType;
-	typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
-	typedef typename MeshType::CoordinatesType CoordinatesType;
-
-
-
-	__host__ static String getType();
-	__host__ bool init( const Config::ParameterContainer& parameters );
-	__host__ bool run();
-
-#ifdef HAVE_CUDA
-	__device__ bool initGrid(int i, int j, int k);
-	__device__ void updateValue(const Index i, const Index j, const Index k);
-	__device__ void updateValue(const Index i, const Index j, const Index k, double** sharedMem, const int k3);
-	__device__ Real fabsMin(const Real x, const Real y);
-
-	tnlFastSweeping< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >* cudaSolver;
-	double* cudaDofVector;
-	double* cudaDofVector2;
-	int counter;
-#endif
-
-	MeshType Mesh;
-
-protected:
-
-
-
-	bool exactInput;
-
-	tnlMeshFunction<MeshType> dofVector;
-	DofVectorType data;
-
-	RealType h;
-
-
-};
-
-
-
-
-
-
-
-#ifdef HAVE_CUDA
-//template<int sweep_t>
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i);
-__global__ void runCUDA(tnlFastSweeping< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver, int sweep, int i);
-
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 2,double, TNL::Devices::Host, int >, double, int >* solver);
-__global__ void initCUDA(tnlFastSweeping< tnlGrid< 3,double, TNL::Devices::Host, int >, double, int >* solver);
-#endif
-
-/*various implementtions.... choose one*/
-//#include "tnlFastSweeping2D_CUDA_impl.h"
-//#include "tnlFastSweeping2D_CUDA_v2_impl.h"
-//#include "tnlFastSweeping2D_CUDA_v3_impl.h"
-#include "tnlFastSweeping2D_CUDA_v4_impl.h"
-//#include "tnlFastSweeping2D_CUDA_v5_impl.h"
-
-
-#include "tnlFastSweeping3D_CUDA_impl.h"
-
-#endif /* TNLFASTSWEEPING_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/CMakeLists.txt b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/CMakeLists.txt
deleted file mode 100644
index 48382df82de6e7e175e47d24fc3ce69e13c217b5..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-set( tnl_hamilton_jacobi_parallel_map_SOURCES
-#     MainBuildConfig.h
-#     tnlParallelMapSolver2D_impl.h
-#     tnlParallelMapSolver.h
-#     parallelMapConfig.h 
-#	  main.cu
-     main.cpp)
-
-
-IF(  BUILD_CUDA ) 
-	CUDA_ADD_EXECUTABLE(hamilton-jacobi-parallel-map main.cu)
-ELSE(  BUILD_CUDA )                
-	ADD_EXECUTABLE(hamilton-jacobi-parallel-map main.cpp)
-ENDIF( BUILD_CUDA )
-target_link_libraries (hamilton-jacobi-parallel-map tnl )
-
-
-INSTALL( TARGETS hamilton-jacobi-parallel-map
-         RUNTIME DESTINATION bin
-         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
-        
-#INSTALL( FILES ${tnl_hamilton_jacobi_parallel_map_SOURCES}
-#         DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/hamilton-jacobi-parallel-map )
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/MainBuildConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/MainBuildConfig.h
deleted file mode 100644
index ed3d686eb99379af1589d734eac9b5812cccdedf..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/MainBuildConfig.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
-                          MainBuildConfig.h  -  description
-                             -------------------
-    begin                : Jul 7, 2014
-    copyright            : (C) 2014 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 MAINBUILDCONFIG_H_
-#define MAINBUILDCONFIG_H_
-
-#include <solvers/tnlBuildConfigTags.h>
-
-class MainBuildConfig
-{
-   public:
-
-      static void print() {std::cerr << "MainBuildConfig" <<std::endl; }
-};
-
-/****
- * Turn off support for float and long double.
- */
-template<> struct tnlConfigTagReal< MainBuildConfig, float > { enum { enabled = false }; };
-template<> struct tnlConfigTagReal< MainBuildConfig, long double > { enum { enabled = false }; };
-
-/****
- * Turn off support for short int and long int indexing.
- */
-template<> struct tnlConfigTagIndex< MainBuildConfig, short int >{ enum { enabled = false }; };
-template<> struct tnlConfigTagIndex< MainBuildConfig, long int >{ enum { enabled = false }; };
-
-/****
- * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.
- */
-template< int Dimensions, typename Real, typename Device, typename Index >
-   struct tnlConfigTagMesh< MainBuildConfig, tnlGrid< Dimensions, Real, Device, Index > >
-      { enum { enabled = tnlConfigTagDimensions< MainBuildConfig, Dimensions >::enabled  &&
-                         tnlConfigTagReal< MainBuildConfig, Real >::enabled &&
-                         tnlConfigTagDevice< MainBuildConfig, Device >::enabled &&
-                         tnlConfigTagIndex< MainBuildConfig, Index >::enabled }; };
-
-/****
- * Please, chose your preferred time discretisation  here.
- */
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = false}; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };
-
-/****
- * Only the Runge-Kutta-Merson solver is enabled by default.
- */
-template<> struct tnlConfigTagExplicitSolver< MainBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };
-
-#endif /* MAINBUILDCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/gnuplot.txt b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/gnuplot.txt
deleted file mode 100644
index d4ae61983910a676269a23e3d992f5f46ea83a8f..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/gnuplot.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-tomas@tomas-linux:~/Desktop/VU_CPU_MAPA/work_dir$ gnuplot
-
-	G N U P L O T
-	Version 4.6 patchlevel 4    last modified 2013-10-02 
-	Build System: Linux x86_64
-
-	Copyright (C) 1986-1993, 1998, 2004, 2007-2013
-	Thomas Williams, Colin Kelley and many others
-
-	gnuplot home:     http://www.gnuplot.info
-	faq, bugs, etc:   type "help FAQ"
-	immediate help:   type "help"  (plot window: hit 'h')
-
-Terminal type set to 'wxt'
-gnuplot> set cntrparam levels 15
-gnuplot> set cntrparam bspline
-gnuplot> set contour
-gnuplot> splot 'u-00001.gplt'
-
-gnuplot> unset surface
-gnuplot> splot 'u-00001.gplt'
-
-gnuplot> set table "test.gplt"
-gnuplot> splot 'u-00001.gplt'
-gnuplot> unset table
-
-gnuplot> set table "test2.gplt"
-gnuplot> plot 'test.gplt' index 10
-gnuplot> unset table
-
-gnuplot> plot 'test2.gplt' 
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.cpp b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.cpp
deleted file mode 100644
index b13498e17330fae7bb00a0bdc2abcc7a19f8e7a8..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Jul 8 , 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.cu b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.cu
deleted file mode 100644
index 7101976712e153d73c5f0979b211164a36ec648d..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cu  -  description
-                             -------------------
-    begin                : Mar 30 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.h
deleted file mode 100644
index fff21c77eb5980a3f3f86c28170b4169dd6f7917..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/main.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/***************************************************************************
-                          main.h  -  description
-                             -------------------
-    begin                : Mar 22 , 2016
-    copyright            : (C) 2016 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "tnlParallelMapSolver.h"
-#include "parallelMapConfig.h"
-#include "MainBuildConfig.h"
-#include <solvers/tnlBuildConfigTags.h>
-#include <operators/hamilton-jacobi/godunov-eikonal/parallelGodunovMap.h>
-#include <mesh/tnlGrid.h>
-#include <core/tnlDevice.h>
-#include <time.h>
-#include <ctime>
-
-typedef MainBuildConfig BuildConfig;
-
-int main( int argc, char* argv[] )
-{
-	time_t start;
-	time_t stop;
-	time(&start);
-	std::clock_t start2= std::clock();
-	Config::ParameterContainer parameters;
-	tnlConfigDescription configDescription;
-	parallelMapConfig< BuildConfig >::configSetup( configDescription );
-
-	if( ! parseCommandLine( argc, argv, configDescription, parameters ) )
-	  return false;
-
-
-	tnlDeviceEnum device;
-	device = TNL::Devices::HostDevice;
-
-	const int& dim = parameters.getParameter< int >( "dim" );
-
-	if(dim == 2)
-	{
-
-	   typedef parallelGodunovMapScheme< tnlGrid<2,double,TNL::Devices::Host, int>, double, int > SchemeTypeHost;
-/*#ifdef HAVE_CUDA
-		   typedef parallelGodunovMapScheme< tnlGrid<2,double,tnlCuda, int>, double, int > SchemeTypeDevice;
-#endif
-#ifndef HAVE_CUDA*/
-	   typedef parallelGodunovMapScheme< tnlGrid<2,double,TNL::Devices::Host, int>, double, int > SchemeTypeDevice;
-/*#endif*/
-
-	   if(device==TNL::Devices::HostDevice)
-	   {
-		   typedef TNL::Devices::Host Device;
-
-
-		   tnlParallelMapSolver<2,SchemeTypeHost,SchemeTypeDevice, Device> solver;
-		   if(!solver.init(parameters))
-		   {
-			  std::cerr << "Solver failed to initialize." <<std::endl;
-			   return EXIT_FAILURE;
-		   }
-		  std::cout << "-------------------------------------------------------------" <<std::endl;
-		  std::cout << "Starting solver loop..." <<std::endl;
-		   solver.run();
-	   }
-	   else if(device==tnlCudaDevice )
-	   {
-		   typedef tnlCuda Device;
-//typedef parallelGodunovMapScheme< tnlGrid<2,double,Device, int>, double, int > SchemeType;
-
-		   tnlParallelMapSolver<2,SchemeTypeHost,SchemeTypeDevice, Device> solver;
-		   if(!solver.init(parameters))
-		   {
-			  std::cerr << "Solver failed to initialize." <<std::endl;
-			   return EXIT_FAILURE;
-		   }
-		  std::cout << "-------------------------------------------------------------" <<std::endl;
-		  std::cout << "Starting solver loop..." <<std::endl;
-		   solver.run();
-	   }
-	}
-
-
-	time(&stop);
-	cout <<std::endl;
-	cout << "Running time was: " << difftime(stop,start) << " .... " << (std::clock() - start2) / (double)(CLOCKS_PER_SEC) <<std::endl;
-	return EXIT_SUCCESS;
-}
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/mapa_png.png b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/mapa_png.png
deleted file mode 100644
index 668b6fe24b17b2fec486db28505b41e3beb2091a..0000000000000000000000000000000000000000
Binary files a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/mapa_png.png and /dev/null differ
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/no-Makefile b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/no-Makefile
deleted file mode 100644
index bfdc1ef236ca02ecfe6bc88f81d872e9524ec621..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/no-Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-TNL_VERSION=0.1
-TNL_INSTALL_DIR=${HOME}/local/lib
-TNL_INCLUDE_DIR=${HOME}/local/include/tnl-${TNL_VERSION}
-
-TARGET = hamiltonJacobiParallelSolver
-#CONFIG_FILE = $(TARGET).cfg.desc
-INSTALL_DIR = ${HOME}/local
-CXX = g++
-CUDA_CXX = nvcc
-OMP_FLAGS = -DHAVE_OPENMP -fopenmp
-CXX_FLAGS = -std=gnu++0x -I$(TNL_INCLUDE_DIR) -O3 $(OMP_FLAGS) -DDEBUG
-LD_FLAGS = -L$(TNL_INSTALL_DIR) -ltnl-0.1 -lgomp
-
-SOURCES = main.cpp
-HEADERS = 
-OBJECTS = main.o
-DIST = $(SOURCES) Makefile
-
-all: $(TARGET)
-clean: 
-	rm -f $(OBJECTS)
-	rm -f $(TARGET)-conf.h	
-
-dist: $(DIST)
-	tar zcvf $(TARGET).tgz $(DIST) 
-
-install: $(TARGET)
-	cp $(TARGET) $(INSTALL_DIR)/bin
-	cp $(CONFIG_FILE) $(INSTALL_DIR)/share
-
-uninstall: $(TARGET)
-	rm -f $(INSTALL_DIR)/bin/$(TARGET) 
-	rm -f $(CONFIG_FILE) $(INSTALL_DIR)/share
-
-$(TARGET): $(OBJECTS)
-	$(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)
-
-%.o: %.cpp $(HEADERS)
-	$(CXX) -c -o $@ $(CXX_FLAGS) $<
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/parallelMapConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/parallelMapConfig.h
deleted file mode 100644
index c07ee95aa04bb8c7a1f3cc376aabd859ff7bc5be..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/parallelMapConfig.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
-                          parallelMapConfig.h  -  description
-                             -------------------
-    begin                : Mar 22 , 2016
-    copyright            : (C) 2016 by Tomas Sobotik
-    email                :
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 HAMILTONJACOBIPARALLELMAPPROBLEMCONFIG_H_
-#define HAMILTONJACOBIPARALLELMAPPROBLEMCONFIG_H_
-
-#include <config/tnlConfigDescription.h>
-
-template< typename ConfigTag >
-class parallelMapConfig
-{
-   public:
-      static void configSetup( tnlConfigDescription& config )
-      {
-         config.addDelimiter( "Parallel Eikonal solver settings:" );
-         config.addEntry        < String > ( "problem-name", "This defines particular problem.", "hamilton-jacobi-parallel" );
-         config.addEntry       < String > ( "scheme", "This defines scheme used for discretization.", "godunov" );
-         config.addEntryEnum( "godunov" );
-         config.addEntryEnum( "upwind" );
-         config.addRequiredEntry        < String > ( "initial-condition", "Initial condition for solver");
-         config.addRequiredEntry        < String > ( "map", "Gradient map for solver");
-         config.addEntry       < String > ( "mesh", "Name of mesh.", "mesh.tnl" );
-         config.addEntry        < double > ( "epsilon", "This defines epsilon for smoothening of sign().", 0.0 );
-         config.addEntry        < double > ( "delta", " Allowed difference on subgrid boundaries", 0.0 );
-         config.addRequiredEntry        < double > ( "stop-time", " Final time for solver");
-         config.addRequiredEntry        < double > ( "initial-tau", " initial tau for solver" );
-         config.addEntry        < double > ( "cfl-condition", " CFL condition", 0.0 );
-         config.addEntry        < int > ( "subgrid-size", "Subgrid size.", 16 );
-         config.addRequiredEntry        < int > ( "dim", "Dimension of problem.");
-      }
-};
-
-#endif /* HAMILTONJACOBIPARALLELMAPPROBLEMCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/run b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/run
deleted file mode 100755
index 48441996274633f8d391d9b32978b05b2e4fa263..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/run
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-
-dimensions=2
-
-size=2
-
-time=50
-
-rm -r work_dir
-mkdir work_dir
-cp mapa_png.png work_dir/mapa_png.png
-cd  work_dir
-
-tnl-image-converter 		--image-format png\
-		    		--input-images mapa_png.png
-
-
-tnl-init 			--test-function sdf-para \
-	     			--x-centre 0.5 \
-	    			--y-centre 1.0 \
- 	   			--offset 0.05 \
-           			--output-file init.tnl \
-	     			--final-time 0.0 \
-	     			--snapshot-period 0.1
-
-hamilton-jacobi-parallel-map-dbg 	--initial-condition init.tnl \
-				--map mapa_png.tnl \
-              			--cfl-condition 50 \
-	      	  		--mesh mesh.tnl \
-	     	  		--initial-tau 1.0e-3 \
-	      	  		--epsilon 4.0 \
-        	  		--delta 0.0 \
-       	      			--stop-time $time \
-	          		--scheme godunov \
-	          		--subgrid-size 8 \
-		  		--dim $dimensions
-
-	
-#cp ../template.dat1 template.dat1
-#cp ../template.dat2 template.dat2
-#cp ../gplt2eps.py gplt2eps.py
-cd ..
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnl-err2eoc-2.py b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnl-err2eoc-2.py
deleted file mode 100755
index f8cde3768e9b76156507e133f8bc3ecaa526fc71..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnl-err2eoc-2.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env python
-
-import sys, string, math
-
-arguments = sys. argv[1:]
-format = "txt"
-output_file_name = "eoc-table.txt"
-input_files = []
-verbose = 1
-size = 1.0
-
-i = 0
-while i < len( arguments ):
-   if arguments[ i ] == "--format":
-      format = arguments[ i + 1 ]
-      i = i + 2
-      continue
-   if arguments[ i ] == "--output-file":
-      output_file_name = arguments[ i + 1 ]
-      i = i + 2
-      continue
-   if arguments[ i ] == "--verbose":
-       verbose = float( arguments[ i + 1 ] )
-       i = i +2
-       continue
-   if arguments[ i ] == "--size":
-       size = float( arguments[ i + 1 ] )
-       i = i +2
-       continue
-   input_files. append( arguments[ i ] )
-   i = i + 1
-
-if not verbose == 0:
-   print "Writing to " + output_file_name + " in " + format + "."
-
-h_list = []
-l1_norm_list = []
-l2_norm_list = []
-max_norm_list = []
-items = 0
-
-for file_name in input_files:
-   if not verbose == 0:
-       print "Processing file " + file_name
-   file = open( file_name, "r" )
-   
-   l1_max = 0.0
-   l_max_max = 0.0
-   file.readline();
-   file.readline();
-   for line in file. readlines():
-         data = string. split( line )
-         h_list. append( size/(float(file_name[0:len(file_name)-5] ) - 1.0) )
-         l1_norm_list. append( float( data[ 1 ] ) )
-         l2_norm_list. append( float( data[ 2 ] ) )
-         max_norm_list. append( float( data[ 3 ] ) )
-         items = items + 1
-         if not verbose == 0:
-            print line
-   file. close()
-
-h_width = 12
-err_width = 15
-file = open( output_file_name, "w" )
-if format == "latex":
-      file. write( "\\begin{tabular}{|r|l|l|l|l|l|l|}\\hline\n" )
-      file. write( "\\raisebox{-1ex}[0ex]{$h$}& \n" )
-      file. write( "\\multicolumn{2}{|c|}{\\raisebox{1ex}[3.5ex]{$\\left\| \\cdot \\right\\|_{L_1\\left(\\omega_h;\\left[0,T\\right]\\right)}^{h,\\tau}$}}& \n" )
-      file. write( "\\multicolumn{2}{|c|}{\\raisebox{1ex}[3.5ex]{$\\left\| \\cdot \\right\\|_{L_2\\left(\\omega_h;\left[0,T\\right]\\right)}^{h,\\tau}$}}& \n" )
-      file. write( "\\multicolumn{2}{|c|}{\\raisebox{1ex}[3.5ex]{$\\left\| \\cdot \\right\\|_{L_\\infty\\left(\\omega_h;\\left[0,T\\right]\\right)}^{h,\\tau}$}}\\\\ \\cline{2-7} \n" )
-      file. write( " " + string. rjust( " ", h_width ) + "&" +
-                string. rjust( "Error", err_width ) + "&" +
-                string. rjust( "{\\bf EOC}", err_width ) + "&" +
-                string. rjust( "Error", err_width ) + "&" +
-                string. rjust( "{\\bf EOC}", err_width ) + "&" +
-                string. rjust( "Error.", err_width ) + "&" +
-                string. rjust( "{\\bf EOC}", err_width ) +
-                "\\\\ \\hline \\hline \n")
-if format == "txt":
-    file. write( "+--------------+----------------+----------------+----------------+----------------+----------------+----------------+\n" )
-    file. write( "|       h      |     L1 Err.    |     L1 EOC.    |     L2 Err.    |      L2 EOC    |    MAX Err.    |     MAX EOC    |\n" )
-    file. write( "+==============+================+================+================+================+================+================+\n" )
-                  
-
-i = 0
-while i < items:
-   if i == 0:
-      if format == "latex":
-         file. write( " " + string. ljust( str( h_list[ i ] ), h_width ) + "&" +
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + "&" + 
-                      string. rjust( " ", err_width ) + "&"+ 
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( " ", err_width ) + "&" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( " ", err_width ) + "\\\\\n" )
-      if format == "txt":
-         file. write( "| " + string. ljust( str( h_list[ i ] ), h_width ) + " |" + 
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( " ", err_width ) + " |" +
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( " ", err_width ) + " |" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( " ", err_width ) + " |\n" )
-         file. write( "+--------------+----------------+----------------+----------------+----------------+----------------+----------------+\n" )
-      i = i + 1;
-      continue
-   if h_list[ i ] == h_list[ i - 1 ]:
-      print "Unable to count eoc since h[ " + \
-      str( i ) + " ] = h[ " + str( i - 1 ) + \
-      " ] = " + str( h_list[ i ] ) + ". \n"
-      file. write( " eoc error:  h[ " + \
-      str( i ) + " ] = h[ " + str( i - 1 ) + \
-      " ] = " + str( h_list[ i ] ) + ". \n" )
-   else:
-      h_ratio = math. log( h_list[ i ] / h_list[ i - 1 ] )
-      l1_ratio = math. log( l1_norm_list[ i ] / l1_norm_list[ i - 1 ] )
-      l2_ratio = math. log( l2_norm_list[ i ] / l2_norm_list[ i - 1 ] )
-      max_ratio = math. log( max_norm_list[ i ] / max_norm_list[ i - 1 ] )
-      if format == "latex":
-         file. write( " " + string. ljust( str( h_list[ i ] ), h_width ) + "&" +
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( "{\\bf " + "%.2g" % ( l1_ratio / h_ratio ) + "}", err_width ) + "&" +
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( "{\\bf " + "%.2g" % ( l2_ratio / h_ratio ) + "}", err_width ) + "&" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( "{\\bf " + "%.2g" % ( max_ratio / h_ratio ) + "}", err_width ) + "\\\\\n" )
-      if format == "txt":
-         file. write( "| " + string. ljust( str( h_list[ i ] ), h_width ) + " |" +
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( "**" + "%.2g" % ( l1_ratio / h_ratio ) + "**", err_width ) + " |" +
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( "**" + "%.2g" % ( l2_ratio / h_ratio ) + "**", err_width ) + " |" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( "**" + "%.2g" % ( max_ratio / h_ratio ) + "**", err_width ) + " |\n" )
-         file. write( "+--------------+----------------+----------------+----------------+----------------+----------------+----------------+\n" )
-   i = i + 1
-
-if format == "latex":
-   file. write( "\\hline \n" )
-   file. write( "\\end{tabular} \n" )
-    
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnlParallelMapSolver.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnlParallelMapSolver.h
deleted file mode 100644
index 400e163c9dcc8d536a478a0952aabf8ccbb1a2d8..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnlParallelMapSolver.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/***************************************************************************
-                          tnlParallelMapSolver.h  -  description
-                             -------------------
-    begin                : Mar 22 , 2016
-    copyright            : (C) 2016 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 TNLPARALLELMAPSOLVER_H_
-#define TNLPARALLELMAPSOLVER_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <functions/tnlMeshFunction.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
-
-
-#include <ctime>
-
-#ifdef HAVE_CUDA
-#include <core/tnlCuda.h>
-#endif
-
-
-template< int Dimension,
-		  typename SchemeHost,
-		  typename SchemeDevice,
-		  typename Device,
-		  typename RealType = double,
-          typename IndexType = int >
-class tnlParallelMapSolver
-{};
-
-template<typename SchemeHost, typename SchemeDevice, typename Device>
-class tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >
-{
-public:
-
-	typedef SchemeDevice SchemeTypeDevice;
-	typedef SchemeHost SchemeTypeHost;
-	typedef Device DeviceType;
-	typedef TNL::Containers::Vector< double, TNL::Devices::Host, int > VectorType;
-	typedef TNL::Containers::Vector< int, TNL::Devices::Host, int > IntVectorType;
-	typedef tnlGrid< 2, double, TNL::Devices::Host, int > MeshType;
-#ifdef HAVE_CUDA
-	typedef TNL::Containers::Vector< double, TNL::Devices::Host, int > VectorTypeCUDA;
-	typedef TNL::Containers::Vector< int, TNL::Devices::Host, int > IntVectorTypeCUDA;
-	typedef tnlGrid< 2, double, TNL::Devices::Host, int > MeshTypeCUDA;
-#endif
-	tnlParallelMapSolver();
-	bool init( const Config::ParameterContainer& parameters );
-	void run();
-
-	void test();
-
-/*private:*/
-
-
-	void synchronize();
-
-	int getOwner( int i) const;
-
-	int getSubgridValue( int i ) const;
-
-	void setSubgridValue( int i, int value );
-
-	int getBoundaryCondition( int i ) const;
-
-	void setBoundaryCondition( int i, int value );
-
-	void stretchGrid();
-
-	void contractGrid();
-
-	VectorType getSubgrid( const int i ) const;
-
-	void insertSubgrid( VectorType u, const int i );
-
-	VectorType runSubgrid( int boundaryCondition, VectorType u, int subGridID,VectorType map);
-
-
-	tnlMeshFunction<MeshType> u0;
-	VectorType work_u, map_stretched, map;
-	IntVectorType subgridValues, boundaryConditions, unusedCell, calculationsCount;
-	MeshType mesh, subMesh;
-
-//	tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage > Entity;
-
-	SchemeHost schemeHost;
-	SchemeDevice schemeDevice;
-	double delta, tau0, stopTime,cflCondition;
-	int gridRows, gridCols, gridLevels, currentStep, n;
-
-	std::clock_t start;
-	double time_diff;
-
-
-	tnlDeviceEnum device;
-
-	tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* getSelf()
-	{
-		return this;
-	};
-
-#ifdef HAVE_CUDA
-
-	tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver;
-
-	double* work_u_cuda;
-	double* map_stretched_cuda;
-
-	int* subgridValues_cuda;
-	int* boundaryConditions_cuda;
-	int* unusedCell_cuda;
-	int* calculationsCount_cuda;
-	double* tmpw;
-	double* tmp_map;
-
-
-	int* runcuda;
-	int run_host;
-
-
-	__device__ void getSubgridCUDA2D( const int i, tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller, double* a);
-
-	__device__ void updateSubgridCUDA2D( const int i, tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller, double* a);
-
-	__device__ void insertSubgridCUDA2D( double u, const int i );
-
-	__device__ void runSubgridCUDA2D( int boundaryCondition, double* u, int subGridID);
-
-	__device__ int getOwnerCUDA2D( int i) const;
-
-	__device__ int getSubgridValueCUDA2D( int i ) const;
-
-	__device__ void setSubgridValueCUDA2D( int i, int value );
-
-	__device__ int getBoundaryConditionCUDA2D( int i ) const;
-
-	__device__ void setBoundaryConditionCUDA2D( int i, int value );
-
-#endif
-
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#ifdef HAVE_CUDA
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void runCUDA2D(tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void initRunCUDA2D(tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void initCUDA2D( tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr, int * ptr2, int* ptr3, double* tmp_map_ptr);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void synchronizeCUDA2D(tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void synchronize2CUDA2D(tnlParallelMapSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-
-
-__device__
-double fabsMin( double x, double y)
-{
-	double fx = abs(x);
-
-	if(Min(fx,abs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__device__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(__longlong_as_double(assumed),val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-#endif
-
-#include "tnlParallelMapSolver2D_impl.h"
-#endif /* TNLPARALLELMAPSOLVER_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnlParallelMapSolver2D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnlParallelMapSolver2D_impl.h
deleted file mode 100644
index e8cbc6fc1619c8a936a0239a5b4e0056361412e3..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel-map/tnlParallelMapSolver2D_impl.h
+++ /dev/null
@@ -1,1315 +0,0 @@
-/***************************************************************************
-                          tnlParallelMapSolver2D_impl.h  -  description
-                             -------------------
-    begin                : Mar 22 , 2016
-    copyright            : (C) 2016 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 TNLPARALLELMAPSOLVER2D_IMPL_H_
-#define TNLPARALLELMAPSOLVER2D_IMPL_H_
-
-
-#include "tnlParallelMapSolver.h"
-#include <core/mfilename.h>
-
-
-
-
-#define MAP_SOLVER_MAX_VALUE 3
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::tnlParallelMapSolver()
-{
-	this->device = TNL::Devices::HostDevice;  /////////////// tnlCuda Device --- vypocet na GPU, TNL::Devices::HostDevice   ---    vypocet na CPU
-
-#ifdef HAVE_CUDA
-	if(this->device == tnlCudaDevice)
-	{
-	run_host = 1;
-	}
-#endif
-
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::test()
-{
-/*
-	for(int i =0; i < this->subgridValues.getSize(); i++ )
-	{
-		insertSubgrid(getSubgrid(i), i);
-	}
-*/
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-
-bool tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::init( const Config::ParameterContainer& parameters )
-{
-	cout << "Initializating solver..." <<std::endl;
-	const String& meshLocation = parameters.getParameter <String>("mesh");
-	this->mesh.load( meshLocation );
-
-	this->n = parameters.getParameter <int>("subgrid-size");
-	cout << "Setting N to " << this->n <<std::endl;
-
-	this->subMesh.setDimensions( this->n, this->n );
-	this->subMesh.setDomain( Containers::StaticVector<2,double>(0.0, 0.0),
-							 Containers::StaticVector<2,double>(mesh.template getSpaceStepsProducts< 1, 0 >()*(double)(this->n), mesh.template getSpaceStepsProducts< 0, 1 >()*(double)(this->n)) );
-
-	this->subMesh.save("submesh.tnl");
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	this->u0.load( initialCondition );
-
-	/* LOAD MAP */
-	const String& mapFile = parameters.getParameter <String>("map");
-	if(! this->map.load( mapFile ))
-		cout << "Failed to load map file : " << mapFile <<std::endl;
-
-
-	this->delta = parameters.getParameter <double>("delta");
-	this->delta *= mesh.template getSpaceStepsProducts< 1, 0 >()*mesh.template getSpaceStepsProducts< 0, 1 >();
-
-	cout << "Setting delta to " << this->delta <<std::endl;
-
-	this->tau0 = parameters.getParameter <double>("initial-tau");
-	cout << "Setting initial tau to " << this->tau0 <<std::endl;
-	this->stopTime = parameters.getParameter <double>("stop-time");
-
-	this->cflCondition = parameters.getParameter <double>("cfl-condition");
-	this -> cflCondition *= sqrt(mesh.template getSpaceStepsProducts< 1, 0 >()*mesh.template getSpaceStepsProducts< 0, 1 >());
-	cout << "Setting CFL to " << this->cflCondition <<std::endl;
-
-	stretchGrid();
-	this->stopTime /= (double)(this->gridCols);
-	this->stopTime *= (1.0+1.0/((double)(this->n) - 2.0));
-	cout << "Setting stopping time to " << this->stopTime <<std::endl;
-
-	cout << "Initializating scheme..." <<std::endl;
-	if(!this->schemeHost.init(parameters))
-	{
-		cerr << "SchemeHost failed to initialize." <<std::endl;
-		return false;
-	}
-	cout << "Scheme initialized." <<std::endl;
-
-	test();
-
-	VectorType* tmp = new VectorType[subgridValues.getSize()];
-	bool containsCurve = false;
-
-#ifdef HAVE_CUDA
-
-	if(this->device == tnlCudaDevice)
-	{
-		cudaMalloc(&(this->cudaSolver), sizeof(tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >));
-		cudaMemcpy(this->cudaSolver, this,sizeof(tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >), cudaMemcpyHostToDevice);
-
-		double** tmpdev = NULL;
-		cudaMalloc(&tmpdev, sizeof(double*));
-		cudaMalloc(&(this->tmpw), this->work_u.getSize()*sizeof(double));
-		cudaMalloc(&(this->tmp_map), this->map_stretched.getSize()*sizeof(double));
-		cudaMalloc(&(this->runcuda), sizeof(int));
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		int* tmpUC;
-		cudaMalloc(&(tmpUC), this->work_u.getSize()*sizeof(int));
-		cudaMemcpy(tmpUC, this->unusedCell.getData(), this->unusedCell.getSize()*sizeof(int), cudaMemcpyHostToDevice);
-
-		initCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<1,1>>>(this->cudaSolver, (this->tmpw), (this->runcuda),tmpUC, tmp_map);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		double* tmpu = NULL;
-		cudaMemcpy(&tmpu, tmpdev,sizeof(double*), cudaMemcpyDeviceToHost);
-		cudaMemcpy((this->tmpw), this->work_u.getData(), this->work_u.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-		cudaMemcpy((this->tmp_map), this->map_stretched.getData(), this->map_stretched.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-	}
-#endif
-
-	if(this->device == TNL::Devices::HostDevice)
-	{
-		VectorType tmp_map;
-		tmp_map.setSize(this->n * this->n);
-		for(int i = 0; i < this->subgridValues.getSize(); i++)
-		{
-
-			if(! tmp[i].setSize(this->n * this->n))
-				cout << "Could not allocate tmp["<< i <<"] array." <<std::endl;
-				tmp[i] = getSubgrid(i);
-			containsCurve = false;
-
-			for(int j = 0; j < tmp[i].getSize(); j++)
-			{
-				if(tmp[i][0]*tmp[i][j] <= 0.0)
-				{
-					containsCurve = true;
-					j=tmp[i].getSize();
-				}
-
-			}
-			if(containsCurve)
-			{
-				for( int j = 0; j < tmp_map.getSize(); j++)
-				{
-					tmp_map[j] = this->map_stretched[ (i / this->gridCols) * this->n*this->n*this->gridCols
-										 + (i % this->gridCols) * this->n
-										 + (j/this->n) * this->n*this->gridCols
-										 + (j % this->n) ];
-				}
-				//cout << "Computing initial SDF on subgrid " << i << "." <<std::endl;
-				tmp[i] = runSubgrid(0, tmp[i],i,tmp_map);
-				insertSubgrid(tmp[i], i);
-				setSubgridValue(i, 4);
-				//cout << "Computed initial SDF on subgrid " << i  << "." <<std::endl;
-			}
-			containsCurve = false;
-
-		}
-	}
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		dim3 threadsPerBlock(this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		initRunCUDA2D<SchemeTypeHost,SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock,3*this->n*this->n*sizeof(double)>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-	}
-#endif
-
-
-	this->currentStep = 1;
-	if(this->device == TNL::Devices::HostDevice)
-		synchronize();
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		dim3 threadsPerBlock(this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows);
-
-		synchronizeCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		synchronize2CUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,1>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-	}
-
-#endif
-	cout << "Solver initialized." <<std::endl;
-
-	return true;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::run()
-{
-	if(this->device == TNL::Devices::HostDevice)
-	{
-		while ((this->boundaryConditions.max() > 0 )/* || !end*/)
-		{
-
-#ifdef HAVE_OPENMP
-#pragma omp parallel for num_threads(4) schedule(dynamic)
-#endif
-			for(int i = 0; i < this->subgridValues.getSize(); i++)
-			{
-				if(getSubgridValue(i) != INT_MAX)
-				{
-					VectorType tmp, tmp_map;
-					tmp.setSize(this->n * this->n);
-					tmp_map.setSize(this->n * this->n);
-					for( int j = 0; j < tmp_map.getSize(); j++)
-					{
-						tmp_map[j] = this->map_stretched[ (i / this->gridCols) * this->n*this->n*this->gridCols
-											 + (i % this->gridCols) * this->n
-											 + (j/this->n) * this->n*this->gridCols
-											 + (j % this->n) ];
-					}
-
-					if(getSubgridValue(i) == currentStep+4)
-					{
-
-						if(getBoundaryCondition(i) & 1)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(1, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-						if(getBoundaryCondition(i) & 2)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(2, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-						if(getBoundaryCondition(i) & 4)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(4, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-						if(getBoundaryCondition(i) & 8)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(8, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-					}
-					else
-					{
-
-						if(getBoundaryCondition(i) == 1)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(1, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-						if(getBoundaryCondition(i) == 2)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(2, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-						if(getBoundaryCondition(i) == 4)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(4, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-						if(getBoundaryCondition(i) == 8)
-						{
-							tmp = getSubgrid(i);
-							tmp = runSubgrid(8, tmp ,i,tmp_map);
-							insertSubgrid( tmp, i);
-							this->calculationsCount[i]++;
-						}
-					}
-
-					if(getBoundaryCondition(i) & 3)
-					{
-						//cout << "3 @ " << getBoundaryCondition(i) <<std::endl;
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(3, tmp ,i,tmp_map);
-						insertSubgrid( tmp, i);
-					}
-					if(getBoundaryCondition(i) & 5)
-					{
-						//cout << "5 @ " << getBoundaryCondition(i) <<std::endl;
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(5, tmp ,i,tmp_map);
-						insertSubgrid( tmp, i);
-					}
-					if(getBoundaryCondition(i) & 10)
-					{
-						//cout << "10 @ " << getBoundaryCondition(i) <<std::endl;
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(10, tmp ,i,tmp_map);
-						insertSubgrid( tmp, i);
-					}
-					if(getBoundaryCondition(i) & 12)
-					{
-						//cout << "12 @ " << getBoundaryCondition(i) <<std::endl;
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(12, tmp ,i,tmp_map);
-						insertSubgrid( tmp, i);
-					}
-
-
-					setBoundaryCondition(i, 0);
-
-					setSubgridValue(i, getSubgridValue(i)-1);
-
-				}
-			}
-			synchronize();
-		}
-	}
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		bool end_cuda = false;
-		dim3 threadsPerBlock(this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		bool* tmpb;
-		cudaMemcpy(&(this->run_host),this->runcuda,sizeof(int), cudaMemcpyDeviceToHost);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-
-		int i = 1;
-		time_diff = 0.0;
-		while (run_host || !end_cuda)
-		{
-			cout << "Computing at step "<< i++ <<std::endl;
-			if(run_host != 0 )
-				end_cuda = true;
-			else
-				end_cuda = false;
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			start = std::clock();
-			runCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock,3*this->n*this->n*sizeof(double)>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			time_diff += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
-
-			//start = std::clock();
-			synchronizeCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			synchronize2CUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,1>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			//time_diff += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
-
-			cudaMemcpy(&run_host, (this->runcuda),sizeof(int), cudaMemcpyDeviceToHost);
-		}
-		cout << "Solving time was: " << time_diff <<std::endl;
-
-		cudaMemcpy(this->work_u.getData()/* test*/, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-
-		cudaDeviceSynchronize();
-	}
-#endif
-	contractGrid();
-	this->u0.save("u-00001.tnl");
-	cout << "Maximum number of calculations on one subgrid was " << this->calculationsCount.absMax() <<std::endl;
-	cout << "Average number of calculations on one subgrid was " << ( (double) this->calculationsCount.sum() / (double) this->calculationsCount.getSize() ) <<std::endl;
-	cout << "Solver finished" <<std::endl;
-
-#ifdef HAVE_CUDA
-	if(this->device == tnlCudaDevice)
-	{
-		cudaFree(this->runcuda);
-		cudaFree(this->tmpw);
-		cudaFree(this->tmp_map);
-		cudaFree(this->cudaSolver);
-	}
-#endif
-
-}
-
-//north - 1, east - 2, west - 4, south - 8
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::synchronize() //needs fix ---- maybe not anymore --- but frankly: yeah, it does -- aaaa-and maybe fixed now
-{
-	cout << "Synchronizig..." <<std::endl;
-	int tmp1, tmp2;
-	int grid1, grid2;
-
-//	if(this->currentStep & 1)
-//	{
-		for(int j = 0; j < this->gridRows - 1; j++)
-		{
-			for (int i = 0; i < this->gridCols*this->n; i++)
-			{
-				tmp1 = this->gridCols*this->n*((this->n-1)+j*this->n) + i;
-				tmp2 = this->gridCols*this->n*((this->n)+j*this->n) + i;
-				grid1 = getSubgridValue(getOwner(tmp1));
-				grid2 = getSubgridValue(getOwner(tmp2));
-				if(getOwner(tmp1)==getOwner(tmp2))
-					cout << "i, j" << i << "," << j <<std::endl;
-				if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-				{
-					this->work_u[tmp2] = this->work_u[tmp1];
-					this->unusedCell[tmp2] = 0;
-					if(grid2 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp2), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp2)) & 8) )
-						setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+8);
-				}
-				else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-				{
-					this->work_u[tmp1] = this->work_u[tmp2];
-					this->unusedCell[tmp1] = 0;
-					if(grid1 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp1), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp1)) & 1) )
-						setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+1);
-				}
-			}
-		}
-
-//	}
-//	else
-//	{
-		for(int i = 1; i < this->gridCols; i++)
-		{
-			for (int j = 0; j < this->gridRows*this->n; j++)
-			{
-				tmp1 = this->gridCols*this->n*j + i*this->n - 1;
-				tmp2 = this->gridCols*this->n*j + i*this->n ;
-				grid1 = getSubgridValue(getOwner(tmp1));
-				grid2 = getSubgridValue(getOwner(tmp2));
-				if(getOwner(tmp1)==getOwner(tmp2))
-					cout << "i, j" << i << "," << j <<std::endl;
-				if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-				{
-					this->work_u[tmp2] = this->work_u[tmp1];
-					this->unusedCell[tmp2] = 0;
-					if(grid2 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp2), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp2)) & 4) )
-						setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+4);
-				}
-				else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-				{
-					this->work_u[tmp1] = this->work_u[tmp2];
-					this->unusedCell[tmp1] = 0;
-					if(grid1 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp1), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp1)) & 2) )
-						setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+2);
-				}
-			}
-		}
-//	}
-
-
-	this->currentStep++;
-	int stepValue = this->currentStep + 4;
-	for (int i = 0; i < this->subgridValues.getSize(); i++)
-	{
-		if( getSubgridValue(i) == -INT_MAX )
-			setSubgridValue(i, stepValue);
-	}
-
-	cout << "Grid synchronized at step " << (this->currentStep - 1 ) <<std::endl;
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getOwner(int i) const
-{
-
-	return (i / (this->gridCols*this->n*this->n))*this->gridCols + (i % (this->gridCols*this->n))/this->n;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgridValue( int i ) const
-{
-	return this->subgridValues[i];
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setSubgridValue(int i, int value)
-{
-	this->subgridValues[i] = value;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getBoundaryCondition( int i ) const
-{
-	return this->boundaryConditions[i];
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setBoundaryCondition(int i, int value)
-{
-	this->boundaryConditions[i] = value;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::stretchGrid()
-{
-	cout << "Stretching grid..." <<std::endl;
-
-
-	this->gridCols = ceil( ((double)(this->mesh.getDimensions().x()-1)) / ((double)(this->n-1)) );
-	this->gridRows = ceil( ((double)(this->mesh.getDimensions().y()-1)) / ((double)(this->n-1)) );
-
-
-	cout << "Setting gridCols to " << this->gridCols << "." <<std::endl;
-	cout << "Setting gridRows to " << this->gridRows << "." <<std::endl;
-
-	this->subgridValues.setSize(this->gridCols*this->gridRows);
-	this->subgridValues.setValue(0);
-	this->boundaryConditions.setSize(this->gridCols*this->gridRows);
-	this->boundaryConditions.setValue(0);
-	this->calculationsCount.setSize(this->gridCols*this->gridRows);
-	this->calculationsCount.setValue(0);
-
-	for(int i = 0; i < this->subgridValues.getSize(); i++ )
-	{
-		this->subgridValues[i] = INT_MAX;
-		this->boundaryConditions[i] = 0;
-	}
-
-	int stretchedSize = this->n*this->n*this->gridCols*this->gridRows;
-
-	if(!this->work_u.setSize(stretchedSize))
-		cerr << "Could not allocate memory for stretched grid." <<std::endl;
-	if(!this->map_stretched.setSize(stretchedSize))
-		cerr << "Could not allocate memory for stretched map." <<std::endl;
-	if(!this->unusedCell.setSize(stretchedSize))
-		cerr << "Could not allocate memory for supporting stretched grid." <<std::endl;
-	int idealStretch =this->mesh.getDimensions().x() + (this->mesh.getDimensions().x()-2)/(this->n-1);
-	cout << idealStretch <<std::endl;
-
-	for(int i = 0; i < stretchedSize; i++)
-	{
-		this->unusedCell[i] = 1;
-		int diff =(this->n*this->gridCols) - idealStretch ;
-		int k = i/this->n - i/(this->n*this->gridCols) + this->mesh.getDimensions().x()*(i/(this->n*this->n*this->gridCols)) + (i/(this->n*this->gridCols))*diff;
-
-		if(i%(this->n*this->gridCols) - idealStretch  >= 0)
-		{
-			k+= i%(this->n*this->gridCols) - idealStretch +1 ;
-		}
-
-		if(i/(this->n*this->gridCols) - idealStretch + 1  > 0)
-		{
-			k+= (i/(this->n*this->gridCols) - idealStretch +1 )* this->mesh.getDimensions().x() ;
-		}
-
-
-		if(fabs(this->u0[i-k]) < mesh.template getSpaceStepsProducts< 1, 0 >()+mesh.template getSpaceStepsProducts< 0, 1 >() )
-			this->work_u[i] = this->u0[i-k];
-		else
-			this->work_u[i] = sign(this->u0[i-k])*MAP_SOLVER_MAX_VALUE;
-
-		this->map_stretched[i] = this->map[i-k];
-	}
-
-
-	cout << "Grid stretched." <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::contractGrid()
-{
-	cout << "Contracting grid..." <<std::endl;
-	int stretchedSize = this->n*this->n*this->gridCols*this->gridRows;
-
-	int idealStretch =this->mesh.getDimensions().x() + (this->mesh.getDimensions().x()-2)/(this->n-1);
-	cout << idealStretch <<std::endl;
-
-	for(int i = 0; i < stretchedSize; i++)
-	{
-		int diff =(this->n*this->gridCols) - idealStretch ;
-		int k = i/this->n - i/(this->n*this->gridCols) + this->mesh.getDimensions().x()*(i/(this->n*this->n*this->gridCols)) + (i/(this->n*this->gridCols))*diff;
-
-		if((i%(this->n*this->gridCols) - idealStretch  < 0) && (i/(this->n*this->gridCols) - idealStretch + 1  <= 0))
-		{
-			this->u0[i-k] = this->work_u[i];
-		}
-
-	}
-
-	cout << "Grid contracted" <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-typename tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::VectorType
-tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgrid( const int i ) const
-{
-	VectorType u;
-	u.setSize(this->n*this->n);
-
-	for( int j = 0; j < u.getSize(); j++)
-	{
-		u[j] = this->work_u[ (i / this->gridCols) * this->n*this->n*this->gridCols
-		                     + (i % this->gridCols) * this->n
-		                     + (j/this->n) * this->n*this->gridCols
-		                     + (j % this->n) ];
-	}
-	return u;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::insertSubgrid( VectorType u, const int i )
-{
-
-	for( int j = 0; j < this->n*this->n; j++)
-	{
-		int index = (i / this->gridCols)*this->n*this->n*this->gridCols + (i % this->gridCols)*this->n + (j/this->n)*this->n*this->gridCols + (j % this->n);
-		if( (fabs(this->work_u[index]) > fabs(u[j])) || (this->unusedCell[index] == 1) )
-		{
-			this->work_u[index] = u[j];
-			this->unusedCell[index] = 0;
-		}
-	}
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-typename tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::VectorType
-tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::runSubgrid( int boundaryCondition, VectorType u, int subGridID,VectorType map)
-{
-
-	VectorType fu;
-
-	fu.setLike(u);
-	fu.setValue( 0.0 );
-
-
-
-	bool tmp = false;
-	for(int i = 0; i < u.getSize(); i++)
-	{
-		if(u[0]*u[i] <= 0.0)
-			tmp=true;
-		int centerGID = (this->n*(subGridID / this->gridRows)+ (this->n >> 1))*(this->n*this->gridCols) + this->n*(subGridID % this->gridRows) + (this->n >> 1);
-		if(this->unusedCell[centerGID] == 0 || boundaryCondition == 0)
-			tmp = true;
-	}
-
-
-	double value = sign(u[0]) * u.absMax();
-
-	if(tmp)
-	{}
-
-
-	//north - 1, east - 2, west - 4, south - 8
-	else if(boundaryCondition == 4)
-	{
-		for(int i = 0; i < this->n; i++)
-			for(int j = 1;j < this->n; j++)
-				//if(fabs(u[i*this->n + j]) <  fabs(u[i*this->n]))
-				u[i*this->n + j] = value;// u[i*this->n];
-	}
-	else if(boundaryCondition == 2)
-	{
-		for(int i = 0; i < this->n; i++)
-			for(int j =0 ;j < this->n -1; j++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[(i+1)*this->n - 1]))
-				u[i*this->n + j] = value;// u[(i+1)*this->n - 1];
-	}
-	else if(boundaryCondition == 1)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 0;i < this->n - 1; i++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j + this->n*(this->n - 1)]))
-				u[i*this->n + j] = value;// u[j + this->n*(this->n - 1)];
-	}
-	else if(boundaryCondition == 8)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 1;i < this->n; i++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j]))
-				u[i*this->n + j] = value;// u[j];
-	}
-
-
-
-   double time = 0.0;
-   double currentTau = this->tau0;
-   double finalTime = this->stopTime;// + 3.0*(u.max() - u.min());
-   if( time + currentTau > finalTime ) currentTau = finalTime - time;
-
-   double maxResidue( 1.0 );
-   tnlGridEntity<MeshType, 2, tnlGridEntityNoStencilStorage > Entity(subMesh);
-   tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-
-   for( int i = 0; i < u.getSize(); i ++ )
-   {
-		if(map[i] == 0.0)
-		{
-			u[i] = /*sign(u[l])**/MAP_SOLVER_MAX_VALUE;
-		}
-   }
-
-   while( time < finalTime )
-   {
-      /****
-       * Compute the RHS
-       */
-
-      for( int i = 0; i < fu.getSize(); i ++ )
-      {
-			Entity.setCoordinates(Containers::StaticVector<2,int>(i % subMesh.getDimensions().x(),i / subMesh.getDimensions().x()));
-			Entity.refresh();
-			neighborEntities.refresh(subMesh,Entity.getIndex());
-			if(map[i] != 0.0)
-				fu[ i ] = schemeHost.getValue( this->subMesh, i, Containers::StaticVector<2,int>(i % subMesh.getDimensions().x(),i / subMesh.getDimensions().x()), u, time, boundaryCondition,neighborEntities,map);
-      }
-      maxResidue = fu. absMax();
-
-
-      if(maxResidue != 0.0)
-    	  currentTau =  fabs(this -> cflCondition / maxResidue);
-
-
-      if(currentTau > 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >())
-      {
-    	  currentTau = 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >();
-      }
-
-
-      if( time + currentTau > finalTime ) currentTau = finalTime - time;
-
-
-
-      for( int i = 0; i < fu.getSize(); i ++ )
-      {
-    	  if(map[i] != 0.0)
-    		  u[ i ] += currentTau * fu[ i ];
-      }
-      time += currentTau;
-
-   }
-   return u;
-}
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgridCUDA2D( const int i ,tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller, double* a)
-{
-	int th = (blockIdx.y) * caller->n*caller->n*caller->gridCols
-            + (blockIdx.x) * caller->n
-            + threadIdx.y * caller->n*caller->gridCols
-            + threadIdx.x;
-
-	*a = caller->work_u_cuda[th];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::updateSubgridCUDA2D( const int i ,tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller, double* a)
-{
-	int index = (blockIdx.y) * caller->n*caller->n*caller->gridCols
-            + (blockIdx.x) * caller->n
-            + threadIdx.y * caller->n*caller->gridCols
-            + threadIdx.x;
-
-	if( (fabs(caller->work_u_cuda[index]) > fabs(*a)) || (caller->unusedCell_cuda[index] == 1) )
-	{
-		caller->work_u_cuda[index] = *a;
-		caller->unusedCell_cuda[index] = 0;
-
-	}
-
-	*a = caller->work_u_cuda[index];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::insertSubgridCUDA2D( double u, const int i )
-{
-		int index = (blockIdx.y)*this->n*this->n*this->gridCols
-					+ (blockIdx.x)*this->n
-					+ threadIdx.y*this->n*this->gridCols
-					+ threadIdx.x;
-
-		if( (fabs(this->work_u_cuda[index]) > fabs(u)) || (this->unusedCell_cuda[index] == 1) )
-		{
-			this->work_u_cuda[index] = u;
-			this->unusedCell_cuda[index] = 0;
-
-		}
-
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::runSubgridCUDA2D( int boundaryCondition, double* u, int subGridID)
-{
-
-	__shared__ int tmp;
-	__shared__ double value;
-	volatile double* sharedTau = &u[blockDim.x*blockDim.y];
-	double* map_local = &u[2*blockDim.x*blockDim.y];
-
-	int i = threadIdx.x;
-	int j = threadIdx.y;
-	int l = threadIdx.y * blockDim.x + threadIdx.x;
-	int gid = (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
-
-	/* LOAD MAP */
-	map_local[l]=this->map_stretched_cuda[gid];
-	if(map_local[l] != 0.0)
-		map_local[l] = 1.0/map_local[l];
-	/* LOADED */
-
-	bool computeFU = !((i == 0 && (boundaryCondition & 4)) or
-			 (i == blockDim.x - 1 && (boundaryCondition & 2)) or
-			 (j == 0 && (boundaryCondition & 8)) or
-			 (j == blockDim.y - 1  && (boundaryCondition & 1)));
-
-	if(l == 0)
-	{
-		tmp = 0;
-		int centerGID = (blockDim.y*blockIdx.y + (blockDim.y>>1))*(blockDim.x*gridDim.x) + blockDim.x*blockIdx.x + (blockDim.x>>1);
-		if(this->unusedCell_cuda[centerGID] == 0 || boundaryCondition == 0)
-			tmp = 1;
-	}
-	__syncthreads();
-
-
-	if(tmp !=1)
-	{
-		if(computeFU)
-		{
-			if(boundaryCondition == 4)
-				u[l] = u[threadIdx.y * blockDim.x] ;//+ sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(threadIdx.x);
-			else if(boundaryCondition == 2)
-				u[l] = u[threadIdx.y * blockDim.x + blockDim.x - 1] ;//+ sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(this->n - 1 - threadIdx.x);
-			else if(boundaryCondition == 8)
-				u[l] = u[threadIdx.x] ;//+ sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(threadIdx.y);
-			else if(boundaryCondition == 1)
-				u[l] = u[(blockDim.y - 1)* blockDim.x + threadIdx.x] ;//+ sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(this->n - 1 - threadIdx.y);
-		}
-	}
-
-   double time = 0.0;
-   __shared__ double currentTau;
-   double cfl = this->cflCondition;
-   double fu = 0.0;
-
-   double finalTime = this->stopTime;
-   if(boundaryCondition == 0)
-	   finalTime*=2.0;
-   __syncthreads();
-
-   tnlGridEntity<MeshType, 2, tnlGridEntityNoStencilStorage > Entity(subMesh);
-   tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-   Entity.setCoordinates(Containers::StaticVector<2,int>(i,j));
-   Entity.refresh();
-   neighborEntities.refresh(subMesh,Entity.getIndex());
-
-
-	if(map_local[l] == 0.0)
-	{
-		u[l] = /*sign(u[l])**/MAP_SOLVER_MAX_VALUE;
-		computeFU = false;
-	}
-	__syncthreads();
-
-
-   while( time < finalTime )
-   {
-	  sharedTau[l] = finalTime;
-
-	  if(computeFU)
-	  {
-		  fu = schemeHost.getValueDev( this->subMesh, l, Containers::StaticVector<2,int>(i,j), u, time, boundaryCondition, neighborEntities, map_local);
-	  	  sharedTau[l]=abs(cfl/fu);
-	  }
-
-
-
-      if(l == 0)
-      {
-    	  if(sharedTau[0] > 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >())	sharedTau[0] = 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >();
-      }
-      else if(l == blockDim.x*blockDim.y - 1)
-    	  if( time + sharedTau[l] > finalTime )		sharedTau[l] = finalTime - time;
-
-
-      if((blockDim.x == 16) && (l < 128))		sharedTau[l] = Min(sharedTau[l],sharedTau[l+128]);
-      __syncthreads();
-      if((blockDim.x == 16) && (l < 64))		sharedTau[l] = Min(sharedTau[l],sharedTau[l+64]);
-      __syncthreads();
-      if(l < 32)    							sharedTau[l] = Min(sharedTau[l],sharedTau[l+32]);
-      if(l < 16)								sharedTau[l] = Min(sharedTau[l],sharedTau[l+16]);
-      if(l < 8)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+8]);
-      if(l < 4)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+4]);
-      if(l < 2)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+2]);
-      if(l < 1)									currentTau   = Min(sharedTau[l],sharedTau[l+1]);
-      __syncthreads();
-
-      u[l] += currentTau * fu;
-      time += currentTau;
-   }
-
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getOwnerCUDA2D(int i) const
-{
-
-	return ((i / (this->gridCols*this->n*this->n))*this->gridCols
-			+ (i % (this->gridCols*this->n))/this->n);
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgridValueCUDA2D( int i ) const
-{
-	return this->subgridValues_cuda[i];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setSubgridValueCUDA2D(int i, int value)
-{
-	this->subgridValues_cuda[i] = value;
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getBoundaryConditionCUDA2D( int i ) const
-{
-	return this->boundaryConditions_cuda[i];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setBoundaryConditionCUDA2D(int i, int value)
-{
-	this->boundaryConditions_cuda[i] = value;
-}
-
-
-
-//north - 1, east - 2, west - 4, south - 8
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void synchronizeCUDA2D(tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver) //needs fix ---- maybe not anymore --- but frankly: yeah, it does -- aaaa-and maybe fixed now
-{
-
-	__shared__ int boundary[4]; // north,east,west,south
-	__shared__ int subgridValue;
-	__shared__ int newSubgridValue;
-
-
-	int gid = (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
-	double u = cudaSolver->work_u_cuda[gid];
-	double u_cmp;
-	int subgridValue_cmp=INT_MAX;
-	int boundary_index=0;
-
-
-	if(threadIdx.x+threadIdx.y == 0)
-	{
-		subgridValue = cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x);
-		boundary[0] = 0;
-		boundary[1] = 0;
-		boundary[2] = 0;
-		boundary[3] = 0;
-		newSubgridValue = 0;
-	}
-	__syncthreads();
-
-
-
-	if(		(threadIdx.x == 0 				 /*	&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.y == 0 				 /*	&& (cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.x == blockDim.x - 1 	 /*	&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.y == blockDim.y - 1 	 /*	&& (cudaSolver->currentStep & 1)*/) 		)
-	{
-		if(threadIdx.x == 0 && (blockIdx.x != 0)/* && !(cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - 1];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x - 1);
-			boundary_index = 2;
-		}
-
-		if(threadIdx.x == blockDim.x - 1 && (blockIdx.x != gridDim.x - 1)/* && !(cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + 1];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x + 1);
-			boundary_index = 1;
-		}
-
-		__threadfence();
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-			u=u_cmp;
-		}
-		__threadfence();
-		if(threadIdx.y == 0 && (blockIdx.y != 0)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - blockDim.x*gridDim.x];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D((blockIdx.y - 1)*gridDim.x + blockIdx.x);
-			boundary_index = 3;
-		}
-		if(threadIdx.y == blockDim.y - 1 && (blockIdx.y != gridDim.y - 1)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + blockDim.x*gridDim.x];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D((blockIdx.y + 1)*gridDim.x + blockIdx.x);
-			boundary_index = 0;
-		}
-
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-		}
-	}
-	__threadfence();
-	__syncthreads();
-
-	if(threadIdx.x+threadIdx.y == 0)
-	{
-		if(subgridValue == INT_MAX && newSubgridValue !=0)
-			cudaSolver->setSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, -INT_MAX);
-
-		cudaSolver->setBoundaryConditionCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, 	boundary[0] +
-																				2 * boundary[1] +
-																				4 * boundary[2] +
-																				8 * boundary[3]);
-
-
-		if(blockIdx.x+blockIdx.y ==0)
-		{
-			cudaSolver->currentStep += 1;
-			*(cudaSolver->runcuda) = 0;
-		}
-	}
-
-}
-
-
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void synchronize2CUDA2D(tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver)
-{
-
-
-	int stepValue = cudaSolver->currentStep + 4;
-	if( cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x) == -INT_MAX )
-			cudaSolver->setSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, stepValue);
-
-	atomicMax((cudaSolver->runcuda),cudaSolver->getBoundaryConditionCUDA2D(blockIdx.y*gridDim.x + blockIdx.x));
-}
-
-
-
-
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void initCUDA2D( tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr , int* ptr2, int* ptr3, double* tmp_map_ptr)
-{
-
-
-	cudaSolver->work_u_cuda = ptr;
-	cudaSolver->map_stretched_cuda = tmp_map_ptr;
-	cudaSolver->unusedCell_cuda = ptr3;
-	cudaSolver->subgridValues_cuda =(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*sizeof(int));
-	cudaSolver->boundaryConditions_cuda =(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*sizeof(int));
-	cudaSolver->runcuda = ptr2;
-	*(cudaSolver->runcuda) = 1;
-
-/* CHANGED !!!!!! from 1 to 0*/	cudaSolver->currentStep = 0;
-
-	printf("GPU memory allocated.\n");
-
-	for(int i = 0; i < cudaSolver->gridCols*cudaSolver->gridRows; i++)
-	{
-		cudaSolver->subgridValues_cuda[i] = INT_MAX;
-		cudaSolver->boundaryConditions_cuda[i] = 0;
-	}
-
-	printf("GPU memory initialized.\n");
-}
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device >
-__global__
-void initRunCUDA2D(tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller)
-
-{
-	extern __shared__ double u[];
-
-	int i = blockIdx.y * gridDim.x + blockIdx.x;
-	int l = threadIdx.y * blockDim.x + threadIdx.x;
-
-	__shared__ int containsCurve;
-	if(l == 0)
-		containsCurve = 0;
-
-
-	caller->getSubgridCUDA2D(i,caller, &u[l]);
-	__syncthreads();
-
-	if(u[0] * u[l] <= 0.0)
-		atomicMax( &containsCurve, 1);
-
-	__syncthreads();
-	if(containsCurve == 1)
-	{
-		caller->runSubgridCUDA2D(0,u,i);
-		caller->insertSubgridCUDA2D(u[l],i);
-		__syncthreads();
-		if(l == 0)
-			caller->setSubgridValueCUDA2D(i, 4);
-	}
-
-
-}
-
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device >
-__global__
-void runCUDA2D(tnlParallelMapSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller)
-{
-	extern __shared__ double u[];
-	int i = blockIdx.y * gridDim.x + blockIdx.x;
-	int l = threadIdx.y * blockDim.x + threadIdx.x;
-	int bound = caller->getBoundaryConditionCUDA2D(i);
-
-	if(caller->getSubgridValueCUDA2D(i) != INT_MAX && bound != 0 && caller->getSubgridValueCUDA2D(i) > 0)
-	{
-		caller->getSubgridCUDA2D(i,caller, &u[l]);
-
-
-		if(caller->getSubgridValueCUDA2D(i) == caller->currentStep+4)
-		{
-			if(bound & 1)
-			{
-				caller->runSubgridCUDA2D(1,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 2)
-			{
-				caller->runSubgridCUDA2D(2,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 4)
-			{
-				caller->runSubgridCUDA2D(4,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 8)
-			{
-				caller->runSubgridCUDA2D(8,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-		}
-		else
-		{
-
-			if(bound == 1)
-			{
-				caller->runSubgridCUDA2D(1,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound == 2)
-			{
-				caller->runSubgridCUDA2D(2,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound == 4)
-			{
-				caller->runSubgridCUDA2D(4,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound == 8)
-			{
-				caller->runSubgridCUDA2D(8,u,i);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-		}
-
-		if(bound & 3)
-		{
-			caller->runSubgridCUDA2D(3,u,i);
-			caller->updateSubgridCUDA2D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if(bound & 5)
-		{
-			caller->runSubgridCUDA2D(5,u,i);
-			caller->updateSubgridCUDA2D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if(bound & 10)
-		{
-			caller->runSubgridCUDA2D(10,u,i);
-			caller->updateSubgridCUDA2D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if(bound & 12)
-		{
-			caller->runSubgridCUDA2D(12,u,i);
-			caller->updateSubgridCUDA2D(i,caller, &u[l]);
-			__syncthreads();
-		}
-
-
-		if(l==0)
-		{
-			caller->setBoundaryConditionCUDA2D(i, 0);
-			caller->setSubgridValueCUDA2D(i, caller->getSubgridValueCUDA2D(i) - 1 );
-		}
-
-
-	}
-
-
-
-}
-
-#endif /*HAVE_CUDA*/
-
-#endif /* TNLPARALLELMAPSOLVER2D_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/CMakeLists.txt b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/CMakeLists.txt
deleted file mode 100644
index f6a00127c7f79344a0c9303c1a0f4b2a8ad84832..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-set( tnl_hamilton_jacobi_parallel_SOURCES
-#     MainBuildConfig.h
-#     tnlParallelEikonalSolver2D_impl.h
-#     tnlParallelEikonalSolver3D_impl.h
-#     tnlParallelEikonalSolver.h
-#     parallelEikonalConfig.h 
-     main.cpp)
-
-
-IF(  BUILD_CUDA ) 
-	CUDA_ADD_EXECUTABLE(hamilton-jacobi-parallel main.cu)
-ELSE(  BUILD_CUDA )                
-	ADD_EXECUTABLE(hamilton-jacobi-parallel main.cpp)
-ENDIF( BUILD_CUDA )
-target_link_libraries (hamilton-jacobi-parallel tnl )
-
-
-INSTALL( TARGETS hamilton-jacobi-parallel
-         RUNTIME DESTINATION bin
-         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
-        
-#INSTALL( FILES ${tnl_hamilton_jacobi_parallel_SOURCES}
-#         DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/hamilton-jacobi-parallel )
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/MainBuildConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/MainBuildConfig.h
deleted file mode 100644
index ed3d686eb99379af1589d734eac9b5812cccdedf..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/MainBuildConfig.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
-                          MainBuildConfig.h  -  description
-                             -------------------
-    begin                : Jul 7, 2014
-    copyright            : (C) 2014 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 MAINBUILDCONFIG_H_
-#define MAINBUILDCONFIG_H_
-
-#include <solvers/tnlBuildConfigTags.h>
-
-class MainBuildConfig
-{
-   public:
-
-      static void print() {std::cerr << "MainBuildConfig" <<std::endl; }
-};
-
-/****
- * Turn off support for float and long double.
- */
-template<> struct tnlConfigTagReal< MainBuildConfig, float > { enum { enabled = false }; };
-template<> struct tnlConfigTagReal< MainBuildConfig, long double > { enum { enabled = false }; };
-
-/****
- * Turn off support for short int and long int indexing.
- */
-template<> struct tnlConfigTagIndex< MainBuildConfig, short int >{ enum { enabled = false }; };
-template<> struct tnlConfigTagIndex< MainBuildConfig, long int >{ enum { enabled = false }; };
-
-/****
- * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.
- */
-template< int Dimensions, typename Real, typename Device, typename Index >
-   struct tnlConfigTagMesh< MainBuildConfig, tnlGrid< Dimensions, Real, Device, Index > >
-      { enum { enabled = tnlConfigTagDimensions< MainBuildConfig, Dimensions >::enabled  &&
-                         tnlConfigTagReal< MainBuildConfig, Real >::enabled &&
-                         tnlConfigTagDevice< MainBuildConfig, Device >::enabled &&
-                         tnlConfigTagIndex< MainBuildConfig, Index >::enabled }; };
-
-/****
- * Please, chose your preferred time discretisation  here.
- */
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = false}; };
-template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };
-
-/****
- * Only the Runge-Kutta-Merson solver is enabled by default.
- */
-template<> struct tnlConfigTagExplicitSolver< MainBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };
-
-#endif /* MAINBUILDCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.cpp b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.cpp
deleted file mode 100644
index b13498e17330fae7bb00a0bdc2abcc7a19f8e7a8..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cpp  -  description
-                             -------------------
-    begin                : Jul 8 , 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.cu b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.cu
deleted file mode 100644
index 7101976712e153d73c5f0979b211164a36ec648d..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************
-                          main.cu  -  description
-                             -------------------
-    begin                : Mar 30 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "main.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.h
deleted file mode 100644
index dbaebdcebd3b2bdf0509eda61729c1b11579716a..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/main.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/***************************************************************************
-                          main.h  -  description
-                             -------------------
-    begin                : Mar 30 , 2015
-    copyright            : (C) 2015 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.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "tnlParallelEikonalSolver.h"
-#include "parallelEikonalConfig.h"
-#include "MainBuildConfig.h"
-#include <solvers/tnlBuildConfigTags.h>
-#include <operators/hamilton-jacobi/godunov-eikonal/parallelGodunovEikonal.h>
-#include <mesh/tnlGrid.h>
-#include <core/tnlDevice.h>
-#include <time.h>
-#include <ctime>
-
-typedef MainBuildConfig BuildConfig;
-
-int main( int argc, char* argv[] )
-{
-	time_t start;
-	time_t stop;
-	time(&start);
-	std::clock_t start2= std::clock();
-   Config::ParameterContainer parameters;
-   tnlConfigDescription configDescription;
-   parallelEikonalConfig< BuildConfig >::configSetup( configDescription );
-
-   if( ! parseCommandLine( argc, argv, configDescription, parameters ) )
-      return false;
-
-   //if (parameters.GetParameter <String>("scheme") == "godunov")
-   //{
-   tnlDeviceEnum device;
-   device = TNL::Devices::HostDevice;
-
-   const int& dim = parameters.getParameter< int >( "dim" );
-
-  if(dim == 2)
-  {
-
-	   typedef parallelGodunovEikonalScheme< tnlGrid<2,double,TNL::Devices::Host, int>, double, int > SchemeTypeHost;
-		/*#ifdef HAVE_CUDA
-		   typedef parallelGodunovEikonalScheme< tnlGrid<2,double,tnlCuda, int>, double, int > SchemeTypeDevice;
-		#endif
-		#ifndef HAVE_CUDA*/
-	   typedef parallelGodunovEikonalScheme< tnlGrid<2,double,TNL::Devices::Host, int>, double, int > SchemeTypeDevice;
-		/*#endif*/
-
-	   if(device==TNL::Devices::HostDevice)
-	   {
-		   typedef TNL::Devices::Host Device;
-
-
-		   tnlParallelEikonalSolver<2,SchemeTypeHost,SchemeTypeDevice, Device> solver;
-		   if(!solver.init(parameters))
-		   {
-			  std::cerr << "Solver failed to initialize." <<std::endl;
-			   return EXIT_FAILURE;
-		   }
-		  std::cout << "-------------------------------------------------------------" <<std::endl;
-		  std::cout << "Starting solver loop..." <<std::endl;
-		   solver.run();
-	   }
-	   else if(device==tnlCudaDevice )
-	   {
-		   typedef tnlCuda Device;
-		   //typedef parallelGodunovEikonalScheme< tnlGrid<2,double,Device, int>, double, int > SchemeType;
-
-		   tnlParallelEikonalSolver<2,SchemeTypeHost,SchemeTypeDevice, Device> solver;
-		   if(!solver.init(parameters))
-		   {
-			  std::cerr << "Solver failed to initialize." <<std::endl;
-			   return EXIT_FAILURE;
-		   }
-		  std::cout << "-------------------------------------------------------------" <<std::endl;
-		  std::cout << "Starting solver loop..." <<std::endl;
-		   solver.run();
-	   }
-  // }
-  }
-  else if(dim == 3)
-  {
-
-	   typedef parallelGodunovEikonalScheme< tnlGrid<3,double,TNL::Devices::Host, int>, double, int > SchemeTypeHost;
-		/*#ifdef HAVE_CUDA
-		   typedef parallelGodunovEikonalScheme< tnlGrid<2,double,tnlCuda, int>, double, int > SchemeTypeDevice;
-		#endif
-		#ifndef HAVE_CUDA*/
-	   typedef parallelGodunovEikonalScheme< tnlGrid<3,double,TNL::Devices::Host, int>, double, int > SchemeTypeDevice;
-		/*#endif*/
-
-	   if(device==TNL::Devices::HostDevice)
-	   {
-		   typedef TNL::Devices::Host Device;
-
-
-		   tnlParallelEikonalSolver<3,SchemeTypeHost,SchemeTypeDevice, Device> solver;
-		   if(!solver.init(parameters))
-		   {
-			  std::cerr << "Solver failed to initialize." <<std::endl;
-			   return EXIT_FAILURE;
-		   }
-		  std::cout << "-------------------------------------------------------------" <<std::endl;
-		  std::cout << "Starting solver loop..." <<std::endl;
-		   solver.run();
-	   }
-	   else if(device==tnlCudaDevice )
-	   {
-		   typedef tnlCuda Device;
-		   //typedef parallelGodunovEikonalScheme< tnlGrid<2,double,Device, int>, double, int > SchemeType;
-
-		   tnlParallelEikonalSolver<3,SchemeTypeHost,SchemeTypeDevice, Device> solver;
-		   if(!solver.init(parameters))
-		   {
-			  std::cerr << "Solver failed to initialize." <<std::endl;
-			   return EXIT_FAILURE;
-		   }
-		  std::cout << "-------------------------------------------------------------" <<std::endl;
-		  std::cout << "Starting solver loop..." <<std::endl;
-		   solver.run();
-	   }
- // }
-  }
-
-   time(&stop);
-  std::cout <<std::endl;
-  std::cout << "Running time was: " << difftime(stop,start) << " .... " << (std::clock() - start2) / (double)(CLOCKS_PER_SEC) <<std::endl;
-   return EXIT_SUCCESS;
-}
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/no-Makefile b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/no-Makefile
deleted file mode 100644
index bfdc1ef236ca02ecfe6bc88f81d872e9524ec621..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/no-Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-TNL_VERSION=0.1
-TNL_INSTALL_DIR=${HOME}/local/lib
-TNL_INCLUDE_DIR=${HOME}/local/include/tnl-${TNL_VERSION}
-
-TARGET = hamiltonJacobiParallelSolver
-#CONFIG_FILE = $(TARGET).cfg.desc
-INSTALL_DIR = ${HOME}/local
-CXX = g++
-CUDA_CXX = nvcc
-OMP_FLAGS = -DHAVE_OPENMP -fopenmp
-CXX_FLAGS = -std=gnu++0x -I$(TNL_INCLUDE_DIR) -O3 $(OMP_FLAGS) -DDEBUG
-LD_FLAGS = -L$(TNL_INSTALL_DIR) -ltnl-0.1 -lgomp
-
-SOURCES = main.cpp
-HEADERS = 
-OBJECTS = main.o
-DIST = $(SOURCES) Makefile
-
-all: $(TARGET)
-clean: 
-	rm -f $(OBJECTS)
-	rm -f $(TARGET)-conf.h	
-
-dist: $(DIST)
-	tar zcvf $(TARGET).tgz $(DIST) 
-
-install: $(TARGET)
-	cp $(TARGET) $(INSTALL_DIR)/bin
-	cp $(CONFIG_FILE) $(INSTALL_DIR)/share
-
-uninstall: $(TARGET)
-	rm -f $(INSTALL_DIR)/bin/$(TARGET) 
-	rm -f $(CONFIG_FILE) $(INSTALL_DIR)/share
-
-$(TARGET): $(OBJECTS)
-	$(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)
-
-%.o: %.cpp $(HEADERS)
-	$(CXX) -c -o $@ $(CXX_FLAGS) $<
-
-
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/parallelEikonalConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/parallelEikonalConfig.h
deleted file mode 100644
index c27f5ebb39e5c4db31ed13d1a8e80b8ca8915d51..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/parallelEikonalConfig.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/***************************************************************************
-                          parallelEikonalConfig.h  -  description
-                             -------------------
-    begin                : Oct 5, 2014
-    copyright            : (C) 2014 by Tomas Sobotik
-    email                :
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   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 HAMILTONJACOBIPARALLELEIKONALPROBLEMCONFIG_H_
-#define HAMILTONJACOBIPARALLELEIKONALPROBLEMCONFIG_H_
-
-#include <config/tnlConfigDescription.h>
-
-template< typename ConfigTag >
-class parallelEikonalConfig
-{
-   public:
-      static void configSetup( tnlConfigDescription& config )
-      {
-         config.addDelimiter( "Parallel Eikonal solver settings:" );
-         config.addEntry        < String > ( "problem-name", "This defines particular problem.", "hamilton-jacobi-parallel" );
-         config.addEntry       < String > ( "scheme", "This defines scheme used for discretization.", "godunov" );
-         config.addEntryEnum( "godunov" );
-         config.addEntryEnum( "upwind" );
-         config.addRequiredEntry        < String > ( "initial-condition", "Initial condition for solver");
-         config.addEntry       < String > ( "mesh", "Name of mesh.", "mesh.tnl" );
-         config.addEntry        < double > ( "epsilon", "This defines epsilon for smoothening of sign().", 0.0 );
-         config.addEntry        < double > ( "delta", " Allowed difference on subgrid boundaries", 0.0 );
-         config.addRequiredEntry        < double > ( "stop-time", " Final time for solver");
-         config.addRequiredEntry        < double > ( "initial-tau", " initial tau for solver" );
-         config.addEntry        < double > ( "cfl-condition", " CFL condition", 0.0 );
-         config.addEntry        < int > ( "subgrid-size", "Subgrid size.", 16 );
-         config.addRequiredEntry        < int > ( "dim", "Dimension of problem.");
-      }
-};
-
-#endif /* HAMILTONJACOBIPARALLELEIKONALPROBLEMCONFIG_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/run b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/run
deleted file mode 100755
index 3aece294a9c1189cd885acbe459dba20be713716..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/run
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-
-#GRID_SIZES="0897"
-GRID_SIZES="0008 0015 0029 0057 0113 0225 0449"
-#GRID_SIZES="1793"
-
-dimensions=2
-
-size=2
-
-time=3
-
-for grid_size in $GRID_SIZES;
-
-do
-
-	rm -r grid-${grid_size}
-   	mkdir grid-${grid_size}
-   	cd grid-${grid_size}
-
-	tnl-grid-setup --dimensions $dimensions \
-	               --origin-x -1.0 \
-	               --origin-y -1.0 \
-	               --origin-z -1.0 \
-	               --proportions-x $size \
-	               --proportions-y $size \
-	               --proportions-z $size \
-	               --size-x ${grid_size} \
-	               --size-y ${grid_size} \
-	               --size-z ${grid_size}
-
-	tnl-init --test-function sdf-para \
-		     --offset 0.25 \
-	             --output-file init.tnl \
-		     --final-time 0.0 \
-		     --snapshot-period 0.1 \
-
-
-	tnl-init --test-function sdf-para-sdf \
-		     --offset 0.25 \
-	             --output-file sdf.tnl \
-		     --final-time 0.0 \
-		     --snapshot-period 0.1
-
-	hamilton-jacobi-parallel --initial-condition init.tnl \
-	              --cfl-condition 1.0e-1 \
-		      	  --mesh mesh.tnl \
-		     	  --initial-tau 1.0e-3 \
-		      	  --epsilon 1.0 \
-	        	  --delta 0.0 \
-	       	      --stop-time $time \
-		          --scheme godunov \
-		          --subgrid-size 8
-
-        tnl-diff --mesh mesh.tnl --mode sequence --input-files sdf.tnl u-00001.tnl --write-difference yes --output-file ../${grid_size}.diff
-	
-	cd ..
-
-done
-
-
-./tnl-err2eoc-2.py --format txt --size $size *.diff
-
-              
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnl-err2eoc-2.py b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnl-err2eoc-2.py
deleted file mode 100755
index f8cde3768e9b76156507e133f8bc3ecaa526fc71..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnl-err2eoc-2.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env python
-
-import sys, string, math
-
-arguments = sys. argv[1:]
-format = "txt"
-output_file_name = "eoc-table.txt"
-input_files = []
-verbose = 1
-size = 1.0
-
-i = 0
-while i < len( arguments ):
-   if arguments[ i ] == "--format":
-      format = arguments[ i + 1 ]
-      i = i + 2
-      continue
-   if arguments[ i ] == "--output-file":
-      output_file_name = arguments[ i + 1 ]
-      i = i + 2
-      continue
-   if arguments[ i ] == "--verbose":
-       verbose = float( arguments[ i + 1 ] )
-       i = i +2
-       continue
-   if arguments[ i ] == "--size":
-       size = float( arguments[ i + 1 ] )
-       i = i +2
-       continue
-   input_files. append( arguments[ i ] )
-   i = i + 1
-
-if not verbose == 0:
-   print "Writing to " + output_file_name + " in " + format + "."
-
-h_list = []
-l1_norm_list = []
-l2_norm_list = []
-max_norm_list = []
-items = 0
-
-for file_name in input_files:
-   if not verbose == 0:
-       print "Processing file " + file_name
-   file = open( file_name, "r" )
-   
-   l1_max = 0.0
-   l_max_max = 0.0
-   file.readline();
-   file.readline();
-   for line in file. readlines():
-         data = string. split( line )
-         h_list. append( size/(float(file_name[0:len(file_name)-5] ) - 1.0) )
-         l1_norm_list. append( float( data[ 1 ] ) )
-         l2_norm_list. append( float( data[ 2 ] ) )
-         max_norm_list. append( float( data[ 3 ] ) )
-         items = items + 1
-         if not verbose == 0:
-            print line
-   file. close()
-
-h_width = 12
-err_width = 15
-file = open( output_file_name, "w" )
-if format == "latex":
-      file. write( "\\begin{tabular}{|r|l|l|l|l|l|l|}\\hline\n" )
-      file. write( "\\raisebox{-1ex}[0ex]{$h$}& \n" )
-      file. write( "\\multicolumn{2}{|c|}{\\raisebox{1ex}[3.5ex]{$\\left\| \\cdot \\right\\|_{L_1\\left(\\omega_h;\\left[0,T\\right]\\right)}^{h,\\tau}$}}& \n" )
-      file. write( "\\multicolumn{2}{|c|}{\\raisebox{1ex}[3.5ex]{$\\left\| \\cdot \\right\\|_{L_2\\left(\\omega_h;\left[0,T\\right]\\right)}^{h,\\tau}$}}& \n" )
-      file. write( "\\multicolumn{2}{|c|}{\\raisebox{1ex}[3.5ex]{$\\left\| \\cdot \\right\\|_{L_\\infty\\left(\\omega_h;\\left[0,T\\right]\\right)}^{h,\\tau}$}}\\\\ \\cline{2-7} \n" )
-      file. write( " " + string. rjust( " ", h_width ) + "&" +
-                string. rjust( "Error", err_width ) + "&" +
-                string. rjust( "{\\bf EOC}", err_width ) + "&" +
-                string. rjust( "Error", err_width ) + "&" +
-                string. rjust( "{\\bf EOC}", err_width ) + "&" +
-                string. rjust( "Error.", err_width ) + "&" +
-                string. rjust( "{\\bf EOC}", err_width ) +
-                "\\\\ \\hline \\hline \n")
-if format == "txt":
-    file. write( "+--------------+----------------+----------------+----------------+----------------+----------------+----------------+\n" )
-    file. write( "|       h      |     L1 Err.    |     L1 EOC.    |     L2 Err.    |      L2 EOC    |    MAX Err.    |     MAX EOC    |\n" )
-    file. write( "+==============+================+================+================+================+================+================+\n" )
-                  
-
-i = 0
-while i < items:
-   if i == 0:
-      if format == "latex":
-         file. write( " " + string. ljust( str( h_list[ i ] ), h_width ) + "&" +
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + "&" + 
-                      string. rjust( " ", err_width ) + "&"+ 
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( " ", err_width ) + "&" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( " ", err_width ) + "\\\\\n" )
-      if format == "txt":
-         file. write( "| " + string. ljust( str( h_list[ i ] ), h_width ) + " |" + 
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( " ", err_width ) + " |" +
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( " ", err_width ) + " |" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( " ", err_width ) + " |\n" )
-         file. write( "+--------------+----------------+----------------+----------------+----------------+----------------+----------------+\n" )
-      i = i + 1;
-      continue
-   if h_list[ i ] == h_list[ i - 1 ]:
-      print "Unable to count eoc since h[ " + \
-      str( i ) + " ] = h[ " + str( i - 1 ) + \
-      " ] = " + str( h_list[ i ] ) + ". \n"
-      file. write( " eoc error:  h[ " + \
-      str( i ) + " ] = h[ " + str( i - 1 ) + \
-      " ] = " + str( h_list[ i ] ) + ". \n" )
-   else:
-      h_ratio = math. log( h_list[ i ] / h_list[ i - 1 ] )
-      l1_ratio = math. log( l1_norm_list[ i ] / l1_norm_list[ i - 1 ] )
-      l2_ratio = math. log( l2_norm_list[ i ] / l2_norm_list[ i - 1 ] )
-      max_ratio = math. log( max_norm_list[ i ] / max_norm_list[ i - 1 ] )
-      if format == "latex":
-         file. write( " " + string. ljust( str( h_list[ i ] ), h_width ) + "&" +
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( "{\\bf " + "%.2g" % ( l1_ratio / h_ratio ) + "}", err_width ) + "&" +
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( "{\\bf " + "%.2g" % ( l2_ratio / h_ratio ) + "}", err_width ) + "&" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + "&" +
-                      string. rjust( "{\\bf " + "%.2g" % ( max_ratio / h_ratio ) + "}", err_width ) + "\\\\\n" )
-      if format == "txt":
-         file. write( "| " + string. ljust( str( h_list[ i ] ), h_width ) + " |" +
-                      string. rjust( "%.2g" % l1_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( "**" + "%.2g" % ( l1_ratio / h_ratio ) + "**", err_width ) + " |" +
-                      string. rjust( "%.2g" % l2_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( "**" + "%.2g" % ( l2_ratio / h_ratio ) + "**", err_width ) + " |" +
-                      string. rjust( "%.2g" % max_norm_list[ i ], err_width ) + " |" +
-                      string. rjust( "**" + "%.2g" % ( max_ratio / h_ratio ) + "**", err_width ) + " |\n" )
-         file. write( "+--------------+----------------+----------------+----------------+----------------+----------------+----------------+\n" )
-   i = i + 1
-
-if format == "latex":
-   file. write( "\\hline \n" )
-   file. write( "\\end{tabular} \n" )
-    
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver.h
deleted file mode 100644
index 19cdd949359d4349172af820def49169146c8717..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/***************************************************************************
-                          tnlParallelEikonalSolver.h  -  description
-                             -------------------
-    begin                : Nov 28 , 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 TNLPARALLELEIKONALSOLVER_H_
-#define TNLPARALLELEIKONALSOLVER_H_
-
-#include <TNL/Config/ParameterContainer.h>
-#include <TNL/Containers/Vector.h>
-#include <TNL/Containers/StaticVector.h>
-#include <functions/tnlMeshFunction.h>
-#include <TNL/Devices/Host.h>
-#include <mesh/tnlGrid.h>
-#include <mesh/grids/tnlGridEntity.h>
-#include <limits.h>
-#include <core/tnlDevice.h>
- #include <omp.h>
-
-
-#include <ctime>
-
-#ifdef HAVE_CUDA
-#include <core/tnlCuda.h>
-#endif
-
-
-template< int Dimension,
-		  typename SchemeHost,
-		  typename SchemeDevice,
-		  typename Device,
-		  typename RealType = double,
-          typename IndexType = int >
-class tnlParallelEikonalSolver
-{};
-
-template<typename SchemeHost, typename SchemeDevice, typename Device>
-class tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >
-{
-public:
-
-	typedef SchemeDevice SchemeTypeDevice;
-	typedef SchemeHost SchemeTypeHost;
-	typedef Device DeviceType;
-	typedef TNL::Containers::Vector< double, TNL::Devices::Host, int > VectorType;
-	typedef TNL::Containers::Vector< int, TNL::Devices::Host, int > IntVectorType;
-	typedef tnlGrid< 2, double, TNL::Devices::Host, int > MeshType;
-#ifdef HAVE_CUDA
-	typedef TNL::Containers::Vector< double, TNL::Devices::Host, int > VectorTypeCUDA;
-	typedef TNL::Containers::Vector< int, TNL::Devices::Host, int > IntVectorTypeCUDA;
-	typedef tnlGrid< 2, double, TNL::Devices::Host, int > MeshTypeCUDA;
-#endif
-	tnlParallelEikonalSolver();
-	bool init( const Config::ParameterContainer& parameters );
-	void run();
-
-	void test();
-
-/*private:*/
-
-
-	void synchronize();
-
-	int getOwner( int i) const;
-
-	int getSubgridValue( int i ) const;
-
-	void setSubgridValue( int i, int value );
-
-	int getBoundaryCondition( int i ) const;
-
-	void setBoundaryCondition( int i, int value );
-
-	void stretchGrid();
-
-	void contractGrid();
-
-	VectorType getSubgrid( const int i ) const;
-
-	void insertSubgrid( VectorType u, const int i );
-
-	VectorType runSubgrid( int boundaryCondition, VectorType u, int subGridID);
-
-
-	tnlMeshFunction<MeshType> u0;
-	VectorType work_u;
-	IntVectorType subgridValues, boundaryConditions, unusedCell, calculationsCount;
-	MeshType mesh, subMesh;
-
-//	tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage > Entity;
-
-	SchemeHost schemeHost;
-	SchemeDevice schemeDevice;
-	double delta, tau0, stopTime,cflCondition;
-	int gridRows, gridCols, gridLevels, currentStep, n;
-
-	std::clock_t start;
-	double time_diff;
-
-
-	tnlDeviceEnum device;
-
-	tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* getSelf()
-	{
-		return this;
-	};
-
-#ifdef HAVE_CUDA
-
-	tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver;
-
-	double* work_u_cuda;
-
-	int* subgridValues_cuda;
-	int*boundaryConditions_cuda;
-	int* unusedCell_cuda;
-	int* calculationsCount_cuda;
-	double* tmpw;
-	//MeshTypeCUDA mesh_cuda, subMesh_cuda;
-	//SchemeDevice scheme_cuda;
-	//double delta_cuda, tau0_cuda, stopTime_cuda,cflCondition_cuda;
-	//int gridRows_cuda, gridCols_cuda, currentStep_cuda, n_cuda;
-
-	int* runcuda;
-	int run_host;
-
-
-	__device__ void getSubgridCUDA2D( const int i, tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller, double* a);
-
-	__device__ void updateSubgridCUDA2D( const int i, tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller, double* a);
-
-	__device__ void insertSubgridCUDA2D( double u, const int i );
-
-	__device__ void runSubgridCUDA2D( int boundaryCondition, double* u, int subGridID);
-
-	/*__global__ void runCUDA();*/
-
-	//__device__ void synchronizeCUDA();
-
-	__device__ int getOwnerCUDA2D( int i) const;
-
-	__device__ int getSubgridValueCUDA2D( int i ) const;
-
-	__device__ void setSubgridValueCUDA2D( int i, int value );
-
-	__device__ int getBoundaryConditionCUDA2D( int i ) const;
-
-	__device__ void setBoundaryConditionCUDA2D( int i, int value );
-
-	//__device__ bool initCUDA( tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-	/*__global__ void initRunCUDA(tnlParallelEikonalSolver<Scheme, double, TNL::Devices::Host, int >* caller);*/
-
-#endif
-
-};
-
-
-
-
-
-
-
-	template<typename SchemeHost, typename SchemeDevice, typename Device>
-	class tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >
-	{
-	public:
-
-		typedef SchemeDevice SchemeTypeDevice;
-		typedef SchemeHost SchemeTypeHost;
-		typedef Device DeviceType;
-		typedef TNL::Containers::Vector< double, TNL::Devices::Host, int > VectorType;
-		typedef TNL::Containers::Vector< int, TNL::Devices::Host, int > IntVectorType;
-		typedef tnlGrid< 3, double, TNL::Devices::Host, int > MeshType;
-	#ifdef HAVE_CUDA
-		typedef TNL::Containers::Vector< double, TNL::Devices::Host, int > VectorTypeCUDA;
-		typedef TNL::Containers::Vector< int, TNL::Devices::Host, int > IntVectorTypeCUDA;
-		typedef tnlGrid< 3, double, TNL::Devices::Host, int > MeshTypeCUDA;
-	#endif
-		tnlParallelEikonalSolver();
-		bool init( const Config::ParameterContainer& parameters );
-		void run();
-
-		void test();
-
-	/*private:*/
-
-
-		void synchronize();
-
-		int getOwner( int i) const;
-
-		int getSubgridValue( int i ) const;
-
-		void setSubgridValue( int i, int value );
-
-		int getBoundaryCondition( int i ) const;
-
-		void setBoundaryCondition( int i, int value );
-
-		void stretchGrid();
-
-		void contractGrid();
-
-		VectorType getSubgrid( const int i ) const;
-
-		void insertSubgrid( VectorType u, const int i );
-
-		VectorType runSubgrid( int boundaryCondition, VectorType u, int subGridID);
-
-
-		tnlMeshFunction<MeshType> u0;
-		VectorType work_u;
-		IntVectorType subgridValues, boundaryConditions, unusedCell, calculationsCount;
-		MeshType mesh, subMesh;
-		SchemeHost schemeHost;
-		SchemeDevice schemeDevice;
-		double delta, tau0, stopTime,cflCondition;
-		int gridRows, gridCols, gridLevels, currentStep, n;
-
-		std::clock_t start;
-		double time_diff;
-
-
-		tnlDeviceEnum device;
-
-		tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* getSelf()
-		{
-			return this;
-		};
-
-#ifdef HAVE_CUDA
-
-	tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver;
-
-	double* work_u_cuda;
-
-	int* subgridValues_cuda;
-	int*boundaryConditions_cuda;
-	int* unusedCell_cuda;
-	int* calculationsCount_cuda;
-	double* tmpw;
-	//MeshTypeCUDA mesh_cuda, subMesh_cuda;
-	//SchemeDevice scheme_cuda;
-	//double delta_cuda, tau0_cuda, stopTime_cuda,cflCondition_cuda;
-	//int gridRows_cuda, gridCols_cuda, currentStep_cuda, n_cuda;
-
-	int* runcuda;
-	int run_host;
-
-
-	__device__ void getSubgridCUDA3D( const int i, tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* caller, double* a);
-
-	__device__ void updateSubgridCUDA3D( const int i, tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* caller, double* a);
-
-	__device__ void insertSubgridCUDA3D( double u, const int i );
-
-	__device__ void runSubgridCUDA3D( int boundaryCondition, double* u, int subGridID);
-
-	/*__global__ void runCUDA();*/
-
-	//__device__ void synchronizeCUDA();
-
-	__device__ int getOwnerCUDA3D( int i) const;
-
-	__device__ int getSubgridValueCUDA3D( int i ) const;
-
-	__device__ void setSubgridValueCUDA3D( int i, int value );
-
-	__device__ int getBoundaryConditionCUDA3D( int i ) const;
-
-	__device__ void setBoundaryConditionCUDA3D( int i, int value );
-
-	//__device__ bool initCUDA( tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-	/*__global__ void initRunCUDA(tnlParallelEikonalSolver<Scheme, double, TNL::Devices::Host, int >* caller);*/
-
-#endif
-
-};
-
-
-
-
-
-
-#ifdef HAVE_CUDA
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void runCUDA2D(tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void initRunCUDA2D(tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* caller);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void initCUDA2D( tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr, int * ptr2, int* ptr3);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void synchronizeCUDA2D(tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void synchronize2CUDA2D(tnlParallelEikonalSolver<2, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-
-
-
-
-
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void runCUDA3D(tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* caller);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void initRunCUDA3D(tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* caller);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void initCUDA3D( tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr, int * ptr2, int* ptr3);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void synchronizeCUDA3D(tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__ void synchronize2CUDA3D(tnlParallelEikonalSolver<3, SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
-#endif
-
-
-#ifdef HAVE_CUDA
-__cuda_callable__
-double fabsMin( double x, double y)
-{
-	double fx = fabs(x);
-
-	if(Min(fx,fabs(y)) == fx)
-		return x;
-	else
-		return y;
-}
-
-__cuda_callable__
-double atomicFabsMin(double* address, double val)
-{
-	unsigned long long int* address_as_ull =
-						  (unsigned long long int*)address;
-	unsigned long long int old = *address_as_ull, assumed;
-	do {
-		assumed = old;
-			old = atomicCAS(address_as_ull, assumed,__double_as_longlong( fabsMin(__longlong_as_double(assumed),val) ));
-	} while (assumed != old);
-	return __longlong_as_double(old);
-}
-
-#endif
-
-#include "tnlParallelEikonalSolver2D_impl.h"
-#include "tnlParallelEikonalSolver3D_impl.h"
-#endif /* TNLPARALLELEIKONALSOLVER_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver2D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver2D_impl.h
deleted file mode 100644
index 76cf49bc8aa28890d598fe010aa777acb2c6edfd..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver2D_impl.h
+++ /dev/null
@@ -1,1928 +0,0 @@
-/***************************************************************************
-                          tnlParallelEikonalSolver2D_impl.h  -  description
-                             -------------------
-    begin                : Nov 28 , 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 TNLPARALLELEIKONALSOLVER2D_IMPL_H_
-#define TNLPARALLELEIKONALSOLVER2D_IMPL_H_
-
-
-#include "tnlParallelEikonalSolver.h"
-#include <core/mfilename.h>
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::tnlParallelEikonalSolver()
-{
-	cout << "a" <<std::endl;
-	this->device = tnlCudaDevice;  /////////////// tnlCuda Device --- vypocet na GPU, TNL::Devices::HostDevice   ---    vypocet na CPU
-
-#ifdef HAVE_CUDA
-	if(this->device == tnlCudaDevice)
-	{
-	run_host = 1;
-	}
-#endif
-
-	cout << "b" <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::test()
-{
-/*
-	for(int i =0; i < this->subgridValues.getSize(); i++ )
-	{
-		insertSubgrid(getSubgrid(i), i);
-	}
-*/
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-
-bool tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::init( const Config::ParameterContainer& parameters )
-{
-	cout << "Initializating solver..." <<std::endl;
-	const String& meshLocation = parameters.getParameter <String>("mesh");
-	this->mesh.load( meshLocation );
-
-	this->n = parameters.getParameter <int>("subgrid-size");
-	cout << "Setting N to " << this->n <<std::endl;
-
-	this->subMesh.setDimensions( this->n, this->n );
-	this->subMesh.setDomain( Containers::StaticVector<2,double>(0.0, 0.0),
-							 Containers::StaticVector<2,double>(mesh.template getSpaceStepsProducts< 1, 0 >()*(double)(this->n), mesh.template getSpaceStepsProducts< 0, 1 >()*(double)(this->n)) );
-
-	this->subMesh.save("submesh.tnl");
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	this->u0.load( initialCondition );
-
-	//cout << this->mesh.getCellCenter(0) <<std::endl;
-
-	this->delta = parameters.getParameter <double>("delta");
-	this->delta *= mesh.template getSpaceStepsProducts< 1, 0 >()*mesh.template getSpaceStepsProducts< 0, 1 >();
-
-	cout << "Setting delta to " << this->delta <<std::endl;
-
-	this->tau0 = parameters.getParameter <double>("initial-tau");
-	cout << "Setting initial tau to " << this->tau0 <<std::endl;
-	this->stopTime = parameters.getParameter <double>("stop-time");
-
-	this->cflCondition = parameters.getParameter <double>("cfl-condition");
-	this -> cflCondition *= sqrt(mesh.template getSpaceStepsProducts< 1, 0 >()*mesh.template getSpaceStepsProducts< 0, 1 >());
-	cout << "Setting CFL to " << this->cflCondition <<std::endl;
-
-	stretchGrid();
-	this->stopTime /= (double)(this->gridCols);
-	this->stopTime *= (1.0+1.0/((double)(this->n) - 2.0));
-	cout << "Setting stopping time to " << this->stopTime <<std::endl;
-	//this->stopTime = 1.5*((double)(this->n))*parameters.getParameter <double>("stop-time")*this->mesh.template getSpaceStepsProducts< 1, 0 >();
-	//cout << "Setting stopping time to " << this->stopTime <<std::endl;
-
-	cout << "Initializating scheme..." <<std::endl;
-	if(!this->schemeHost.init(parameters))
-	{
-		cerr << "SchemeHost failed to initialize." <<std::endl;
-		return false;
-	}
-	cout << "Scheme initialized." <<std::endl;
-
-	test();
-
-	VectorType* tmp = new VectorType[subgridValues.getSize()];
-	bool containsCurve = false;
-
-#ifdef HAVE_CUDA
-
-	if(this->device == tnlCudaDevice)
-	{
-	/*cout << "Testing... " <<std::endl;
-	if(this->device == tnlCudaDevice)
-	{
-	if( !initCUDA2D(parameters, gridRows, gridCols) )
-		return false;
-	}*/
-		//cout << "s" <<std::endl;
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >));
-	//cout << "s" <<std::endl;
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >), cudaMemcpyHostToDevice);
-	//cout << "s" <<std::endl;
-	double** tmpdev = NULL;
-	cudaMalloc(&tmpdev, sizeof(double*));
-	//double* tmpw;
-	cudaMalloc(&(this->tmpw), this->work_u.getSize()*sizeof(double));
-	cudaMalloc(&(this->runcuda), sizeof(int));
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	int* tmpUC;
-	cudaMalloc(&(tmpUC), this->work_u.getSize()*sizeof(int));
-	cudaMemcpy(tmpUC, this->unusedCell.getData(), this->unusedCell.getSize()*sizeof(int), cudaMemcpyHostToDevice);
-
-	initCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<1,1>>>(this->cudaSolver, (this->tmpw), (this->runcuda),tmpUC);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	//cout << "s " <<std::endl;
-	//cudaMalloc(&(cudaSolver->work_u_cuda), this->work_u.getSize()*sizeof(double));
-	double* tmpu = NULL;
-
-	cudaMemcpy(&tmpu, tmpdev,sizeof(double*), cudaMemcpyDeviceToHost);
-	//printf("%p %p \n",tmpu,tmpw);
-	cudaMemcpy((this->tmpw), this->work_u.getData(), this->work_u.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	//cout << "s "<<std::endl;
-
-	}
-#endif
-
-	if(this->device == TNL::Devices::HostDevice)
-	{
-	for(int i = 0; i < this->subgridValues.getSize(); i++)
-	{
-
-		if(! tmp[i].setSize(this->n * this->n))
-			cout << "Could not allocate tmp["<< i <<"] array." <<std::endl;
-			tmp[i] = getSubgrid(i);
-		containsCurve = false;
-
-		for(int j = 0; j < tmp[i].getSize(); j++)
-		{
-			if(tmp[i][0]*tmp[i][j] <= 0.0)
-			{
-				containsCurve = true;
-				j=tmp[i].getSize();
-			}
-
-		}
-		if(containsCurve)
-		{
-			//cout << "Computing initial SDF on subgrid " << i << "." <<std::endl;
-			tmp[i] = runSubgrid(0, tmp[i],i);
-			insertSubgrid(tmp[i], i);
-			setSubgridValue(i, 4);
-			//cout << "Computed initial SDF on subgrid " << i  << "." <<std::endl;
-		}
-		containsCurve = false;
-
-	}
-	}
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-//		cout << "pre 1 kernel" <<std::endl;
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		dim3 threadsPerBlock(this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		initRunCUDA2D<SchemeTypeHost,SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock,3*this->n*this->n*sizeof(double)>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-//		cout << "post 1 kernel" <<std::endl;
-
-	}
-#endif
-
-
-	this->currentStep = 1;
-	if(this->device == TNL::Devices::HostDevice)
-		synchronize();
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		dim3 threadsPerBlock(this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows);
-		//double * test = (double*)malloc(this->work_u.getSize()*sizeof(double));
-		//cout << test[0] <<"   " << test[1] <<"   " << test[2] <<"   " << test[3] <<std::endl;
-		//cudaMemcpy(/*this->work_u.getData()*/ test, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//cout << this->tmpw << "   " <<  test[0] <<"   " << test[1] << "   " <<test[2] << "   " <<test[3] <<std::endl;
-
-		TNL_CHECK_CUDA_DEVICE;
-
-		synchronizeCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		synchronize2CUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,1>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		//cout << test[0] << "   " <<test[1] <<"   " << test[2] << "   " <<test[3] <<std::endl;
-		//cudaMemcpy(/*this->work_u.getData()*/ test, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//TNL_CHECK_CUDA_DEVICE;
-		//cout << this->tmpw << "   " <<  test[0] << "   " <<test[1] << "   " <<test[2] <<"   " << test[3] <<std::endl;
-		//free(test);
-
-	}
-
-#endif
-	cout << "Solver initialized." <<std::endl;
-
-	return true;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::run()
-{
-	if(this->device == TNL::Devices::HostDevice)
-	{
-
-	bool end = false;
-	while ((this->boundaryConditions.max() > 0 ) || !end)
-	{
-		if(this->boundaryConditions.max() == 0 )
-			end=true;
-		else
-			end=false;
-#ifdef HAVE_OPENMP
-#pragma omp parallel for num_threads(4) schedule(dynamic)
-#endif
-		for(int i = 0; i < this->subgridValues.getSize(); i++)
-		{
-			if(getSubgridValue(i) != INT_MAX)
-			{
-				VectorType tmp;
-				tmp.setSize(this->n * this->n);
-				//cout << "subMesh: " << i << ", BC: " << getBoundaryCondition(i) <<std::endl;
-
-				if(getSubgridValue(i) == currentStep+4)
-				{
-
-				if(getBoundaryCondition(i) & 1)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(1, tmp ,i);
-					insertSubgrid( tmp, i);
-					this->calculationsCount[i]++;
-				}
-				if(getBoundaryCondition(i) & 2)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(1, tmp ,i);
-					insertSubgrid( tmp, 2);
-					this->calculationsCount[i]++;
-				}
-				if(getBoundaryCondition(i) & 4)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(4, tmp ,i);
-					insertSubgrid( tmp, i);
-					this->calculationsCount[i]++;
-				}
-				if(getBoundaryCondition(i) & 8)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(8, tmp ,i);
-					insertSubgrid( tmp, i);
-					this->calculationsCount[i]++;
-				}
-				}
-
-				if( ((getBoundaryCondition(i) & 2) )|| (getBoundaryCondition(i) & 1)//)
-					/*	&&(!(getBoundaryCondition(i) & 5) && !(getBoundaryCondition(i) & 10)) */)
-				{
-					//cout << "3 @ " << getBoundaryCondition(i) <<std::endl;
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(1, tmp ,i);
-					insertSubgrid( tmp, 3);
-				}
-				if( ((getBoundaryCondition(i) & 4) )|| (getBoundaryCondition(i) & 1)//)
-					/*	&&(!(getBoundaryCondition(i) & 3) && !(getBoundaryCondition(i) & 12)) */)
-				{
-					//cout << "5 @ " << getBoundaryCondition(i) <<std::endl;
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(5, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( ((getBoundaryCondition(i) & 2) )|| (getBoundaryCondition(i) & 8)//)
-					/*	&&(!(getBoundaryCondition(i) & 12) && !(getBoundaryCondition(i) & 3))*/ )
-				{
-					//cout << "10 @ " << getBoundaryCondition(i) <<std::endl;
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(10, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if(   ((getBoundaryCondition(i) & 4) )|| (getBoundaryCondition(i) & 8)//)
-					/*&&(!(getBoundaryCondition(i) & 10) && !(getBoundaryCondition(i) & 5)) */)
-				{
-					//cout << "12 @ " << getBoundaryCondition(i) <<std::endl;
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(12, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-
-
-				/*if(getBoundaryCondition(i))
-				{
-					insertSubgrid( runSubgrid(15, getSubgrid(i),i), i);
-				}*/
-
-				setBoundaryCondition(i, 0);
-
-				setSubgridValue(i, getSubgridValue(i)-1);
-
-			}
-		}
-		synchronize();
-	}
-	}
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		//cout << "fn" <<std::endl;
-		bool end_cuda = false;
-		dim3 threadsPerBlock(this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		//cudaMalloc(&runcuda,sizeof(bool));
-		//cudaMemcpy(runcuda, &run_host, sizeof(bool), cudaMemcpyHostToDevice);
-		//cout << "fn" <<std::endl;
-		bool* tmpb;
-		//cudaMemcpy(tmpb, &(cudaSolver->runcuda),sizeof(bool*), cudaMemcpyDeviceToHost);
-		//cudaDeviceSynchronize();
-		//TNL_CHECK_CUDA_DEVICE;
-		cudaMemcpy(&(this->run_host),this->runcuda,sizeof(int), cudaMemcpyDeviceToHost);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		//cout << "fn" <<std::endl;
-		int i = 1;
-		time_diff = 0.0;
-		while (run_host || !end_cuda)
-		{
-			cout << "Computing at step "<< i++ <<std::endl;
-			if(run_host != 0 )
-				end_cuda = true;
-			else
-				end_cuda = false;
-			//cout << "a" <<std::endl;
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			start = std::clock();
-			runCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock,3*this->n*this->n*sizeof(double)>>>(this->cudaSolver);
-			//cout << "a" <<std::endl;
-			cudaDeviceSynchronize();
-			time_diff += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
-
-			//start = std::clock();
-			synchronizeCUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			synchronize2CUDA2D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,1>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			//time_diff += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
-
-
-			//cout << "a" <<std::endl;
-			//run_host = false;
-			//cout << "in kernel loop" << run_host <<std::endl;
-			//cudaMemcpy(tmpb, &(cudaSolver->runcuda),sizeof(bool*), cudaMemcpyDeviceToHost);
-			cudaMemcpy(&run_host, (this->runcuda),sizeof(int), cudaMemcpyDeviceToHost);
-			//cout << "in kernel loop" << run_host <<std::endl;
-		}
-		cout << "Solving time was: " << time_diff <<std::endl;
-		//cout << "b" <<std::endl;
-
-		//double* tmpu;
-		//cudaMemcpy(tmpu, &(cudaSolver->work_u_cuda),sizeof(double*), cudaMemcpyHostToDevice);
-		//cudaMemcpy(this->work_u.getData(), tmpu, this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//cout << this->work_u.getData()[0] <<std::endl;
-
-		//double * test = (double*)malloc(this->work_u.getSize()*sizeof(double));
-		//cout << test[0] << test[1] << test[2] << test[3] <<std::endl;
-		cudaMemcpy(this->work_u.getData()/* test*/, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//cout << this->tmpw << "   " <<  test[0] << test[1] << test[2] << test[3] <<std::endl;
-		//free(test);
-
-		cudaDeviceSynchronize();
-	}
-#endif
-	contractGrid();
-	this->u0.save("u-00001.tnl");
-	cout << "Maximum number of calculations on one subgrid was " << this->calculationsCount.absMax() <<std::endl;
-	cout << "Average number of calculations on one subgrid was " << ( (double) this->calculationsCount.sum() / (double) this->calculationsCount.getSize() ) <<std::endl;
-	cout << "Solver finished" <<std::endl;
-
-#ifdef HAVE_CUDA
-	if(this->device == tnlCudaDevice)
-	{
-		cudaFree(this->runcuda);
-		cudaFree(this->tmpw);
-		cudaFree(this->cudaSolver);
-	}
-#endif
-
-}
-
-//north - 1, east - 2, west - 4, south - 8
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::synchronize() //needs fix ---- maybe not anymore --- but frankly: yeah, it does -- aaaa-and maybe fixed now
-{
-	cout << "Synchronizig..." <<std::endl;
-	int tmp1, tmp2;
-	int grid1, grid2;
-
-	if(this->currentStep & 1)
-	{
-		for(int j = 0; j < this->gridRows - 1; j++)
-		{
-			for (int i = 0; i < this->gridCols*this->n; i++)
-			{
-				tmp1 = this->gridCols*this->n*((this->n-1)+j*this->n) + i;
-				tmp2 = this->gridCols*this->n*((this->n)+j*this->n) + i;
-				grid1 = getSubgridValue(getOwner(tmp1));
-				grid2 = getSubgridValue(getOwner(tmp2));
-				if(getOwner(tmp1)==getOwner(tmp2))
-					cout << "i, j" << i << "," << j <<std::endl;
-				if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-				{
-					this->work_u[tmp2] = this->work_u[tmp1];
-					this->unusedCell[tmp2] = 0;
-					if(grid2 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp2), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp2)) & 8) )
-						setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+8);
-				}
-				else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-				{
-					this->work_u[tmp1] = this->work_u[tmp2];
-					this->unusedCell[tmp1] = 0;
-					if(grid1 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp1), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp1)) & 1) )
-						setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+1);
-				}
-			}
-		}
-
-	}
-	else
-	{
-		for(int i = 1; i < this->gridCols; i++)
-		{
-			for (int j = 0; j < this->gridRows*this->n; j++)
-			{
-				tmp1 = this->gridCols*this->n*j + i*this->n - 1;
-				tmp2 = this->gridCols*this->n*j + i*this->n ;
-				grid1 = getSubgridValue(getOwner(tmp1));
-				grid2 = getSubgridValue(getOwner(tmp2));
-				if(getOwner(tmp1)==getOwner(tmp2))
-					cout << "i, j" << i << "," << j <<std::endl;
-				if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-				{
-					this->work_u[tmp2] = this->work_u[tmp1];
-					this->unusedCell[tmp2] = 0;
-					if(grid2 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp2), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp2)) & 4) )
-						setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+4);
-				}
-				else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-				{
-					this->work_u[tmp1] = this->work_u[tmp2];
-					this->unusedCell[tmp1] = 0;
-					if(grid1 == INT_MAX)
-					{
-						setSubgridValue(getOwner(tmp1), -INT_MAX);
-					}
-					if(! (getBoundaryCondition(getOwner(tmp1)) & 2) )
-						setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+2);
-				}
-			}
-		}
-	}
-
-
-	this->currentStep++;
-	int stepValue = this->currentStep + 4;
-	for (int i = 0; i < this->subgridValues.getSize(); i++)
-	{
-		if( getSubgridValue(i) == -INT_MAX )
-			setSubgridValue(i, stepValue);
-	}
-
-	cout << "Grid synchronized at step " << (this->currentStep - 1 ) <<std::endl;
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getOwner(int i) const
-{
-
-	return (i / (this->gridCols*this->n*this->n))*this->gridCols + (i % (this->gridCols*this->n))/this->n;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgridValue( int i ) const
-{
-	return this->subgridValues[i];
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setSubgridValue(int i, int value)
-{
-	this->subgridValues[i] = value;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getBoundaryCondition( int i ) const
-{
-	return this->boundaryConditions[i];
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setBoundaryCondition(int i, int value)
-{
-	this->boundaryConditions[i] = value;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::stretchGrid()
-{
-	cout << "Stretching grid..." <<std::endl;
-
-
-	this->gridCols = ceil( ((double)(this->mesh.getDimensions().x()-1)) / ((double)(this->n-1)) );
-	this->gridRows = ceil( ((double)(this->mesh.getDimensions().y()-1)) / ((double)(this->n-1)) );
-
-	//this->gridCols = (this->mesh.getDimensions().x()-1) / (this->n-1) ;
-	//this->gridRows = (this->mesh.getDimensions().y()-1) / (this->n-1) ;
-
-	cout << "Setting gridCols to " << this->gridCols << "." <<std::endl;
-	cout << "Setting gridRows to " << this->gridRows << "." <<std::endl;
-
-	this->subgridValues.setSize(this->gridCols*this->gridRows);
-	this->subgridValues.setValue(0);
-	this->boundaryConditions.setSize(this->gridCols*this->gridRows);
-	this->boundaryConditions.setValue(0);
-	this->calculationsCount.setSize(this->gridCols*this->gridRows);
-	this->calculationsCount.setValue(0);
-
-	for(int i = 0; i < this->subgridValues.getSize(); i++ )
-	{
-		this->subgridValues[i] = INT_MAX;
-		this->boundaryConditions[i] = 0;
-	}
-
-	int stretchedSize = this->n*this->n*this->gridCols*this->gridRows;
-
-	if(!this->work_u.setSize(stretchedSize))
-		cerr << "Could not allocate memory for stretched grid." <<std::endl;
-	if(!this->unusedCell.setSize(stretchedSize))
-		cerr << "Could not allocate memory for supporting stretched grid." <<std::endl;
-	int idealStretch =this->mesh.getDimensions().x() + (this->mesh.getDimensions().x()-2)/(this->n-1);
-	cout << idealStretch <<std::endl;
-
-	for(int i = 0; i < stretchedSize; i++)
-	{
-		this->unusedCell[i] = 1;
-		int diff =(this->n*this->gridCols) - idealStretch ;
-		//cout << "diff = " << diff <<endl;
-		int k = i/this->n - i/(this->n*this->gridCols) + this->mesh.getDimensions().x()*(i/(this->n*this->n*this->gridCols)) + (i/(this->n*this->gridCols))*diff;
-
-		if(i%(this->n*this->gridCols) - idealStretch  >= 0)
-		{
-			//cout << i%(this->n*this->gridCols) - idealStretch +1 <<std::endl;
-			k+= i%(this->n*this->gridCols) - idealStretch +1 ;
-		}
-
-		if(i/(this->n*this->gridCols) - idealStretch + 1  > 0)
-		{
-			//cout << i/(this->n*this->gridCols) - idealStretch + 1  <<std::endl;
-			k+= (i/(this->n*this->gridCols) - idealStretch +1 )* this->mesh.getDimensions().x() ;
-		}
-
-		//cout << "i = " << i << " : i-k = " << i-k <<std::endl;
-		/*int j=(i % (this->n*this->gridCols)) - ( (this->mesh.getDimensions().x() - this->n)/(this->n - 1) + this->mesh.getDimensions().x() - 1)
-				+ (this->n*this->gridCols - this->mesh.getDimensions().x())*(i/(this->n*this->n*this->gridCols)) ;
-
-		if(j > 0)
-			k += j;
-
-		int l = i-k - (this->u0.getSize() - 1);
-		int m = (l % this->mesh.getDimensions().x());
-
-		if(l>0)
-			k+= l + ( (l / this->mesh.getDimensions().x()) + 1 )*this->mesh.getDimensions().x() - (l % this->mesh.getDimensions().x());*/
-
-		this->work_u[i] = this->u0[i-k];
-		//cout << (i-k) <<endl;
-	}
-
-
-	cout << "Grid stretched." <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::contractGrid()
-{
-	cout << "Contracting grid..." <<std::endl;
-	int stretchedSize = this->n*this->n*this->gridCols*this->gridRows;
-
-	int idealStretch =this->mesh.getDimensions().x() + (this->mesh.getDimensions().x()-2)/(this->n-1);
-	cout << idealStretch <<std::endl;
-
-	for(int i = 0; i < stretchedSize; i++)
-	{
-		int diff =(this->n*this->gridCols) - idealStretch ;
-		int k = i/this->n - i/(this->n*this->gridCols) + this->mesh.getDimensions().x()*(i/(this->n*this->n*this->gridCols)) + (i/(this->n*this->gridCols))*diff;
-
-		if((i%(this->n*this->gridCols) - idealStretch  < 0) && (i/(this->n*this->gridCols) - idealStretch + 1  <= 0))
-		{
-			//cout << i <<" : " <<i-k<<std::endl;
-			this->u0[i-k] = this->work_u[i];
-		}
-
-	}
-
-	cout << "Grid contracted" <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-typename tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::VectorType
-tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgrid( const int i ) const
-{
-	VectorType u;
-	u.setSize(this->n*this->n);
-
-	for( int j = 0; j < u.getSize(); j++)
-	{
-		u[j] = this->work_u[ (i / this->gridCols) * this->n*this->n*this->gridCols
-		                     + (i % this->gridCols) * this->n
-		                     + (j/this->n) * this->n*this->gridCols
-		                     + (j % this->n) ];
-	}
-	return u;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::insertSubgrid( VectorType u, const int i )
-{
-
-	for( int j = 0; j < this->n*this->n; j++)
-	{
-		int index = (i / this->gridCols)*this->n*this->n*this->gridCols
-					+ (i % this->gridCols)*this->n
-					+ (j/this->n)*this->n*this->gridCols
-					+ (j % this->n);
-		//OMP LOCK index
-		if( (fabs(this->work_u[index]) > fabs(u[j])) || (this->unusedCell[index] == 1) )
-		{
-			this->work_u[index] = u[j];
-			this->unusedCell[index] = 0;
-		}
-		//OMP UNLOCK index
-	}
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-typename tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::VectorType
-tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::runSubgrid( int boundaryCondition, VectorType u, int subGridID)
-{
-
-	VectorType fu;
-
-	fu.setLike(u);
-	fu.setValue( 0.0 );
-
-/*
- *          Insert Euler-Solver Here
- */
-
-	/**/
-
-	/*for(int i = 0; i < u.getSize(); i++)
-	{
-		int x = this->subMesh.getCellCoordinates(i).x();
-		int y = this->subMesh.getCellCoordinates(i).y();
-
-		if(x == 0 && (boundaryCondition & 4) && y ==0)
-		{
-			if((u[subMesh.getCellYSuccessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 0, 1 >() > 1.0)
-			{
-				//cout << "x = 0; y = 0" <<std::endl;
-				u[i] = u[subMesh.getCellYSuccessor( i )] - subMesh.template getSpaceStepsProducts< 0, 1 >();
-			}
-		}
-		else if(x == 0 && (boundaryCondition & 4) && y == subMesh.getDimensions().y() - 1)
-		{
-			if((u[subMesh.getCellYPredecessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 0, 1 >() > 1.0)
-			{
-				//cout << "x = 0; y = n" <<std::endl;
-				u[i] = u[subMesh.getCellYPredecessor( i )] - subMesh.template getSpaceStepsProducts< 0, 1 >();
-			}
-		}
-
-
-		else if(x == subMesh.getDimensions().x() - 1 && (boundaryCondition & 2) && y ==0)
-		{
-			if((u[subMesh.getCellYSuccessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 0, 1 >() > 1.0)
-			{
-				//cout << "x = n; y = 0" <<std::endl;
-				u[i] = u[subMesh.getCellYSuccessor( i )] - subMesh.template getSpaceStepsProducts< 0, 1 >();
-			}
-		}
-		else if(x == subMesh.getDimensions().x() - 1 && (boundaryCondition & 2) && y == subMesh.getDimensions().y() - 1)
-		{
-			if((u[subMesh.getCellYPredecessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 0, 1 >() > 1.0)
-			{
-				//cout << "x = n; y = n" <<std::endl;
-				u[i] = u[subMesh.getCellYPredecessor( i )] - subMesh.template getSpaceStepsProducts< 0, 1 >();
-			}
-		}
-
-
-		else if(y == 0 && (boundaryCondition & 8) && x ==0)
-		{
-			if((u[subMesh.getCellXSuccessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 1, 0 >() > 1.0)
-			{
-				//cout << "y = 0; x = 0" <<std::endl;
-				u[i] = u[subMesh.getCellXSuccessor( i )] - subMesh.template getSpaceStepsProducts< 1, 0 >();
-			}
-		}
-		else if(y == 0 && (boundaryCondition & 8) && x == subMesh.getDimensions().x() - 1)
-		{
-			if((u[subMesh.getCellXPredecessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 1, 0 >() > 1.0)
-			{
-				//cout << "y = 0; x = n" <<std::endl;
-				u[i] = u[subMesh.getCellXPredecessor( i )] - subMesh.template getSpaceStepsProducts< 1, 0 >();
-			}
-		}
-
-
-		else if(y == subMesh.getDimensions().y() - 1 && (boundaryCondition & 1) && x ==0)
-		{
-			if((u[subMesh.getCellXSuccessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 1, 0 >() > 1.0)			{
-				//cout << "y = n; x = 0" <<std::endl;
-				u[i] = u[subMesh.getCellXSuccessor( i )] - subMesh.template getSpaceStepsProducts< 1, 0 >();
-			}
-		}
-		else if(y == subMesh.getDimensions().y() - 1 && (boundaryCondition & 1) && x == subMesh.getDimensions().x() - 1)
-		{
-			if((u[subMesh.getCellXPredecessor( i )] - u[i])/subMesh.template getSpaceStepsProducts< 1, 0 >() > 1.0)
-			{
-				//cout << "y = n; x = n" <<std::endl;
-				u[i] = u[subMesh.getCellXPredecessor( i )] - subMesh.template getSpaceStepsProducts< 1, 0 >();
-			}
-		}
-	}*/
-
-	/**/
-
-
-/*	bool tmp = false;
-	for(int i = 0; i < u.getSize(); i++)
-	{
-		if(u[0]*u[i] <= 0.0)
-			tmp=true;
-	}
-
-
-	if(tmp)
-	{}
-	else if(boundaryCondition == 4)
-	{
-		int i;
-		for(i = 0; i < u.getSize() - subMesh.getDimensions().x() ; i=subMesh.getCellYSuccessor(i))
-		{
-			int j;
-			for(j = i; j < subMesh.getDimensions().x() - 1; j=subMesh.getCellXSuccessor(j))
-			{
-				u[j] = u[i];
-			}
-			u[j] = u[i];
-		}
-		int j;
-		for(j = i; j < subMesh.getDimensions().x() - 1; j=subMesh.getCellXSuccessor(j))
-		{
-			u[j] = u[i];
-		}
-		u[j] = u[i];
-	}
-	else if(boundaryCondition == 8)
-	{
-		int i;
-		for(i = 0; i < subMesh.getDimensions().x() - 1; i=subMesh.getCellXSuccessor(i))
-		{
-			int j;
-			for(j = i; j < u.getSize() - subMesh.getDimensions().x(); j=subMesh.getCellYSuccessor(j))
-			{
-				u[j] = u[i];
-			}
-			u[j] = u[i];
-		}
-		int j;
-		for(j = i; j < u.getSize() - subMesh.getDimensions().x(); j=subMesh.getCellYSuccessor(j))
-		{
-			u[j] = u[i];
-		}
-		u[j] = u[i];
-
-	}
-	else if(boundaryCondition == 2)
-	{
-		int i;
-		for(i = subMesh.getDimensions().x() - 1; i < u.getSize() - subMesh.getDimensions().x() ; i=subMesh.getCellYSuccessor(i))
-		{
-			int j;
-			for(j = i; j > (i-1)*subMesh.getDimensions().x(); j=subMesh.getCellXPredecessor(j))
-			{
-				u[j] = u[i];
-			}
-			u[j] = u[i];
-		}
-		int j;
-		for(j = i; j > (i-1)*subMesh.getDimensions().x(); j=subMesh.getCellXPredecessor(j))
-		{
-			u[j] = u[i];
-		}
-		u[j] = u[i];
-	}
-	else if(boundaryCondition == 1)
-	{
-		int i;
-		for(i = (subMesh.getDimensions().y() - 1)*subMesh.getDimensions().x(); i < u.getSize() - 1; i=subMesh.getCellXSuccessor(i))
-		{
-			int j;
-			for(j = i; j >=subMesh.getDimensions().x(); j=subMesh.getCellYPredecessor(j))
-			{
-				u[j] = u[i];
-			}
-			u[j] = u[i];
-		}
-		int j;
-		for(j = i; j >=subMesh.getDimensions().x(); j=subMesh.getCellYPredecessor(j))
-		{
-			u[j] = u[i];
-		}
-		u[j] = u[i];
-	}
-*/
-	/**/
-
-
-
-	bool tmp = false;
-	for(int i = 0; i < u.getSize(); i++)
-	{
-		if(u[0]*u[i] <= 0.0)
-			tmp=true;
-		int centerGID = (this->n*(subGridID / this->gridRows)+ (this->n >> 1))*(this->n*this->gridCols) + this->n*(subGridID % this->gridRows) + (this->n >> 1);
-		if(this->unusedCell[centerGID] == 0 || boundaryCondition == 0)
-			tmp = true;
-	}
-	//if(this->currentStep + 3 < getSubgridValue(subGridID))
-		//tmp = true;
-
-
-	double value = sign(u[0]) * u.absMax();
-
-	if(tmp)
-	{}
-
-
-	//north - 1, east - 2, west - 4, south - 8
-	else if(boundaryCondition == 4)
-	{
-		for(int i = 0; i < this->n; i++)
-			for(int j = 1;j < this->n; j++)
-				//if(fabs(u[i*this->n + j]) <  fabs(u[i*this->n]))
-				u[i*this->n + j] = value;// u[i*this->n];
-	}
-	else if(boundaryCondition == 2)
-	{
-		for(int i = 0; i < this->n; i++)
-			for(int j =0 ;j < this->n -1; j++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[(i+1)*this->n - 1]))
-				u[i*this->n + j] = value;// u[(i+1)*this->n - 1];
-	}
-	else if(boundaryCondition == 1)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 0;i < this->n - 1; i++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j + this->n*(this->n - 1)]))
-				u[i*this->n + j] = value;// u[j + this->n*(this->n - 1)];
-	}
-	else if(boundaryCondition == 8)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 1;i < this->n; i++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j]))
-				u[i*this->n + j] = value;// u[j];
-	}
-
-/*
-
-	else if(boundaryCondition == 5)
-	{
-		for(int i = 0; i < this->n - 1; i++)
-			for(int j = 1;j < this->n; j++)
-				//if(fabs(u[i*this->n + j]) <  fabs(u[i*this->n]))
-				u[i*this->n + j] = value;// u[i*this->n];
-	}
-	else if(boundaryCondition == 10)
-	{
-		for(int i = 1; i < this->n; i++)
-			for(int j =0 ;j < this->n -1; j++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[(i+1)*this->n - 1]))
-				u[i*this->n + j] = value;// u[(i+1)*this->n - 1];
-	}
-	else if(boundaryCondition == 3)
-	{
-		for(int j = 0; j < this->n - 1; j++)
-			for(int i = 0;i < this->n - 1; i++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j + this->n*(this->n - 1)]))
-				u[i*this->n + j] = value;// u[j + this->n*(this->n - 1)];
-	}
-	else if(boundaryCondition == 12)
-	{
-		for(int j = 1; j < this->n; j++)
-			for(int i = 1;i < this->n; i++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j]))
-				u[i*this->n + j] = value;// u[j];
-	}
-*/
-
-
-	/**/
-
-	/*if (u.max() > 0.0)
-		this->stopTime *=(double) this->gridCols;*/
-
-
-   double time = 0.0;
-   double currentTau = this->tau0;
-   double finalTime = this->stopTime;// + 3.0*(u.max() - u.min());
-   if( time + currentTau > finalTime ) currentTau = finalTime - time;
-
-   double maxResidue( 1.0 );
-   //double lastResidue( 10000.0 );
-   tnlGridEntity<MeshType, 2, tnlGridEntityNoStencilStorage > Entity(subMesh);
-   tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-   while( time < finalTime /*|| maxResidue > subMesh.template getSpaceStepsProducts< 1, 0 >()*/)
-   {
-      /****
-       * Compute the RHS
-       */
-
-      for( int i = 0; i < fu.getSize(); i ++ )
-      {
-			Entity.setCoordinates(Containers::StaticVector<2,int>(i % subMesh.getDimensions().x(),i / subMesh.getDimensions().x()));
-			Entity.refresh();
-			neighborEntities.refresh(subMesh,Entity.getIndex());
-    	  fu[ i ] = schemeHost.getValue( this->subMesh, i, Containers::StaticVector<2,int>(i % subMesh.getDimensions().x(),i / subMesh.getDimensions().x()), u, time, boundaryCondition,neighborEntities);
-      }
-      maxResidue = fu. absMax();
-
-
-      if( this -> cflCondition * maxResidue != 0.0)
-    	  currentTau =  this -> cflCondition / maxResidue;
-
-     /* if (maxResidue < 0.05)
-    	 std::cout << "Max < 0.05" <<std::endl;*/
-      if(currentTau > 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >())
-      {
-    	  //cout << currentTau << " >= " << 2.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >() <<std::endl;
-    	  currentTau = 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >();
-      }
-      /*if(maxResidue > lastResidue)
-    	  currentTau *=(1.0/10.0);*/
-
-
-      if( time + currentTau > finalTime ) currentTau = finalTime - time;
-//      for( int i = 0; i < fu.getSize(); i ++ )
-//      {
-//    	  //cout << "Too big RHS! i = " << i << ", fu = " << fu[i] << ", u = " << u[i] <<std::endl;
-//    	  if((u[i]+currentTau * fu[ i ])*u[i] < 0.0 && fu[i] != 0.0 && u[i] != 0.0 )
-//    		  currentTau = fabs(u[i]/(2.0*fu[i]));
-//
-//      }
-
-
-      for( int i = 0; i < fu.getSize(); i ++ )
-      {
-    	  double add = u[i] + currentTau * fu[ i ];
-    	  //if( fabs(u[i]) < fabs(add) or (this->subgridValues[subGridID] == this->currentStep +4) )
-    		  u[ i ] = add;
-      }
-      time += currentTau;
-
-      //cout << '\r' << flush;
-     //cout << maxResidue << "   " << currentTau << " @ " << time << flush;
-     //lastResidue = maxResidue;
-   }
-   //cout << "Time: " << time << ", Res: " << maxResidue <<endl;
-	/*if (u.max() > 0.0)
-		this->stopTime /=(double) this->gridCols;*/
-
-	VectorType solution;
-	solution.setLike(u);
-    for( int i = 0; i < u.getSize(); i ++ )
-  	{
-    	solution[i]=u[i];
-   	}
-	return solution;
-}
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgridCUDA2D( const int i ,tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller, double* a)
-{
-	//int j = threadIdx.x + threadIdx.y * blockDim.x;
-	int th = (blockIdx.y) * caller->n*caller->n*caller->gridCols
-            + (blockIdx.x) * caller->n
-            + threadIdx.y * caller->n*caller->gridCols
-            + threadIdx.x;
-	//printf("i= %d,j= %d,th= %d\n",i,j,th);
-	*a = caller->work_u_cuda[th];
-	//printf("Hi %f \n", *a);
-	//return ret;
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::updateSubgridCUDA2D( const int i ,tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller, double* a)
-{
-//	int j = threadIdx.x + threadIdx.y * blockDim.x;
-	int index = (blockIdx.y) * caller->n*caller->n*caller->gridCols
-            + (blockIdx.x) * caller->n
-            + threadIdx.y * caller->n*caller->gridCols
-            + threadIdx.x;
-
-	if( (fabs(caller->work_u_cuda[index]) > fabs(*a)) || (caller->unusedCell_cuda[index] == 1) )
-	{
-		caller->work_u_cuda[index] = *a;
-		caller->unusedCell_cuda[index] = 0;
-
-	}
-
-	*a = caller->work_u_cuda[index];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::insertSubgridCUDA2D( double u, const int i )
-{
-
-
-//	int j = threadIdx.x + threadIdx.y * blockDim.x;
-	//printf("j = %d, u = %f\n", j,u);
-
-		int index = (blockIdx.y)*this->n*this->n*this->gridCols
-					+ (blockIdx.x)*this->n
-					+ threadIdx.y*this->n*this->gridCols
-					+ threadIdx.x;
-
-		//printf("i= %d,j= %d,index= %d\n",i,j,index);
-		if( (fabs(this->work_u_cuda[index]) > fabs(u)) || (this->unusedCell_cuda[index] == 1) )
-		{
-			this->work_u_cuda[index] = u;
-			this->unusedCell_cuda[index] = 0;
-
-		}
-
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::runSubgridCUDA2D( int boundaryCondition, double* u, int subGridID)
-{
-
-	__shared__ int tmp;
-	__shared__ double value;
-	//double tmpRes = 0.0;
-	volatile double* sharedTau = &u[blockDim.x*blockDim.y];
-	volatile double* absVal = &u[2*blockDim.x*blockDim.y];
-	int i = threadIdx.x;
-	int j = threadIdx.y;
-	int l = threadIdx.y * blockDim.x + threadIdx.x;
-	bool computeFU = !((i == 0 && (boundaryCondition & 4)) or
-			 (i == blockDim.x - 1 && (boundaryCondition & 2)) or
-			 (j == 0 && (boundaryCondition & 8)) or
-			 (j == blockDim.y - 1  && (boundaryCondition & 1)));
-
-	if(l == 0)
-	{
-		tmp = 0;
-		int centerGID = (blockDim.y*blockIdx.y + (blockDim.y>>1))*(blockDim.x*gridDim.x) + blockDim.x*blockIdx.x + (blockDim.x>>1);
-		if(this->unusedCell_cuda[centerGID] == 0 || boundaryCondition == 0)
-			tmp = 1;
-	}
-	__syncthreads();
-
-	/*if(!tmp && (u[0]*u[l] <= 0.0))
-		atomicMax( &tmp, 1);*/
-
-	__syncthreads();
-	if(tmp !=1)
-	{
-//		if(computeFU)
-//			absVal[l]=0.0;
-//		else
-//			absVal[l] = fabs(u[l]);
-//
-//		__syncthreads();
-//
-//	      if((blockDim.x == 16) && (l < 128))		absVal[l] = Max(absVal[l],absVal[l+128]);
-//	      __syncthreads();
-//	      if((blockDim.x == 16) && (l < 64))		absVal[l] = Max(absVal[l],absVal[l+64]);
-//	      __syncthreads();
-//	      if(l < 32)    							absVal[l] = Max(absVal[l],absVal[l+32]);
-//	      if(l < 16)								absVal[l] = Max(absVal[l],absVal[l+16]);
-//	      if(l < 8)									absVal[l] = Max(absVal[l],absVal[l+8]);
-//	      if(l < 4)									absVal[l] = Max(absVal[l],absVal[l+4]);
-//	      if(l < 2)									absVal[l] = Max(absVal[l],absVal[l+2]);
-//	      if(l < 1)									value   = sign(u[0])*Max(absVal[l],absVal[l+1]);
-//		__syncthreads();
-//
-//		if(computeFU)
-//			u[l] = value;
-		if(computeFU)
-		{
-			if(boundaryCondition == 4)
-				u[l] = u[threadIdx.y * blockDim.x] + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(threadIdx.x) ;//+  2*sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(threadIdx.x+this->n);
-			else if(boundaryCondition == 2)
-				u[l] = u[threadIdx.y * blockDim.x + blockDim.x - 1] + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(this->n - 1 - threadIdx.x);//+ 2*sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(blockDim.x - threadIdx.x - 1+this->n);
-			else if(boundaryCondition == 8)
-				u[l] = u[threadIdx.x] + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(threadIdx.y) ;//+ 2*sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(threadIdx.y+this->n);
-			else if(boundaryCondition == 1)
-				u[l] = u[(blockDim.y - 1)* blockDim.x + threadIdx.x] + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(this->n - 1 - threadIdx.y) ;//+ sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0 >()*(blockDim.y - threadIdx.y  - 1 +this->n);
-		}
-	}
-
-   double time = 0.0;
-   __shared__ double currentTau;
-   double cfl = this->cflCondition;
-   double fu = 0.0;
-//   if(threadIdx.x * threadIdx.y == 0)
-//   {
-//	   currentTau = finalTime;
-//   }
-   double finalTime = this->stopTime;
-   __syncthreads();
-//   if( time + currentTau > finalTime ) currentTau = finalTime - time;
-
-   tnlGridEntity<MeshType, 2, tnlGridEntityNoStencilStorage > Entity(subMesh);
-   tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage >,2> neighborEntities(Entity);
-   Entity.setCoordinates(Containers::StaticVector<2,int>(i,j));
-   Entity.refresh();
-   neighborEntities.refresh(subMesh,Entity.getIndex());
-
-
-   while( time < finalTime )
-   {
-	  if(computeFU)
-		  fu = schemeHost.getValueDev( this->subMesh, l, Containers::StaticVector<2,int>(i,j)/*this->subMesh.getCellCoordinates(l)*/, u, time, boundaryCondition, neighborEntities);
-
-	  sharedTau[l]=abs(cfl/fu);
-
-      if(l == 0)
-      {
-    	  if(sharedTau[0] > 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >())	sharedTau[0] = 1.0 * this->subMesh.template getSpaceStepsProducts< 1, 0 >();
-      }
-      else if(l == blockDim.x*blockDim.y - 1)
-    	  if( time + sharedTau[l] > finalTime )		sharedTau[l] = finalTime - time;
-
-
-//      if(  (sign(u[l]+sharedTau[l]*fu) != sign(u[l])) && fu != 0.0 && fu != -0.0)
-//    	  {
-//    	  printf("orig: %10f", sharedTau[l]);
-//    	  sharedTau[l]=abs(u[l]/(1.1*fu)) ;
-//    	  printf("   new: %10f\n", sharedTau[l]);
-//    	  }
-
-
-
-      if((blockDim.x == 16) && (l < 128))		sharedTau[l] = Min(sharedTau[l],sharedTau[l+128]);
-      __syncthreads();
-      if((blockDim.x == 16) && (l < 64))		sharedTau[l] = Min(sharedTau[l],sharedTau[l+64]);
-      __syncthreads();
-      if(l < 32)    							sharedTau[l] = Min(sharedTau[l],sharedTau[l+32]);
-      if(l < 16)								sharedTau[l] = Min(sharedTau[l],sharedTau[l+16]);
-      if(l < 8)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+8]);
-      if(l < 4)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+4]);
-      if(l < 2)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+2]);
-      if(l < 1)									currentTau   = Min(sharedTau[l],sharedTau[l+1]);
-	__syncthreads();
-
-      u[l] += currentTau * fu;
-      time += currentTau;
-   }
-
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getOwnerCUDA2D(int i) const
-{
-
-	return ((i / (this->gridCols*this->n*this->n))*this->gridCols
-			+ (i % (this->gridCols*this->n))/this->n);
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getSubgridValueCUDA2D( int i ) const
-{
-	return this->subgridValues_cuda[i];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setSubgridValueCUDA2D(int i, int value)
-{
-	this->subgridValues_cuda[i] = value;
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::getBoundaryConditionCUDA2D( int i ) const
-{
-	return this->boundaryConditions_cuda[i];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::setBoundaryConditionCUDA2D(int i, int value)
-{
-	this->boundaryConditions_cuda[i] = value;
-}
-
-
-
-//north - 1, east - 2, west - 4, south - 8
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void /*tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::*/synchronizeCUDA2D(tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver) //needs fix ---- maybe not anymore --- but frankly: yeah, it does -- aaaa-and maybe fixed now
-{
-
-	__shared__ int boundary[4]; // north,east,west,south
-	__shared__ int subgridValue;
-	__shared__ int newSubgridValue;
-
-
-	int gid = (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
-	double u = cudaSolver->work_u_cuda[gid];
-	double u_cmp;
-	int subgridValue_cmp=INT_MAX;
-	int boundary_index=0;
-
-
-	if(threadIdx.x+threadIdx.y == 0)
-	{
-		subgridValue = cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x);
-		boundary[0] = 0;
-		boundary[1] = 0;
-		boundary[2] = 0;
-		boundary[3] = 0;
-		newSubgridValue = 0;
-		//printf("%d   %d\n", blockDim.x, gridDim.x);
-	}
-	__syncthreads();
-
-
-
-	if(		(threadIdx.x == 0 				/*				&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.y == 0 				 	/*			&& (cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.x == blockDim.x - 1 	 /*	&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.y == blockDim.y - 1 	 /*	&& (cudaSolver->currentStep & 1)*/) 		)
-	{
-		if(threadIdx.x == 0 && (blockIdx.x != 0)/* && !(cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - 1];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x - 1);
-			boundary_index = 2;
-		}
-
-		if(threadIdx.x == blockDim.x - 1 && (blockIdx.x != gridDim.x - 1)/* && !(cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + 1];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x + 1);
-			boundary_index = 1;
-		}
-
-		__threadfence();
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-			u=u_cmp;
-		}
-		__threadfence();
-		if(threadIdx.y == 0 && (blockIdx.y != 0)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - blockDim.x*gridDim.x];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D((blockIdx.y - 1)*gridDim.x + blockIdx.x);
-			boundary_index = 3;
-		}
-		if(threadIdx.y == blockDim.y - 1 && (blockIdx.y != gridDim.y - 1)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + blockDim.x*gridDim.x];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA2D((blockIdx.y + 1)*gridDim.x + blockIdx.x);
-			boundary_index = 0;
-		}
-
-//		__threadfence();
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-		}
-	}
-	__threadfence();
-	__syncthreads();
-
-	if(threadIdx.x+threadIdx.y == 0)
-	{
-		if(subgridValue == INT_MAX && newSubgridValue !=0)
-			cudaSolver->setSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, -INT_MAX);
-
-		cudaSolver->setBoundaryConditionCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, 	boundary[0] +
-																				2 * boundary[1] +
-																				4 * boundary[2] +
-																				8 * boundary[3]);
-
-
-		if(blockIdx.x+blockIdx.y ==0)
-		{
-			cudaSolver->currentStep = cudaSolver->currentStep + 1;
-			*(cudaSolver->runcuda) = 0;
-		}
-//
-//		int stepValue = cudaSolver->currentStep + 4;
-//		if( cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x) == -INT_MAX )
-//				cudaSolver->setSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, stepValue);
-//
-//		atomicMax((cudaSolver->runcuda),cudaSolver->getBoundaryConditionCUDA2D(blockIdx.y*gridDim.x + blockIdx.x));
-	}
-
-
-	/*
-	//printf("I am not an empty kernel!\n");
-	//cout << "Synchronizig..." <<std::endl;
-	int tmp1, tmp2;
-	int grid1, grid2;
-
-	if(cudaSolver->currentStep & 1)
-	{
-		//printf("I am not an empty kernel! 1\n");
-		for(int j = 0; j < cudaSolver->gridRows - 1; j++)
-		{
-			//printf("I am not an empty kernel! 3\n");
-			for (int i = 0; i < cudaSolver->gridCols*cudaSolver->n; i++)
-			{
-				tmp1 = cudaSolver->gridCols*cudaSolver->n*((cudaSolver->n-1)+j*cudaSolver->n) + i;
-				tmp2 = cudaSolver->gridCols*cudaSolver->n*((cudaSolver->n)+j*cudaSolver->n) + i;
-				grid1 = cudaSolver->getSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1));
-				grid2 = cudaSolver->getSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2));
-
-				if ((fabs(cudaSolver->work_u_cuda[tmp1]) < fabs(cudaSolver->work_u_cuda[tmp2]) - cudaSolver->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-				{
-					//printf("%d %d %d %d \n",tmp1,tmp2,cudaSolver->getOwnerCUDA2D(tmp1),cudaSolver->getOwnerCUDA2D(tmp2));
-					cudaSolver->work_u_cuda[tmp2] = cudaSolver->work_u_cuda[tmp1];
-					cudaSolver->unusedCell_cuda[tmp2] = 0;
-					if(grid2 == INT_MAX)
-					{
-						cudaSolver->setSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2), -INT_MAX);
-					}
-					if(! (cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2)) & 8) )
-						cudaSolver->setBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2), cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2))+8);
-				}
-				else if ((fabs(cudaSolver->work_u_cuda[tmp1]) > fabs(cudaSolver->work_u_cuda[tmp2]) + cudaSolver->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-				{
-					//printf("%d %d %d %d \n",tmp1,tmp2,cudaSolver->getOwnerCUDA2D(tmp1),cudaSolver->getOwnerCUDA2D(tmp2));
-					cudaSolver->work_u_cuda[tmp1] = cudaSolver->work_u_cuda[tmp2];
-					cudaSolver->unusedCell_cuda[tmp1] = 0;
-					if(grid1 == INT_MAX)
-					{
-						cudaSolver->setSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1), -INT_MAX);
-					}
-					if(! (cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1)) & 1) )
-						cudaSolver->setBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1), cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1))+1);
-				}
-			}
-		}
-
-	}
-	else
-	{
-		//printf("I am not an empty kernel! 2\n");
-		for(int i = 1; i < cudaSolver->gridCols; i++)
-		{
-			//printf("I am not an empty kernel! 4\n");
-			for (int j = 0; j < cudaSolver->gridRows*cudaSolver->n; j++)
-			{
-
-				tmp1 = cudaSolver->gridCols*cudaSolver->n*j + i*cudaSolver->n - 1;
-				tmp2 = cudaSolver->gridCols*cudaSolver->n*j + i*cudaSolver->n ;
-				grid1 = cudaSolver->getSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1));
-				grid2 = cudaSolver->getSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2));
-
-				if ((fabs(cudaSolver->work_u_cuda[tmp1]) < fabs(cudaSolver->work_u_cuda[tmp2]) - cudaSolver->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-				{
-					//printf("%d %d %d %d \n",tmp1,tmp2,cudaSolver->getOwnerCUDA2D(tmp1),cudaSolver->getOwnerCUDA2D(tmp2));
-					cudaSolver->work_u_cuda[tmp2] = cudaSolver->work_u_cuda[tmp1];
-					cudaSolver->unusedCell_cuda[tmp2] = 0;
-					if(grid2 == INT_MAX)
-					{
-						cudaSolver->setSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2), -INT_MAX);
-					}
-					if(! (cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2)) & 4) )
-						cudaSolver->setBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2), cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp2))+4);
-				}
-				else if ((fabs(cudaSolver->work_u_cuda[tmp1]) > fabs(cudaSolver->work_u_cuda[tmp2]) + cudaSolver->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-				{
-					//printf("%d %d %d %d \n",tmp1,tmp2,cudaSolver->getOwnerCUDA2D(tmp1),cudaSolver->getOwnerCUDA2D(tmp2));
-					cudaSolver->work_u_cuda[tmp1] = cudaSolver->work_u_cuda[tmp2];
-					cudaSolver->unusedCell_cuda[tmp1] = 0;
-					if(grid1 == INT_MAX)
-					{
-						cudaSolver->setSubgridValueCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1), -INT_MAX);
-					}
-					if(! (cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1)) & 2) )
-						cudaSolver->setBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1), cudaSolver->getBoundaryConditionCUDA2D(cudaSolver->getOwnerCUDA2D(tmp1))+2);
-				}
-			}
-		}
-	}
-	//printf("I am not an empty kernel! 5 cudaSolver->currentStep : %d \n", cudaSolver->currentStep);
-
-	cudaSolver->currentStep = cudaSolver->currentStep + 1;
-	int stepValue = cudaSolver->currentStep + 4;
-	for (int i = 0; i < cudaSolver->gridRows * cudaSolver->gridCols; i++)
-	{
-		if( cudaSolver->getSubgridValueCUDA2D(i) == -INT_MAX )
-			cudaSolver->setSubgridValueCUDA2D(i, stepValue);
-	}
-
-	int maxi = 0;
-	for(int q=0; q < cudaSolver->gridRows*cudaSolver->gridCols;q++)
-	{
-		//printf("%d : %d\n", q, cudaSolver->boundaryConditions_cuda[q]);
-		maxi=Max(maxi,cudaSolver->getBoundaryConditionCUDA2D(q));
-	}
-	//printf("I am not an empty kernel! %d\n", maxi);
-	*(cudaSolver->runcuda) = (maxi > 0);
-	//printf("I am not an empty kernel! 7 %d\n", cudaSolver->boundaryConditions_cuda[0]);
-	//cout << "Grid synchronized at step " << (this->currentStep - 1 ) <<std::endl;
-*/
-}
-
-
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void synchronize2CUDA2D(tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver)
-{
-//	if(blockIdx.x+blockIdx.y ==0)
-//	{
-//		cudaSolver->currentStep = cudaSolver->currentStep + 1;
-//		*(cudaSolver->runcuda) = 0;
-//	}
-
-	int stepValue = cudaSolver->currentStep + 4;
-	if( cudaSolver->getSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x) == -INT_MAX )
-			cudaSolver->setSubgridValueCUDA2D(blockIdx.y*gridDim.x + blockIdx.x, stepValue);
-
-	atomicMax((cudaSolver->runcuda),cudaSolver->getBoundaryConditionCUDA2D(blockIdx.y*gridDim.x + blockIdx.x));
-}
-
-
-
-
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void /*tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::*/initCUDA2D( tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr , int* ptr2, int* ptr3)
-{
-	//cout << "Initializating solver..." <<std::endl;
-	//const String& meshLocation = parameters.getParameter <String>("mesh");
-	//this->mesh_cuda.load( meshLocation );
-
-	//this->n_cuda = parameters.getParameter <int>("subgrid-size");
-	//cout << "Setting N << this->n_cuda <<std::endl;
-
-	//this->subMesh_cuda.setDimensions( this->n_cuda, this->n_cuda );
-	//this->subMesh_cuda.setDomain( Containers::StaticVector<2,double>(0.0, 0.0),
-							 //Containers::StaticVector<2,double>(this->mesh_cuda.template getSpaceStepsProducts< 1, 0 >()*(double)(this->n_cuda), this->mesh_cuda.template getSpaceStepsProducts< 0, 1 >()*(double)(this->n_cuda)) );
-
-	//this->subMesh_cuda.save("submesh.tnl");
-
-//	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-//	this->u0.load( initialCondition );
-
-	//cout << this->mesh.getCellCenter(0) <<std::endl;
-
-	//this->delta_cuda = parameters.getParameter <double>("delta");
-	//this->delta_cuda *= this->mesh_cuda.template getSpaceStepsProducts< 1, 0 >()*this->mesh_cuda.template getSpaceStepsProducts< 0, 1 >();
-
-	//cout << "Setting delta to " << this->delta <<std::endl;
-
-	//this->tau0_cuda = parameters.getParameter <double>("initial-tau");
-	//cout << "Setting initial tau to " << this->tau0_cuda <<std::endl;
-	//this->stopTime_cuda = parameters.getParameter <double>("stop-time");
-
-	//this->cflCondition_cuda = parameters.getParameter <double>("cfl-condition");
-	//this -> cflCondition_cuda *= sqrt(this->mesh_cuda.template getSpaceStepsProducts< 1, 0 >()*this->mesh_cuda.template getSpaceStepsProducts< 0, 1 >());
-	//cout << "Setting CFL to " << this->cflCondition <<std::endl;
-////
-////
-
-//	this->gridRows_cuda = gridRows;
-//	this->gridCols_cuda = gridCols;
-
-	cudaSolver->work_u_cuda = ptr;//(double*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->n*cudaSolver->n*sizeof(double));
-	cudaSolver->unusedCell_cuda = ptr3;//(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->n*cudaSolver->n*sizeof(int));
-	cudaSolver->subgridValues_cuda =(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*sizeof(int));
-	cudaSolver->boundaryConditions_cuda =(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*sizeof(int));
-	cudaSolver->runcuda = ptr2;//(bool*)malloc(sizeof(bool));
-	*(cudaSolver->runcuda) = 1;
-	cudaSolver->currentStep = 1;
-	//cudaMemcpy(ptr,&(cudaSolver->work_u_cuda), sizeof(double*),cudaMemcpyDeviceToHost);
-	//ptr = cudaSolver->work_u_cuda;
-	printf("GPU memory allocated.\n");
-
-	for(int i = 0; i < cudaSolver->gridCols*cudaSolver->gridRows; i++)
-	{
-		cudaSolver->subgridValues_cuda[i] = INT_MAX;
-		cudaSolver->boundaryConditions_cuda[i] = 0;
-	}
-
-	/*for(long int j = 0; j < cudaSolver->n*cudaSolver->n*cudaSolver->gridCols*cudaSolver->gridRows; j++)
-	{
-		printf("%d\n",j);
-		cudaSolver->unusedCell_cuda[ j] = 1;
-	}*/
-	printf("GPU memory initialized.\n");
-
-
-	//cudaSolver->work_u_cuda[50] = 32.153438;
-////
-////
-	//stretchGrid();
-	//this->stopTime_cuda /= (double)(this->gridCols_cuda);
-	//this->stopTime_cuda *= (1.0+1.0/((double)(this->n_cuda) - 1.0));
-	//cout << "Setting stopping time to " << this->stopTime <<std::endl;
-	//this->stopTime_cuda = 1.5*((double)(this->n_cuda))*parameters.getParameter <double>("stop-time")*this->mesh_cuda.template getSpaceStepsProducts< 1, 0 >();
-	//cout << "Setting stopping time to " << this->stopTime <<std::endl;
-
-	//cout << "Initializating scheme..." <<std::endl;
-	//if(!this->schemeDevice.init(parameters))
-//	{
-		//cerr << "Scheme failed to initialize." <<std::endl;
-//		return false;
-//	}
-	//cout << "Scheme initialized." <<std::endl;
-
-	//test();
-
-//	this->currentStep_cuda = 1;
-	//return true;
-}
-
-
-
-
-//extern __shared__ double array[];
-template< typename SchemeHost, typename SchemeDevice, typename Device >
-__global__
-void /*tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::*/initRunCUDA2D(tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller)
-
-{
-
-
-	extern __shared__ double u[];
-	//printf("%p\n",caller->work_u_cuda);
-
-	int i = blockIdx.y * gridDim.x + blockIdx.x;
-	int l = threadIdx.y * blockDim.x + threadIdx.x;
-
-	__shared__ int containsCurve;
-	if(l == 0)
-		containsCurve = 0;
-
-	//double a;
-	caller->getSubgridCUDA2D(i,caller, &u[l]);
-	//printf("%f   %f\n",a , u[l]);
-	//u[l] = a;
-	//printf("Hi %f \n", u[l]);
-	__syncthreads();
-	//printf("hurewrwr %f \n", u[l]);
-	if(u[0] * u[l] <= 0.0)
-	{
-		//printf("contains %d \n",i);
-		atomicMax( &containsCurve, 1);
-	}
-
-	__syncthreads();
-	//printf("hu");
-	//printf("%d : %f\n", l, u[l]);
-	if(containsCurve == 1)
-	{
-		//printf("have curve \n");
-		caller->runSubgridCUDA2D(0,u,i);
-		//printf("%d : %f\n", l, u[l]);
-		__syncthreads();
-		caller->insertSubgridCUDA2D(u[l],i);
-		__syncthreads();
-		if(l == 0)
-			caller->setSubgridValueCUDA2D(i, 4);
-	}
-
-
-}
-
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device >
-__global__
-void /*tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int>::*/runCUDA2D(tnlParallelEikonalSolver<2,SchemeHost, SchemeDevice, Device, double, int >* caller)
-{
-	extern __shared__ double u[];
-	int i = blockIdx.y * gridDim.x + blockIdx.x;
-	int l = threadIdx.y * blockDim.x + threadIdx.x;
-	int bound = caller->getBoundaryConditionCUDA2D(i);
-
-	if(caller->getSubgridValueCUDA2D(i) != INT_MAX && bound != 0 && caller->getSubgridValueCUDA2D(i) > 0)
-	{
-		caller->getSubgridCUDA2D(i,caller, &u[l]);
-
-		//if(l == 0)
-			//printf("i = %d, bound = %d\n",i,caller->getSubgridValueCUDA2D(i));
-		if(caller->getSubgridValueCUDA2D(i) == caller->currentStep+4)
-		{
-			if(bound & 1)
-			{
-				caller->runSubgridCUDA2D(1,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 2 )
-			{
-				caller->runSubgridCUDA2D(2,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 4)
-			{
-				caller->runSubgridCUDA2D(4,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 8)
-			{
-				caller->runSubgridCUDA2D(8,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-
-
-
-
-
-			if( ((bound & 3 )))
-				{
-					caller->runSubgridCUDA2D(3,u,i);
-					//__syncthreads();
-					//caller->insertSubgridCUDA2D(u[l],i);
-					//__syncthreads();
-					//caller->getSubgridCUDA2D(i,caller, &u[l]);
-					caller->updateSubgridCUDA2D(i,caller, &u[l]);
-					__syncthreads();
-				}
-				if( ((bound & 5 )))
-				{
-					caller->runSubgridCUDA2D(5,u,i);
-					//__syncthreads();
-					//caller->insertSubgridCUDA2D(u[l],i);
-					//__syncthreads();
-					//caller->getSubgridCUDA2D(i,caller, &u[l]);
-					caller->updateSubgridCUDA2D(i,caller, &u[l]);
-					__syncthreads();
-				}
-				if( ((bound & 10 )))
-				{
-					caller->runSubgridCUDA2D(10,u,i);
-					//__syncthreads();
-					//caller->insertSubgridCUDA2D(u[l],i);
-					//__syncthreads();
-					//caller->getSubgridCUDA2D(i,caller, &u[l]);
-					caller->updateSubgridCUDA2D(i,caller, &u[l]);
-					__syncthreads();
-				}
-				if(   (bound & 12 ))
-				{
-					caller->runSubgridCUDA2D(12,u,i);
-					//__syncthreads();
-					//caller->insertSubgridCUDA2D(u[l],i);
-					//__syncthreads();
-					//caller->getSubgridCUDA2D(i,caller, &u[l]);
-					caller->updateSubgridCUDA2D(i,caller, &u[l]);
-					__syncthreads();
-				}
-
-
-
-
-
-		}
-
-
-		else
-		{
-
-
-
-
-
-
-
-
-
-			if( ((bound == 2)))
-						{
-							caller->runSubgridCUDA2D(2,u,i);
-							//__syncthreads();
-							//caller->insertSubgridCUDA2D(u[l],i);
-							//__syncthreads();
-							//caller->getSubgridCUDA2D(i,caller, &u[l]);
-							caller->updateSubgridCUDA2D(i,caller, &u[l]);
-							__syncthreads();
-						}
-						if( ((bound == 1) ))
-						{
-							caller->runSubgridCUDA2D(1,u,i);
-							//__syncthreads();
-							//caller->insertSubgridCUDA2D(u[l],i);
-							//__syncthreads();
-							//caller->getSubgridCUDA2D(i,caller, &u[l]);
-							caller->updateSubgridCUDA2D(i,caller, &u[l]);
-							__syncthreads();
-						}
-						if( ((bound == 8) ))
-						{
-							caller->runSubgridCUDA2D(8,u,i);
-							//__syncthreads();
-							//caller->insertSubgridCUDA2D(u[l],i);
-							//__syncthreads();
-							//caller->getSubgridCUDA2D(i,caller, &u[l]);
-							caller->updateSubgridCUDA2D(i,caller, &u[l]);
-							__syncthreads();
-						}
-						if(   (bound == 4))
-						{
-							caller->runSubgridCUDA2D(4,u,i);
-							//__syncthreads();
-							//caller->insertSubgridCUDA2D(u[l],i);
-							//__syncthreads();
-							//caller->getSubgridCUDA2D(i,caller, &u[l]);
-							caller->updateSubgridCUDA2D(i,caller, &u[l]);
-							__syncthreads();
-						}
-
-
-
-
-
-
-
-
-
-
-			if( ((bound & 3) ))
-			{
-				caller->runSubgridCUDA2D(3,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if( ((bound & 5) ))
-			{
-				caller->runSubgridCUDA2D(5,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if( ((bound & 10) ))
-			{
-				caller->runSubgridCUDA2D(10,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(   (bound & 12) )
-			{
-				caller->runSubgridCUDA2D(12,u,i);
-				//__syncthreads();
-				//caller->insertSubgridCUDA2D(u[l],i);
-				//__syncthreads();
-				//caller->getSubgridCUDA2D(i,caller, &u[l]);
-				caller->updateSubgridCUDA2D(i,caller, &u[l]);
-				__syncthreads();
-			}
-
-
-
-
-
-
-
-
-
-
-
-
-		}
-		/*if( bound )
-		{
-			caller->runSubgridCUDA2D(15,u,i);
-			__syncthreads();
-			//caller->insertSubgridCUDA2D(u[l],i);
-			//__syncthreads();
-			//caller->getSubgridCUDA2D(i,caller, &u[l]);
-			caller->updateSubgridCUDA2D(i,caller, &u[l]);
-			__syncthreads();
-		}*/
-
-		if(l==0)
-		{
-			caller->setBoundaryConditionCUDA2D(i, 0);
-			caller->setSubgridValueCUDA2D(i, caller->getSubgridValueCUDA2D(i) - 1 );
-		}
-
-
-	}
-
-
-
-}
-
-#endif /*HAVE_CUDA*/
-
-#endif /* TNLPARALLELEIKONALSOLVER2D_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver3D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver3D_impl.h
deleted file mode 100644
index dc3fd54679bc5c5b6be44841e56e1c32167b5226..0000000000000000000000000000000000000000
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi-parallel/tnlParallelEikonalSolver3D_impl.h
+++ /dev/null
@@ -1,1706 +0,0 @@
-/***************************************************************************
-                          tnlParallelEikonalSolver2D_impl.h  -  description
-                             -------------------
-    begin                : Nov 28 , 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 TNLPARALLELEIKONALSOLVER3D_IMPL_H_
-#define TNLPARALLELEIKONALSOLVER3D_IMPL_H_
-
-
-#include "tnlParallelEikonalSolver.h"
-#include <core/mfilename.h>
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::tnlParallelEikonalSolver()
-{
-	cout << "a" <<std::endl;
-	this->device = TNL::Devices::HostDevice;  /////////////// tnlCuda Device --- vypocet na GPU, TNL::Devices::HostDevice   ---    vypocet na CPU
-
-#ifdef HAVE_CUDA
-	if(this->device == tnlCudaDevice)
-	{
-	run_host = 1;
-	}
-#endif
-
-	cout << "b" <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::test()
-{
-/*
-	for(int i =0; i < this->subgridValues.getSize(); i++ )
-	{
-		insertSubgrid(getSubgrid(i), i);
-	}
-*/
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-
-bool tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::init( const Config::ParameterContainer& parameters )
-{
-	cout << "Initializating solver..." <<std::endl;
-	const String& meshLocation = parameters.getParameter <String>("mesh");
-	this->mesh.load( meshLocation );
-
-	this->n = parameters.getParameter <int>("subgrid-size");
-	cout << "Setting N to " << this->n <<std::endl;
-
-	this->subMesh.setDimensions( this->n, this->n, this->n );
-	this->subMesh.setDomain( Containers::StaticVector<3,double>(0.0, 0.0, 0.0),
-							 Containers::StaticVector<3,double>(mesh.template getSpaceStepsProducts< 1, 0, 0 >()*(double)(this->n), mesh.template getSpaceStepsProducts< 0, 1, 0 >()*(double)(this->n),mesh.template getSpaceStepsProducts< 0, 0, 1 >()*(double)(this->n)) );
-
-	this->subMesh.save("submesh.tnl");
-
-	const String& initialCondition = parameters.getParameter <String>("initial-condition");
-	this->u0.load( initialCondition );
-
-	//cout << this->mesh.getCellCenter(0) <<std::endl;
-
-	this->delta = parameters.getParameter <double>("delta");
-	this->delta *= mesh.template getSpaceStepsProducts< 1, 0, 0 >()*mesh.template getSpaceStepsProducts< 0, 1, 0 >();
-
-	cout << "Setting delta to " << this->delta <<std::endl;
-
-	this->tau0 = parameters.getParameter <double>("initial-tau");
-	cout << "Setting initial tau to " << this->tau0 <<std::endl;
-	this->stopTime = parameters.getParameter <double>("stop-time");
-
-	this->cflCondition = parameters.getParameter <double>("cfl-condition");
-	this -> cflCondition *= sqrt(mesh.template getSpaceStepsProducts< 1, 0, 0 >()*mesh.template getSpaceStepsProducts< 0, 1, 0 >());
-	cout << "Setting CFL to " << this->cflCondition <<std::endl;
-
-	stretchGrid();
-	this->stopTime /= (double)(this->gridCols);
-	this->stopTime *= (1.0+1.0/((double)(this->n) - 2.0));
-	cout << "Setting stopping time to " << this->stopTime <<std::endl;
-	//this->stopTime = 1.5*((double)(this->n))*parameters.getParameter <double>("stop-time")*mesh.template getSpaceStepsProducts< 1, 0, 0 >();
-	//cout << "Setting stopping time to " << this->stopTime <<std::endl;
-
-	cout << "Initializating scheme..." <<std::endl;
-	if(!this->schemeHost.init(parameters))
-	{
-		cerr << "SchemeHost failed to initialize." <<std::endl;
-		return false;
-	}
-	cout << "Scheme initialized." <<std::endl;
-
-	test();
-
-	VectorType* tmp = new VectorType[subgridValues.getSize()];
-
-
-#ifdef HAVE_CUDA
-
-	if(this->device == tnlCudaDevice)
-	{
-	/*cout << "Testing... " <<std::endl;
-	if(this->device == tnlCudaDevice)
-	{
-	if( !initCUDA3D(parameters, gridRows, gridCols) )
-		return false;
-	}*/
-		//cout << "s" <<std::endl;
-	cudaMalloc(&(this->cudaSolver), sizeof(tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >));
-	//cout << "s" <<std::endl;
-	cudaMemcpy(this->cudaSolver, this,sizeof(tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >), cudaMemcpyHostToDevice);
-	//cout << "s" <<std::endl;
-	double** tmpdev = NULL;
-	cudaMalloc(&tmpdev, sizeof(double*));
-	//double* tmpw;
-	cudaMalloc(&(this->tmpw), this->work_u.getSize()*sizeof(double));
-	cudaMalloc(&(this->runcuda), sizeof(int));
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	int* tmpUC;
-	cudaMalloc(&(tmpUC), this->work_u.getSize()*sizeof(int));
-	cudaMemcpy(tmpUC, this->unusedCell.getData(), this->unusedCell.getSize()*sizeof(int), cudaMemcpyHostToDevice);
-
-	initCUDA3D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<1,1>>>(this->cudaSolver, (this->tmpw), (this->runcuda),tmpUC);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	//cout << "s " <<std::endl;
-	//cudaMalloc(&(cudaSolver->work_u_cuda), this->work_u.getSize()*sizeof(double));
-	double* tmpu = NULL;
-
-	cudaMemcpy(&tmpu, tmpdev,sizeof(double*), cudaMemcpyDeviceToHost);
-	//printf("%p %p \n",tmpu,tmpw);
-	cudaMemcpy((this->tmpw), this->work_u.getData(), this->work_u.getSize()*sizeof(double), cudaMemcpyHostToDevice);
-	cudaDeviceSynchronize();
-	TNL_CHECK_CUDA_DEVICE;
-	//cout << "s "<<std::endl;
-
-	}
-#endif
-
-	if(this->device == TNL::Devices::HostDevice)
-	{
-#ifdef HAVE_OPENMP
-#pragma omp parallel for num_threads(4) schedule(dynamic)
-#endif
-		for(int i = 0; i < this->subgridValues.getSize(); i++)
-		{
-			bool containsCurve = false;
-//			cout << "Working on subgrid " << i <<" --- check 1" <<std::endl;
-
-			if(! tmp[i].setSize(this->n*this->n*this->n))
-				cout << "Could not allocate tmp["<< i <<"] array." <<std::endl;
-//			cout << "Working on subgrid " << i <<" --- check 2" <<std::endl;
-
-			tmp[i] = getSubgrid(i);
-			containsCurve = false;
-//			cout << "Working on subgrid " << i <<" --- check 3" <<std::endl;
-
-
-			for(int j = 0; j < tmp[i].getSize(); j++)
-			{
-				if(tmp[i][0]*tmp[i][j] <= 0.0)
-				{
-					containsCurve = true;
-					j=tmp[i].getSize();
-//					cout << tmp[i][0] << " " << tmp[i][j] <<std::endl;
-				}
-
-			}
-//			cout << "Working on subgrid " << i <<" --- check 4" <<std::endl;
-
-			if(containsCurve)
-			{
-//				cout << "Computing initial SDF on subgrid " << i << "." <<std::endl;
-				tmp[i] = runSubgrid(0, tmp[i] ,i);
-				insertSubgrid( tmp[i], i);
-				setSubgridValue(i, 4);
-//				cout << "Computed initial SDF on subgrid " << i  << "." <<std::endl;
-			}
-			containsCurve = false;
-
-		}
-//		cout << "CPU: Curve found" <<std::endl;
-	}
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-//		cout << "pre 1 kernel" <<std::endl;
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		dim3 threadsPerBlock(this->n, this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows,this->gridLevels);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		initRunCUDA3D<SchemeTypeHost,SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock,2*this->n*this->n*this->n*sizeof(double)>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-//		cout << "post 1 kernel" <<std::endl;
-
-	}
-#endif
-
-
-	this->currentStep = 1;
-	if(this->device == TNL::Devices::HostDevice)
-		synchronize();
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		dim3 threadsPerBlock(this->n, this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows,this->gridLevels);
-		//double * test = (double*)malloc(this->work_u.getSize()*sizeof(double));
-		//cout << test[0] <<"   " << test[1] <<"   " << test[2] <<"   " << test[3] <<std::endl;
-		//cudaMemcpy(/*this->work_u.getData()*/ test, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//cout << this->tmpw << "   " <<  test[0] <<"   " << test[1] << "   " <<test[2] << "   " <<test[3] <<std::endl;
-
-		TNL_CHECK_CUDA_DEVICE;
-
-		synchronizeCUDA3D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-		cout << cudaGetErrorString(cudaDeviceSynchronize()) <<std::endl;
-		TNL_CHECK_CUDA_DEVICE;
-		synchronize2CUDA3D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,1>>>(this->cudaSolver);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		//cout << test[0] << "   " <<test[1] <<"   " << test[2] << "   " <<test[3] <<std::endl;
-		//cudaMemcpy(/*this->work_u.getData()*/ test, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//TNL_CHECK_CUDA_DEVICE;
-		//cout << this->tmpw << "   " <<  test[0] << "   " <<test[1] << "   " <<test[2] <<"   " << test[3] <<std::endl;
-		//free(test);
-
-	}
-
-#endif
-	cout << "Solver initialized." <<std::endl;
-
-	return true;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::run()
-{
-	if(this->device == TNL::Devices::HostDevice)
-	{
-
-	bool end = false;
-	while (/*(this->boundaryConditions.max() > 0 ) ||*/ !end)
-	{
-		if(this->boundaryConditions.max() == 0 || this->subgridValues.max() < 0)
-			end=true;
-		else
-			end=false;
-#ifdef HAVE_OPENMP
-#pragma omp parallel for num_threads(4) schedule(dynamic)
-#endif
-		for(int i = 0; i < this->subgridValues.getSize(); i++)
-		{
-			VectorType tmp;
-			tmp.setSize(this->n*this->n*this->n);
-			if(getSubgridValue(i) != INT_MAX)
-			{
-				//cout << "subMesh: " << i << ", BC: " << getBoundaryCondition(i) <<std::endl;
-
-				if(getSubgridValue(i) == currentStep+4)
-				{
-
-					if(getBoundaryCondition(i) & 1)
-					{
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(1, tmp ,i);
-						insertSubgrid( tmp, i);
-						this->calculationsCount[i]++;
-					}
-					if(getBoundaryCondition(i) & 2)
-					{
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(2, tmp ,i);
-						insertSubgrid( tmp, i);
-						this->calculationsCount[i]++;
-					}
-					if(getBoundaryCondition(i) & 4)
-					{
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(4, tmp ,i);
-						insertSubgrid( tmp, i);
-						this->calculationsCount[i]++;
-					}
-					if(getBoundaryCondition(i) & 8)
-					{
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(8, tmp ,i);
-						insertSubgrid( tmp, i);
-						this->calculationsCount[i]++;
-					}
-					if(getBoundaryCondition(i) & 16)
-					{
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(16, tmp ,i);
-						insertSubgrid( tmp, i);
-						this->calculationsCount[i]++;
-					}
-					if(getBoundaryCondition(i) & 32)
-					{
-						tmp = getSubgrid(i);
-						tmp = runSubgrid(32, tmp ,i);
-						insertSubgrid( tmp, i);
-						this->calculationsCount[i]++;
-					}
-				}
-
-				if( getBoundaryCondition(i) & 19)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(19, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( getBoundaryCondition(i) & 21)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(21, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( getBoundaryCondition(i) & 26)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(26, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( getBoundaryCondition(i) & 28)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(28, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-
-				if( getBoundaryCondition(i) & 35)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(35, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( getBoundaryCondition(i) & 37)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(37, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( getBoundaryCondition(i) & 42)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(42, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-				if( getBoundaryCondition(i) & 44)
-				{
-					tmp = getSubgrid(i);
-					tmp = runSubgrid(44, tmp ,i);
-					insertSubgrid( tmp, i);
-				}
-
-
-				setBoundaryCondition(i, 0);
-				setSubgridValue(i, getSubgridValue(i)-1);
-
-			}
-		}
-		synchronize();
-	}
-	}
-#ifdef HAVE_CUDA
-	else if(this->device == tnlCudaDevice)
-	{
-		//cout << "fn" <<std::endl;
-		bool end_cuda = false;
-		dim3 threadsPerBlock(this->n, this->n, this->n);
-		dim3 numBlocks(this->gridCols,this->gridRows,this->gridLevels);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		//cudaMalloc(&runcuda,sizeof(bool));
-		//cudaMemcpy(runcuda, &run_host, sizeof(bool), cudaMemcpyHostToDevice);
-		//cout << "fn" <<std::endl;
-		bool* tmpb;
-		//cudaMemcpy(tmpb, &(cudaSolver->runcuda),sizeof(bool*), cudaMemcpyDeviceToHost);
-		//cudaDeviceSynchronize();
-		//TNL_CHECK_CUDA_DEVICE;
-		cudaMemcpy(&(this->run_host),this->runcuda,sizeof(int), cudaMemcpyDeviceToHost);
-		cudaDeviceSynchronize();
-		TNL_CHECK_CUDA_DEVICE;
-		//cout << "fn" <<std::endl;
-		int i = 1;
-		time_diff = 0.0;
-		while (run_host || !end_cuda)
-		{
-			cout << "Computing at step "<< i++ <<std::endl;
-			if(run_host != 0 )
-				end_cuda = true;
-			else
-				end_cuda = false;
-			//cout << "a" <<std::endl;
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			start = std::clock();
-			runCUDA3D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock,2*this->n*this->n*this->n*sizeof(double)>>>(this->cudaSolver);
-			//cout << "a" <<std::endl;
-			cudaDeviceSynchronize();
-			time_diff += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
-
-			//start = std::clock();
-			synchronizeCUDA3D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,threadsPerBlock>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			synchronize2CUDA3D<SchemeTypeHost, SchemeTypeDevice, DeviceType><<<numBlocks,1>>>(this->cudaSolver);
-			cudaDeviceSynchronize();
-			TNL_CHECK_CUDA_DEVICE;
-			//time_diff += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
-
-
-			//cout << "a" <<std::endl;
-			//run_host = false;
-			//cout << "in kernel loop" << run_host <<std::endl;
-			//cudaMemcpy(tmpb, &(cudaSolver->runcuda),sizeof(bool*), cudaMemcpyDeviceToHost);
-			cudaMemcpy(&run_host, (this->runcuda),sizeof(int), cudaMemcpyDeviceToHost);
-			//cout << "in kernel loop" << run_host <<std::endl;
-		}
-		cout << "Solving time was: " << time_diff <<std::endl;
-		//cout << "b" <<std::endl;
-
-		//double* tmpu;
-		//cudaMemcpy(tmpu, &(cudaSolver->work_u_cuda),sizeof(double*), cudaMemcpyHostToDevice);
-		//cudaMemcpy(this->work_u.getData(), tmpu, this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//cout << this->work_u.getData()[0] <<std::endl;
-
-		//double * test = (double*)malloc(this->work_u.getSize()*sizeof(double));
-		//cout << test[0] << test[1] << test[2] << test[3] <<std::endl;
-		cudaMemcpy(this->work_u.getData()/* test*/, (this->tmpw), this->work_u.getSize()*sizeof(double), cudaMemcpyDeviceToHost);
-		//cout << this->tmpw << "   " <<  test[0] << test[1] << test[2] << test[3] <<std::endl;
-		//free(test);
-
-		cudaDeviceSynchronize();
-	}
-#endif
-	contractGrid();
-	this->u0.save("u-00001.tnl");
-	cout << "Maximum number of calculations on one subgrid was " << this->calculationsCount.absMax() <<std::endl;
-	cout << "Average number of calculations on one subgrid was " << ( (double) this->calculationsCount.sum() / (double) this->calculationsCount.getSize() ) <<std::endl;
-	cout << "Solver finished" <<std::endl;
-
-#ifdef HAVE_CUDA
-	if(this->device == tnlCudaDevice)
-	{
-		cudaFree(this->runcuda);
-		cudaFree(this->tmpw);
-		cudaFree(this->cudaSolver);
-	}
-#endif
-
-}
-
-//north - 1, east - 2, west - 4, south - 8
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::synchronize() //needs fix ---- maybe not anymore --- but frankly: yeah, it does -- aaaa-and maybe fixed now
-{
-	cout << "Synchronizig..." <<std::endl;
-	int tmp1, tmp2;
-	int grid1, grid2;
-
-//	if(this->currentStep & 1)
-//	{
-		for(int j = 0; j < this->gridRows - 1; j++)
-		{
-			for (int i = 0; i < this->gridCols*this->n; i++)
-			{
-				for (int k = 0; k < this->gridLevels*this->n; k++)
-				{
-//					cout << "a" <<std::endl;
-					tmp1 = this->gridCols*this->n*((this->n-1)+j*this->n) + i + k*this->gridCols*this->n*this->gridRows*this->n;
-//					cout << "b" <<std::endl;
-					tmp2 = this->gridCols*this->n*((this->n)+j*this->n) + i + k*this->gridCols*this->n*this->gridRows*this->n;
-//					cout << "c" <<std::endl;
-					if(tmp1 > work_u.getSize())
-						cout << "tmp1: " << tmp1 << " x: " << j <<" y: " << i <<" z: " << k <<std::endl;
-					if(tmp2 > work_u.getSize())
-						cout << "tmp2: " << tmp2 << " x: " << j <<" y: " << i <<" z: " << k <<std::endl;
-					grid1 = getSubgridValue(getOwner(tmp1));
-//					cout << "d" <<std::endl;
-					grid2 = getSubgridValue(getOwner(tmp2));
-//					cout << "e" <<std::endl;
-					if(getOwner(tmp1)==getOwner(tmp2))
-						cout << "i, j, k" << i << "," << j << "," << k <<std::endl;
-					if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-					{
-						this->work_u[tmp2] = this->work_u[tmp1];
-//						cout << "f" <<std::endl;
-						this->unusedCell[tmp2] = 0;
-//						cout << "g" <<std::endl;
-						if(grid2 == INT_MAX)
-						{
-							setSubgridValue(getOwner(tmp2), -INT_MAX);
-						}
-//						cout << "h" <<std::endl;
-						if(! (getBoundaryCondition(getOwner(tmp2)) & 8) )
-							setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+8);
-//						cout << "i" <<std::endl;
-					}
-					else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-					{
-						this->work_u[tmp1] = this->work_u[tmp2];
-//						cout << "j" <<std::endl;
-						this->unusedCell[tmp1] = 0;
-//						cout << "k" <<std::endl;
-						if(grid1 == INT_MAX)
-						{
-							setSubgridValue(getOwner(tmp1), -INT_MAX);
-						}
-//						cout << "l" <<std::endl;
-						if(! (getBoundaryCondition(getOwner(tmp1)) & 1) )
-							setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+1);
-//						cout << "m" <<std::endl;
-					}
-				}
-			}
-		}
-
-//	}
-//	else
-//	{
-
-		cout << "sync 2" <<std::endl;
-		for(int i = 1; i < this->gridCols; i++)
-		{
-			for (int j = 0; j < this->gridRows*this->n; j++)
-			{
-				for (int k = 0; k < this->gridLevels*this->n; k++)
-				{
-					tmp1 = this->gridCols*this->n*j + i*this->n - 1 + k*this->gridCols*this->n*this->gridRows*this->n;
-					tmp2 = this->gridCols*this->n*j + i*this->n + k*this->gridCols*this->n*this->gridRows*this->n;
-					grid1 = getSubgridValue(getOwner(tmp1));
-					grid2 = getSubgridValue(getOwner(tmp2));
-					if(getOwner(tmp1)==getOwner(tmp2))
-						cout << "i, j, k" << i << "," << j << "," << k <<std::endl;
-					if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-					{
-						this->work_u[tmp2] = this->work_u[tmp1];
-						this->unusedCell[tmp2] = 0;
-						if(grid2 == INT_MAX)
-						{
-							setSubgridValue(getOwner(tmp2), -INT_MAX);
-						}
-						if(! (getBoundaryCondition(getOwner(tmp2)) & 4) )
-							setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+4);
-					}
-					else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-					{
-						this->work_u[tmp1] = this->work_u[tmp2];
-						this->unusedCell[tmp1] = 0;
-						if(grid1 == INT_MAX)
-						{
-							setSubgridValue(getOwner(tmp1), -INT_MAX);
-						}
-						if(! (getBoundaryCondition(getOwner(tmp1)) & 2) )
-							setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+2);
-					}
-				}
-			}
-		}
-
-		cout << "sync 3" <<std::endl;
-
-		for(int k = 1; k < this->gridLevels; k++)
-		{
-			for (int j = 0; j < this->gridRows*this->n; j++)
-			{
-				for (int i = 0; i < this->gridCols*this->n; i++)
-				{
-					tmp1 = this->gridCols*this->n*j + i + (k*this->n-1)*this->gridCols*this->n*this->gridRows*this->n;
-					tmp2 = this->gridCols*this->n*j + i + k*this->n*this->gridCols*this->n*this->gridRows*this->n;
-					grid1 = getSubgridValue(getOwner(tmp1));
-					grid2 = getSubgridValue(getOwner(tmp2));
-					if(getOwner(tmp1)==getOwner(tmp2))
-						cout << "i, j, k" << i << "," << j << "," << k <<std::endl;
-					if ((fabs(this->work_u[tmp1]) < fabs(this->work_u[tmp2]) - this->delta || grid2 == INT_MAX || grid2 == -INT_MAX) && (grid1 != INT_MAX && grid1 != -INT_MAX))
-					{
-						this->work_u[tmp2] = this->work_u[tmp1];
-						this->unusedCell[tmp2] = 0;
-						if(grid2 == INT_MAX)
-						{
-							setSubgridValue(getOwner(tmp2), -INT_MAX);
-						}
-						if(! (getBoundaryCondition(getOwner(tmp2)) & 32) )
-							setBoundaryCondition(getOwner(tmp2), getBoundaryCondition(getOwner(tmp2))+32);
-					}
-					else if ((fabs(this->work_u[tmp1]) > fabs(this->work_u[tmp2]) + this->delta || grid1 == INT_MAX || grid1 == -INT_MAX) && (grid2 != INT_MAX && grid2 != -INT_MAX))
-					{
-						this->work_u[tmp1] = this->work_u[tmp2];
-						this->unusedCell[tmp1] = 0;
-						if(grid1 == INT_MAX)
-						{
-							setSubgridValue(getOwner(tmp1), -INT_MAX);
-						}
-						if(! (getBoundaryCondition(getOwner(tmp1)) & 16) )
-							setBoundaryCondition(getOwner(tmp1), getBoundaryCondition(getOwner(tmp1))+16);
-					}
-				}
-			}
-		}
-//		}
-
-
-
-	this->currentStep++;
-	int stepValue = this->currentStep + 4;
-	for (int i = 0; i < this->subgridValues.getSize(); i++)
-	{
-		if( getSubgridValue(i) == -INT_MAX )
-			setSubgridValue(i, stepValue);
-	}
-
-	cout << "Grid synchronized at step " << (this->currentStep - 1 ) <<std::endl;
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getOwner(int i) const
-{
-
-	int j = i % (this->gridCols*this->gridRows*this->n*this->n);
-
-	return ( (i / (this->gridCols*this->gridRows*this->n*this->n*this->n))*this->gridCols*this->gridRows
-			+ (j / (this->gridCols*this->n*this->n))*this->gridCols
-			+ (j % (this->gridCols*this->n))/this->n);
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getSubgridValue( int i ) const
-{
-	return this->subgridValues[i];
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::setSubgridValue(int i, int value)
-{
-	this->subgridValues[i] = value;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-int tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getBoundaryCondition( int i ) const
-{
-	return this->boundaryConditions[i];
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::setBoundaryCondition(int i, int value)
-{
-	this->boundaryConditions[i] = value;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::stretchGrid()
-{
-	cout << "Stretching grid..." <<std::endl;
-
-
-	this->gridCols = ceil( ((double)(this->mesh.getDimensions().x()-1)) / ((double)(this->n-1)) );
-	this->gridRows = ceil( ((double)(this->mesh.getDimensions().y()-1)) / ((double)(this->n-1)) );
-	this->gridLevels = ceil( ((double)(this->mesh.getDimensions().z()-1)) / ((double)(this->n-1)) );
-
-	//this->gridCols = (this->mesh.getDimensions().x()-1) / (this->n-1) ;
-	//this->gridRows = (this->mesh.getDimensions().y()-1) / (this->n-1) ;
-
-	cout << "Setting gridCols to " << this->gridCols << "." <<std::endl;
-	cout << "Setting gridRows to " << this->gridRows << "." <<std::endl;
-	cout << "Setting gridLevels to " << this->gridLevels << "." <<std::endl;
-
-	this->subgridValues.setSize(this->gridCols*this->gridRows*this->gridLevels);
-	this->subgridValues.setValue(0);
-	this->boundaryConditions.setSize(this->gridCols*this->gridRows*this->gridLevels);
-	this->boundaryConditions.setValue(0);
-	this->calculationsCount.setSize(this->gridCols*this->gridRows*this->gridLevels);
-	this->calculationsCount.setValue(0);
-
-	for(int i = 0; i < this->subgridValues.getSize(); i++ )
-	{
-		this->subgridValues[i] = INT_MAX;
-		this->boundaryConditions[i] = 0;
-	}
-
-	int levelSize = this->n*this->n*this->gridCols*this->gridRows;
-	int stretchedSize = this->n*levelSize*this->gridLevels;
-
-	if(!this->work_u.setSize(stretchedSize))
-		cerr << "Could not allocate memory for stretched grid." <<std::endl;
-	if(!this->unusedCell.setSize(stretchedSize))
-		cerr << "Could not allocate memory for supporting stretched grid." <<std::endl;
-	int idealStretch =this->mesh.getDimensions().x() + (this->mesh.getDimensions().x()-2)/(this->n-1);
-	cout << idealStretch <<std::endl;
-
-
-
-
-	for(int i = 0; i < levelSize; i++)
-	{
-		int diff =(this->n*this->gridCols) - idealStretch ;
-
-		int k = i/this->n - i/(this->n*this->gridCols) + this->mesh.getDimensions().x()*(i/(this->n*this->n*this->gridCols)) + (i/(this->n*this->gridCols))*diff;
-
-		if(i%(this->n*this->gridCols) - idealStretch  >= 0)
-		{
-			k+= i%(this->n*this->gridCols) - idealStretch +1 ;
-		}
-
-		if(i/(this->n*this->gridCols) - idealStretch + 1  > 0)
-		{
-			k+= (i/(this->n*this->gridCols) - idealStretch +1 )* this->mesh.getDimensions().x() ;
-		}
-
-		for( int j = 0; j<this->n*this->gridLevels; j++)
-		{
-			this->unusedCell[i+j*levelSize] = 1;
-			int l = j/this->n;
-
-			if(j - idealStretch  >= 0)
-			{
-				l+= j - idealStretch + 1;
-			}
-
-			this->work_u[i+j*levelSize] = this->u0[i+(j-l)*mesh.getDimensions().x()*mesh.getDimensions().y()-k];
-		}
-
-	}
-
-
-
-	cout << "Grid stretched." <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::contractGrid()
-{
-	cout << "Contracting grid..." <<std::endl;
-	int levelSize = this->n*this->n*this->gridCols*this->gridRows;
-	int stretchedSize = this->n*levelSize*this->gridLevels;
-
-	int idealStretch =this->mesh.getDimensions().x() + (this->mesh.getDimensions().x()-2)/(this->n-1);
-	cout << idealStretch <<std::endl;
-
-
-	for(int i = 0; i < levelSize; i++)
-	{
-		int diff =(this->n*this->gridCols) - idealStretch ;
-		int k = i/this->n - i/(this->n*this->gridCols) + this->mesh.getDimensions().x()*(i/(this->n*this->n*this->gridCols)) + (i/(this->n*this->gridCols))*diff;
-
-		if((i%(this->n*this->gridCols) - idealStretch  < 0) && (i/(this->n*this->gridCols) - idealStretch + 1  <= 0) )
-		{
-			for( int j = 0; j<this->n*this->gridLevels; j++)
-			{
-				int l = j/this->n;
-				if(j - idealStretch  < 0)
-					this->u0[i+(j-l)*mesh.getDimensions().x()*mesh.getDimensions().y()-k] = this->work_u[i+j*levelSize];
-			}
-		}
-
-	}
-
-	cout << "Grid contracted" <<std::endl;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-typename tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::VectorType
-tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getSubgrid( const int i ) const
-{
-
-	VectorType u;
-	u.setSize(this->n*this->n*this->n);
-
-	int idx, idy, idz;
-	idz = i / (gridRows*this->gridCols);
-	idy = (i % (this->gridRows*this->gridCols)) / this->gridCols;
-	idx = i %  (this->gridCols);
-
-	for( int j = 0; j < this->n; j++)
-	{
-	//	int index = (i / this->gridCols)*this->n*this->n*this->gridCols + (i % this->gridCols)*this->n + (j/this->n)*this->n*this->gridCols + (j % this->n);
-		for( int k = 0; k < this->n; k++)
-		{
-			for( int l = 0; l < this->n; l++)
-			{
-				int index = (idz*this->n + l) * this->n*this->n*this->gridCols*this->gridRows
-						 + (idy) * this->n*this->n*this->gridCols
-						 + (idx) * this->n
-						 + k * this->n*this->gridCols
-						 + j;
-
-				u[j + k*this->n  + l*this->n*this->n] = this->work_u[ index ];
-			}
-		}
-	}
-	return u;
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::insertSubgrid( VectorType u, const int i )
-{
-	int idx, idy, idz;
-	idz = i / (this->gridRows*this->gridCols);
-	idy = (i % (this->gridRows*this->gridCols)) / this->gridCols;
-	idx = i %  (this->gridCols);
-
-	for( int j = 0; j < this->n; j++)
-	{
-	//	int index = (i / this->gridCols)*this->n*this->n*this->gridCols + (i % this->gridCols)*this->n + (j/this->n)*this->n*this->gridCols + (j % this->n);
-		for( int k = 0; k < this->n; k++)
-		{
-			for( int l = 0; l < this->n; l++)
-			{
-
-				int index = (idz*this->n + l) * this->n*this->n*this->gridCols*this->gridRows
-						 + (idy) * this->n*this->n*this->gridCols
-						 + (idx) * this->n
-						 + k * this->n*this->gridCols
-						 + j;
-
-				//OMP LOCK index
-//				cout<< idx << " " << idy << " " << idz << " " << j << " " << k << " " << l << " " << idz << " " << unusedCell.getSize() << " " << u.getSize() << " " << index <<endl;
-				if( (fabs(this->work_u[index]) > fabs(u[j + k*this->n  + l*this->n*this->n])) || (this->unusedCell[index] == 1) )
-				{
-					this->work_u[index] = u[j + k*this->n  + l*this->n*this->n];
-					this->unusedCell[index] = 0;
-				}
-				//OMP UNLOCK index
-			}
-		}
-	}
-}
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-typename tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::VectorType
-tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::runSubgrid( int boundaryCondition, VectorType u, int subGridID)
-{
-
-	VectorType fu;
-
-	fu.setLike(u);
-	fu.setValue( 0.0 );
-
-
-	bool tmp = false;
-	for(int i = 0; i < u.getSize(); i++)
-	{
-		if(u[0]*u[i] <= 0.0)
-			tmp=true;
-	}
-	int idx,idy,idz;
-	idz = subGridID / (this->gridRows*this->gridCols);
-	idy = (subGridID % (this->gridRows*this->gridCols)) / this->gridCols;
-	idx = subGridID %  (this->gridCols);
-	int centerGID = (this->n*idy + (this->n>>1) )*(this->n*this->gridCols) + this->n*idx + (this->n>>1)
-			      + ((this->n>>1)+this->n*idz)*this->n*this->n*this->gridRows*this->gridCols;
-	if(this->unusedCell[centerGID] == 0 || boundaryCondition == 0)
-		tmp = true;
-	//if(this->currentStep + 3 < getSubgridValue(subGridID))
-		//tmp = true;
-
-
-	double value = sign(u[0]) * u.absMax();
-
-	if(tmp)
-	{}
-
-
-	//north - 1, east - 2, west - 4, south - 8
-	else if(boundaryCondition == 4)
-	{
-		for(int i = 0; i < this->n; i++)
-			for(int j = 1;j < this->n; j++)
-				for(int k = 0;k < this->n; k++)
-				//if(fabs(u[i*this->n + j]) <  fabs(u[i*this->n]))
-				u[k*this->n*this->n + i*this->n + j] = value;// u[i*this->n];
-	}
-	else if(boundaryCondition == 2)
-	{
-		for(int i = 0; i < this->n; i++)
-			for(int j =0 ;j < this->n -1; j++)
-				for(int k = 0;k < this->n; k++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[(i+1)*this->n - 1]))
-				u[k*this->n*this->n + i*this->n + j] = value;// u[(i+1)*this->n - 1];
-	}
-	else if(boundaryCondition == 1)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 0;i < this->n - 1; i++)
-				for(int k = 0;k < this->n; k++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j + this->n*(this->n - 1)]))
-				u[k*this->n*this->n + i*this->n + j] = value;// u[j + this->n*(this->n - 1)];
-	}
-	else if(boundaryCondition == 8)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 1;i < this->n; i++)
-				for(int k = 0;k < this->n; k++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j]))
-				u[k*this->n*this->n + i*this->n + j] = value;// u[j];
-	}
-	else if(boundaryCondition == 16)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 0;i < this->n ; i++)
-				for(int k = 0;k < this->n-1; k++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j + this->n*(this->n - 1)]))
-				u[k*this->n*this->n + i*this->n + j] = value;// u[j + this->n*(this->n - 1)];
-	}
-	else if(boundaryCondition == 32)
-	{
-		for(int j = 0; j < this->n; j++)
-			for(int i = 0;i < this->n; i++)
-				for(int k = 1;k < this->n; k++)
-				//if(fabs(u[i*this->n + j]) < fabs(u[j]))
-				u[k*this->n*this->n + i*this->n + j] = value;// u[j];
-	}
-
-
-   double time = 0.0;
-   double currentTau = this->tau0;
-   double finalTime = this->stopTime;// + 3.0*(u.max() - u.min());
-   if(boundaryCondition == 0) finalTime *= 2.0;
-   if( time + currentTau > finalTime ) currentTau = finalTime - time;
-
-   double maxResidue( 1.0 );
-   //double lastResidue( 10000.0 );
-   tnlGridEntity<MeshType, 3, tnlGridEntityNoStencilStorage > Entity(subMesh);
-   tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage >,3> neighborEntities(Entity);
-   while( time < finalTime /*|| maxResidue > subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*/)
-   {
-      /****
-       * Compute the RHS
-       */
-
-      for( int i = 0; i < fu.getSize(); i ++ )
-      {
-//    	 std::cout << "i: " << i << ", time: " << time <<endl;
-    	  Containers::StaticVector<3,int> coords(i % subMesh.getDimensions().x(),
-    	  								(i % (subMesh.getDimensions().x()*subMesh.getDimensions().y())) / subMesh.getDimensions().x(),
-    	  								i / (subMesh.getDimensions().x()*subMesh.getDimensions().y()));
-//    	  	cout << "b " << i << " " << i % subMesh.getDimensions().x() << " " << (i % (subMesh.getDimensions().x()*subMesh.getDimensions().y())) << " " << (i % subMesh.getDimensions().x()*subMesh.getDimensions().y()) / subMesh.getDimensions().x() << " " << subMesh.getDimensions().x()*subMesh.getDimensions().y() << " " <<endl;
-			Entity.setCoordinates(coords);
-//			cout <<"c" << coords <<std::endl;
-			Entity.refresh();
-//			cout << "d" <<endl;
-			neighborEntities.refresh(subMesh,Entity.getIndex());
-//			cout << "e" <<endl;
-    	  fu[ i ] = schemeHost.getValue( this->subMesh, i, coords,u, time, boundaryCondition, neighborEntities );
-//    	 std::cout << "f" <<endl;
-      }
-      maxResidue = fu. absMax();
-
-
-      if( this -> cflCondition * maxResidue != 0.0)
-    	  currentTau =  this -> cflCondition / maxResidue;
-
-     /* if (maxResidue < 0.05)
-    	 std::cout << "Max < 0.05" <<std::endl;*/
-      if(currentTau > 0.5 * this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >())
-    	  currentTau = 0.5 * this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >();
-      /*if(maxResidue > lastResidue)
-    	  currentTau *=(1.0/10.0);*/
-
-
-      if( time + currentTau > finalTime ) currentTau = finalTime - time;
-//      for( int i = 0; i < fu.getSize(); i ++ )
-//      {
-//    	  //cout << "Too big RHS! i = " << i << ", fu = " << fu[i] << ", u = " << u[i] <<std::endl;
-//    	  if((u[i]+currentTau * fu[ i ])*u[i] < 0.0 && fu[i] != 0.0 && u[i] != 0.0 )
-//    		  currentTau = fabs(u[i]/(2.0*fu[i]));
-//
-//      }
-
-
-      for( int i = 0; i < fu.getSize(); i ++ )
-      {
-    	  double add = u[i] + currentTau * fu[ i ];
-    	  //if( fabs(u[i]) < fabs(add) or (this->subgridValues[subGridID] == this->currentStep +4) )
-    		  u[ i ] = add;
-      }
-      time += currentTau;
-
-      //cout << '\r' << flush;
-     //cout << maxResidue << "   " << currentTau << " @ " << time << flush;
-     //lastResidue = maxResidue;
-   }
-   //cout << "Time: " << time << ", Res: " << maxResidue <<endl;
-	/*if (u.max() > 0.0)
-		this->stopTime /=(double) this->gridCols;*/
-
-//	VectorType solution;
-//	solution.setLike(u);
-//    for( int i = 0; i < u.getSize(); i ++ )
-//  	{
-//    	solution[i]=u[i];
-//   	}
-//	return solution;
-	return u;
-}
-
-
-#ifdef HAVE_CUDA
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getSubgridCUDA3D( const int i ,tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* caller, double* a)
-{
-	//int j = threadIdx.x + threadIdx.y * blockDim.x;
-//	int index = (blockIdx.z*this->n + threadIdx.z) * this->n*this->n*this->gridCols*this->gridRows
-//			 + (blockIdx.y) * this->n*this->n*this->gridCols
-//             + (blockIdx.x) * this->n
-//             + threadIdx.y * this->n*this->gridCols
-//             + threadIdx.x;
-
-
-	int index =  blockDim.x*blockIdx.x + threadIdx.x +
-			  (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x +
-			  (blockDim.z*blockIdx.z + threadIdx.z)*blockDim.x*gridDim.x*blockDim.y*gridDim.y;
-
-	//printf("i= %d,j= %d,th= %d\n",i,j,th);
-	*a = caller->work_u_cuda[index];
-	//printf("Hi %f \n", *a);
-	//return ret;
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::updateSubgridCUDA3D( const int i ,tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* caller, double* a)
-{
-//	int j = threadIdx.x + threadIdx.y * blockDim.x;
-//	int index = (blockIdx.z*this->n + threadIdx.z) * this->n*this->n*this->gridCols*this->gridRows
-//			 + (blockIdx.y) * this->n*this->n*this->gridCols
-//             + (blockIdx.x) * this->n
-//             + threadIdx.y * this->n*this->gridCols
-//             + threadIdx.x;
-
-	int index =  blockDim.x*blockIdx.x + threadIdx.x +
-			  (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x +
-			  (blockDim.z*blockIdx.z + threadIdx.z)*blockDim.x*gridDim.x*blockDim.y*gridDim.y;
-
-	if( (fabs(caller->work_u_cuda[index]) > fabs(*a)) || (caller->unusedCell_cuda[index] == 1) )
-	{
-		caller->work_u_cuda[index] = *a;
-		caller->unusedCell_cuda[index] = 0;
-
-	}
-
-	*a = caller->work_u_cuda[index];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::insertSubgridCUDA3D( double u, const int i )
-{
-
-
-//	int j = threadIdx.x + threadIdx.y * blockDim.x;
-	//printf("j = %d, u = %f\n", j,u);
-
-//		int index = (blockIdx.z*this->n + threadIdx.z) * this->n*this->n*this->gridCols*this->gridRows
-//				 + (blockIdx.y) * this->n*this->n*this->gridCols
-//	             + (blockIdx.x) * this->n
-//	             + threadIdx.y * this->n*this->gridCols
-//	             + threadIdx.x;
-
-		int index =  blockDim.x*blockIdx.x + threadIdx.x +
-				  (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x +
-				  (blockDim.z*blockIdx.z + threadIdx.z)*blockDim.x*gridDim.x*blockDim.y*gridDim.y;
-
-		//printf("i= %d,j= %d,index= %d\n",i,j,index);
-		if( (fabs(this->work_u_cuda[index]) > fabs(u)) || (this->unusedCell_cuda[index] == 1) )
-		{
-			this->work_u_cuda[index] = u;
-			this->unusedCell_cuda[index] = 0;
-
-		}
-
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::runSubgridCUDA3D( int boundaryCondition, double* u, int subGridID)
-{
-
-	__shared__ int tmp;
-	__shared__ double value;
-	//double tmpRes = 0.0;
-	volatile double* sharedTau = &u[blockDim.x*blockDim.y*blockDim.z];
-//	volatile double* absVal = &u[2*blockDim.x*blockDim.y*blockDim.z];
-	int i = threadIdx.x;
-	int j = threadIdx.y;
-	int k = threadIdx.z;
-	int l = threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z*blockDim.x*blockDim.y;
-	bool computeFU = !((i == 0 && (boundaryCondition & 4)) or
-			 (i == blockDim.x - 1 && (boundaryCondition & 2)) or
-			 (j == 0 && (boundaryCondition & 8)) or
-			 (j == blockDim.y - 1  && (boundaryCondition & 1))or
-			 (k == 0 && (boundaryCondition & 32)) or
-			 (k == blockDim.z - 1  && (boundaryCondition & 16)));
-
-	if(l == 0)
-	{
-		tmp = 0;
-		int centerGID = (blockDim.y*blockIdx.y + (blockDim.y>>1) )*(blockDim.x*gridDim.x) + blockDim.x*blockIdx.x + (blockDim.x>>1)
-				      + ((blockDim.z>>1)+blockDim.z*blockIdx.z)*blockDim.x*blockDim.y*gridDim.x*gridDim.y;
-		if(this->unusedCell_cuda[centerGID] == 0 || boundaryCondition == 0)
-			tmp = 1;
-	}
-	__syncthreads();
-
-
-	__syncthreads();
-	if(tmp !=1)
-	{
-//		if(computeFU)
-//			absVal[l]=0.0;
-//		else
-//			absVal[l] = fabs(u[l]);
-//
-//		__syncthreads();
-//
-//	      if((blockDim.x == 16) && (l < 128))		absVal[l] = Max(absVal[l],absVal[l+128]);
-//	      __syncthreads();
-//	      if((blockDim.x == 16) && (l < 64))		absVal[l] = Max(absVal[l],absVal[l+64]);
-//	      __syncthreads();
-//	      if(l < 32)    							absVal[l] = Max(absVal[l],absVal[l+32]);
-//	      if(l < 16)								absVal[l] = Max(absVal[l],absVal[l+16]);
-//	      if(l < 8)									absVal[l] = Max(absVal[l],absVal[l+8]);
-//	      if(l < 4)									absVal[l] = Max(absVal[l],absVal[l+4]);
-//	      if(l < 2)									absVal[l] = Max(absVal[l],absVal[l+2]);
-//	      if(l < 1)									value   = sign(u[0])*Max(absVal[l],absVal[l+1]);
-//		__syncthreads();
-//
-//		if(computeFU)
-//			u[l] = value;
-		if(computeFU)
-		{
-			tnlGridEntity<MeshType, 3, tnlGridEntityNoStencilStorage > Ent(subMesh);
-			if(boundaryCondition == 4)
-			{
-				Ent.setCoordinates(Containers::StaticVector<3,int>(0,j,k));
-			   	Ent.refresh();
-				u[l] = u[Ent.getIndex()];// + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*(threadIdx.x) ;//+  2*sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*(threadIdx.x+this->n);
-			}
-			else if(boundaryCondition == 2)
-			{
-				Ent.setCoordinates(Containers::StaticVector<3,int>(blockDim.x - 1,j,k));
-			   	Ent.refresh();
-				u[l] = u[Ent.getIndex()];// + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*(this->n - 1 - threadIdx.x);//+ 2*sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*(blockDim.x - threadIdx.x - 1+this->n);
-			}
-			else if(boundaryCondition == 8)
-			{
-				Ent.setCoordinates(Containers::StaticVector<3,int>(i,0,k));
-			   	Ent.refresh();
-				u[l] = u[Ent.getIndex()];// + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 0, 1, 0 >()*(threadIdx.y) ;//+ 2*sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*(threadIdx.y+this->n);
-			}
-			else if(boundaryCondition == 1)
-			{
-				Ent.setCoordinates(Containers::StaticVector<3,int>(i,blockDim.y - 1,k));
-			   	Ent.refresh();
-				u[l] = u[Ent.getIndex()];// + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 0, 1, 0 >()*(this->n - 1 - threadIdx.y) ;//+ sign(u[0])*this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >()*(blockDim.y - threadIdx.y  - 1 +this->n);
-			}
-			else if(boundaryCondition == 32)
-			{
-				Ent.setCoordinates(Containers::StaticVector<3,int>(i,j,0));
-			   	Ent.refresh();
-				u[l] = u[Ent.getIndex()];// + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 0, 0, 1 >()*(threadIdx.z);
-			}
-			else if(boundaryCondition == 16)
-			{
-				Ent.setCoordinates(Containers::StaticVector<3,int>(i,j,blockDim.z - 1));
-			   	Ent.refresh();
-				u[l] = u[Ent.getIndex()];// + sign(u[0])*this->subMesh.template getSpaceStepsProducts< 0, 0, 1 >()*(this->n - 1 - threadIdx.z) ;
-			}
-		}
-	}
-
-   double time = 0.0;
-   __shared__ double currentTau;
-   double cfl = this->cflCondition;
-   double fu = 0.0;
-//   if(threadIdx.x * threadIdx.y * threadIdx.z == 0)
-//   {
-//	   currentTau = this->tau0;
-//   }
-   double finalTime = this->stopTime;
-   __syncthreads();
-   if( boundaryCondition == 0 ) finalTime *= 2.0;
-
-   tnlGridEntity<MeshType, 3, tnlGridEntityNoStencilStorage > Entity(subMesh);
-   tnlNeighborGridEntityGetter<tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage >,3> neighborEntities(Entity);
-   Entity.setCoordinates(Containers::StaticVector<3,int>(i,j,k));
-   Entity.refresh();
-   neighborEntities.refresh(subMesh,Entity.getIndex());
-
-
-   while( time < finalTime )
-   {
-	  sharedTau[l]=finalTime;
-
-	  if(computeFU)
-	  {
-		  fu = schemeHost.getValueDev( this->subMesh, l, Containers::StaticVector<3,int>(i,j,k), u, time, boundaryCondition, neighborEntities);
-		  if(abs(fu) > 0.0)
-			  sharedTau[l]=abs(cfl/fu);
-	  }
-
-      if(l == 0)
-      {
-    	  if(sharedTau[0] > 0.5 * this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >())	sharedTau[0] = 0.5 * this->subMesh.template getSpaceStepsProducts< 1, 0, 0 >();
-      }
-      else if(l == blockDim.x*blockDim.y*blockDim.z - 1)
-      {
-    	  if( time + sharedTau[l] > finalTime )		sharedTau[l] = finalTime - time;
-      }
-
-      __syncthreads();
-      if(l < 256)								sharedTau[l] = Min(sharedTau[l],sharedTau[l+256]);
-      __syncthreads();
-      if(l < 128)								sharedTau[l] = Min(sharedTau[l],sharedTau[l+128]);
-      __syncthreads();
-      if(l < 64)								sharedTau[l] = Min(sharedTau[l],sharedTau[l+64]);
-      __syncthreads();
-      if(l < 32)    							sharedTau[l] = Min(sharedTau[l],sharedTau[l+32]);
-      __syncthreads();
-      if(l < 16)								sharedTau[l] = Min(sharedTau[l],sharedTau[l+16]);
-      if(l < 8)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+8]);
-      if(l < 4)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+4]);
-      if(l < 2)									sharedTau[l] = Min(sharedTau[l],sharedTau[l+2]);
-      if(l < 1)									currentTau   = Min(sharedTau[l],sharedTau[l+1]);
-      __syncthreads();
-
-//	if(abs(fu) < 10000.0)
-//		printf("bla");
-      if(computeFU)
-    	  u[l] += currentTau * fu;
-      time += currentTau;
-      __syncthreads();
-   }
-
-
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getOwnerCUDA3D(int i) const
-{
-	int j = i % (this->gridCols*this->gridRows*this->n*this->n);
-
-	return ( (i / (this->gridCols*this->gridRows*this->n*this->n))*this->gridCols*this->gridRows
-			+ (j / (this->gridCols*this->n*this->n))*this->gridCols
-			+ (j % (this->gridCols*this->n))/this->n);
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getSubgridValueCUDA3D( int i ) const
-{
-	return this->subgridValues_cuda[i];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::setSubgridValueCUDA3D(int i, int value)
-{
-	this->subgridValues_cuda[i] = value;
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-int tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::getBoundaryConditionCUDA3D( int i ) const
-{
-	return this->boundaryConditions_cuda[i];
-}
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__device__
-void tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::setBoundaryConditionCUDA3D(int i, int value)
-{
-	this->boundaryConditions_cuda[i] = value;
-}
-
-
-
-//north - 1, east - 2, west - 4, south - 8, up -16, down - 32
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void /*tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int>::*/synchronizeCUDA3D(tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver) //needs fix ---- maybe not anymore --- but frankly: yeah, it does -- aaaa-and maybe fixed now
-{
-
-	__shared__ int boundary[6]; // north,east,west,south
-	__shared__ int subgridValue;
-	__shared__ int newSubgridValue;
-
-
-	int gid =  blockDim.x*blockIdx.x + threadIdx.x +
-			  (blockDim.y*blockIdx.y + threadIdx.y)*blockDim.x*gridDim.x +
-			  (blockDim.z*blockIdx.z + threadIdx.z)*blockDim.x*gridDim.x*blockDim.y*gridDim.y;
-	double u = cudaSolver->work_u_cuda[gid];
-	double u_cmp;
-	int subgridValue_cmp=INT_MAX;
-	int boundary_index=0;
-
-
-	if(threadIdx.x+threadIdx.y+threadIdx.z == 0)
-	{
-		subgridValue = cudaSolver->getSubgridValueCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y);
-		boundary[0] = 0;
-		boundary[1] = 0;
-		boundary[2] = 0;
-		boundary[3] = 0;
-		boundary[4] = 0;
-		boundary[5] = 0;
-		newSubgridValue = 0;
-//		printf("aaa z = %d, y = %d, x = %d\n",blockIdx.z,blockIdx.y,blockIdx.x);
-	}
-	__syncthreads();
-
-
-
-	if(		(threadIdx.x == 0 				/*				&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.y == 0 				 	/*			&& (cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.z == 0 	 /*	&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.x == blockDim.x - 1 	 /*	&& !(cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.y == blockDim.y - 1 	 /*	&& (cudaSolver->currentStep & 1)*/) 		||
-			(threadIdx.z == blockDim.z - 1 	 /*	&& (cudaSolver->currentStep & 1)*/) 		)
-	{
-		if(threadIdx.x == 0 && (blockIdx.x != 0)/* && !(cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - 1];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y - 1);
-			boundary_index = 2;
-		}
-
-		if(threadIdx.x == blockDim.x - 1 && (blockIdx.x != gridDim.x - 1)/* && !(cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + 1];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y + 1);
-			boundary_index = 1;
-		}
-
-		__threadfence();
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-			u=u_cmp;
-		}
-		__threadfence();
-		if(threadIdx.y == 0 && (blockIdx.y != 0)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - blockDim.x*gridDim.x];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA3D((blockIdx.y - 1)*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y);
-			boundary_index = 3;
-		}
-		if(threadIdx.y == blockDim.y - 1 && (blockIdx.y != gridDim.y - 1)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + blockDim.x*gridDim.x];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA3D((blockIdx.y + 1)*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y);
-			boundary_index = 0;
-		}
-
-		__threadfence();
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-			u=u_cmp;
-		}
-		__threadfence();
-
-		if(threadIdx.z == 0 && (blockIdx.z != 0)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid - blockDim.x*gridDim.x*blockDim.y*gridDim.y];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + (blockIdx.z - 1)*gridDim.x*gridDim.y);
-			boundary_index = 5;
-		}
-		if(threadIdx.z == blockDim.z - 1 && (blockIdx.z != gridDim.z - 1)/* && (cudaSolver->currentStep & 1)*/)
-		{
-			u_cmp = cudaSolver->work_u_cuda[gid + blockDim.x*gridDim.x*blockDim.y*gridDim.y];
-			subgridValue_cmp = cudaSolver->getSubgridValueCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + (blockIdx.z + 1)*gridDim.x*gridDim.y);
-			boundary_index = 4;
-		}
-		__threadfence();
-
-		if((subgridValue == INT_MAX || fabs(u_cmp) + cudaSolver->delta < fabs(u) ) && (subgridValue_cmp != INT_MAX && subgridValue_cmp != -INT_MAX))
-		{
-			cudaSolver->unusedCell_cuda[gid] = 0;
-			atomicMax(&newSubgridValue, INT_MAX);
-			atomicMax(&boundary[boundary_index], 1);
-			cudaSolver->work_u_cuda[gid] = u_cmp;
-		}
-		__threadfence();
-
-	}
-	__syncthreads();
-
-	if(threadIdx.x+threadIdx.y+threadIdx.z == 0)
-	{
-
-		if(subgridValue == INT_MAX && newSubgridValue != 0)
-			cudaSolver->setSubgridValueCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y, -INT_MAX);
-
-		cudaSolver->setBoundaryConditionCUDA3D(blockIdx.y*gridDim.x + blockIdx.x + blockIdx.z*gridDim.x*gridDim.y, 	1  * boundary[0] +
-																													2  * boundary[1] +
-																													4  * boundary[2] +
-																													8  * boundary[3] +
-																													16 * boundary[4] +
-																													32 * boundary[5] );
-		if(blockIdx.x+blockIdx.y+blockIdx.z == 0)
-		{
-			cudaSolver->currentStep = cudaSolver->currentStep + 1;
-			*(cudaSolver->runcuda) = 0;
-		}
-	}
-}
-
-
-
-template <typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void synchronize2CUDA3D(tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver)
-{
-	int stepValue = cudaSolver->currentStep + 4;
-	if( cudaSolver->getSubgridValueCUDA3D(blockIdx.z*gridDim.x*gridDim.y + blockIdx.y*gridDim.x + blockIdx.x) == -INT_MAX )
-			cudaSolver->setSubgridValueCUDA3D(blockIdx.z*gridDim.x*gridDim.y + blockIdx.y*gridDim.x + blockIdx.x, stepValue);
-
-	atomicMax((cudaSolver->runcuda),cudaSolver->getBoundaryConditionCUDA3D(blockIdx.z*gridDim.x*gridDim.y + blockIdx.y*gridDim.x + blockIdx.x));
-}
-
-
-
-
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device>
-__global__
-void initCUDA3D( tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr , int* ptr2, int* ptr3)
-{
-
-
-	cudaSolver->work_u_cuda = ptr;//(double*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->n*cudaSolver->n*sizeof(double));
-	cudaSolver->unusedCell_cuda = ptr3;//(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->n*cudaSolver->n*sizeof(int));
-	cudaSolver->subgridValues_cuda =(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->gridLevels*sizeof(int));
-	cudaSolver->boundaryConditions_cuda =(int*)malloc(cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->gridLevels*sizeof(int));
-	cudaSolver->runcuda = ptr2;//(bool*)malloc(sizeof(bool));
-	*(cudaSolver->runcuda) = 1;
-	cudaSolver->currentStep = 1;
-	//cudaMemcpy(ptr,&(cudaSolver->work_u_cuda), sizeof(double*),cudaMemcpyDeviceToHost);
-	//ptr = cudaSolver->work_u_cuda;
-	printf("GPU memory allocated.\n");
-
-	for(int i = 0; i < cudaSolver->gridCols*cudaSolver->gridRows*cudaSolver->gridLevels; i++)
-	{
-		cudaSolver->subgridValues_cuda[i] = INT_MAX;
-		cudaSolver->boundaryConditions_cuda[i] = 0;
-	}
-
-	/*for(long int j = 0; j < cudaSolver->n*cudaSolver->n*cudaSolver->gridCols*cudaSolver->gridRows; j++)
-	{
-		printf("%d\n",j);
-		cudaSolver->unusedCell_cuda[ j] = 1;
-	}*/
-	printf("GPU memory initialized.\n");
-}
-
-
-
-
-//extern __shared__ double array[];
-template< typename SchemeHost, typename SchemeDevice, typename Device >
-__global__
-void initRunCUDA3D(tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* caller)
-
-{
-
-
-	extern __shared__ double u[];
-
-	int i =  blockIdx.z *  gridDim.x *  gridDim.y +  blockIdx.y *  gridDim.x +  blockIdx.x;
-	int l = threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
-
-	__shared__ int containsCurve;
-	if(l == 0)
-	{
-//		printf("z = %d, y = %d, x = %d\n",blockIdx.z,blockIdx.y,blockIdx.x);
-		containsCurve = 0;
-	}
-
-	caller->getSubgridCUDA3D(i,caller, &u[l]);
-	__syncthreads();
-	if(u[0] * u[l] <= 0.0)
-	{
-		atomicMax( &containsCurve, 1);
-	}
-
-	__syncthreads();
-	if(containsCurve == 1)
-	{
-		caller->runSubgridCUDA3D(0,u,i);
-		__syncthreads();
-//		caller->insertSubgridCUDA3D(u[l],i);
-		caller->updateSubgridCUDA3D(i,caller, &u[l]);
-
-		__syncthreads();
-		if(l == 0)
-			caller->setSubgridValueCUDA3D(i, 4);
-	}
-
-
-}
-
-
-
-
-
-template< typename SchemeHost, typename SchemeDevice, typename Device >
-__global__
-void runCUDA3D(tnlParallelEikonalSolver<3,SchemeHost, SchemeDevice, Device, double, int >* caller)
-{
-	extern __shared__ double u[];
-	int i =  blockIdx.z *  gridDim.x *  gridDim.y +  blockIdx.y *  gridDim.x +  blockIdx.x;
-	int l = threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
-	int bound = caller->getBoundaryConditionCUDA3D(i);
-
-	if(caller->getSubgridValueCUDA3D(i) != INT_MAX && bound != 0 && caller->getSubgridValueCUDA3D(i) > 0)
-	{
-		caller->getSubgridCUDA3D(i,caller, &u[l]);
-
-		//if(l == 0)
-			//printf("i = %d, bound = %d\n",i,caller->getSubgridValueCUDA3D(i));
-		if(caller->getSubgridValueCUDA3D(i) == caller->currentStep+4)
-		{
-			if(bound & 1)
-			{
-				caller->runSubgridCUDA3D(1,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 2 )
-			{
-				caller->runSubgridCUDA3D(2,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 4)
-			{
-				caller->runSubgridCUDA3D(4,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 8)
-			{
-				caller->runSubgridCUDA3D(8,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 16)
-			{
-				caller->runSubgridCUDA3D(16,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound & 32)
-			{
-				caller->runSubgridCUDA3D(32,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-
-		}
-		else
-		{
-			if( ((bound == 2)))
-			{
-				caller->runSubgridCUDA3D(2,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if( ((bound == 1) ))
-			{
-				caller->runSubgridCUDA3D(1,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if( ((bound == 8) ))
-			{
-				caller->runSubgridCUDA3D(8,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if((bound == 4))
-			{
-				caller->runSubgridCUDA3D(4,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound == 16)
-			{
-				caller->runSubgridCUDA3D(16,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-			if(bound == 32)
-			{
-				caller->runSubgridCUDA3D(32,u,i);
-				caller->updateSubgridCUDA3D(i,caller, &u[l]);
-				__syncthreads();
-			}
-		}
-																/*  1  2  4  8  16  32  */
-
-		if( ((bound & 19 )))									/*  1  1  0  0   1   0  */
-		{
-			caller->runSubgridCUDA3D(19,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if( ((bound & 21 )))									/*  1  0  1  0   1   0  */
-		{
-			caller->runSubgridCUDA3D(21,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if( ((bound & 26 )))									/*  0  1  0  1   1   0  */
-		{
-			caller->runSubgridCUDA3D(26,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if(   (bound & 28 ))									/*  0  0  1  1   1   0  */
-		{
-			caller->runSubgridCUDA3D(28,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-
-
-
-		if( ((bound & 35 )))									/*  1  0  1  0   0   1  */
-		{
-			caller->runSubgridCUDA3D(35,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if( ((bound & 37 )))									/*  1  0  1  0   0   1  */
-		{
-			caller->runSubgridCUDA3D(37,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if( ((bound & 42 )))									/*  0  1  0  1   0   1  */
-		{
-			caller->runSubgridCUDA3D(42,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-		if(   (bound & 44 ))									/*  0  0  1  1   0   1  */
-		{
-			caller->runSubgridCUDA3D(44,u,i);
-			caller->updateSubgridCUDA3D(i,caller, &u[l]);
-			__syncthreads();
-		}
-
-		if(l==0)
-		{
-			caller->setBoundaryConditionCUDA3D(i, 0);
-			caller->setSubgridValueCUDA3D(i, caller->getSubgridValueCUDA3D(i) - 1 );
-		}
-
-
-	}
-
-
-
-}
-
-#endif /*HAVE_CUDA*/
-
-#endif /* TNLPARALLELEIKONALSOLVER3D_IMPL_H_ */
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/MainBuildConfig.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/MainBuildConfig.h
index f8f9187fa514cc9d836bc8072a7adbfddd5f8216..a2a1d7372caadb2ec725a1051e3b9975d0fa82df 100644
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/MainBuildConfig.h
+++ b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/MainBuildConfig.h
@@ -23,7 +23,7 @@ namespace Solvers {
 /****
  * Turn off support for float and long double.
  */
-template<> struct ConfigTagReal< HamiltonJacobiBuildConfig, float > { enum { enabled = false }; };
+template<> struct ConfigTagReal< HamiltonJacobiBuildConfig, float > { enum { enabled = true }; };
 template<> struct ConfigTagReal< HamiltonJacobiBuildConfig, long double > { enum { enabled = false }; };
 
 /****
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase.h
index b981a92a8cb5c7d495736ab1c12cb4b891167bee..f712ce2cc9ff3de5701a8550722b8904d33c4229 100644
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase.h
+++ b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase.h
@@ -19,92 +19,112 @@ class tnlDirectEikonalMethodsBase
 };
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 class tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >
 {
-   public:
-      
-      typedef Meshes::Grid< 1, Real, Device, Index > MeshType;
-      typedef Real RealType;
-      typedef Device DevcieType;
-      typedef Index IndexType;
-      typedef Functions::MeshFunction< MeshType > MeshFunctionType;
-      typedef Functions::MeshFunction< MeshType, 1, bool > InterfaceMapType;
-      using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
-      using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;
-      
-      void initInterface( const MeshFunctionPointer& input,
-                          MeshFunctionPointer& output,
-                          InterfaceMapPointer& interfaceMap );
-      
-      template< typename MeshEntity >
-      __cuda_callable__ void updateCell( MeshFunctionType& u,
-                                         const MeshEntity& cell,
-                                         const RealType velocity = 1.0  );
-      
-      __cuda_callable__ bool updateCell( volatile Real sArray[18],
-                                         int thri, const Real h,
-                                         const Real velocity = 1.0 );
+  public:
+    
+    typedef Meshes::Grid< 1, Real, Device, Index > MeshType;
+    typedef Real RealType;
+    typedef Device DevcieType;
+    typedef Index IndexType;
+    typedef Functions::MeshFunction< MeshType > MeshFunctionType;
+    typedef Functions::MeshFunction< MeshType, 1, bool > InterfaceMapType;
+    using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
+    using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;
+    
+    void initInterface( const MeshFunctionPointer& input,
+            MeshFunctionPointer& output,
+            InterfaceMapPointer& interfaceMap );
+    
+    template< typename MeshEntity >
+    __cuda_callable__ void updateCell( MeshFunctionType& u,
+            const MeshEntity& cell,
+            const RealType velocity = 1.0  );
+    
+    __cuda_callable__ bool updateCell( volatile Real sArray[18],
+            int thri, const Real h,
+            const Real velocity = 1.0 );
 };
 
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 class tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >
 {
-   public:
-      typedef Meshes::Grid< 2, Real, Device, Index > MeshType;
-      typedef Real RealType;
-      typedef Device DevcieType;
-      typedef Index IndexType;
-      typedef Functions::MeshFunction< MeshType > MeshFunctionType;
-      typedef Functions::MeshFunction< MeshType, 2, bool > InterfaceMapType;
-      using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
-      using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;      
-
-      void initInterface( const MeshFunctionPointer& input,
-                          MeshFunctionPointer& output,
-                          InterfaceMapPointer& interfaceMap );
-      
-      template< typename MeshEntity >
-      __cuda_callable__ void updateCell( MeshFunctionType& u,
-                                         const MeshEntity& cell,
-                                         const RealType velocity = 1.0 );
-      
-      __cuda_callable__ bool updateCell( volatile Real sArray[18][18],
-                                         int thri, int thrj, const Real hx, const Real hy,
-                                         const Real velocity = 1.0 );
+  public:
+    typedef Meshes::Grid< 2, Real, Device, Index > MeshType;
+    typedef Real RealType;
+    typedef Device DevcieType;
+    typedef Index IndexType;
+    typedef Functions::MeshFunction< MeshType > MeshFunctionType;
+    typedef Functions::MeshFunction< MeshType, 2, bool > InterfaceMapType;
+    typedef TNL::Containers::Array< int, Device, IndexType > ArrayContainer;
+    using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
+    using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;
+    
+    void initInterface( const MeshFunctionPointer& input,
+            MeshFunctionPointer& output,
+            InterfaceMapPointer& interfaceMap );
+    
+    template< typename MeshEntity >
+    __cuda_callable__ void updateCell( MeshFunctionType& u,
+            const MeshEntity& cell,
+            const RealType velocity = 1.0 );
+    
+    template< int sizeSArray >
+    __cuda_callable__ bool updateCell( volatile Real *sArray,
+            int thri, int thrj, const Real hx, const Real hy,
+            const Real velocity = 1.0 );
+    
+    template< int sizeSArray >
+    void updateBlocks( InterfaceMapType interfaceMap,
+            MeshFunctionType aux,
+            MeshFunctionType helpFunc,
+            ArrayContainer BlockIterHost, int numThreadsPerBlock/*, Real **sArray*/ );
+    
+    void getNeighbours( ArrayContainer BlockIterHost, int numBlockX, int numBlockY  );
 };
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 class tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >
 {
-   public:
-      typedef Meshes::Grid< 3, Real, Device, Index > MeshType;
-      typedef Real RealType;
-      typedef Device DevcieType;
-      typedef Index IndexType;
-      typedef Functions::MeshFunction< MeshType > MeshFunctionType;
-      typedef Functions::MeshFunction< MeshType, 3, bool > InterfaceMapType;
-      using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
-      using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;      
-
-      void initInterface( const MeshFunctionPointer& input,
-                          MeshFunctionPointer& output,
-                          InterfaceMapPointer& interfaceMap );
-      
-      template< typename MeshEntity >
-      __cuda_callable__ void updateCell( MeshFunctionType& u,
-                                         const MeshEntity& cell,
-                                         const RealType velocity = 1.0);
-      
-      __cuda_callable__ bool updateCell( volatile Real sArray[10][10][10],
-                                         int thri, int thrj, int thrk, const Real hx, const Real hy, const Real hz,
-                                         const Real velocity = 1.0 );
+  public:
+    typedef Meshes::Grid< 3, Real, Device, Index > MeshType;
+    typedef Real RealType;
+    typedef Device DevcieType;
+    typedef Index IndexType;
+    typedef Functions::MeshFunction< MeshType > MeshFunctionType;
+    typedef Functions::MeshFunction< MeshType, 3, bool > InterfaceMapType;
+    typedef TNL::Containers::Array< int, Device, IndexType > ArrayContainer;
+    using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
+    using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;      
+    
+    void initInterface( const MeshFunctionPointer& input,
+            MeshFunctionPointer& output,
+            InterfaceMapPointer& interfaceMap );
+    
+    template< typename MeshEntity >
+    __cuda_callable__ void updateCell( MeshFunctionType& u,
+            const MeshEntity& cell,
+            const RealType velocity = 1.0);
+    
+    template< int sizeSArray >
+    void updateBlocks( const InterfaceMapType interfaceMap,
+            const MeshFunctionType aux,
+            MeshFunctionType& helpFunc,
+            ArrayContainer BlockIterHost, int numThreadsPerBlock/*, Real **sArray*/ );
+    
+    void getNeighbours( ArrayContainer BlockIterHost, int numBlockX, int numBlockY, int numBlockZ );
+    
+    template< int sizeSArray >
+    __cuda_callable__ bool updateCell3D( volatile Real *sArray,
+            int thri, int thrj, int thrk, const Real hx, const Real hy, const Real hz,
+            const Real velocity = 1.0 );
 };
 
 template < typename T1, typename T2 >
@@ -113,44 +133,54 @@ T1 meet2DCondition( T1 a, T1 b, const T2 ha, const T2 hb, const T1 value, double
 template < typename T1 >
 __cuda_callable__ void sortMinims( T1 pom[] );
 
-
 #ifdef HAVE_CUDA
 template < typename Real, typename Device, typename Index >
 __global__ void CudaInitCaller( const Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& input, 
-                                Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& output,
-                                Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index >, 1, bool >& interfaceMap  );
+        Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& output,
+        Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index >, 1, bool >& interfaceMap  );
 
 template < typename Real, typename Device, typename Index >
 __global__ void CudaUpdateCellCaller( tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > > ptr,
-                                      const Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index >, 1, bool >& interfaceMap,
-                                      Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& aux,
-                                      bool *BlockIterDevice );
+        const Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index >, 1, bool >& interfaceMap,
+        Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& aux,
+        bool *BlockIterDevice );
 
-template < typename Real, typename Device, typename Index >
+template < int sizeSArray, typename Real, typename Device, typename Index >
 __global__ void CudaUpdateCellCaller( tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > ptr,
-                                      const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap,
-                                      Real *aux,
-                                      int *BlockIterDevice);
-__global__ void CudaParallelReduc( int *BlockIterDevice, int *dBlock, int nBlocks );
+        const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap,
+        const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& aux,
+        Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& helpFunc,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice, int oddEvenBlock =0);
 
-template < typename Real, typename Device, typename Index >
-__global__ void aux1( Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& aux, Real *dAux, int a );
+template < typename Index >
+__global__ void CudaParallelReduc( TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice,
+        TNL::Containers::Array< int, Devices::Cuda, Index > dBlock, int nBlocks );
+
+template < typename Index >
+__global__ void GetNeighbours( TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterPom, int numBlockX, int numBlockY );
 
 template < typename Real, typename Device, typename Index >
 __global__ void CudaInitCaller( const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& input, 
-                                Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& output,
-                                Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap );
+        Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& output,
+        Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap );
 
 template < typename Real, typename Device, typename Index >
 __global__ void CudaInitCaller3d( const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& input, 
-                                  Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& output,
-                                  Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap );
+        Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& output,
+        Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap );
 
-template < typename Real, typename Device, typename Index >
+template < int sizeSArray, typename Real, typename Device, typename Index >
 __global__ void CudaUpdateCellCaller( tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > ptr,
-                                      const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap,
-                                      Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& aux,
-                                      int *BlockIterDevice );
+        const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap,
+        const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& aux,
+        Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& helpFunc,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice );
+
+template < typename Index >
+__global__ void GetNeighbours3D( TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterPom,
+        int numBlockX, int numBlockY, int numBlockZ );
 #endif
 
 #include "tnlDirectEikonalMethodsBase_impl.h"
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase_impl.h
index 649a5ad43a3041fcd479ab7828f7fb1a85634b1c..8f7937541d4708f519cd73a1cb50f0b582fbad48 100644
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase_impl.h
+++ b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlDirectEikonalMethodsBase_impl.h
@@ -1,4 +1,4 @@
- /* 
+/* 
  * File:   tnlDirectEikonalMethodsBase_impl.h
  * Author: oberhuber
  *
@@ -11,1061 +11,1649 @@
 
 #include <iostream>
 #include "tnlFastSweepingMethod.h"
+#include "tnlDirectEikonalMethodsBase.h"
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 void
 tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >::
 initInterface( const MeshFunctionPointer& _input,
-               MeshFunctionPointer& _output,
-               InterfaceMapPointer& _interfaceMap  )
+        MeshFunctionPointer& _output,
+        InterfaceMapPointer& _interfaceMap  )
 {
-    if( std::is_same< Device, Devices::Cuda >::value )
-    {
+  if( std::is_same< Device, Devices::Cuda >::value )
+  {
 #ifdef HAVE_CUDA
-        const MeshType& mesh = _input->getMesh();
-        
-        const int cudaBlockSize( 16 );
-        int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().x(), cudaBlockSize );
-        dim3 blockSize( cudaBlockSize );
-        dim3 gridSize( numBlocksX );
-        Devices::Cuda::synchronizeDevice();
-        CudaInitCaller<<< gridSize, blockSize >>>( _input.template getData< Device >(),
-                                                   _output.template modifyData< Device >(),
-                                                   _interfaceMap.template modifyData< Device >() );
-        cudaDeviceSynchronize();
-        TNL_CHECK_CUDA_DEVICE;
+    const MeshType& mesh = _input->getMesh();
+    
+    const int cudaBlockSize( 16 );
+    int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().x(), cudaBlockSize );
+    dim3 blockSize( cudaBlockSize );
+    dim3 gridSize( numBlocksX );
+    Devices::Cuda::synchronizeDevice();
+    CudaInitCaller<<< gridSize, blockSize >>>( _input.template getData< Device >(),
+            _output.template modifyData< Device >(),
+            _interfaceMap.template modifyData< Device >() );
+    cudaDeviceSynchronize();
+    TNL_CHECK_CUDA_DEVICE;
 #endif
-    }
-    if( std::is_same< Device, Devices::Host >::value )
-    {
-        const MeshType& mesh = _input->getMesh();
-        typedef typename MeshType::Cell Cell;
-        const MeshFunctionType& input = _input.getData();
-        MeshFunctionType& output = _output.modifyData();
-        InterfaceMapType& interfaceMap = _interfaceMap.modifyData();
-        Cell cell( mesh );
-        for( cell.getCoordinates().x() = 0;
+  }
+  if( std::is_same< Device, Devices::Host >::value )
+  {
+    const MeshType& mesh = _input->getMesh();
+    typedef typename MeshType::Cell Cell;
+    const MeshFunctionType& input = _input.getData();
+    MeshFunctionType& output = _output.modifyData();
+    InterfaceMapType& interfaceMap = _interfaceMap.modifyData();
+    Cell cell( mesh );
+    for( cell.getCoordinates().x() = 0;
             cell.getCoordinates().x() < mesh.getDimensions().x();
             cell.getCoordinates().x() ++ )
-           {
-               cell.refresh();
-               output[ cell.getIndex() ] =
-               input( cell ) >= 0 ? std::numeric_limits< RealType >::max() :
-                                  -std::numeric_limits< RealType >::max();
-               interfaceMap[ cell.getIndex() ] = false;
-           }
+    {
+      cell.refresh();
+      output[ cell.getIndex() ] =
+              input( cell ) >= 0 ? std::numeric_limits< RealType >::max() :
+                -std::numeric_limits< RealType >::max();
+      interfaceMap[ cell.getIndex() ] = false;
+    }
+    
+    
+    const RealType& h = mesh.getSpaceSteps().x();
+    for( cell.getCoordinates().x() = 0;
+            cell.getCoordinates().x() < mesh.getDimensions().x() - 1;
+            cell.getCoordinates().x() ++ )
+    {
+      cell.refresh();
+      const RealType& c = input( cell );      
+      if( ! cell.isBoundaryEntity()  )
+      {
+        const auto& neighbors = cell.getNeighborEntities();
+        Real pom = 0;
+        //const IndexType& c = cell.getIndex();
+        const IndexType e = neighbors.template getEntityIndex<  1 >();
+        if( c * input[ e ] <= 0 )
+        {
+          pom = TNL::sign( c )*( h * c )/( c - input[ e ]);
+          if( TNL::abs( output[ cell.getIndex() ] ) > TNL::abs( pom ) )
+            output[ cell.getIndex() ] = pom;
+          
+          pom = pom - TNL::sign( c )*h; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
+          if( TNL::abs( output[ e ] ) > TNL::abs( pom ) )
+            output[ e ] = pom; 
+          
+          interfaceMap[ cell.getIndex() ] = true;
+          interfaceMap[ e ] = true;
+        }
+      }
+    }
+  }
+}
+
+template< typename Real,
+        typename Device,
+        typename Index >
+template< int sizeSArray >
+void
+tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >::
+updateBlocks( InterfaceMapType interfaceMap,
+        MeshFunctionType aux,
+        MeshFunctionType helpFunc,
+        ArrayContainer BlockIterHost, int numThreadsPerBlock/*, Real **sArray*/ )
+{
+#pragma omp parallel for schedule( dynamic )
+  for( int i = 0; i < BlockIterHost.getSize(); i++ )
+  {
+    if( BlockIterHost[ i ] )
+    {
+      MeshType mesh = interfaceMap.template getMesh< Devices::Host >();
+      
+      int dimX = mesh.getDimensions().x(); int dimY = mesh.getDimensions().y();
+      //std::cout << "dimX = " << dimX << " ,dimY = " << dimY << std::endl;
+      int numOfBlocky = dimY/numThreadsPerBlock + ((dimY%numThreadsPerBlock != 0) ? 1:0);
+      int numOfBlockx = dimX/numThreadsPerBlock + ((dimX%numThreadsPerBlock != 0) ? 1:0);
+      //std::cout << "numOfBlockx = " << numOfBlockx << " ,numOfBlocky = " << numOfBlocky << std::endl;
+      int xkolik = numThreadsPerBlock + 1;
+      int ykolik = numThreadsPerBlock + 1;
+      
+      int blIdx = i%numOfBlockx;
+      int blIdy = i/numOfBlockx;
+      //std::cout << "blIdx = " << blIdx << " ,blIdy = " << blIdy << std::endl;
+      
+      if( numOfBlockx - 1 == blIdx )
+        xkolik = dimX - (blIdx)*numThreadsPerBlock+1;
+      
+      if( numOfBlocky -1 == blIdy )
+        ykolik = dimY - (blIdy)*numThreadsPerBlock+1;
+      //std::cout << "xkolik = " << xkolik << " ,ykolik = " << ykolik << std::endl;
+      
+      
+      /*bool changed[numThreadsPerBlock*numThreadsPerBlock];
+       changed[ 0 ] = 1;*/
+      Real hx = mesh.getSpaceSteps().x();
+      Real hy = mesh.getSpaceSteps().y();
+      
+      bool changed = false;
+      BlockIterHost[ blIdy * numOfBlockx + blIdx ] = 0;
+      
+      
+      Real *sArray;
+      sArray = new Real[ sizeSArray * sizeSArray ];
+      if( sArray == nullptr )
+        std::cout << "Error while allocating memory for sArray." << std::endl;
+      
+      for( int thri = 0; thri < sizeSArray; thri++ ){
+        for( int thrj = 0; thrj < sizeSArray; thrj++ )
+          sArray[ thri * sizeSArray + thrj ] = std::numeric_limits< Real >::max();
+      }
+      
+      
+      //printf("numThreadsPerBlock = %d\n", numThreadsPerBlock);
+      for( int thrj = 0; thrj < numThreadsPerBlock + 1; thrj++ )
+      {        
+        if( dimX > (blIdx+1) * numThreadsPerBlock  && thrj+1 < ykolik )
+          sArray[ ( thrj+1 )* sizeSArray +xkolik] = aux[ blIdy*numThreadsPerBlock*dimX - dimX + blIdx*numThreadsPerBlock - 1 + (thrj+1)*dimX + xkolik ];
         
         
-        const RealType& h = mesh.getSpaceSteps().x();
-        for( cell.getCoordinates().x() = 0;
-             cell.getCoordinates().x() < mesh.getDimensions().x() - 1;
-             cell.getCoordinates().x() ++ )
+        if( blIdx != 0 && thrj+1 < ykolik )
+          sArray[(thrj+1)* sizeSArray] = aux[ blIdy*numThreadsPerBlock*dimX - dimX + blIdx*numThreadsPerBlock - 1 + (thrj+1)*dimX ];
+        
+        if( dimY > (blIdy+1) * numThreadsPerBlock  && thrj+1 < xkolik )
+          sArray[ykolik * sizeSArray + thrj+1] = aux[ blIdy*numThreadsPerBlock*dimX - dimX + blIdx*numThreadsPerBlock - 1 + ykolik*dimX + thrj+1 ];
+        
+        if( blIdy != 0 && thrj+1 < xkolik )
+          sArray[thrj+1] = aux[ blIdy*numThreadsPerBlock*dimX - dimX + blIdx*numThreadsPerBlock - 1 + thrj+1 ];
+      }
+      
+      for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ )
+          if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX )
+            sArray[(k+1) * sizeSArray + l+1] = aux[ blIdy * numThreadsPerBlock * dimX + numThreadsPerBlock * blIdx  + k*dimX + l ];
+      }
+      
+      for( int k = 0; k < numThreadsPerBlock; k++ ){ 
+        for( int l = 0; l < numThreadsPerBlock; l++ ){
+          if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX ){
+            //std::cout << "proslo i = " << k * numThreadsPerBlock + l << std::endl;
+            if( ! interfaceMap[ blIdy * numThreadsPerBlock * dimX + numThreadsPerBlock * blIdx  + k*dimX + l ] )
+            {
+              changed = this->template updateCell< sizeSArray >( sArray, l+1, k+1, hx,hy) || changed;
+              
+            }
+          }
+        }
+      }
+      /*aux.save( "aux-1pruch.tnl" );
+       for( int k = 0; k < sizeSArray; k++ ){ 
+       for( int l = 0; l < sizeSArray; l++ ) {
+       std::cout << sArray[ k * sizeSArray + l] << " ";
+       }
+       std::cout << std::endl;
+       }*/
+      
+      for( int k = 0; k < numThreadsPerBlock; k++ ) 
+        for( int l = numThreadsPerBlock-1; l >-1; l-- ) { 
+          if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX )
+          {
+            if( ! interfaceMap[ blIdy * numThreadsPerBlock * dimX + numThreadsPerBlock * blIdx  + k*dimX + l ] )
+            {
+              this->template updateCell< sizeSArray >( sArray, l+1, k+1, hx,hy);
+            }
+          }
+        }
+      /*aux.save( "aux-2pruch.tnl" );
+       for( int k = 0; k < sizeSArray; k++ ){ 
+       for( int l = 0; l < sizeSArray; l++ ) {
+       std::cout << sArray[ k * sizeSArray + l] << " ";
+       }
+       std::cout << std::endl;
+       }*/
+      
+      for( int k = numThreadsPerBlock-1; k > -1; k-- ) 
+        for( int l = 0; l < numThreadsPerBlock; l++ ) {
+          if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX )
+          {
+            if( ! interfaceMap[ blIdy * numThreadsPerBlock * dimX + numThreadsPerBlock * blIdx  + k*dimX + l ] )
+            {
+              this->template updateCell< sizeSArray >( sArray, l+1, k+1, hx,hy);
+            }
+          }
+        }
+      /*aux.save( "aux-3pruch.tnl" );
+       for( int k = 0; k < sizeSArray; k++ ){ 
+       for( int l = 0; l < sizeSArray; l++ ) {
+       std::cout << sArray[ k * sizeSArray + l] << " ";
+       }
+       std::cout << std::endl;
+       }*/
+      
+      for( int k = numThreadsPerBlock-1; k > -1; k-- ){
+        for( int l = numThreadsPerBlock-1; l >-1; l-- ) { 
+          if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX )
+          {
+            if( ! interfaceMap[ blIdy * numThreadsPerBlock * dimX + numThreadsPerBlock * blIdx  + k*dimX + l ] )
+            {
+              this->template updateCell< sizeSArray >( sArray, l+1, k+1, hx, hy, 1.0);
+            }
+          }
+        }
+      }
+      /*aux.save( "aux-4pruch.tnl" );
+       for( int k = 0; k < sizeSArray; k++ ){ 
+       for( int l = 0; l < sizeSArray; l++ ) {
+       std::cout << sArray[ k * sizeSArray + l] << " ";
+       }
+       std::cout << std::endl;
+       }*/
+      
+      
+      if( changed ){
+        BlockIterHost[ blIdy * numOfBlockx + blIdx ] = 1;
+      }
+      
+      
+      for( int k = 0; k < numThreadsPerBlock; k++ ){ 
+        for( int l = 0; l < numThreadsPerBlock; l++ ) {
+          if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX )      
+            helpFunc[ blIdy * numThreadsPerBlock * dimX + numThreadsPerBlock * blIdx  + k*dimX + l ] = sArray[ (k + 1)* sizeSArray + l + 1 ];
+          //std::cout<< sArray[k+1][l+1];
+        }
+        //std::cout<<std::endl;
+      }
+      delete []sArray;
+    }
+  }
+}
+template< typename Real,
+        typename Device,
+        typename Index >
+template< int sizeSArray >
+void
+tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >::
+updateBlocks( const InterfaceMapType interfaceMap,
+        const MeshFunctionType aux,
+        MeshFunctionType& helpFunc,
+        ArrayContainer BlockIterHost, int numThreadsPerBlock/*, Real **sArray*/ )
+{  
+//#pragma omp parallel for schedule( dynamic )
+  for( int i = 0; i < BlockIterHost.getSize(); i++ )
+  {
+    if( BlockIterHost[ i ] )
+    {
+      MeshType mesh = interfaceMap.template getMesh< Devices::Host >();
+      
+      int dimX = mesh.getDimensions().x(); int dimY = mesh.getDimensions().y();
+      int dimZ = mesh.getDimensions().z();
+      //std::cout << "dimX = " << dimX << " ,dimY = " << dimY << std::endl;
+      int numOfBlocky = dimY/numThreadsPerBlock + ((dimY%numThreadsPerBlock != 0) ? 1:0);
+      int numOfBlockx = dimX/numThreadsPerBlock + ((dimX%numThreadsPerBlock != 0) ? 1:0);
+      int numOfBlockz = dimZ/numThreadsPerBlock + ((dimZ%numThreadsPerBlock != 0) ? 1:0);
+      //std::cout << "numOfBlockx = " << numOfBlockx << " ,numOfBlocky = " << numOfBlocky << std::endl;
+      int xkolik = numThreadsPerBlock + 1;
+      int ykolik = numThreadsPerBlock + 1;
+      int zkolik = numThreadsPerBlock + 1;
+      
+      
+      int blIdz = i/( numOfBlockx * numOfBlocky );
+      int blIdy = (i-blIdz*numOfBlockx * numOfBlocky )/(numOfBlockx );
+      int blIdx = (i-blIdz*numOfBlockx * numOfBlocky )%( numOfBlockx );
+      //std::cout << "blIdx = " << blIdx << " ,blIdy = " << blIdy << std::endl;
+      
+      if( numOfBlockx - 1 == blIdx )
+        xkolik = dimX - (blIdx)*numThreadsPerBlock+1;
+      if( numOfBlocky -1 == blIdy )
+        ykolik = dimY - (blIdy)*numThreadsPerBlock+1;
+      if( numOfBlockz-1 == blIdz )
+        zkolik = dimZ - (blIdz)*numThreadsPerBlock+1;
+      //std::cout << "xkolik = " << xkolik << " ,ykolik = " << ykolik << std::endl;
+      
+      
+      /*bool changed[numThreadsPerBlock*numThreadsPerBlock];
+       changed[ 0 ] = 1;*/
+      Real hx = mesh.getSpaceSteps().x();
+      Real hy = mesh.getSpaceSteps().y();
+      Real hz = mesh.getSpaceSteps().z();
+      
+      bool changed = false;
+      BlockIterHost[ i ] = 0;
+      
+      
+      Real *sArray;
+      sArray = new Real[ sizeSArray * sizeSArray * sizeSArray ];
+      if( sArray == nullptr )
+        std::cout << "Error while allocating memory for sArray." << std::endl;
+      
+      for( int k = 0; k < sizeSArray; k++ )
+        for( int l = 0; l < sizeSArray; l++ )
+          for( int m = 0; m < sizeSArray; m++ ){
+            sArray[ m * sizeSArray * sizeSArray + k * sizeSArray + l ] = std::numeric_limits< Real >::max();
+          }
+      
+      
+      for( int thrk = 0; thrk < numThreadsPerBlock; thrk++ )
+        for( int thrj = 0; thrj < numThreadsPerBlock; thrj++ )
         {
-           cell.refresh();
-           const RealType& c = input( cell );      
-           if( ! cell.isBoundaryEntity()  )
-           {
-              const auto& neighbors = cell.getNeighborEntities();
-              Real pom = 0;
-              //const IndexType& c = cell.getIndex();
-              const IndexType e = neighbors.template getEntityIndex<  1 >();
-              if( c * input[ e ] <= 0 )
+          if( blIdx != 0 && thrj+1 < ykolik && thrk+1 < zkolik )
+            sArray[(thrk+1 )* sizeSArray * sizeSArray + (thrj+1)*sizeSArray + 0] = 
+                    aux[ blIdz*numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock*dimX + blIdx*numThreadsPerBlock + thrj * dimX -1 + thrk*dimX*dimY ];
+          
+          if( dimX > (blIdx+1) * numThreadsPerBlock && thrj+1 < ykolik && thrk+1 < zkolik )
+            sArray[ (thrk+1) * sizeSArray * sizeSArray + (thrj+1) *sizeSArray + xkolik ] = 
+                    aux[ blIdz*numThreadsPerBlock * dimX * dimY + blIdy *numThreadsPerBlock*dimX+ blIdx*numThreadsPerBlock + numThreadsPerBlock + thrj * dimX + thrk*dimX*dimY ];
+          
+          if( blIdy != 0 && thrj+1 < xkolik && thrk+1 < zkolik )
+            sArray[ (thrk+1) * sizeSArray * sizeSArray +0*sizeSArray + thrj+1] = 
+                    aux[ blIdz*numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock*dimX + blIdx*numThreadsPerBlock - dimX + thrj + thrk*dimX*dimY ];
+          
+          if( dimY > (blIdy+1) * numThreadsPerBlock && thrj+1 < xkolik && thrk+1 < zkolik )
+            sArray[ (thrk+1) * sizeSArray * sizeSArray + ykolik*sizeSArray + thrj+1] = 
+                    aux[ blIdz*numThreadsPerBlock * dimX * dimY + (blIdy+1) * numThreadsPerBlock*dimX + blIdx*numThreadsPerBlock + thrj + thrk*dimX*dimY ];
+          
+          if( blIdz != 0 && thrj+1 < ykolik && thrk+1 < xkolik )
+            sArray[ 0 * sizeSArray * sizeSArray +(thrj+1 )* sizeSArray + thrk+1] = 
+                    aux[ blIdz*numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock*dimX + blIdx*numThreadsPerBlock - dimX * dimY + thrj * dimX + thrk ];
+          
+          if( dimZ > (blIdz+1) * numThreadsPerBlock && thrj+1 < ykolik && thrk+1 < xkolik )
+            sArray[zkolik * sizeSArray * sizeSArray + (thrj+1) * sizeSArray + thrk+1] = 
+                    aux[ (blIdz+1)*numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock*dimX + blIdx*numThreadsPerBlock + thrj * dimX + thrk ];
+        }
+      
+      for( int m = 0; m < numThreadsPerBlock; m++ ){
+        for( int k = 0; k < numThreadsPerBlock; k++ ){
+          for( int l = 0; l < numThreadsPerBlock; l++ ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+              sArray[(m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1] = 
+                      aux[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l ];
+          }
+        }
+      }
+      /*string s;
+      int numWhile = 0;
+      for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      for( int m = 0; m < numThreadsPerBlock; m++ ){
+        for( int k = 0; k < numThreadsPerBlock; k++ ){ 
+          for( int l = 0; l < numThreadsPerBlock; l++ ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ ){
+              //std::cout << "proslo i = " << k * numThreadsPerBlock + l << std::endl;
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
               {
-                pom = TNL::sign( c )*( h * c )/( c - input[ e ]);
-                if( TNL::abs( output[ cell.getIndex() ] ) > TNL::abs( pom ) )
-                    output[ cell.getIndex() ] = pom;
-
-                pom = pom - TNL::sign( c )*h; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
-                if( TNL::abs( output[ e ] ) > TNL::abs( pom ) )
-                    output[ e ] = pom; 
-
-                interfaceMap[ cell.getIndex() ] = true;
-                interfaceMap[ e ] = true;
+                //printf("In with point m  = %d, k = %d, l = %d\n", m, k, l);
+                changed = this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz) || changed;
+                
               }
-           }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      for( int m = numThreadsPerBlock-1; m >-1; m-- ){
+        for( int k = 0; k < numThreadsPerBlock; k++ ){
+          for( int l = 0; l <numThreadsPerBlock; l++ ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
         }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      for( int m = 0; m < numThreadsPerBlock; m++ ){
+        for( int k = 0; k < numThreadsPerBlock; k++ ){
+          for( int l = numThreadsPerBlock-1; l >-1; l-- ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );
+      */
+      for( int m = numThreadsPerBlock-1; m >-1; m-- ){
+        for( int k = 0; k < numThreadsPerBlock; k++ ){
+          for( int l = numThreadsPerBlock-1; l >-1; l-- ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >(  sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      for( int m = 0; m < numThreadsPerBlock; m++ ){
+        for( int k = numThreadsPerBlock-1; k > -1; k-- ){
+          for( int l = 0; l <numThreadsPerBlock; l++ ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      for( int m = numThreadsPerBlock-1; m >-1; m-- ){
+        for( int k = numThreadsPerBlock-1; k > -1; k-- ){
+          for( int l = 0; l <numThreadsPerBlock; l++ ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      for( int m = 0; m < numThreadsPerBlock; m++ ){
+        for( int k = numThreadsPerBlock-1; k > -1; k-- ){
+          for( int l = numThreadsPerBlock-1; l >-1; l-- ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      
+      for( int m = numThreadsPerBlock-1; m >-1; m-- ){
+        for( int k = numThreadsPerBlock-1; k > -1; k-- ){
+          for( int l = numThreadsPerBlock-1; l >-1; l-- ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )
+            {
+              if( ! interfaceMap[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l  ] )
+              {
+                this->template updateCell3D< sizeSArray >( sArray, l+1, k+1, m+1, hx,hy,hz);
+              }
+            }
+          }
+        }
+      }
+      /*for( int k = 0; k < numThreadsPerBlock; k++ ){
+        for( int l = 0; l < numThreadsPerBlock; l++ ) 
+          for( int m = 0; m < numThreadsPerBlock; m++ )
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ )     
+              helpFunc[ m*dimX*dimY + k*dimX + l ] = sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+      } 
+      numWhile++;
+      s = "helpFunc-"+ std::to_string(numWhile) + ".tnl";
+      helpFunc.save( s );*/
+      
+      if( changed ){
+        BlockIterHost[ i ] = 1;
+      }
+      
+      
+      for( int k = 0; k < numThreadsPerBlock; k++ ){ 
+        for( int l = 0; l < numThreadsPerBlock; l++ ) {
+          for( int m = 0; m < numThreadsPerBlock; m++ ){
+            if( blIdy * numThreadsPerBlock + k < dimY && blIdx * numThreadsPerBlock + l < dimX && blIdz * numThreadsPerBlock + m < dimZ ){      
+              helpFunc[ blIdz * numThreadsPerBlock * dimX * dimY + blIdy * numThreadsPerBlock * dimX + blIdx*numThreadsPerBlock + m*dimX*dimY + k*dimX + l ] = 
+                      sArray[ (m+1) * sizeSArray * sizeSArray + (k+1) *sizeSArray + l+1 ];
+              //std::cout << helpFunc[ m*dimX*dimY + k*dimX + l ] << " ";
+            }
+          }
+          //std::cout << std::endl;
+        }
+        //std::cout << std::endl;
+      }
+      //helpFunc.save( "helpF.tnl");
+      delete []sArray;
     }
+  }
+}
+template< typename Real,
+        typename Device,
+        typename Index >
+void 
+tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >::
+getNeighbours( ArrayContainer BlockIterHost, int numBlockX, int numBlockY, int numBlockZ )
+{
+  int* BlockIterPom; 
+  BlockIterPom = new int [ numBlockX * numBlockY * numBlockZ ];
+  
+  for( int i = 0; i< BlockIterHost.getSize(); i++)
+  {
+    BlockIterPom[ i ] = 0;
+    
+    int m=0, l=0, k=0;
+    l = i/( numBlockX * numBlockY );
+    k = (i-l*numBlockX * numBlockY )/(numBlockX );
+    m = (i-l*numBlockX * numBlockY )%( numBlockX );
+    
+    if( m > 0 && BlockIterHost[ i - 1 ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( m < numBlockX -1 && BlockIterHost[ i + 1 ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( k > 0 && BlockIterHost[ i - numBlockX ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( k < numBlockY -1 && BlockIterHost[ i + numBlockX ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( l > 0 && BlockIterHost[ i - numBlockX*numBlockY ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( l < numBlockZ-1 && BlockIterHost[ i + numBlockX*numBlockY ] ){
+      BlockIterPom[ i ] = 1;
+    }
+  }
+  for( int i = 0; i< BlockIterHost.getSize(); i++)
+  { 
+    BlockIterHost[ i ] = BlockIterPom[ i ];
+  }
+}
+
+
+template< typename Real,
+        typename Device,
+        typename Index >
+void 
+tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >::
+getNeighbours( ArrayContainer BlockIterHost, int numBlockX, int numBlockY )
+{
+  int* BlockIterPom; 
+  BlockIterPom = new int [numBlockX * numBlockY];
+  
+  for(int i = 0; i < numBlockX * numBlockY; i++)
+  {
+    BlockIterPom[ i ] = 0;//BlockIterPom[ i ] = 0;
+    int m=0, k=0;
+    m = i%numBlockX;
+    k = i/numBlockX;
+    if( m > 0 && BlockIterHost[ i - 1 ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( m < numBlockX -1 && BlockIterHost[ i + 1 ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( k > 0 && BlockIterHost[ i - numBlockX ] ){
+      BlockIterPom[ i ] = 1;
+    }else if( k < numBlockY -1 && BlockIterHost[ i + numBlockX ] ){
+      BlockIterPom[ i ] = 1;
+    }
+    //BlockIterPom[ i ];
+  }
+  
+  for(int i = 0; i < numBlockX * numBlockY; i++)
+  {
+    if( !BlockIterHost[ i ] )
+      BlockIterHost[ i ] = BlockIterPom[ i ];
+  }
+  /*else
+   BlockIter[ i ] = 0;*/
+  /*for( int i = numBlockX-1; i > -1; i-- )
+   {
+   for( int j = 0; j< numBlockY; j++ )
+   std::cout << BlockIterHost[ i*numBlockY + j ];
+   std::cout << std::endl;
+   }
+   std::cout << std::endl;*/
+  delete[] BlockIterPom;
 }
 
 template< typename Real,
-          typename Device,
-          typename Index >
-   template< typename MeshEntity >
+        typename Device,
+        typename Index >
+template< typename MeshEntity >
 void
 tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >::
 updateCell( MeshFunctionType& u,
-            const MeshEntity& cell, 
-            const RealType v )
+        const MeshEntity& cell, 
+        const RealType v )
 {
-    const auto& neighborEntities = cell.template getNeighborEntities< 1 >();
-    const MeshType& mesh = cell.getMesh();
-    const RealType& h = mesh.getSpaceSteps().x();
-    const RealType value = u( cell );
-    RealType a, tmp = std::numeric_limits< RealType >::max();
-
-    if( cell.getCoordinates().x() == 0 )
-       a = u[ neighborEntities.template getEntityIndex< 1 >() ];
-    else if( cell.getCoordinates().x() == mesh.getDimensions().x() - 1 )
-       a = u[ neighborEntities.template getEntityIndex< -1 >() ];
-    else
-    {
-       a = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< -1 >() ],
-                           u[ neighborEntities.template getEntityIndex<  1 >() ] );
-    }
-
-    if( fabs( a ) == std::numeric_limits< RealType >::max() )
-      return;
-   
-    tmp = a + TNL::sign( value ) * h/v;
-    
-    u[ cell.getIndex() ] = argAbsMin( value, tmp );
+  const auto& neighborEntities = cell.template getNeighborEntities< 1 >();
+  const MeshType& mesh = cell.getMesh();
+  const RealType& h = mesh.getSpaceSteps().x();
+  const RealType value = u( cell );
+  RealType a, tmp = std::numeric_limits< RealType >::max();
+  
+  if( cell.getCoordinates().x() == 0 )
+    a = u[ neighborEntities.template getEntityIndex< 1 >() ];
+  else if( cell.getCoordinates().x() == mesh.getDimensions().x() - 1 )
+    a = u[ neighborEntities.template getEntityIndex< -1 >() ];
+  else
+  {
+    a = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< -1 >() ],
+            u[ neighborEntities.template getEntityIndex<  1 >() ] );
+  }
+  
+  if( fabs( a ) == std::numeric_limits< RealType >::max() )
+    return;
+  
+  tmp = a + TNL::sign( value ) * h/v;
+  
+  u[ cell.getIndex() ] = argAbsMin( value, tmp );
 }
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 void
 tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >::
 initInterface( const MeshFunctionPointer& _input,
-               MeshFunctionPointer& _output,
-               InterfaceMapPointer& _interfaceMap )
+        MeshFunctionPointer& _output,
+        InterfaceMapPointer& _interfaceMap )
 {
-            
-    if( std::is_same< Device, Devices::Cuda >::value )
-    {
+  
+  if( std::is_same< Device, Devices::Cuda >::value )
+  {
 #ifdef HAVE_CUDA
-        const MeshType& mesh = _input->getMesh();
-        
-        const int cudaBlockSize( 16 );
-        int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().x(), cudaBlockSize );
-        int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().y(), cudaBlockSize );
-        dim3 blockSize( cudaBlockSize, cudaBlockSize );
-        dim3 gridSize( numBlocksX, numBlocksY );
-        Devices::Cuda::synchronizeDevice();
-        CudaInitCaller<<< gridSize, blockSize >>>( _input.template getData< Device >(),
-                                                   _output.template modifyData< Device >(),
-                                                   _interfaceMap.template modifyData< Device >() );
-        cudaDeviceSynchronize();
-        TNL_CHECK_CUDA_DEVICE;
+    const MeshType& mesh = _input->getMesh();
+    
+    const int cudaBlockSize( 16 );
+    int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().x(), cudaBlockSize );
+    int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().y(), cudaBlockSize );
+    dim3 blockSize( cudaBlockSize, cudaBlockSize );
+    dim3 gridSize( numBlocksX, numBlocksY );
+    Devices::Cuda::synchronizeDevice();
+    CudaInitCaller<<< gridSize, blockSize >>>( _input.template getData< Device >(),
+            _output.template modifyData< Device >(),
+            _interfaceMap.template modifyData< Device >() );
+    cudaDeviceSynchronize();
+    TNL_CHECK_CUDA_DEVICE;
 #endif
-    }
-    if( std::is_same< Device, Devices::Host >::value )
-    {
-        MeshFunctionType input = _input.getData();
-        
-        /*double A[320][320];
-        std::ifstream fileInit("/home/maty/Downloads/initData.txt");
-
-        for (int i = 0; i < 320; i++)
-            for (int j = 0; j < 320; j++)
-                fileInit >> A[i][j];
-        fileInit.close();
-        for (int i = 0; i < 320; i++)
-            for (int j = 0; j < 320; j++)
-                input[i*320 + j] = A[i][j];*/
-        
-        
-         MeshFunctionType& output = _output.modifyData();
-         InterfaceMapType& interfaceMap = _interfaceMap.modifyData();
-        const MeshType& mesh = input.getMesh();
-        typedef typename MeshType::Cell Cell;
-        Cell cell( mesh );
-        for( cell.getCoordinates().y() = 0;
-             cell.getCoordinates().y() < mesh.getDimensions().y();
-             cell.getCoordinates().y() ++ )
-            for( cell.getCoordinates().x() = 0;
-                 cell.getCoordinates().x() < mesh.getDimensions().x();
-                 cell.getCoordinates().x() ++ )
-                {
-                    cell.refresh();
-                    output[ cell.getIndex() ] =
-                    input( cell ) >= 0 ? std::numeric_limits< RealType >::max() :
-                                       - std::numeric_limits< RealType >::max();
-                    interfaceMap[ cell.getIndex() ] = false;
-                }
-
-       const RealType& hx = mesh.getSpaceSteps().x();
-       const RealType& hy = mesh.getSpaceSteps().y();     
-       for( cell.getCoordinates().y() = 0;
+  }
+  if( std::is_same< Device, Devices::Host >::value )
+  {
+    MeshFunctionType input = _input.getData();
+    
+    /*double A[320][320];
+     std::ifstream fileInit("/home/maty/Downloads/initData.txt");
+     
+     for (int i = 0; i < 320; i++)
+     for (int j = 0; j < 320; j++)
+     fileInit >> A[j];
+     fileInit.close();
+     for (int i = 0; i < 320; i++)
+     for (int j = 0; j < 320; j++)
+     input[i*320 + j] = A[j];*/
+    
+    
+    MeshFunctionType& output = _output.modifyData();
+    InterfaceMapType& interfaceMap = _interfaceMap.modifyData();
+    const MeshType& mesh = input.getMesh();
+    typedef typename MeshType::Cell Cell;
+    Cell cell( mesh );
+    for( cell.getCoordinates().y() = 0;
+            cell.getCoordinates().y() < mesh.getDimensions().y();
+            cell.getCoordinates().y() ++ )
+      for( cell.getCoordinates().x() = 0;
+              cell.getCoordinates().x() < mesh.getDimensions().x();
+              cell.getCoordinates().x() ++ )
+      {
+        cell.refresh();
+        output[ cell.getIndex() ] =
+                input( cell ) >= 0 ? std::numeric_limits< RealType >::max() :
+                  - std::numeric_limits< RealType >::max();
+        interfaceMap[ cell.getIndex() ] = false;
+      }
+    
+    const RealType& hx = mesh.getSpaceSteps().x();
+    const RealType& hy = mesh.getSpaceSteps().y();     
+    for( cell.getCoordinates().y() = 0;
             cell.getCoordinates().y() < mesh.getDimensions().y();
             cell.getCoordinates().y() ++ )
-          for( cell.getCoordinates().x() = 0;
-               cell.getCoordinates().x() < mesh.getDimensions().x();
-               cell.getCoordinates().x() ++ )
+      for( cell.getCoordinates().x() = 0;
+              cell.getCoordinates().x() < mesh.getDimensions().x();
+              cell.getCoordinates().x() ++ )
+      {
+        cell.refresh();
+        const RealType& c = input( cell );
+        if( ! cell.isBoundaryEntity()  )
+        {
+          auto neighbors = cell.getNeighborEntities();
+          Real pom = 0;
+          const IndexType e = neighbors.template getEntityIndex<  1,  0 >();
+          const IndexType n = neighbors.template getEntityIndex<  0,  1 >();
+          //Try init with exact data:
+          /*if( c * input[ n ] <= 0 )
+           {
+           output[ cell.getIndex() ] = c;
+           output[ n ] = input[ n ];
+           interfaceMap[ cell.getIndex() ] = true;
+           interfaceMap[ n ] = true;
+           }   
+           if( c * input[ e ] <= 0 )
+           {   
+           output[ cell.getIndex() ] = c;
+           output[ e ] = input[ e ];
+           interfaceMap[ cell.getIndex() ] = true;
+           interfaceMap[ e ] = true;
+           }*/
+          if( c * input[ n ] <= 0 )
           {
-             cell.refresh();
-             const RealType& c = input( cell );
-             if( ! cell.isBoundaryEntity()  )
+            /*if( c >= 0 )
+             {*/
+            pom = TNL::sign( c )*( hy * c )/( c - input[ n ]);
+            if( TNL::abs( output[ cell.getIndex() ] ) > TNL::abs( pom ) ) 
+              output[ cell.getIndex() ] = pom;
+            pom = pom - TNL::sign( c )*hy;
+            if( TNL::abs( output[ n ] ) > TNL::abs( pom ) )
+              output[ n ] = pom; //( hy * c )/( c - input[ n ]) - hy;
+            /*}else
              {
-                auto neighbors = cell.getNeighborEntities();
-                Real pom = 0;
-                const IndexType e = neighbors.template getEntityIndex<  1,  0 >();
-                const IndexType n = neighbors.template getEntityIndex<  0,  1 >();
-                //Try init with exact data:
-                /*if( c * input[ n ] <= 0 )
-                {
-                    output[ cell.getIndex() ] = c;
-                    output[ n ] = input[ n ];
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ n ] = true;
-                }   
-                if( c * input[ e ] <= 0 )
-                {   
-                    output[ cell.getIndex() ] = c;
-                    output[ e ] = input[ e ];
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ e ] = true;
-                }*/
-                if( c * input[ n ] <= 0 )
-                {
-                    /*if( c >= 0 )
-                    {*/
-                        pom = TNL::sign( c )*( hy * c )/( c - input[ n ]);
-                        if( TNL::abs( output[ cell.getIndex() ] ) > TNL::abs( pom ) ) 
-                            output[ cell.getIndex() ] = pom;
-                        pom = pom - TNL::sign( c )*hy;
-                        if( TNL::abs( output[ n ] ) > TNL::abs( pom ) )
-                            output[ n ] = pom; //( hy * c )/( c - input[ n ]) - hy;
-                    /*}else
-                    {
-                        pom = - ( hy * c )/( c - input[ n ]);
-                        if( output[ cell.getIndex() ] < pom )
-                            output[ cell.getIndex() ] = pom;
-                        if( output[ n ] > hy + pom )
-                            output[ n ] = hy + pom; //hy - ( hy * c )/( c - input[ n ]);
-                    }*/
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ n ] = true;
-                }
-                if( c * input[ e ] <= 0 )
-                {
-                    /*if( c >= 0 )
-                    {*/
-                        pom = TNL::sign( c )*( hx * c )/( c - input[ e ]);
-                        if( TNL::abs( output[ cell.getIndex() ] ) > TNL::abs( pom ) )
-                            output[ cell.getIndex() ] = pom;
-
-                        pom = pom - TNL::sign( c )*hx; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
-                        if( TNL::abs( output[ e ] ) > TNL::abs( pom ) )
-                            output[ e ] = pom; 
-                    /*}else
-                    {
-                        pom = - (hx * c)/( c - input[ e ]);
-                        if( output[ cell.getIndex() ] < pom )
-                            output[ cell.getIndex() ] = pom;
-
-                        pom = pom + hx; //output[ e ] = hx - (hx * c)/( c - input[ e ]);
-                        if( output[ e ] > pom )
-                            output[ e ] = pom;
-                    }*/
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ e ] = true;
-                }
-             }
+             pom = - ( hy * c )/( c - input[ n ]);
+             if( output[ cell.getIndex() ] < pom )
+             output[ cell.getIndex() ] = pom;
+             if( output[ n ] > hy + pom )
+             output[ n ] = hy + pom; //hy - ( hy * c )/( c - input[ n ]);
+             }*/
+            interfaceMap[ cell.getIndex() ] = true;
+            interfaceMap[ n ] = true;
           }
+          if( c * input[ e ] <= 0 )
+          {
+            /*if( c >= 0 )
+             {*/
+            pom = TNL::sign( c )*( hx * c )/( c - input[ e ]);
+            if( TNL::abs( output[ cell.getIndex() ] ) > TNL::abs( pom ) )
+              output[ cell.getIndex() ] = pom;
+            
+            pom = pom - TNL::sign( c )*hx; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
+            if( TNL::abs( output[ e ] ) > TNL::abs( pom ) )
+              output[ e ] = pom; 
+            /*}else
+             {
+             pom = - (hx * c)/( c - input[ e ]);
+             if( output[ cell.getIndex() ] < pom )
+             output[ cell.getIndex() ] = pom;
+             
+             pom = pom + hx; //output[ e ] = hx - (hx * c)/( c - input[ e ]);
+             if( output[ e ] > pom )
+             output[ e ] = pom;
+             }*/
+            interfaceMap[ cell.getIndex() ] = true;
+            interfaceMap[ e ] = true;
+          }
+        }
       }
+  }
 }
 
 template< typename Real,
-          typename Device,
-          typename Index >
-   template< typename MeshEntity >
+        typename Device,
+        typename Index >
+template< typename MeshEntity >
 __cuda_callable__
 void
 tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >::
 updateCell( MeshFunctionType& u,
-            const MeshEntity& cell,   
-            const RealType v)
+        const MeshEntity& cell,   
+        const RealType v)
 {
-   const auto& neighborEntities = cell.template getNeighborEntities< 2 >();
-   const MeshType& mesh = cell.getMesh();
-   const RealType& hx = mesh.getSpaceSteps().x();
-   const RealType& hy = mesh.getSpaceSteps().y();
-   const RealType value = u( cell );
-   RealType a, b, tmp = std::numeric_limits< RealType >::max();
-   
-   if( cell.getCoordinates().x() == 0 )
-      a = u[ neighborEntities.template getEntityIndex< 1,  0 >() ];
-   else if( cell.getCoordinates().x() == mesh.getDimensions().x() - 1 )
-      a = u[ neighborEntities.template getEntityIndex< -1,  0 >() ];
-   else
-   {
-      a = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< -1,  0 >() ],
-                          u[ neighborEntities.template getEntityIndex<  1,  0 >() ] );
-   }
-
-   if( cell.getCoordinates().y() == 0 )
-      b = u[ neighborEntities.template getEntityIndex< 0,  1 >()];
-   else if( cell.getCoordinates().y() == mesh.getDimensions().y() - 1 )
-      b = u[ neighborEntities.template getEntityIndex< 0,  -1 >() ];
-   else
-   {
-      b = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< 0,  -1 >() ],
-                          u[ neighborEntities.template getEntityIndex< 0,   1 >() ] );
-   }
-   if( fabs( a ) == std::numeric_limits< RealType >::max() && 
-       fabs( b ) == std::numeric_limits< RealType >::max() )
-      return;
-   /*if( fabs( a ) == TypeInfo< Real >::getMaxValue() ||
-       fabs( b ) == TypeInfo< Real >::getMaxValue() ||
-       fabs( a - b ) >= TNL::sqrt( (hx * hx + hy * hy)/v ) )
+  const auto& neighborEntities = cell.template getNeighborEntities< 2 >();
+  const MeshType& mesh = cell.getMesh();
+  const RealType& hx = mesh.getSpaceSteps().x();
+  const RealType& hy = mesh.getSpaceSteps().y();
+  const RealType value = u( cell );
+  RealType a, b, tmp = std::numeric_limits< RealType >::max();
+  
+  if( cell.getCoordinates().x() == 0 )
+    a = u[ neighborEntities.template getEntityIndex< 1,  0 >() ];
+  else if( cell.getCoordinates().x() == mesh.getDimensions().x() - 1 )
+    a = u[ neighborEntities.template getEntityIndex< -1,  0 >() ];
+  else
+  {
+    a = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< -1,  0 >() ],
+            u[ neighborEntities.template getEntityIndex<  1,  0 >() ] );
+  }
+  
+  if( cell.getCoordinates().y() == 0 )
+    b = u[ neighborEntities.template getEntityIndex< 0,  1 >()];
+  else if( cell.getCoordinates().y() == mesh.getDimensions().y() - 1 )
+    b = u[ neighborEntities.template getEntityIndex< 0,  -1 >() ];
+  else
+  {
+    b = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< 0,  -1 >() ],
+            u[ neighborEntities.template getEntityIndex< 0,   1 >() ] );
+  }
+  if( fabs( a ) == std::numeric_limits< RealType >::max() && 
+          fabs( b ) == std::numeric_limits< RealType >::max() )
+    return;
+  /*if( fabs( a ) == TypeInfo< Real >::getMaxValue() ||
+   fabs( b ) == TypeInfo< Real >::getMaxValue() ||
+   fabs( a - b ) >= TNL::sqrt( (hx * hx + hy * hy)/v ) )
    {
-      tmp = 
-        fabs( a ) >= fabs( b ) ? b + TNL::sign( value ) * hy :
-                                 a + TNL::sign( value ) * hx;
+   tmp = 
+   fabs( a ) >= fabs( b ) ? b + TNL::sign( value ) * hy :
+   a + TNL::sign( value ) * hx;
    }*/
-   /*if( fabs( a ) != TypeInfo< Real >::getMaxValue() &&
-       fabs( b ) != TypeInfo< Real >::getMaxValue() &&
-       fabs( a - b ) < TNL::sqrt( (hx * hx + hy * hy)/v ) )
+  /*if( fabs( a ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( b ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( a - b ) < TNL::sqrt( (hx * hx + hy * hy)/v ) )
    {
-       tmp = ( hx * hx * b + hy * hy * a + 
-            sign( value ) * hx * hy * TNL::sqrt( ( hx * hx + hy * hy )/v - 
-            ( a - b ) * ( a - b ) ) )/( hx * hx + hy * hy );
-       u[ cell.getIndex() ] =  tmp;
+   tmp = ( hx * hx * b + hy * hy * a + 
+   sign( value ) * hx * hy * TNL::sqrt( ( hx * hx + hy * hy )/v - 
+   ( a - b ) * ( a - b ) ) )/( hx * hx + hy * hy );
+   u[ cell.getIndex() ] =  tmp;
    }
    else
    {
-       tmp = 
-          fabs( a ) > fabs( b ) ? b + TNL::sign( value ) * hy/v :
-                                   a + TNL::sign( value ) * hx/v;
-       u[ cell.getIndex() ] = argAbsMin( value, tmp );
-       //tmp = TypeInfo< RealType >::getMaxValue();
+   tmp = 
+   fabs( a ) > fabs( b ) ? b + TNL::sign( value ) * hy/v :
+   a + TNL::sign( value ) * hx/v;
+   u[ cell.getIndex() ] = argAbsMin( value, tmp );
+   //tmp = TypeInfo< RealType >::getMaxValue();
    }*/
-    RealType pom[6] = { a, b, std::numeric_limits< RealType >::max(), (RealType)hx, (RealType)hy, 0.0 };
-    sortMinims( pom );
-    tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ]/v;
-    
-                                
-    if( fabs( tmp ) < fabs( pom[ 1 ] ) ) 
-        u[ cell.getIndex() ] = argAbsMin( value, tmp );
-    else
-    {
-        tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
+  RealType pom[6] = { a, b, std::numeric_limits< RealType >::max(), (RealType)hx, (RealType)hy, 0.0 };
+  sortMinims( pom );
+  tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ]/v;
+  
+  
+  if( fabs( tmp ) < fabs( pom[ 1 ] ) ) 
+    u[ cell.getIndex() ] = argAbsMin( value, tmp );
+  else
+  {
+    tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
             TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
             ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
-        u[ cell.getIndex() ] = argAbsMin( value, tmp );
-    }
+    u[ cell.getIndex() ] = argAbsMin( value, tmp );
+  }
 }
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 void
 tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >::
 initInterface( const MeshFunctionPointer& _input,
-               MeshFunctionPointer& _output,
-               InterfaceMapPointer& _interfaceMap  )
+        MeshFunctionPointer& _output,
+        InterfaceMapPointer& _interfaceMap  )
 {
-    if( std::is_same< Device, Devices::Cuda >::value )
-    {
+  if( std::is_same< Device, Devices::Cuda >::value )
+  {
 #ifdef HAVE_CUDA
-        const MeshType& mesh = _input->getMesh();
-        
-        const int cudaBlockSize( 8 );
-        int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().x(), cudaBlockSize );
-        int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().y(), cudaBlockSize );
-        int numBlocksZ = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().z(), cudaBlockSize );
-        if( cudaBlockSize * cudaBlockSize * cudaBlockSize > 1024 || numBlocksX > 1024 || numBlocksY > 1024 || numBlocksZ > 64 )
-            std::cout << "Invalid kernel call. Dimensions of grid are max: [1024,1024,64], and maximum threads per block are 1024!" << std::endl;
-        dim3 blockSize( cudaBlockSize, cudaBlockSize, cudaBlockSize );
-        dim3 gridSize( numBlocksX, numBlocksY, numBlocksZ );
-        Devices::Cuda::synchronizeDevice();
-        CudaInitCaller3d<<< gridSize, blockSize >>>( _input.template getData< Device >(),
-                                                     _output.template modifyData< Device >(),
-                                                     _interfaceMap.template modifyData< Device >() );
-        cudaDeviceSynchronize();
-        TNL_CHECK_CUDA_DEVICE;
+    const MeshType& mesh = _input->getMesh();
+    
+    const int cudaBlockSize( 8 );
+    int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().x(), cudaBlockSize );
+    int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().y(), cudaBlockSize );
+    int numBlocksZ = Devices::Cuda::getNumberOfBlocks( mesh.getDimensions().z(), cudaBlockSize );
+    if( cudaBlockSize * cudaBlockSize * cudaBlockSize > 1024 || numBlocksX > 1024 || numBlocksY > 1024 || numBlocksZ > 64 )
+      std::cout << "Invalid kernel call. Dimensions of grid are max: [1024,1024,64], and maximum threads per block are 1024!" << std::endl;
+    dim3 blockSize( cudaBlockSize, cudaBlockSize, cudaBlockSize );
+    dim3 gridSize( numBlocksX, numBlocksY, numBlocksZ );
+    Devices::Cuda::synchronizeDevice();
+    CudaInitCaller3d<<< gridSize, blockSize >>>( _input.template getData< Device >(),
+            _output.template modifyData< Device >(),
+            _interfaceMap.template modifyData< Device >() );
+    cudaDeviceSynchronize();
+    TNL_CHECK_CUDA_DEVICE;
 #endif
-    }
-    if( std::is_same< Device, Devices::Host >::value )
-    {
-        const MeshFunctionType& input =  _input.getData();
-        MeshFunctionType& output =  _output.modifyData();
-        InterfaceMapType& interfaceMap =  _interfaceMap.modifyData();
-        const MeshType& mesh = input.getMesh();
-        typedef typename MeshType::Cell Cell;
-        Cell cell( mesh );
-        for( cell.getCoordinates().z() = 0;
-             cell.getCoordinates().z() < mesh.getDimensions().z();
-             cell.getCoordinates().z() ++ )
-             for( cell.getCoordinates().y() = 0;
-                  cell.getCoordinates().y() < mesh.getDimensions().y();
-                  cell.getCoordinates().y() ++ )
-                 for( cell.getCoordinates().x() = 0;
-                      cell.getCoordinates().x() < mesh.getDimensions().x();
-                      cell.getCoordinates().x() ++ )
-                 {
-                     cell.refresh();
-                     output[ cell.getIndex() ] =
-                     input( cell ) > 0 ? std::numeric_limits< RealType >::max() :
-                                        - std::numeric_limits< RealType >::max();
-                     interfaceMap[ cell.getIndex() ] = false;
-                 }
-
-        const RealType& hx = mesh.getSpaceSteps().x();
-        const RealType& hy = mesh.getSpaceSteps().y();
-        const RealType& hz = mesh.getSpaceSteps().z();
-        for( cell.getCoordinates().z() = 0;
-             cell.getCoordinates().z() < mesh.getDimensions().z();
-             cell.getCoordinates().z() ++ )   
-           for( cell.getCoordinates().y() = 0;
-                cell.getCoordinates().y() < mesh.getDimensions().y();
-                cell.getCoordinates().y() ++ )
-              for( cell.getCoordinates().x() = 0;
-                   cell.getCoordinates().x() < mesh.getDimensions().x();
-                   cell.getCoordinates().x() ++ )
+  }
+  if( std::is_same< Device, Devices::Host >::value )
+  {
+    const MeshFunctionType& input =  _input.getData();
+    MeshFunctionType& output =  _output.modifyData();
+    InterfaceMapType& interfaceMap =  _interfaceMap.modifyData();
+    const MeshType& mesh = input.getMesh();
+    typedef typename MeshType::Cell Cell;
+    Cell cell( mesh );
+    for( cell.getCoordinates().z() = 0;
+            cell.getCoordinates().z() < mesh.getDimensions().z();
+            cell.getCoordinates().z() ++ )
+      for( cell.getCoordinates().y() = 0;
+              cell.getCoordinates().y() < mesh.getDimensions().y();
+              cell.getCoordinates().y() ++ )
+        for( cell.getCoordinates().x() = 0;
+                cell.getCoordinates().x() < mesh.getDimensions().x();
+                cell.getCoordinates().x() ++ )
+        {
+          cell.refresh();
+          output[ cell.getIndex() ] =
+                  input( cell ) > 0 ? 10://std::numeric_limits< RealType >::max() :
+                    -10;//- std::numeric_limits< RealType >::max();
+          interfaceMap[ cell.getIndex() ] = false;
+        }
+    
+    const RealType& hx = mesh.getSpaceSteps().x();
+    const RealType& hy = mesh.getSpaceSteps().y();
+    const RealType& hz = mesh.getSpaceSteps().z();
+    for( cell.getCoordinates().z() = 0;
+            cell.getCoordinates().z() < mesh.getDimensions().z();
+            cell.getCoordinates().z() ++ )   
+      for( cell.getCoordinates().y() = 0;
+              cell.getCoordinates().y() < mesh.getDimensions().y();
+              cell.getCoordinates().y() ++ )
+        for( cell.getCoordinates().x() = 0;
+                cell.getCoordinates().x() < mesh.getDimensions().x();
+                cell.getCoordinates().x() ++ )
+        {
+          cell.refresh();
+          const RealType& c = input( cell );
+          if( ! cell.isBoundaryEntity() )
+          {
+            auto neighbors = cell.getNeighborEntities();
+            Real pom = 0;
+            const IndexType e = neighbors.template getEntityIndex<  1,  0,  0 >();
+            const IndexType n = neighbors.template getEntityIndex<  0,  1,  0 >();
+            const IndexType t = neighbors.template getEntityIndex<  0,  0,  1 >();
+            //Try exact initiation
+            /*const IndexType w = neighbors.template getEntityIndex< -1,  0,  0 >();
+             const IndexType s = neighbors.template getEntityIndex<  0, -1,  0 >();
+             const IndexType b = neighbors.template getEntityIndex<  0,  0, -1 >();
+             if( c * input[ e ] <= 0 )
+             {
+             output[ cell.getIndex() ] = c;
+             output[ e ] = input[ e ];
+             interfaceMap[ e ] = true;   
+             interfaceMap[ cell.getIndex() ] = true;
+             }
+             else if( c * input[ n ] <= 0 )
+             {
+             output[ cell.getIndex() ] = c;
+             output[ n ] = input[ n ];
+             interfaceMap[ n ] = true;   
+             interfaceMap[ cell.getIndex() ] = true;
+             }
+             else if( c * input[ t ] <= 0 )
+             {
+             output[ cell.getIndex() ] = c;
+             output[ t ] = input[ t ];
+             interfaceMap[ t ] = true;   
+             interfaceMap[ cell.getIndex() ] = true;
+             }*/
+            if( c * input[ n ] <= 0 )
+            {
+              if( c >= 0 )
               {
-                 cell.refresh();
-                 const RealType& c = input( cell );
-                 if( ! cell.isBoundaryEntity() )
-                 {
-                    auto neighbors = cell.getNeighborEntities();
-                    Real pom = 0;
-                    const IndexType e = neighbors.template getEntityIndex<  1,  0,  0 >();
-                    const IndexType n = neighbors.template getEntityIndex<  0,  1,  0 >();
-                    const IndexType t = neighbors.template getEntityIndex<  0,  0,  1 >();
-                    //Try exact initiation
-                    /*const IndexType w = neighbors.template getEntityIndex< -1,  0,  0 >();
-                    const IndexType s = neighbors.template getEntityIndex<  0, -1,  0 >();
-                    const IndexType b = neighbors.template getEntityIndex<  0,  0, -1 >();
-                    if( c * input[ e ] <= 0 )
-                    {
-                       output[ cell.getIndex() ] = c;
-                       output[ e ] = input[ e ];
-                       interfaceMap[ e ] = true;   
-                       interfaceMap[ cell.getIndex() ] = true;
-                    }
-                    else if( c * input[ n ] <= 0 )
-                    {
-                       output[ cell.getIndex() ] = c;
-                       output[ n ] = input[ n ];
-                       interfaceMap[ n ] = true;   
-                       interfaceMap[ cell.getIndex() ] = true;
-                    }
-                    else if( c * input[ t ] <= 0 )
-                    {
-                       output[ cell.getIndex() ] = c;
-                       output[ t ] = input[ t ];
-                       interfaceMap[ t ] = true;   
-                       interfaceMap[ cell.getIndex() ] = true;
-                    }*/
-                    if( c * input[ n ] <= 0 )
-                    {
-                        if( c >= 0 )
-                        {
-                        pom = ( hy * c )/( c - input[ n ]);
-                        if( output[ cell.getIndex() ] > pom ) 
-                            output[ cell.getIndex() ] = pom;
-
-                        if ( output[ n ] < pom - hy)
-                             output[ n ] = pom - hy; // ( hy * c )/( c - input[ n ]) - hy;
-
-                        }else
-                        {
-                          pom = - ( hy * c )/( c - input[ n ]);
-                          if( output[ cell.getIndex() ] < pom )
-                              output[ cell.getIndex() ] = pom;
-                          if( output[ n ] > hy + pom )
-                              output[ n ] = hy + pom; //hy - ( hy * c )/( c - input[ n ]);
-
-                        }
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ n ] = true;
-                    }
-                    if( c * input[ e ] <= 0 )
-                    {
-                        if( c >= 0 )
-                        {
-                            pom = ( hx * c )/( c - input[ e ]);
-                            if( output[ cell.getIndex() ] > pom )
-                                output[ cell.getIndex() ] = pom;
-
-                            pom = pom - hx; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
-                            if( output[ e ] < pom )
-                                output[ e ] = pom;      
-
-                        }else
-                        {
-                            pom = - (hx * c)/( c - input[ e ]);
-                            if( output[ cell.getIndex() ] < pom )
-                                output[ cell.getIndex() ] = pom;
-
-                            pom = pom + hx; //output[ e ] = hx - (hx * c)/( c - input[ e ]);
-                            if( output[ e ] > pom )
-                                output[ e ] = pom;
-                        }
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ e ] = true;
-                    }
-                    if( c * input[ t ] <= 0 )
-                    {
-                        if( c >= 0 )
-                        {
-                            pom = ( hz * c )/( c - input[ t ]);
-                            if( output[ cell.getIndex() ] > pom )
-                                output[ cell.getIndex() ] = pom;
-
-                            pom = pom - hz; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
-                            if( output[ t ] < pom )
-                                output[ t ] = pom; 
-
-                        }else
-                        {
-                            pom = - (hz * c)/( c - input[ t ]);
-                            if( output[ cell.getIndex() ] < pom )
-                                output[ cell.getIndex() ] = pom;
-
-                            pom = pom + hz; //output[ e ] = hx - (hx * c)/( c - input[ e ]);
-                            if( output[ t ] > pom )
-                                output[ t ] = pom;
-
-                        }
-                    interfaceMap[ cell.getIndex() ] = true;
-                    interfaceMap[ t ] = true;
-                    }    
-                 }
-                 /*output[ cell.getIndex() ] =
-                    c > 0 ? TypeInfo< RealType >::getMaxValue() :
-                           -TypeInfo< RealType >::getMaxValue();
-                 interfaceMap[ cell.getIndex() ] = false;*/ //is on line 245
+                pom = ( hy * c )/( c - input[ n ]);
+                if( output[ cell.getIndex() ] > pom ) 
+                  output[ cell.getIndex() ] = pom;
+                
+                if ( output[ n ] < pom - hy)
+                  output[ n ] = pom - hy; // ( hy * c )/( c - input[ n ]) - hy;
+                
+              }else
+              {
+                pom = - ( hy * c )/( c - input[ n ]);
+                if( output[ cell.getIndex() ] < pom )
+                  output[ cell.getIndex() ] = pom;
+                if( output[ n ] > hy + pom )
+                  output[ n ] = hy + pom; //hy - ( hy * c )/( c - input[ n ]);
+                
               }
-    }
+              interfaceMap[ cell.getIndex() ] = true;
+              interfaceMap[ n ] = true;
+            }
+            if( c * input[ e ] <= 0 )
+            {
+              if( c >= 0 )
+              {
+                pom = ( hx * c )/( c - input[ e ]);
+                if( output[ cell.getIndex() ] > pom )
+                  output[ cell.getIndex() ] = pom;
+                
+                pom = pom - hx; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
+                if( output[ e ] < pom )
+                  output[ e ] = pom;      
+                
+              }else
+              {
+                pom = - (hx * c)/( c - input[ e ]);
+                if( output[ cell.getIndex() ] < pom )
+                  output[ cell.getIndex() ] = pom;
+                
+                pom = pom + hx; //output[ e ] = hx - (hx * c)/( c - input[ e ]);
+                if( output[ e ] > pom )
+                  output[ e ] = pom;
+              }
+              interfaceMap[ cell.getIndex() ] = true;
+              interfaceMap[ e ] = true;
+            }
+            if( c * input[ t ] <= 0 )
+            {
+              if( c >= 0 )
+              {
+                pom = ( hz * c )/( c - input[ t ]);
+                if( output[ cell.getIndex() ] > pom )
+                  output[ cell.getIndex() ] = pom;
+                
+                pom = pom - hz; //output[ e ] = (hx * c)/( c - input[ e ]) - hx;
+                if( output[ t ] < pom )
+                  output[ t ] = pom; 
+                
+              }else
+              {
+                pom = - (hz * c)/( c - input[ t ]);
+                if( output[ cell.getIndex() ] < pom )
+                  output[ cell.getIndex() ] = pom;
+                
+                pom = pom + hz; //output[ e ] = hx - (hx * c)/( c - input[ e ]);
+                if( output[ t ] > pom )
+                  output[ t ] = pom;
+                
+              }
+              interfaceMap[ cell.getIndex() ] = true;
+              interfaceMap[ t ] = true;
+            }    
+          }
+          /*output[ cell.getIndex() ] =
+           c > 0 ? TypeInfo< RealType >::getMaxValue() :
+           -TypeInfo< RealType >::getMaxValue();
+           interfaceMap[ cell.getIndex() ] = false;*/ //is on line 245
+        }
+  }
 }
 
 template< typename Real,
-          typename Device,
-          typename Index >
-   template< typename MeshEntity >
+        typename Device,
+        typename Index >
+template< typename MeshEntity >
 __cuda_callable__
 void
 tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >::
 updateCell( MeshFunctionType& u,
-            const MeshEntity& cell, 
-            const RealType v )
+        const MeshEntity& cell, 
+        const RealType v )
 {
-   const auto& neighborEntities = cell.template getNeighborEntities< 3 >();
-   const MeshType& mesh = cell.getMesh();
+  const auto& neighborEntities = cell.template getNeighborEntities< 3 >();
+  const MeshType& mesh = cell.getMesh();
   
-   const RealType& hx = mesh.getSpaceSteps().x();
-   const RealType& hy = mesh.getSpaceSteps().y();
-   const RealType& hz = mesh.getSpaceSteps().z();
-   const RealType value = u( cell );
-   //std::cout << value << std::endl;
-   RealType a, b, c, tmp = std::numeric_limits< RealType >::max();
-   
-   
-   if( cell.getCoordinates().x() == 0 )
-      a = u[ neighborEntities.template getEntityIndex< 1, 0, 0 >() ];
-   else if( cell.getCoordinates().x() == mesh.getDimensions().x() - 1 )
-      a = u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ];
-   else
+  const RealType& hx = mesh.getSpaceSteps().x();
+  const RealType& hy = mesh.getSpaceSteps().y();
+  const RealType& hz = mesh.getSpaceSteps().z();
+  const RealType value = u( cell );
+  //std::cout << value << std::endl;
+  RealType a, b, c, tmp = std::numeric_limits< RealType >::max();
+  
+  
+  if( cell.getCoordinates().x() == 0 )
+    a = u[ neighborEntities.template getEntityIndex< 1, 0, 0 >() ];
+  else if( cell.getCoordinates().x() == mesh.getDimensions().x() - 1 )
+    a = u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ];
+  else
+  {
+    a = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ],
+            u[ neighborEntities.template getEntityIndex< 1, 0, 0 >() ] );
+  }
+  if( cell.getCoordinates().y() == 0 )
+    b = u[ neighborEntities.template getEntityIndex< 0, 1, 0 >() ];
+  else if( cell.getCoordinates().y() == mesh.getDimensions().y() - 1 )
+    b = u[ neighborEntities.template getEntityIndex< 0, -1, 0 >() ];
+  else
+  {
+    b = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< 0, -1, 0 >() ],
+            u[ neighborEntities.template getEntityIndex< 0, 1, 0 >() ] );
+  }if( cell.getCoordinates().z() == 0 )
+    c = u[ neighborEntities.template getEntityIndex< 0, 0, 1 >() ];
+  else if( cell.getCoordinates().z() == mesh.getDimensions().z() - 1 )
+    c = u[ neighborEntities.template getEntityIndex< 0, 0, -1 >() ];
+  else
+  {
+    c = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< 0, 0, -1 >() ],
+            u[ neighborEntities.template getEntityIndex< 0, 0, 1 >() ] );
+  }
+  if( fabs( a ) == std::numeric_limits< RealType >::max() && 
+          fabs( b ) == std::numeric_limits< RealType >::max() &&
+          fabs( c ) == std::numeric_limits< RealType >::max() )
+    return;
+  
+  
+  /*if( fabs( a ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( b ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( a - b ) >= TNL::sqrt( (hx * hx + hy * hy)/v ) )
    {
-      a = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ],
-                        u[ neighborEntities.template getEntityIndex< 1, 0, 0 >() ] );
+   tmp = ( hx * hx * a + hy * hy * b + 
+   sign( value ) * hx * hy * sqrt( ( hx * hx + hy * hy )/v - 
+   ( a - b ) * ( a - b ) ) )/( hx * hx + hy * hy );
    }
-   if( cell.getCoordinates().y() == 0 )
-      b = u[ neighborEntities.template getEntityIndex< 0, 1, 0 >() ];
-   else if( cell.getCoordinates().y() == mesh.getDimensions().y() - 1 )
-      b = u[ neighborEntities.template getEntityIndex< 0, -1, 0 >() ];
-   else
-   {
-      b = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< 0, -1, 0 >() ],
-                        u[ neighborEntities.template getEntityIndex< 0, 1, 0 >() ] );
-   }if( cell.getCoordinates().z() == 0 )
-      c = u[ neighborEntities.template getEntityIndex< 0, 0, 1 >() ];
-   else if( cell.getCoordinates().z() == mesh.getDimensions().z() - 1 )
-      c = u[ neighborEntities.template getEntityIndex< 0, 0, -1 >() ];
-   else
+   if( fabs( a ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( c ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( a - c ) >= TNL::sqrt( (hx * hx + hz * hz)/v ) )
    {
-      c = TNL::argAbsMin( u[ neighborEntities.template getEntityIndex< 0, 0, -1 >() ],
-                         u[ neighborEntities.template getEntityIndex< 0, 0, 1 >() ] );
+   tmp = ( hx * hx * a + hz * hz * c + 
+   sign( value ) * hx * hz * sqrt( ( hx * hx + hz * hz )/v - 
+   ( a - c ) * ( a - c ) ) )/( hx * hx + hz * hz );
    }
-   if( fabs( a ) == std::numeric_limits< RealType >::max() && 
-       fabs( b ) == std::numeric_limits< RealType >::max() &&
-       fabs( c ) == std::numeric_limits< RealType >::max() )
-      return;
-   
-   
-       /*if( fabs( a ) != TypeInfo< Real >::getMaxValue() &&
-           fabs( b ) != TypeInfo< Real >::getMaxValue() &&
-           fabs( a - b ) >= TNL::sqrt( (hx * hx + hy * hy)/v ) )
-       {
-           tmp = ( hx * hx * a + hy * hy * b + 
-                sign( value ) * hx * hy * sqrt( ( hx * hx + hy * hy )/v - 
-                ( a - b ) * ( a - b ) ) )/( hx * hx + hy * hy );
-       }
-       if( fabs( a ) != TypeInfo< Real >::getMaxValue() &&
-           fabs( c ) != TypeInfo< Real >::getMaxValue() &&
-           fabs( a - c ) >= TNL::sqrt( (hx * hx + hz * hz)/v ) )
-       {
-           tmp = ( hx * hx * a + hz * hz * c + 
-                sign( value ) * hx * hz * sqrt( ( hx * hx + hz * hz )/v - 
-                ( a - c ) * ( a - c ) ) )/( hx * hx + hz * hz );
-       }
-       if( fabs( b ) != TypeInfo< Real >::getMaxValue() &&
-           fabs( c ) != TypeInfo< Real >::getMaxValue() &&
-           fabs( b - c ) >= TNL::sqrt( (hy * hy + hz * hz)/v ) )
-       {
-           tmp = ( hy * hy * b + hz * hz * c + 
-                sign( value ) * hy * hz * sqrt( ( hy * hy + hz * hz )/v - 
-                ( b - c ) * ( b - c ) ) )/( hy * hy + hz * hz );
-       }*/
-    RealType pom[6] = { a, b, c, (RealType)hx, (RealType)hy, (RealType)hz};
-    sortMinims( pom );   
-    tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ];
-    if( fabs( tmp ) < fabs( pom[ 1 ] ) )
+   if( fabs( b ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( c ) != TypeInfo< Real >::getMaxValue() &&
+   fabs( b - c ) >= TNL::sqrt( (hy * hy + hz * hz)/v ) )
+   {
+   tmp = ( hy * hy * b + hz * hz * c + 
+   sign( value ) * hy * hz * sqrt( ( hy * hy + hz * hz )/v - 
+   ( b - c ) * ( b - c ) ) )/( hy * hy + hz * hz );
+   }*/
+  RealType pom[6] = { a, b, c, (RealType)hx, (RealType)hy, (RealType)hz};
+  sortMinims( pom );   
+  tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ];
+  if( fabs( tmp ) < fabs( pom[ 1 ] ) )
+  {
+    u[ cell.getIndex() ] = argAbsMin( value, tmp ); 
+  }
+  else
+  {
+    tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
+            TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
+            ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
+    if( fabs( tmp ) < fabs( pom[ 2 ]) ) 
     {
-        u[ cell.getIndex() ] = argAbsMin( value, tmp ); 
+      u[ cell.getIndex() ] = argAbsMin( value, tmp );
     }
     else
     {
-        tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
-            TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
-            ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
-        if( fabs( tmp ) < fabs( pom[ 2 ]) ) 
-        {
-            u[ cell.getIndex() ] = argAbsMin( value, tmp );
-        }
-        else
-        {
-            tmp = ( hy * hy * hz * hz * a + hx * hx * hz * hz * b + hx * hx * hy * hy * c +
-                TNL::sign( value ) * hx * hy * hz * TNL::sqrt( ( hx * hx * hz * hz + hy * hy * hz * hz + hx * hx * hy * hy)/( v * v ) - 
-                hz * hz * ( a - b ) * ( a - b ) - hy * hy * ( a - c ) * ( a - c ) -
-                hx * hx * ( b - c ) * ( b - c ) ) )/( hx * hx * hy * hy + hy * hy * hz * hz + hz * hz * hx *hx );
-            u[ cell.getIndex() ] = argAbsMin( value, tmp );
-        }
+      tmp = ( hy * hy * hz * hz * a + hx * hx * hz * hz * b + hx * hx * hy * hy * c +
+              TNL::sign( value ) * hx * hy * hz * TNL::sqrt( ( hx * hx * hz * hz + hy * hy * hz * hz + hx * hx * hy * hy)/( v * v ) - 
+              hz * hz * ( a - b ) * ( a - b ) - hy * hy * ( a - c ) * ( a - c ) -
+              hx * hx * ( b - c ) * ( b - c ) ) )/( hx * hx * hy * hy + hy * hy * hz * hz + hz * hz * hx *hx );
+      u[ cell.getIndex() ] = argAbsMin( value, tmp );
     }
+  }
 }
 
 template < typename T1, typename T2 >
 T1 meet2DCondition( T1 a, T1 b, const T2 ha, const T2 hb, const T1 value, double v)
 {
-   T1 tmp;
-   if( fabs( a ) != std::numeric_limits< T1 >::max &&
-       fabs( b ) != std::numeric_limits< T1 >::max &&
-       fabs( a - b ) < ha/v )//TNL::sqrt( (ha * ha + hb * hb)/2 )/v )
-   {
-      tmp = ( ha * ha * b + hb * hb * a + 
+  T1 tmp;
+  if( fabs( a ) != std::numeric_limits< T1 >::max &&
+          fabs( b ) != std::numeric_limits< T1 >::max &&
+          fabs( a - b ) < ha/v )//TNL::sqrt( (ha * ha + hb * hb)/2 )/v )
+  {
+    tmp = ( ha * ha * b + hb * hb * a + 
             TNL::sign( value ) * ha * hb * TNL::sqrt( ( ha * ha + hb * hb )/( v * v ) - 
             ( a - b ) * ( a - b ) ) )/( ha * ha + hb * hb );
-   }
-   else
-   {
-       tmp = std::numeric_limits< T1 >::max;
-   }
-   
-   return tmp;
+  }
+  else
+  {
+    tmp = std::numeric_limits< T1 >::max;
+  }
+  
+  return tmp;
 }
 
 template < typename T1 >
 __cuda_callable__ void sortMinims( T1 pom[] )
 {
-    T1 tmp[6] = {0.0,0.0,0.0,0.0,0.0,0.0}; 
-    if( fabs(pom[0]) <= fabs(pom[1]) && fabs(pom[1]) <= fabs(pom[2])){
-        tmp[0] = pom[0]; tmp[1] = pom[1]; tmp[2] = pom[2];
-        tmp[3] = pom[3]; tmp[4] = pom[4]; tmp[5] = pom[5];
-        
-    }
-    else if( fabs(pom[0]) <= fabs(pom[2]) && fabs(pom[2]) <= fabs(pom[1]) ){
-        tmp[0] = pom[0]; tmp[1] = pom[2]; tmp[2] = pom[1];
-        tmp[3] = pom[3]; tmp[4] = pom[5]; tmp[5] = pom[4];
-    }
-    else if( fabs(pom[1]) <= fabs(pom[0]) && fabs(pom[0]) <= fabs(pom[2]) ){
-        tmp[0] = pom[1]; tmp[1] = pom[0]; tmp[2] = pom[2];
-        tmp[3] = pom[4]; tmp[4] = pom[3]; tmp[5] = pom[5];
-    }
-    else if( fabs(pom[1]) <= fabs(pom[2]) && fabs(pom[2]) <= fabs(pom[0]) ){
-        tmp[0] = pom[1]; tmp[1] = pom[2]; tmp[2] = pom[0];
-        tmp[3] = pom[4]; tmp[4] = pom[5]; tmp[5] = pom[3];
-    }
-    else if( fabs(pom[2]) <= fabs(pom[0]) && fabs(pom[0]) <= fabs(pom[1]) ){
-        tmp[0] = pom[2]; tmp[1] = pom[0]; tmp[2] = pom[1];
-        tmp[3] = pom[5]; tmp[4] = pom[3]; tmp[5] = pom[4];
-    }
-    else if( fabs(pom[2]) <= fabs(pom[1]) && fabs(pom[1]) <= fabs(pom[0]) ){
-        tmp[0] = pom[2]; tmp[1] = pom[1]; tmp[2] = pom[0];
-        tmp[3] = pom[5]; tmp[4] = pom[4]; tmp[5] = pom[3];
-    }
+  T1 tmp[6] = {0.0,0.0,0.0,0.0,0.0,0.0}; 
+  if( fabs(pom[0]) <= fabs(pom[1]) && fabs(pom[1]) <= fabs(pom[2])){
+    tmp[0] = pom[0]; tmp[1] = pom[1]; tmp[2] = pom[2];
+    tmp[3] = pom[3]; tmp[4] = pom[4]; tmp[5] = pom[5];
     
-    for( int i = 0; i < 6; i++ )
-    {
-        pom[ i ] = tmp[ i ];
-    }   
+  }
+  else if( fabs(pom[0]) <= fabs(pom[2]) && fabs(pom[2]) <= fabs(pom[1]) ){
+    tmp[0] = pom[0]; tmp[1] = pom[2]; tmp[2] = pom[1];
+    tmp[3] = pom[3]; tmp[4] = pom[5]; tmp[5] = pom[4];
+  }
+  else if( fabs(pom[1]) <= fabs(pom[0]) && fabs(pom[0]) <= fabs(pom[2]) ){
+    tmp[0] = pom[1]; tmp[1] = pom[0]; tmp[2] = pom[2];
+    tmp[3] = pom[4]; tmp[4] = pom[3]; tmp[5] = pom[5];
+  }
+  else if( fabs(pom[1]) <= fabs(pom[2]) && fabs(pom[2]) <= fabs(pom[0]) ){
+    tmp[0] = pom[1]; tmp[1] = pom[2]; tmp[2] = pom[0];
+    tmp[3] = pom[4]; tmp[4] = pom[5]; tmp[5] = pom[3];
+  }
+  else if( fabs(pom[2]) <= fabs(pom[0]) && fabs(pom[0]) <= fabs(pom[1]) ){
+    tmp[0] = pom[2]; tmp[1] = pom[0]; tmp[2] = pom[1];
+    tmp[3] = pom[5]; tmp[4] = pom[3]; tmp[5] = pom[4];
+  }
+  else if( fabs(pom[2]) <= fabs(pom[1]) && fabs(pom[1]) <= fabs(pom[0]) ){
+    tmp[0] = pom[2]; tmp[1] = pom[1]; tmp[2] = pom[0];
+    tmp[3] = pom[5]; tmp[4] = pom[4]; tmp[5] = pom[3];
+  }
+  
+  for( int i = 0; i < 6; i++ )
+  {
+    pom[ i ] = tmp[ i ];
+  }   
 }
 
-
+template< typename Real,
+        typename Device,
+        typename Index >
+template< int sizeSArray >
+__cuda_callable__
+bool
+tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >::
+updateCell( volatile Real *sArray, int thri, int thrj, const Real hx, const Real hy,
+        const Real v )
+{
+  const RealType value = sArray[ thrj * sizeSArray + thri ];
+  RealType a, b, tmp = std::numeric_limits< RealType >::max();
+  
+  b = TNL::argAbsMin( sArray[ (thrj+1) * sizeSArray + thri ],
+          sArray[ (thrj-1) * sizeSArray + thri ] );
+  
+  a = TNL::argAbsMin( sArray[ thrj * sizeSArray + thri+1 ],
+          sArray[ thrj * sizeSArray + thri-1 ] );
+  
+  if( fabs( a ) == std::numeric_limits< RealType >::max() && 
+          fabs( b ) == std::numeric_limits< RealType >::max() )
+    return false;
+  
+  RealType pom[6] = { a, b, std::numeric_limits< RealType >::max(), (RealType)hx, (RealType)hy, 0.0 };
+  sortMinims( pom );
+  tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ]/v;
+  
+  
+  if( fabs( tmp ) < fabs( pom[ 1 ] ) ) 
+  {
+    sArray[ thrj * sizeSArray + thri ] = argAbsMin( value, tmp );
+    tmp = value - sArray[ thrj * sizeSArray + thri ];
+    if ( fabs( tmp ) >  0.001*hx )
+      return true;
+    else
+      return false;
+  }
+  else
+  {
+    tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
+            TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
+            ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
+    sArray[ thrj * sizeSArray + thri ] = argAbsMin( value, tmp );
+    tmp = value - sArray[ thrj * sizeSArray + thri ];
+    if ( fabs( tmp ) > 0.001*hx )
+      return true;
+    else
+      return false;
+  }
+  
+  return false;
+}
+template< typename Real,
+        typename Device,
+        typename Index >
+template< int sizeSArray >
+__cuda_callable__ 
+bool 
+tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >::
+updateCell3D( volatile Real *sArray, int thri, int thrj, int thrk,
+        const Real hx, const Real hy, const Real hz, const Real v )
+{
+  const RealType value = sArray[thrk *sizeSArray * sizeSArray + thrj * sizeSArray + thri];
+  
+  RealType a, b, c, tmp = std::numeric_limits< RealType >::max();
+  
+  c = TNL::argAbsMin( sArray[ (thrk+1)* sizeSArray*sizeSArray + thrj * sizeSArray + thri ],
+          sArray[ (thrk-1) * sizeSArray *sizeSArray + thrj* sizeSArray + thri ] );
+  
+  b = TNL::argAbsMin( sArray[ thrk* sizeSArray*sizeSArray + (thrj+1) * sizeSArray + thri ],
+          sArray[ thrk* sizeSArray * sizeSArray + (thrj-1)* sizeSArray +thri ] );
+  
+  a = TNL::argAbsMin( sArray[ thrk* sizeSArray* sizeSArray  + thrj* sizeSArray + thri+1 ],
+          sArray[ thrk* sizeSArray * sizeSArray + thrj* sizeSArray +thri-1 ] );
+  
+  /*if( thrk == 8 )
+    printf("Calculating a = %f, b = %f, c = %f\n" , a, b, c );*/
+  
+  if( fabs( a ) == 10&& //std::numeric_limits< RealType >::max() && 
+          fabs( b ) == 10&&//std::numeric_limits< RealType >::max() &&
+          fabs( c ) == 10)//std::numeric_limits< RealType >::max() )
+    return false;
+  
+  RealType pom[6] = { a, b, c, (RealType)hx, (RealType)hy, (RealType)hz};
+  
+  sortMinims( pom );
+  
+  tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ];
+  if( fabs( tmp ) < fabs( pom[ 1 ] ) ) 
+  {
+    sArray[ thrk* sizeSArray* sizeSArray + thrj* sizeSArray + thri ] = argAbsMin( value, tmp );
+    tmp = value - sArray[ thrk* sizeSArray* sizeSArray  + thrj* sizeSArray + thri ];
+    if ( fabs( tmp ) >  0.001*hx )
+      return true;
+    else
+      return false;
+  }
+  else
+  {
+    tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
+            TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
+            ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
+    if( fabs( tmp ) < fabs( pom[ 2 ]) ) 
+    {
+      sArray[ thrk* sizeSArray* sizeSArray  + thrj* sizeSArray + thri ] = argAbsMin( value, tmp );
+      tmp = value - sArray[ thrk* sizeSArray* sizeSArray  + thrj* sizeSArray + thri ];
+      if ( fabs( tmp ) > 0.001*hx )
+        return true;
+      else
+        return false;
+    }
+    else
+    {
+      tmp = ( hy * hy * hz * hz * a + hx * hx * hz * hz * b + hx * hx * hy * hy * c +
+              TNL::sign( value ) * hx * hy * hz * TNL::sqrt( ( hx * hx * hz * hz + hy * hy * hz * hz + hx * hx * hy * hy)/( v * v ) - 
+              hz * hz * ( a - b ) * ( a - b ) - hy * hy * ( a - c ) * ( a - c ) -
+              hx * hx * ( b - c ) * ( b - c ) ) )/( hx * hx * hy * hy + hy * hy * hz * hz + hz * hz * hx *hx );
+      sArray[ thrk* sizeSArray* sizeSArray  + thrj* sizeSArray + thri ] = argAbsMin( value, tmp );
+      tmp = value - sArray[ thrk* sizeSArray* sizeSArray  + thrj* sizeSArray + thri ];
+      if ( fabs( tmp ) > 0.001*hx )
+        return true;
+      else
+        return false;
+    }
+  }
+  
+  return false;
+}
 
 #ifdef HAVE_CUDA
 template < typename Real, typename Device, typename Index >
 __global__ void CudaInitCaller( const Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& input, 
-                                Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& output,
-                                Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index >, 1, bool >& interfaceMap  )
+        Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index > >& output,
+        Functions::MeshFunction< Meshes::Grid< 1, Real, Device, Index >, 1, bool >& interfaceMap  )
 {
-    int i = threadIdx.x + blockDim.x*blockIdx.x;
-    const Meshes::Grid< 1, Real, Device, Index >& mesh = input.template getMesh< Devices::Cuda >();
+  int i = threadIdx.x + blockDim.x*blockIdx.x;
+  const Meshes::Grid< 1, Real, Device, Index >& mesh = input.template getMesh< Devices::Cuda >();
+  
+  if( i < mesh.getDimensions().x()  )
+  {
+    typedef typename Meshes::Grid< 1, Real, Device, Index >::Cell Cell;
+    Cell cell( mesh );
+    cell.getCoordinates().x() = i;
+    cell.refresh();
+    const Index cind = cell.getIndex();
+    
     
-    if( i < mesh.getDimensions().x()  )
+    output[ cind ] =
+            input( cell ) >= 0 ? std::numeric_limits< Real >::max() :
+              - std::numeric_limits< Real >::max();
+    interfaceMap[ cind ] = false; 
+    
+    const Real& h = mesh.getSpaceSteps().x();
+    cell.refresh();
+    const Real& c = input( cell );
+    if( ! cell.isBoundaryEntity()  )
     {
-        typedef typename Meshes::Grid< 1, Real, Device, Index >::Cell Cell;
-        Cell cell( mesh );
-        cell.getCoordinates().x() = i;
-        cell.refresh();
-        const Index cind = cell.getIndex();
-
-
-        output[ cind ] =
-               input( cell ) >= 0 ? std::numeric_limits< Real >::max() :
-                                    - std::numeric_limits< Real >::max();
-        interfaceMap[ cind ] = false; 
-
-        const Real& h = mesh.getSpaceSteps().x();
-        cell.refresh();
-        const Real& c = input( cell );
-        if( ! cell.isBoundaryEntity()  )
-        {
-           auto neighbors = cell.getNeighborEntities();
-           Real pom = 0;
-           const Index e = neighbors.template getEntityIndex< 1 >();
-           const Index w = neighbors.template getEntityIndex< -1 >();
-           if( c * input[ e ] <= 0 )
-           {
-               pom = TNL::sign( c )*( h * c )/( c - input[ e ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) )
-                   output[ cind ] = pom;                       
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ w ] <= 0 )
-           {
-               pom = TNL::sign( c )*( h * c )/( c - input[ w ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-        }
+      auto neighbors = cell.getNeighborEntities();
+      Real pom = 0;
+      const Index e = neighbors.template getEntityIndex< 1 >();
+      const Index w = neighbors.template getEntityIndex< -1 >();
+      if( c * input[ e ] <= 0 )
+      {
+        pom = TNL::sign( c )*( h * c )/( c - input[ e ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) )
+          output[ cind ] = pom;                       
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ w ] <= 0 )
+      {
+        pom = TNL::sign( c )*( h * c )/( c - input[ w ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
     }
-           
+  }
+  
 }
 template < typename Real, typename Device, typename Index >
 __global__ void CudaInitCaller( const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& input, 
-                                Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& output,
-                                Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap ) 
+        Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& output,
+        Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap ) 
 {
-    int i = threadIdx.x + blockDim.x*blockIdx.x;
-    int j = blockDim.y*blockIdx.y + threadIdx.y;
-    const Meshes::Grid< 2, Real, Device, Index >& mesh = input.template getMesh< Devices::Cuda >();
+  int i = threadIdx.x + blockDim.x*blockIdx.x;
+  int j = blockDim.y*blockIdx.y + threadIdx.y;
+  const Meshes::Grid< 2, Real, Device, Index >& mesh = input.template getMesh< Devices::Cuda >();
+  
+  if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() )
+  {
+    typedef typename Meshes::Grid< 2, Real, Device, Index >::Cell Cell;
+    Cell cell( mesh );
+    cell.getCoordinates().x() = i; cell.getCoordinates().y() = j;
+    cell.refresh();
+    const Index cind = cell.getIndex();
+    
     
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() )
+    output[ cind ] =
+            input( cell ) >= 0 ? std::numeric_limits< Real >::max() :
+              - std::numeric_limits< Real >::max();
+    interfaceMap[ cind ] = false; 
+    
+    const Real& hx = mesh.getSpaceSteps().x();
+    const Real& hy = mesh.getSpaceSteps().y();
+    cell.refresh();
+    const Real& c = input( cell );
+    if( ! cell.isBoundaryEntity()  )
     {
-        typedef typename Meshes::Grid< 2, Real, Device, Index >::Cell Cell;
-        Cell cell( mesh );
-        cell.getCoordinates().x() = i; cell.getCoordinates().y() = j;
-        cell.refresh();
-        const Index cind = cell.getIndex();
-
-
-        output[ cind ] =
-               input( cell ) >= 0 ? std::numeric_limits< Real >::max() :
-                                    - std::numeric_limits< Real >::max();
-        interfaceMap[ cind ] = false; 
-
-        const Real& hx = mesh.getSpaceSteps().x();
-        const Real& hy = mesh.getSpaceSteps().y();
-        cell.refresh();
-        const Real& c = input( cell );
-        if( ! cell.isBoundaryEntity()  )
-        {
-           auto neighbors = cell.getNeighborEntities();
-           Real pom = 0;
-           const Index e = neighbors.template getEntityIndex<  1,  0 >();
-           const Index w = neighbors.template getEntityIndex<  -1,  0 >();
-           const Index n = neighbors.template getEntityIndex<  0,  1 >();
-           const Index s = neighbors.template getEntityIndex<  0,  -1 >();
-           
-           if( c * input[ n ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hy * c )/( c - input[ n ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cell.getIndex() ] = true;
-           }
-           if( c * input[ e ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hx * c )/( c - input[ e ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) )
-                   output[ cind ] = pom;                       
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ w ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hx * c )/( c - input[ w ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ s ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hy * c )/( c - input[ s ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-        }
+      auto neighbors = cell.getNeighborEntities();
+      Real pom = 0;
+      const Index e = neighbors.template getEntityIndex<  1,  0 >();
+      const Index w = neighbors.template getEntityIndex<  -1,  0 >();
+      const Index n = neighbors.template getEntityIndex<  0,  1 >();
+      const Index s = neighbors.template getEntityIndex<  0,  -1 >();
+      
+      if( c * input[ n ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hy * c )/( c - input[ n ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cell.getIndex() ] = true;
+      }
+      if( c * input[ e ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hx * c )/( c - input[ e ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) )
+          output[ cind ] = pom;                       
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ w ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hx * c )/( c - input[ w ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ s ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hy * c )/( c - input[ s ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
     }
+  }
 }
 
 template < typename Real, typename Device, typename Index >
 __global__ void CudaInitCaller3d( const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& input, 
-                                  Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& output,
-                                  Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap )
+        Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& output,
+        Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap )
 {
-    int i = threadIdx.x + blockDim.x*blockIdx.x;
-    int j = blockDim.y*blockIdx.y + threadIdx.y;
-    int k = blockDim.z*blockIdx.z + threadIdx.z;
-    const Meshes::Grid< 3, Real, Device, Index >& mesh = input.template getMesh< Devices::Cuda >();
+  int i = threadIdx.x + blockDim.x*blockIdx.x;
+  int j = blockDim.y*blockIdx.y + threadIdx.y;
+  int k = blockDim.z*blockIdx.z + threadIdx.z;
+  const Meshes::Grid< 3, Real, Device, Index >& mesh = input.template getMesh< Devices::Cuda >();
+  
+  if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && k < mesh.getDimensions().z() )
+  {
+    typedef typename Meshes::Grid< 3, Real, Device, Index >::Cell Cell;
+    Cell cell( mesh );
+    cell.getCoordinates().x() = i; cell.getCoordinates().y() = j; cell.getCoordinates().z() = k;
+    cell.refresh();
+    const Index cind = cell.getIndex();
+    
+    
+    output[ cind ] =
+            input( cell ) >= 0 ? std::numeric_limits< Real >::max() :
+              - std::numeric_limits< Real >::max();
+    interfaceMap[ cind ] = false; 
+    cell.refresh();
     
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && k < mesh.getDimensions().z() )
+    const Real& hx = mesh.getSpaceSteps().x();
+    const Real& hy = mesh.getSpaceSteps().y();
+    const Real& hz = mesh.getSpaceSteps().z();
+    const Real& c = input( cell );
+    if( ! cell.isBoundaryEntity()  )
     {
-        typedef typename Meshes::Grid< 3, Real, Device, Index >::Cell Cell;
-        Cell cell( mesh );
-        cell.getCoordinates().x() = i; cell.getCoordinates().y() = j; cell.getCoordinates().z() = k;
-        cell.refresh();
-        const Index cind = cell.getIndex();
-
-
-        output[ cind ] =
-               input( cell ) >= 0 ? std::numeric_limits< Real >::max() :
-                                    - std::numeric_limits< Real >::max();
-        interfaceMap[ cind ] = false; 
-        cell.refresh();
-
-        const Real& hx = mesh.getSpaceSteps().x();
-        const Real& hy = mesh.getSpaceSteps().y();
-        const Real& hz = mesh.getSpaceSteps().z();
-        const Real& c = input( cell );
-        if( ! cell.isBoundaryEntity()  )
-        {
-           auto neighbors = cell.getNeighborEntities();
-           Real pom = 0;
-           const Index e = neighbors.template getEntityIndex<  1, 0, 0 >();
-           const Index w = neighbors.template getEntityIndex<  -1, 0, 0 >();
-           const Index n = neighbors.template getEntityIndex<  0, 1, 0 >();
-           const Index s = neighbors.template getEntityIndex<  0, -1, 0 >();
-           const Index t = neighbors.template getEntityIndex<  0, 0, 1 >();
-           const Index b = neighbors.template getEntityIndex<  0, 0, -1 >();
-           
-           if( c * input[ n ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hy * c )/( c - input[ n ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ e ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hx * c )/( c - input[ e ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) )
-                   output[ cind ] = pom;                       
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ w ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hx * c )/( c - input[ w ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ s ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hy * c )/( c - input[ s ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ b ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hz * c )/( c - input[ b ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-           if( c * input[ t ] <= 0 )
-           {
-               pom = TNL::sign( c )*( hz * c )/( c - input[ t ]);
-               if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
-                   output[ cind ] = pom;
-
-               interfaceMap[ cind ] = true;
-           }
-        }
+      auto neighbors = cell.getNeighborEntities();
+      Real pom = 0;
+      const Index e = neighbors.template getEntityIndex<  1, 0, 0 >();
+      const Index w = neighbors.template getEntityIndex<  -1, 0, 0 >();
+      const Index n = neighbors.template getEntityIndex<  0, 1, 0 >();
+      const Index s = neighbors.template getEntityIndex<  0, -1, 0 >();
+      const Index t = neighbors.template getEntityIndex<  0, 0, 1 >();
+      const Index b = neighbors.template getEntityIndex<  0, 0, -1 >();
+      
+      if( c * input[ n ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hy * c )/( c - input[ n ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ e ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hx * c )/( c - input[ e ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) )
+          output[ cind ] = pom;                       
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ w ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hx * c )/( c - input[ w ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ s ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hy * c )/( c - input[ s ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ b ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hz * c )/( c - input[ b ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
+      if( c * input[ t ] <= 0 )
+      {
+        pom = TNL::sign( c )*( hz * c )/( c - input[ t ]);
+        if( TNL::abs( output[ cind ] ) > TNL::abs( pom ) ) 
+          output[ cind ] = pom;
+        
+        interfaceMap[ cind ] = true;
+      }
     }
+  }
 }
 
 
-template< typename Real,
-          typename Device,
-          typename Index >
-__cuda_callable__
-bool
-tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >::
-updateCell( volatile Real sArray[18][18], int thri, int thrj, const Real hx, const Real hy,
-            const Real v )
-{
-   const RealType value = sArray[ thrj ][ thri ];
-   RealType a, b, tmp = std::numeric_limits< RealType >::max();
-      
-   b = TNL::argAbsMin( sArray[ thrj+1 ][ thri ],
-                        sArray[ thrj-1 ][ thri ] );
-    
-   a = TNL::argAbsMin( sArray[ thrj ][ thri+1 ],
-                        sArray[ thrj ][ thri-1 ] );
 
-    if( fabs( a ) == std::numeric_limits< RealType >::max() && 
-        fabs( b ) == std::numeric_limits< RealType >::max() )
-       return false;
-   
-    RealType pom[6] = { a, b, std::numeric_limits< RealType >::max(), (RealType)hx, (RealType)hy, 0.0 };
-    sortMinims( pom );
-    tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ]/v;
-    
-                                
-    if( fabs( tmp ) < fabs( pom[ 1 ] ) ) 
-    {
-        sArray[ thrj ][ thri ] = argAbsMin( value, tmp );
-        tmp = value - sArray[ thrj ][ thri ];
-        if ( fabs( tmp ) >  0.01*hx )
-            return true;
-        else
-            return false;
-    }
-    else
-    {
-        tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
-            TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
-            ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
-        sArray[ thrj ][ thri ] = argAbsMin( value, tmp );
-        tmp = value - sArray[ thrj ][ thri ];
-        if ( fabs( tmp ) > 0.01*hx )
-            return true;
-        else
-            return false;
-    }
-    
-    return false;
-}
 
 template< typename Real,
-          typename Device,
-          typename Index >
+        typename Device,
+        typename Index >
 __cuda_callable__
 bool
 tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >::
 updateCell( volatile Real sArray[18], int thri, const Real h, const Real v )
 {
-   const RealType value = sArray[ thri ];
-   RealType a, tmp = std::numeric_limits< RealType >::max();
-      
-   a = TNL::argAbsMin( sArray[ thri+1 ],
-                       sArray[ thri-1 ] );
-
-    if( fabs( a ) == std::numeric_limits< RealType >::max() )
-       return false;
-   
-    tmp = a + TNL::sign( value ) * h/v;
-    
-                                
-    sArray[ thri ] = argAbsMin( value, tmp );
-    
-    tmp = value - sArray[ thri ];
-    if ( fabs( tmp ) >  0.01*h )
-        return true;
-    else
-        return false;
-}
-
-template< typename Real,
-          typename Device,
-          typename Index >
-__cuda_callable__ 
-bool 
-tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >::
-updateCell( volatile Real sArray[10][10][10], int thri, int thrj, int thrk,
-        const Real hx, const Real hy, const Real hz, const Real v )
-{
-   const RealType value = sArray[thrk][thrj][thri];
-   //std::cout << value << std::endl;
-   RealType a, b, c, tmp = std::numeric_limits< RealType >::max();
-   
-   c = TNL::argAbsMin( sArray[ thrk+1 ][ thrj ][ thri ],
-                        sArray[ thrk-1 ][ thrj ][ thri ] );
-    
-   b = TNL::argAbsMin( sArray[ thrk ][ thrj+1 ][ thri ],
-                        sArray[ thrk ][ thrj-1 ][ thri ] );
-   
-   a = TNL::argAbsMin( sArray[ thrk ][ thrj ][ thri+1 ],
-                        sArray[ thrk ][ thrj ][ thri-1 ] );
-   
-   
-   if( fabs( a ) == std::numeric_limits< RealType >::max() && 
-       fabs( b ) == std::numeric_limits< RealType >::max() &&
-       fabs( c ) == std::numeric_limits< RealType >::max() )
-      return false;
-   
-    RealType pom[6] = { a, b, c, (RealType)hx, (RealType)hy, (RealType)hz};
-    
-    sortMinims( pom );
-    
-    tmp = pom[ 0 ] + TNL::sign( value ) * pom[ 3 ];
-    if( fabs( tmp ) < fabs( pom[ 1 ] ) ) 
-    {
-        sArray[ thrk ][ thrj ][ thri ] = argAbsMin( value, tmp );
-        tmp = value - sArray[ thrk ][ thrj ][ thri ];
-        if ( fabs( tmp ) >  0.01*hx )
-            return true;
-        else
-            return false;
-    }
-    else
-    {
-        tmp = ( pom[ 3 ] * pom[ 3 ] * pom[ 1 ] + pom[ 4 ] * pom[ 4 ] * pom[ 0 ] + 
-            TNL::sign( value ) * pom[ 3 ] * pom[ 4 ] * TNL::sqrt( ( pom[ 3 ] * pom[ 3 ] +  pom[ 4 ] *  pom[ 4 ] )/( v * v ) - 
-            ( pom[ 1 ] - pom[ 0 ] ) * ( pom[ 1 ] - pom[ 0 ] ) ) )/( pom[ 3 ] * pom[ 3 ] + pom[ 4 ] * pom[ 4 ] );
-        if( fabs( tmp ) < fabs( pom[ 2 ]) ) 
-        {
-            sArray[ thrk ][ thrj ][ thri ] = argAbsMin( value, tmp );
-            tmp = value - sArray[ thrk ][ thrj ][ thri ];
-            if ( fabs( tmp ) > 0.01*hx )
-                return true;
-            else
-                return false;
-        }
-        else
-        {
-            tmp = ( hy * hy * hz * hz * a + hx * hx * hz * hz * b + hx * hx * hy * hy * c +
-                TNL::sign( value ) * hx * hy * hz * TNL::sqrt( ( hx * hx * hz * hz + hy * hy * hz * hz + hx * hx * hy * hy)/( v * v ) - 
-                hz * hz * ( a - b ) * ( a - b ) - hy * hy * ( a - c ) * ( a - c ) -
-                hx * hx * ( b - c ) * ( b - c ) ) )/( hx * hx * hy * hy + hy * hy * hz * hz + hz * hz * hx *hx );
-            sArray[ thrk ][ thrj ][ thri ] = argAbsMin( value, tmp );
-            tmp = value - sArray[ thrk ][ thrj ][ thri ];
-            if ( fabs( tmp ) > 0.01*hx )
-                return true;
-            else
-                return false;
-        }
-    }
-    
+  const RealType value = sArray[ thri ];
+  RealType a, tmp = std::numeric_limits< RealType >::max();
+  
+  a = TNL::argAbsMin( sArray[ thri+1 ],
+          sArray[ thri-1 ] );
+  
+  if( fabs( a ) == std::numeric_limits< RealType >::max() )
+    return false;
+  
+  tmp = a + TNL::sign( value ) * h/v;
+  
+  
+  sArray[ thri ] = argAbsMin( value, tmp );
+  
+  tmp = value - sArray[ thri ];
+  if ( fabs( tmp ) >  0.001*h )
+    return true;
+  else
     return false;
 }
 #endif
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod.h
index fa807742735f8beaa034b9a2555d3bc4a57f9f8e..57b1886e8b67c943051623c0a07f301faa76cad8 100644
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod.h
+++ b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod.h
@@ -1,9 +1,9 @@
 /***************************************************************************
-                          FastSweepingMethod.h  -  description
-                             -------------------
-    begin                : Jul 14, 2016
-    copyright            : (C) 2017 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
+ 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 */
@@ -17,131 +17,134 @@
 
 
 template< typename Mesh,
-          typename Anisotropy = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType > >
+        typename Anisotropy = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType > >
 class FastSweepingMethod
 {   
 };
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 class FastSweepingMethod< Meshes::Grid< 1, Real, Device, Index >, Anisotropy >
-   : public tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >
+: 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." );
-   
-   public:
-      
-      typedef Meshes::Grid< 1, Real, Device, Index > MeshType;
-      typedef Real RealType;
-      typedef Device DeviceType;
-      typedef Index IndexType;
-      typedef Anisotropy AnisotropyType;
-      typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > > BaseType;
-      using MeshPointer = Pointers::SharedPointer<  MeshType >;
-      using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
-      
-      
-      using typename BaseType::InterfaceMapType;
-      using typename BaseType::MeshFunctionType;
-      using typename BaseType::InterfaceMapPointer;
-      using typename BaseType::MeshFunctionPointer;
-      
-      
-      FastSweepingMethod();
-      
-      const IndexType& getMaxIterations() const;
-      
-      void setMaxIterations( const IndexType& maxIterations );
-      
-      void solve( const MeshPointer& mesh,
-                  const AnisotropyPointer& anisotropy,
-                  MeshFunctionPointer& u );
-      
-      
-   protected:
+  //static_assert(  std::is_same< Device, TNL::Devices::Host >::value, "The fast sweeping method works only on CPU." );
+  
+  public:
+    
+    typedef Meshes::Grid< 1, Real, Device, Index > MeshType;
+    typedef Real RealType;
+    typedef Device DeviceType;
+    typedef Index IndexType;
+    typedef Anisotropy AnisotropyType;
+    typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > > BaseType;
+    using MeshPointer = Pointers::SharedPointer<  MeshType >;
+    using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
+    
+    
+    using typename BaseType::InterfaceMapType;
+    using typename BaseType::MeshFunctionType;
+    using typename BaseType::InterfaceMapPointer;
+    using typename BaseType::MeshFunctionPointer;
+    
+    
+    FastSweepingMethod();
+    
+    const IndexType& getMaxIterations() const;
+    
+    void setMaxIterations( const IndexType& maxIterations );
+    
+    void solve( const MeshPointer& mesh,
+            const AnisotropyPointer& anisotropy,
+            MeshFunctionPointer& u );
+    
+    
+    protected:
       
       const IndexType maxIterations;
 };
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 class FastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >
-   : public tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >
+: 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." );
-   
-   public:
-      
-      typedef Meshes::Grid< 2, Real, Device, Index > MeshType;
-      typedef Real RealType;
-      typedef Device DeviceType;
-      typedef Index IndexType;
-      typedef Anisotropy AnisotropyType;
-      typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > BaseType;
-      using MeshPointer = Pointers::SharedPointer<  MeshType >;
-      using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
-
-      using typename BaseType::InterfaceMapType;
-      using typename BaseType::MeshFunctionType;
-      using typename BaseType::InterfaceMapPointer;
-      using typename BaseType::MeshFunctionPointer;      
-
-      FastSweepingMethod();
-      
-      const IndexType& getMaxIterations() const;
-      
-      void setMaxIterations( const IndexType& maxIterations );
-      
-      void solve( const MeshPointer& mesh,
-                  const AnisotropyPointer& anisotropy,
-                  MeshFunctionPointer& u );
-      
-   protected:
+  //static_assert(  std::is_same< Device, TNL::Devices::Host >::value, "The fast sweeping method works only on CPU." );
+  
+  public:
+    
+    typedef Meshes::Grid< 2, Real, Device, Index > MeshType;
+    typedef Real RealType;
+    typedef Device DeviceType;
+    typedef Index IndexType;
+    typedef Anisotropy AnisotropyType;
+    typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > BaseType;
+    using MeshPointer = Pointers::SharedPointer<  MeshType >;
+    using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
+    
+    using typename BaseType::InterfaceMapType;
+    using typename BaseType::MeshFunctionType;
+    using typename BaseType::InterfaceMapPointer;
+    using typename BaseType::MeshFunctionPointer;
+    using typename BaseType::ArrayContainer;
+    
+    FastSweepingMethod();
+    
+    const IndexType& getMaxIterations() const;
+    
+    void setMaxIterations( const IndexType& maxIterations );
+    
+    void solve( const MeshPointer& mesh,
+            const AnisotropyPointer& anisotropy,
+            MeshFunctionPointer& u );
+    
+    protected:
       
       const IndexType maxIterations;
 };
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 class FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >
-   : public tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >
+: 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." );
-   
-   public:
-      
-      typedef Meshes::Grid< 3, Real, Device, Index > MeshType;
-      typedef Real RealType;
-      typedef Device DeviceType;
-      typedef Index IndexType;
-      typedef Anisotropy AnisotropyType;
-      typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > BaseType;
-      using MeshPointer = Pointers::SharedPointer<  MeshType >;
-      using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
-      
-      using typename BaseType::InterfaceMapType;
-      using typename BaseType::MeshFunctionType;
-      using typename BaseType::InterfaceMapPointer;
-      using typename BaseType::MeshFunctionPointer;      
-      
-      FastSweepingMethod();
-      
-      const IndexType& getMaxIterations() const;
-      
-      void setMaxIterations( const IndexType& maxIterations );
-      
-      void solve( const MeshPointer& mesh,
-                  const AnisotropyPointer& anisotropy,
-                  MeshFunctionPointer& u );
-      
-      
-   protected:
+  //static_assert(  std::is_same< Device, TNL::Devices::Host >::value, "The fast sweeping method works only on CPU." );
+  
+  public:
+    
+    typedef Meshes::Grid< 3, Real, Device, Index > MeshType;
+    typedef Real RealType;
+    typedef Device DeviceType;
+    typedef Index IndexType;
+    typedef Anisotropy AnisotropyType;
+    typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > BaseType;
+    using MeshPointer = Pointers::SharedPointer<  MeshType >;
+    using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
+    
+    using typename BaseType::InterfaceMapType;
+    using typename BaseType::MeshFunctionType;
+    using typename BaseType::InterfaceMapPointer;
+    using typename BaseType::MeshFunctionPointer;   
+    using typename BaseType::ArrayContainer;
+    
+    
+    FastSweepingMethod();
+    
+    const IndexType& getMaxIterations() const;
+    
+    void setMaxIterations( const IndexType& maxIterations );
+    
+    void solve( const MeshPointer& mesh,
+            const AnisotropyPointer& anisotropy,
+            MeshFunctionPointer& u );
+    
+    
+    protected:
       
       const IndexType maxIterations;
 };
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h
index 6703843c179ea0215c40cf2d21b9cd66fde99de6..d5ce1efe164bc835866dc7fc95909b3defdf846f 100644
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h
+++ b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod2D_impl.h
@@ -15,511 +15,733 @@
 
 #include "tnlFastSweepingMethod.h"
 #include <TNL/Devices/Cuda.h>
+#include <TNL/Communicators/MpiDefs.h>
 
 
+
+
+#include <string.h>
 #include <iostream>
 #include <fstream>
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 FastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >::
 FastSweepingMethod()
-: maxIterations( 100 )
+: maxIterations( 1 )
 {
-   
+  
 }
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 const Index&
 FastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >::
 getMaxIterations() const
 {
-   
+  
 }
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 void
 FastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >::
 setMaxIterations( const IndexType& maxIterations )
 {
-   
+  
 }
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 void
 FastSweepingMethod< Meshes::Grid< 2, Real, Device, Index >, Anisotropy >::
 solve( const MeshPointer& mesh,
-       const AnisotropyPointer& anisotropy,
-       MeshFunctionPointer& u )
-{
-   /*MeshFunctionType v;
-   v.setMesh(mesh);
-   double A[320][320];
-    for (int i = 0; i < 320; i++)
-        for (int j = 0; j < 320; j++)
-            A[i][j] = 0;
-    
-    std::ifstream file("/home/maty/Downloads/mapa2.txt");
-
-    for (int i = 0; i < 320; i++)
-        for (int j = 0; j < 320; j++)
-            file >> A[i][j];
-    file.close();
-    for (int i = 0; i < 320; i++)
-        for (int j = 0; j < 320; j++)
-            v[i*320 + j] = A[i][j];
-   v.save("mapa.tnl");*/
-   
-       
-   MeshFunctionPointer auxPtr;
-   InterfaceMapPointer interfaceMapPtr;
-   auxPtr->setMesh( mesh );
-   interfaceMapPtr->setMesh( mesh );
-   std::cout << "Initiating the interface cells ..." << std::endl;
-   BaseType::initInterface( u, auxPtr, interfaceMapPtr );
+        const AnisotropyPointer& anisotropy,
+        MeshFunctionPointer& u )
+{  
+  MeshFunctionPointer auxPtr;
+  InterfaceMapPointer interfaceMapPtr;
+  auxPtr->setMesh( mesh );
+  interfaceMapPtr->setMesh( mesh );
+  std::cout << "Initiating the interface cells ..." << std::endl;
+  BaseType::initInterface( u, auxPtr, interfaceMapPtr );
+  
+  auxPtr->save( "aux-ini.tnl" );
+  
+  typename MeshType::Cell cell( *mesh );
+  
+  IndexType iteration( 0 );
+  InterfaceMapType interfaceMap = *interfaceMapPtr;
+  MeshFunctionType aux = *auxPtr;
+  
+  
+//#ifdef HAVE_MPI
+  bool a = Communicators::MpiCommunicator::IsInitialized();
+  if( a )
+    printf("Je Init\n");
+  else
+    printf("Neni Init\n");
+//#endif
+  
+  while( iteration < this->maxIterations )
+  {
+    if( std::is_same< DeviceType, Devices::Host >::value )
+    {
+      int numThreadsPerBlock = -1;
+      
+      numThreadsPerBlock = ( mesh->getDimensions().x()/2 + (mesh->getDimensions().x() % 2 != 0 ? 1:0));
+      //printf("numThreadsPerBlock = %d\n", numThreadsPerBlock);
+      if( numThreadsPerBlock <= 16 )
+        numThreadsPerBlock = 16;
+      else if(numThreadsPerBlock <= 32 )
+        numThreadsPerBlock = 32;
+      else if(numThreadsPerBlock <= 64 )
+        numThreadsPerBlock = 64;
+      else if(numThreadsPerBlock <= 128 )
+        numThreadsPerBlock = 128;
+      else if(numThreadsPerBlock <= 256 )
+        numThreadsPerBlock = 256;
+      else if(numThreadsPerBlock <= 512 )
+        numThreadsPerBlock = 512;
+      else
+        numThreadsPerBlock = 1024;
+      //printf("numThreadsPerBlock = %d\n", numThreadsPerBlock);
+      
+      if( numThreadsPerBlock == -1 ){
+        printf("Fail in setting numThreadsPerBlock.\n");
+        break;
+      }
+      
+      
+      
+      int numBlocksX = mesh->getDimensions().x() / numThreadsPerBlock + (mesh->getDimensions().x() % numThreadsPerBlock != 0 ? 1:0);
+      int numBlocksY = mesh->getDimensions().y() / numThreadsPerBlock + (mesh->getDimensions().y() % numThreadsPerBlock != 0 ? 1:0);
+      
+      //std::cout << "numBlocksX = " << numBlocksX << std::endl;
+      
+      /*Real **sArray = new Real*[numBlocksX*numBlocksY];
+       for( int i = 0; i < numBlocksX * numBlocksY; i++ )
+       sArray[ i ] = new Real [ (numThreadsPerBlock + 2)*(numThreadsPerBlock + 2)];*/
+      
+      ArrayContainer BlockIterHost;
+      BlockIterHost.setSize( numBlocksX * numBlocksY );
+      BlockIterHost.setValue( 1 );
+      int IsCalculationDone = 1;
+      
+      MeshFunctionPointer helpFunc( mesh );
+      MeshFunctionPointer helpFunc1( mesh );
+      helpFunc1 = auxPtr;
+      auxPtr = helpFunc;
+      helpFunc = helpFunc1;
+      //std::cout<< "Size = " << BlockIterHost.getSize() << std::endl;
+      /*for( int k = numBlocksX-1; k >-1; k-- ){
+       for( int l = 0; l < numBlocksY; l++ ){
+       std::cout<< BlockIterHost[ l*numBlocksX  + k ];
+       }
+       std::cout<<std::endl;
+       }
+       std::cout<<std::endl;*/
+      unsigned int numWhile = 0;
+      while( IsCalculationDone )
+      {      
+        IsCalculationDone = 0;
+        helpFunc1 = auxPtr;
+        auxPtr = helpFunc;
+        helpFunc = helpFunc1;
+        switch ( numThreadsPerBlock ){
+          case 16:
+            this->template updateBlocks< 18 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+          case 32:
+            this->template updateBlocks< 34 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+          case 64:
+            this->template updateBlocks< 66 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+          case 128:
+            this->template updateBlocks< 130 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+          case 256:
+            this->template updateBlocks< 258 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+          case 512:
+            this->template updateBlocks< 514 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+          default:
+            this->template updateBlocks< 1028 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+        }
         
-   auxPtr->save( "aux-ini.tnl" );
-
-   typename MeshType::Cell cell( *mesh );
-   
-   IndexType iteration( 0 );
-   InterfaceMapType interfaceMap = *interfaceMapPtr;
-   MeshFunctionType aux = *auxPtr;
-   while( iteration < this->maxIterations )
-   {
-      if( std::is_same< DeviceType, Devices::Host >::value )
-      {
-         for( cell.getCoordinates().y() = 0;
-              cell.getCoordinates().y() < mesh->getDimensions().y();
-              cell.getCoordinates().y()++ )
-         {
-            for( cell.getCoordinates().x() = 0;
-                 cell.getCoordinates().x() < mesh->getDimensions().x();
-                 cell.getCoordinates().x()++ )
-               {
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )
-                     this->updateCell( aux, cell );
-               }
-         }
-
-         //aux.save( "aux-1.tnl" );
-
-         for( cell.getCoordinates().y() = 0;
-              cell.getCoordinates().y() < mesh->getDimensions().y();
-              cell.getCoordinates().y()++ )
-         {
-            for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
-                 cell.getCoordinates().x() >= 0 ;
-                 cell.getCoordinates().x()-- )		
-               {
-                  //std::cerr << "2 -> ";
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )            
-                     this->updateCell( aux, cell );
-               }
-         }
-
-         //aux.save( "aux-2.tnl" );
-
-         for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
-              cell.getCoordinates().y() >= 0 ;
-              cell.getCoordinates().y()-- )
-            {
-            for( cell.getCoordinates().x() = 0;
-                 cell.getCoordinates().x() < mesh->getDimensions().x();
-                 cell.getCoordinates().x()++ )
-               {
-                  //std::cerr << "3 -> ";
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )            
-                     this->updateCell( aux, cell );
-               }
-            }
-
-         //aux.save( "aux-3.tnl" );
-
-         for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
-              cell.getCoordinates().y() >= 0;
-              cell.getCoordinates().y()-- )
-            {
-            for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
-                 cell.getCoordinates().x() >= 0 ;
-                 cell.getCoordinates().x()-- )		
-               {
-                  //std::cerr << "4 -> ";
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )            
-                     this->updateCell( aux, cell );
-               }
-            }
-
-         //aux.save( "aux-4.tnl" );
-
-         /*for( cell.getCoordinates().x() = 0;
-              cell.getCoordinates().x() < mesh->getDimensions().y();
-              cell.getCoordinates().x()++ )
-         {
-            for( cell.getCoordinates().y() = 0;
-                 cell.getCoordinates().y() < mesh->getDimensions().x();
-                 cell.getCoordinates().y()++ )
-               {
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )
-                     this->updateCell( aux, cell );
-               }
-         }     
-
-
-         aux.save( "aux-5.tnl" );
-
-         for( cell.getCoordinates().x() = 0;
-              cell.getCoordinates().x() < mesh->getDimensions().y();
-              cell.getCoordinates().x()++ )
-         {
-            for( cell.getCoordinates().y() = mesh->getDimensions().x() - 1;
-                 cell.getCoordinates().y() >= 0 ;
-                 cell.getCoordinates().y()-- )		
-               {
-                  //std::cerr << "2 -> ";
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )            
-                     this->updateCell( aux, cell );
-               }
+        
+        //Reduction      
+        for( int i = 0; i < BlockIterHost.getSize(); i++ ){
+          if( IsCalculationDone == 0 ){
+            IsCalculationDone = IsCalculationDone || BlockIterHost[ i ];
+            //break;
+          }
+        }
+        numWhile++;
+        /*std::cout <<"numWhile = "<< numWhile <<std::endl;
+        
+        for( int j = numBlocksY-1; j>-1; j-- ){
+          for( int i = 0; i < numBlocksX; i++ )
+            std::cout << BlockIterHost[ j * numBlocksX + i ];
+          std::cout << std::endl;
+        }
+        std::cout << std::endl;*/
+        
+        this->getNeighbours( BlockIterHost, numBlocksX, numBlocksY );
+        
+        /*for( int j = numBlocksY-1; j>-1; j-- ){
+         for( int i = 0; i < numBlocksX; i++ )
+         std::cout << "BlockIterHost = "<< j*numBlocksX + i<< " ," << BlockIterHost[ j * numBlocksX + i ];
+         std::cout << std::endl;
          }
-         aux.save( "aux-6.tnl" );
-
-         for( cell.getCoordinates().x() = mesh->getDimensions().y() - 1;
-              cell.getCoordinates().x() >= 0 ;
-              cell.getCoordinates().x()-- )
-            {
-            for( cell.getCoordinates().y() = 0;
-                 cell.getCoordinates().y() < mesh->getDimensions().x();
-                 cell.getCoordinates().y()++ )
-               {
-                  //std::cerr << "3 -> ";
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )            
-                     this->updateCell( aux, cell );
-               }
-            }
-         aux.save( "aux-7.tnl" );
-
-         for( cell.getCoordinates().x() = mesh->getDimensions().y() - 1;
-              cell.getCoordinates().x() >= 0;
-              cell.getCoordinates().x()-- )
-            {
-            for( cell.getCoordinates().y() = mesh->getDimensions().x() - 1;
-                 cell.getCoordinates().y() >= 0 ;
-                 cell.getCoordinates().y()-- )		
-               {
-                  //std::cerr << "4 -> ";
-                  cell.refresh();
-                  if( ! interfaceMap( cell ) )            
-                     this->updateCell( aux, cell );
-               }
-            }*/
+         std::cout << std::endl;*/
+        
+        //std::cout<<std::endl;
+        //string s( "aux-"+ std::to_string(numWhile) + ".tnl");
+        //aux.save( s );
       }
-      if( std::is_same< DeviceType, Devices::Cuda >::value )
-      {
-         // TODO: CUDA code
+      if( numWhile == 1 ){
+        auxPtr = helpFunc;
+      }
+      /*for( int i = 0; i < numBlocksX * numBlocksY; i++ )
+       delete []sArray[i];*/
+      
+      
+      /*for( cell.getCoordinates().y() = 0;
+       cell.getCoordinates().y() < mesh->getDimensions().y();
+       cell.getCoordinates().y()++ )
+       {
+       for( cell.getCoordinates().x() = 0;
+       cell.getCoordinates().x() < mesh->getDimensions().x();
+       cell.getCoordinates().x()++ )
+       {
+       cell.refresh();
+       if( ! interfaceMap( cell ) )
+       this->updateCell( aux, cell );
+       }
+       } 
+       
+       //aux.save( "aux-1.tnl" );
+       
+       for( cell.getCoordinates().y() = 0;
+       cell.getCoordinates().y() < mesh->getDimensions().y();
+       cell.getCoordinates().y()++ )
+       {
+       for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
+       cell.getCoordinates().x() >= 0 ;
+       cell.getCoordinates().x()-- )		
+       {
+       //std::cerr << "2 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       
+       //aux.save( "aux-2.tnl" );
+       
+       for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
+       cell.getCoordinates().y() >= 0 ;
+       cell.getCoordinates().y()-- )
+       {
+       for( cell.getCoordinates().x() = 0;
+       cell.getCoordinates().x() < mesh->getDimensions().x();
+       cell.getCoordinates().x()++ )
+       {
+       //std::cerr << "3 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       
+       //aux.save( "aux-3.tnl" );
+       
+       for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
+       cell.getCoordinates().y() >= 0;
+       cell.getCoordinates().y()-- )
+       {
+       for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
+       cell.getCoordinates().x() >= 0 ;
+       cell.getCoordinates().x()-- )		
+       {
+       //std::cerr << "4 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       
+       for( int j = 0;
+       j < mesh->getDimensions().y();
+       j++ )
+       {
+       for( int i = 0;
+       i < mesh->getDimensions().x();
+       i++ )
+       {
+       std::cout << aux[ i * mesh->getDimensions().y() + j ] << " ";
+       }
+       std::cout << std::endl;
+       }*/
+      
+    }
+    if( std::is_same< DeviceType, Devices::Cuda >::value )
+    {
+      // TODO: CUDA code
 #ifdef HAVE_CUDA
-          
-          Real *dAux;
-          cudaMalloc(&dAux, ( mesh->getDimensions().x() * mesh->getDimensions().y() ) * sizeof( Real ) );
-          
-          
-          
-          
-          const int cudaBlockSize( 16 );
-          int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().x(), cudaBlockSize );
-          int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().y(), cudaBlockSize );
-          dim3 blockSize( cudaBlockSize, cudaBlockSize );
-          dim3 gridSize( numBlocksX, numBlocksY );
-          
-          tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > ptr;
-          
-          aux1<<< gridSize, blockSize >>>( auxPtr.template modifyData< Device>(), dAux,1 );
-          
-          //int BlockIter = 1;// = (bool*)malloc( ( numBlocksX * numBlocksY ) * sizeof( bool ) );
-
-          int *BlockIterDevice;
-          int BlockIterD = 1;
-          
-          cudaMalloc(&BlockIterDevice, ( numBlocksX * numBlocksY ) * sizeof( int ) );
-          int nBlocks = ( numBlocksX * numBlocksY )/512 + ((( numBlocksX * numBlocksY )%512 != 0) ? 1:0);
-          int *dBlock;
-          cudaMalloc(&dBlock, nBlocks * sizeof( int ) );
-          
-          while( BlockIterD )
-          {
-           /*for( int i = 0; i < numBlocksX * numBlocksY; i++ )
-                BlockIter[ i ] = false;*/
-                       
-            CudaUpdateCellCaller<<< gridSize, blockSize >>>( ptr,
-                                                             interfaceMapPtr.template getData< Device >(),
-                                                             dAux,
-                                                             BlockIterDevice );
-            
-            CudaParallelReduc<<< nBlocks , 512 >>>( BlockIterDevice, dBlock, ( numBlocksX * numBlocksY ) );
-            CudaParallelReduc<<< 1, nBlocks >>>( dBlock, dBlock, nBlocks );
-            
-            cudaMemcpy(&BlockIterD, &dBlock[0], sizeof( int ), cudaMemcpyDeviceToHost);
-                                   
-            /*for( int i = 1; i < numBlocksX * numBlocksY; i++ )
-                BlockIter[ 0 ] = BlockIter[ 0 ] || BlockIter[ i ];*/
-            
-          }
-          aux1<<<gridSize,blockSize>>>( auxPtr.template modifyData< Device>(), dAux, 0 );
-          cudaFree( dAux );
-          cudaFree( BlockIterDevice );
-          cudaFree( dBlock );
-          cudaDeviceSynchronize();
-          
-          TNL_CHECK_CUDA_DEVICE;
-              
-          //aux = *auxPtr;
-          //interfaceMap = *interfaceMapPtr;
-#endif
+      TNL_CHECK_CUDA_DEVICE;
+      // Maximum cudaBlockSite is 32. Because of maximum num. of threads in kernel.
+      const int cudaBlockSize( 16 );
+      
+      int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().x(), cudaBlockSize );
+      int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().y(), cudaBlockSize );
+      dim3 blockSize( cudaBlockSize, cudaBlockSize );
+      dim3 gridSize( numBlocksX, numBlocksY );
+      
+      tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > ptr;
+      
+      int BlockIterD = 1;
+      
+      TNL::Containers::Array< int, Devices::Cuda, IndexType > BlockIterDevice;
+      BlockIterDevice.setSize( numBlocksX * numBlocksY );
+      BlockIterDevice.setValue( 1 );
+      TNL_CHECK_CUDA_DEVICE;
+      
+      
+      TNL::Containers::Array< int, Devices::Cuda, IndexType > BlockIterPom;
+      BlockIterPom.setSize( numBlocksX * numBlocksY  );
+      BlockIterPom.setValue( 0 );
+      /*TNL::Containers::Array< int, Devices::Host, IndexType > BlockIterPom1;
+       BlockIterPom1.setSize( numBlocksX * numBlocksY  );
+       BlockIterPom1.setValue( 0 );*/
+      /*int *BlockIterDevice;
+       cudaMalloc((void**) &BlockIterDevice, ( numBlocksX * numBlocksY ) * sizeof( int ) );*/
+      int nBlocksNeigh = ( numBlocksX * numBlocksY )/1024 + ((( numBlocksX * numBlocksY )%1024 != 0) ? 1:0);
+      //std::cout << "nBlocksNeigh = " << nBlocksNeigh << std::endl;
+      //free( BlockIter );
+      /*int *BlockIterPom;
+       cudaMalloc((void**) &BlockIterPom, ( numBlocksX * numBlocksY ) * sizeof( int ) );*/
+      
+      int nBlocks = ( numBlocksX * numBlocksY )/1024 + ((( numBlocksX * numBlocksY )%1024 != 0) ? 1:0);
+      
+      TNL::Containers::Array< int, Devices::Cuda, IndexType > dBlock;
+      dBlock.setSize( nBlocks );
+      TNL_CHECK_CUDA_DEVICE;
+      /*int *dBlock;
+       cudaMalloc((void**) &dBlock, nBlocks * sizeof( int ) );*/
+      
+      
+      MeshFunctionPointer helpFunc1( mesh );      
+      MeshFunctionPointer helpFunc( mesh );
+      
+      helpFunc1 = auxPtr;
+      auxPtr = helpFunc;
+      helpFunc = helpFunc1;
+      
+      int numIter = 0;
+      
+      //int oddEvenBlock = 0;
+      while( BlockIterD )
+      {
+        /** HERE IS CHESS METHOD **/
+        
+        /*auxPtr = helpFunc;
+         
+         CudaUpdateCellCaller<18><<< gridSize, blockSize >>>( ptr,
+         interfaceMapPtr.template getData< Device >(),
+         auxPtr.template getData< Device>(),
+         helpFunc.template modifyData< Device>(),
+         BlockIterDevice,
+         oddEvenBlock );
+         cudaDeviceSynchronize();
+         TNL_CHECK_CUDA_DEVICE;
+         auxPtr = helpFunc;
+         
+         oddEvenBlock= (oddEvenBlock == 0) ? 1: 0;
+         
+         CudaUpdateCellCaller<18><<< gridSize, blockSize >>>( ptr,
+         interfaceMapPtr.template getData< Device >(),
+         auxPtr.template getData< Device>(),
+         helpFunc.template modifyData< Device>(),
+         BlockIterDevice,
+         oddEvenBlock );
+         cudaDeviceSynchronize();
+         TNL_CHECK_CUDA_DEVICE;
+         auxPtr = helpFunc;
+         
+         oddEvenBlock= (oddEvenBlock == 0) ? 1: 0;
+         
+         CudaParallelReduc<<< nBlocks , 1024 >>>( BlockIterDevice, dBlock, ( numBlocksX * numBlocksY ) );
+         cudaDeviceSynchronize();
+         TNL_CHECK_CUDA_DEVICE;
+         CudaParallelReduc<<< 1, nBlocks >>>( dBlock, dBlock, nBlocks );
+         cudaDeviceSynchronize();
+         TNL_CHECK_CUDA_DEVICE;
+         
+         BlockIterD = dBlock.getElement( 0 );*/
+        
+        /**------------------------------------------------------------------------------------------------*/
+        
+        
+        /** HERE IS FIM **/
+        
+        helpFunc1 = auxPtr;
+        auxPtr = helpFunc;
+        helpFunc = helpFunc1;
+        TNL_CHECK_CUDA_DEVICE;
+        
+        //int pocBloku = 0;
+        Devices::Cuda::synchronizeDevice();
+        CudaUpdateCellCaller<18><<< gridSize, blockSize >>>( ptr,
+                interfaceMapPtr.template getData< Device >(),
+                auxPtr.template modifyData< Device>(),
+                helpFunc.template modifyData< Device>(),
+                BlockIterDevice );
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        
+        //std::cout << "Pocet aktivnich bloku = " << pocBloku << std::endl;
+        //BlockIterPom1 = BlockIterDevice;
+        ///for( int i =0; i< numBlocksX; i++ ){
+        //  for( int j = 0; j < numBlocksY; j++ )
+        //  {
+        //    std::cout << BlockIterPom1[j*numBlocksX + i];
+        //  }
+        //  std::cout << std::endl;
+        //}
+        //std::cout << std::endl;
+        
+        GetNeighbours<<< nBlocksNeigh, 1024 >>>( BlockIterDevice, BlockIterPom, numBlocksX, numBlocksY );
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        BlockIterDevice = BlockIterPom;
+        
+        //std::cout<< "Probehlo" << std::endl;
+        
+        //TNL::swap( auxPtr, helpFunc );
+        
+        
+        CudaParallelReduc<<< nBlocks , 1024 >>>( BlockIterDevice, dBlock, ( numBlocksX * numBlocksY ) );
+        TNL_CHECK_CUDA_DEVICE;
+        
+        CudaParallelReduc<<< 1, nBlocks >>>( dBlock, dBlock, nBlocks );
+        TNL_CHECK_CUDA_DEVICE;
+        
+        
+        BlockIterD = dBlock.getElement( 0 );
+        //cudaMemcpy( &BlockIterD, &dBlock[0], sizeof( int ), cudaMemcpyDeviceToHost);
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        
+        
+        /**-----------------------------------------------------------------------------------------------------------*/
+        /*for( int i = 1; i < numBlocksX * numBlocksY; i++ )
+         BlockIter[ 0 ] = BlockIter[ 0 ] || BlockIter[ i ];*/
+        numIter ++;
       }
-      iteration++;
-   }
-   aux.save("aux-final.tnl");
+      if( numIter == 1 ){
+        auxPtr = helpFunc;
+      }
+      /*cudaFree( BlockIterDevice );
+       cudaFree( dBlock );
+       delete BlockIter;*/
+      cudaDeviceSynchronize();
+      TNL_CHECK_CUDA_DEVICE;
+      
+      aux = *auxPtr;
+      interfaceMap = *interfaceMapPtr;
+#endif
+    }
+    iteration++;
+  }
+  //#endif
+  aux.save("aux-final.tnl");
 }
 
+
 #ifdef HAVE_CUDA
-template < typename Real, typename Device, typename Index >
-__global__ void aux1( Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& aux, Real *dAux, int a )
+
+
+template < typename Index >
+__global__ void GetNeighbours( TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterPom, int numBlockX, int numBlockY )
 {
-    int i = threadIdx.x + blockDim.x*blockIdx.x;
-    int j = blockDim.y*blockIdx.y + threadIdx.y;
-    const Meshes::Grid< 2, Real, Device, Index >& mesh = aux.template getMesh< Devices::Cuda >();
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && a == 1 )
-    {    
-        dAux[ j*mesh.getDimensions().x() + i ] = aux[ j*mesh.getDimensions().x() + i ];
-    }
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && a == 0 )
-    {    
-        aux[ j*mesh.getDimensions().x() + i ] = dAux[ j*mesh.getDimensions().x() + i ];
+  int i = blockIdx.x * 1024 + threadIdx.x;
+  
+  if( i < numBlockX * numBlockY )
+  {
+    int pom = 0;//BlockIterPom[ i ] = 0;
+    int m=0, k=0;
+    m = i%numBlockX;
+    k = i/numBlockX;
+    if( m > 0 && BlockIterDevice[ i - 1 ] ){
+      pom = 1;//BlockIterPom[ i ] = 1;
+    }else if( m < numBlockX -1 && BlockIterDevice[ i + 1 ] ){
+      pom = 1;//BlockIterPom[ i ] = 1;
+    }else if( k > 0 && BlockIterDevice[ i - numBlockX ] ){
+      pom = 1;// BlockIterPom[ i ] = 1;
+    }else if( k < numBlockY -1 && BlockIterDevice[ i + numBlockX ] ){
+      pom = 1;//BlockIterPom[ i ] = 1;
     }
     
+    BlockIterPom[ i ] = pom;//BlockIterPom[ i ];
+  }
 }
 
-__global__ void CudaParallelReduc( int *BlockIterDevice, int *dBlock, int nBlocks )
+template < typename Index >
+__global__ void CudaParallelReduc( TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice,
+        TNL::Containers::Array< int, Devices::Cuda, Index > dBlock, int nBlocks )
 {
-    int i = threadIdx.x;
-    int blId = blockIdx.x;
-    __shared__ volatile int sArray[ 512 ];
-    sArray[ i ] = false;
-    if(blId * 1024 + i < nBlocks )
-        sArray[ i ] = BlockIterDevice[ blId * 1024 + i ];
-    
-    if (blockDim.x * blockDim.y == 1024) {
-        if (i < 512)
-            sArray[ i ] += sArray[ i ];
-    }
-    __syncthreads();
-    if (blockDim.x * blockDim.y >= 512) {
-        if (i < 256) {
-            sArray[ i ] += sArray[ i ];
-        }
-    }
-    if (blockDim.x * blockDim.y >= 256) {
-        if (i < 128) {
-            sArray[ i ] += sArray[ i + 128 ];
-        }
+  int i = threadIdx.x;
+  int blId = blockIdx.x;
+  int blockSize = blockDim.x;
+  /*if ( i == 0 && blId == 0 ){
+   printf( "nBlocks = %d \n", nBlocks );
+   for( int j = nBlocks-1; j > -1 ; j--){
+   printf( "cislo = %d \n", BlockIterDevice[ j ] );
+   }
+   }*/
+  __shared__ int sArray[ 1024 ];
+  sArray[ i ] = 0;
+  if( blId * 1024 + i < nBlocks )
+    sArray[ i ] = BlockIterDevice[ blId * 1024 + i ];
+  __syncthreads();
+  /*extern __shared__ volatile int sArray[];
+   unsigned int i = threadIdx.x;
+   unsigned int gid = blockIdx.x * blockSize * 2 + threadIdx.x;
+   unsigned int gridSize = blockSize * 2 * gridDim.x;
+   sArray[ i ] = 0;
+   while( gid < nBlocks )
+   {
+   sArray[ i ] += BlockIterDevice[ gid ] + BlockIterDevice[ gid + blockSize ];
+   gid += gridSize;
+   }
+   __syncthreads();*/
+  
+  if ( blockSize == 1024) {
+    if (i < 512)
+      sArray[ i ] += sArray[ i + 512 ];
+  }
+  __syncthreads();
+  if (blockSize >= 512) {
+    if (i < 256) {
+      sArray[ i ] += sArray[ i + 256 ];
     }
-    __syncthreads();
-    if (blockDim.x * blockDim.y >= 128) {
-        if (i < 64) {
-            sArray[ i ] += sArray[ i + 64 ];
-        }
+  }
+  __syncthreads();
+  if (blockSize >= 256) {
+    if (i < 128) {
+      sArray[ i ] += sArray[ i + 128 ];
     }
-    __syncthreads();
-    if (i < 32 )
-    {
-        if(  blockDim.x * blockDim.y >= 64 ) sArray[ i ] += sArray[ i + 32 ];
-        if(  blockDim.x * blockDim.y >= 32 )  sArray[ i ] += sArray[ i + 16 ];
-        if(  blockDim.x * blockDim.y >= 16 )  sArray[ i ] += sArray[ i + 8 ];
-        if(  blockDim.x * blockDim.y >= 8 )  sArray[ i ] += sArray[ i + 4 ];
-        if(  blockDim.x * blockDim.y >= 4 )  sArray[ i ] += sArray[ i + 2 ];
-        if(  blockDim.x * blockDim.y >= 2 )  sArray[ i ] += sArray[ i + 1 ];
+  }
+  __syncthreads();
+  if (blockSize >= 128) {
+    if (i < 64) {
+      sArray[ i ] += sArray[ i + 64 ];
     }
-    
-    if( i == 0 )
-        dBlock[ blId ] = sArray[ 0 ];
+  }
+  __syncthreads();
+  if (i < 32 )
+  {
+    if(  blockSize >= 64 ) sArray[ i ] += sArray[ i + 32 ];
+    if(  blockSize >= 32 )  sArray[ i ] += sArray[ i + 16 ];
+    if(  blockSize >= 16 )  sArray[ i ] += sArray[ i + 8 ];
+    if(  blockSize >= 8 )  sArray[ i ] += sArray[ i + 4 ];
+    if(  blockSize >= 4 )  sArray[ i ] += sArray[ i + 2 ];
+    if(  blockSize >= 2 )  sArray[ i ] += sArray[ i + 1 ];
+  }
+  
+  if( i == 0 )
+    dBlock[ blId ] = sArray[ 0 ];
 }
 
 
 
-template < typename Real, typename Device, typename Index >
+template < int sizeSArray, typename Real, typename Device, typename Index >
 __global__ void CudaUpdateCellCaller( tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > ptr,
-                                      const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap,
-                                      Real *aux,
-                                      int *BlockIterDevice )
+        const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index >, 2, bool >& interfaceMap,
+        const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& aux,
+        Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& helpFunc,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice, int oddEvenBlock )
 {
-    int thri = threadIdx.x; int thrj = threadIdx.y;
-    int blIdx = blockIdx.x; int blIdy = blockIdx.y;
-    int i = thri + blockDim.x*blIdx;
-    int j = blockDim.y*blIdy + thrj;
-    int currentIndex = thrj * blockDim.x + thri;
-    
-    //__shared__ volatile bool changed[ blockDim.x*blockDim.y ];
-    __shared__ volatile bool changed[16*16];
-    changed[ currentIndex ] = false;
-    
-    if( thrj == 0 && thri == 0 )
-        changed[ 0 ] = true;
-    
+  int thri = threadIdx.x; int thrj = threadIdx.y;
+  int i = threadIdx.x + blockDim.x*blockIdx.x;
+  int j = blockDim.y*blockIdx.y + threadIdx.y;
+  /** FOR CHESS METHOD */
+  //if( (blockIdx.y%2  + blockIdx.x) % 2 == oddEvenBlock )
+  //{
+  /**------------------------------------------*/
+  
+  
+  /** FOR FIM METHOD */
+  
+  if( BlockIterDevice[ blockIdx.y * gridDim.x + blockIdx.x ] )
+  { 
+    __syncthreads();
+    /**-----------------------------------------*/
     const Meshes::Grid< 2, Real, Device, Index >& mesh = interfaceMap.template getMesh< Devices::Cuda >();
+    __shared__ int dimX;
+    __shared__ int dimY;
     __shared__ Real hx;
     __shared__ Real hy;
-    if( thrj == 1 && thri == 1 )
+    if( thri==0 && thrj == 0)
     {
-        hx = mesh.getSpaceSteps().x();
-        hy = mesh.getSpaceSteps().y();
+      dimX = mesh.getDimensions().x();
+      dimY = mesh.getDimensions().y();
+      hx = mesh.getSpaceSteps().x();
+      hy = mesh.getSpaceSteps().y();
+      BlockIterDevice[ blockIdx.y * gridDim.x + blockIdx.x ] = 0;
     }
+    __syncthreads();
+    int numOfBlockx;
+    int numOfBlocky;
+    int xkolik;
+    int ykolik;
     
-    //__shared__ volatile Real sArray[ blockDim.y+2 ][ blockDim.x+2 ];
-    __shared__ volatile Real sArray[18][18];
-    sArray[thrj][thri] = std::numeric_limits< Real >::max();
+    xkolik = blockDim.x + 1;
+    ykolik = blockDim.y + 1;
+    numOfBlocky = dimY/blockDim.y + ((dimY%blockDim.y != 0) ? 1:0);
+    numOfBlockx = dimX/blockDim.x + ((dimX%blockDim.x != 0) ? 1:0);
     
-    //filling sArray edges
-    int dimX = mesh.getDimensions().x(); int dimY = mesh.getDimensions().y();
-    __shared__ volatile int numOfBlockx;
-    __shared__ volatile int numOfBlocky;
-    __shared__ int xkolik;
-    __shared__ int ykolik;
-    if( thri == 0 && thrj == 0 )
-    {
-        xkolik = blockDim.x + 1;
-        ykolik = blockDim.y + 1;
-        numOfBlocky = dimY/blockDim.y + ((dimY%blockDim.y != 0) ? 1:0);
-        numOfBlockx = dimX/blockDim.x + ((dimX%blockDim.x != 0) ? 1:0);
+    if( numOfBlockx - 1 == blockIdx.x )
+      xkolik = dimX - (blockIdx.x)*blockDim.x+1;
     
-        if( numOfBlockx - 1 == blIdx )
-            xkolik = dimX - (blIdx)*blockDim.x+1;
-
-        if( numOfBlocky -1 == blIdy )
-            ykolik = dimY - (blIdy)*blockDim.y+1;
-        BlockIterDevice[ blIdy * numOfBlockx + blIdx ] = 0;
-    }
+    if( numOfBlocky -1 == blockIdx.y )
+      ykolik = dimY - (blockIdx.y)*blockDim.y+1;
     __syncthreads();
     
+    int currentIndex = thrj * blockDim.x + thri;
+    //__shared__ volatile bool changed[ blockDim.x*blockDim.y ];
+    __shared__ volatile bool changed[ (sizeSArray-2)*(sizeSArray-2)];
+    changed[ currentIndex ] = false;
+    if( thrj == 0 && thri == 0 )
+      changed[ 0 ] = true;
+    
+    
+    //__shared__ volatile Real sArray[ blockDim.y+2 ][ blockDim.x+2 ];
+    __shared__ volatile Real sArray[ sizeSArray * sizeSArray ];
+    sArray[ thrj * sizeSArray + thri ] = std::numeric_limits< Real >::max();
+    
+    //filling sArray edges
     if( thri == 0 )
-    {        
-        if( dimX > (blIdx+1) * blockDim.x  && thrj+1 < ykolik )
-            sArray[thrj+1][xkolik] = aux[ blIdy*blockDim.y*dimX - dimX + blIdx*blockDim.x - 1 + (thrj+1)*dimX + xkolik ];
-        else
-            sArray[thrj+1][xkolik] = std::numeric_limits< Real >::max();
+    {      
+      if( dimX > (blockIdx.x+1) * blockDim.x  && thrj+1 < ykolik )
+        sArray[(thrj+1)*sizeSArray + xkolik] = aux[ blockIdx.y*blockDim.y*dimX - dimX + blockIdx.x*blockDim.x - 1 + (thrj+1)*dimX + xkolik ];
+      else
+        sArray[(thrj+1)*sizeSArray + xkolik] = std::numeric_limits< Real >::max();
     }
     
     if( thri == 1 )
     {
-        if( blIdx != 0 && thrj+1 < ykolik )
-            sArray[thrj+1][0] = aux[ blIdy*blockDim.y*dimX - dimX + blIdx*blockDim.x - 1 + (thrj+1)*dimX ];
-        else
-            sArray[thrj+1][0] = std::numeric_limits< Real >::max();
+      if( blockIdx.x != 0 && thrj+1 < ykolik )
+        sArray[(thrj+1)*sizeSArray + 0] = aux[ blockIdx.y*blockDim.y*dimX - dimX + blockIdx.x*blockDim.x - 1 + (thrj+1)*dimX ];
+      else
+        sArray[(thrj+1)*sizeSArray + 0] = std::numeric_limits< Real >::max();
     }
     
     if( thri == 2 )
     {
-        if( dimY > (blIdy+1) * blockDim.y  && thri+1 < xkolik )
-            sArray[ykolik][thrj+1] = aux[ blIdy*blockDim.y*dimX - dimX + blIdx*blockDim.x - 1 + ykolik*dimX + thrj+1 ];
-        else
-           sArray[ykolik][thrj+1] = std::numeric_limits< Real >::max();
+      if( dimY > (blockIdx.y+1) * blockDim.y  && thrj+1 < xkolik )
+        sArray[ ykolik*sizeSArray + thrj+1 ] = aux[ blockIdx.y*blockDim.y*dimX - dimX + blockIdx.x*blockDim.x - 1 + ykolik*dimX + thrj+1 ];
+      else
+        sArray[ykolik*sizeSArray + thrj+1] = std::numeric_limits< Real >::max();
+      
     }
     
     if( thri == 3 )
     {
-        if( blIdy != 0 && thrj+1 < xkolik )
-            sArray[0][thrj+1] = aux[ blIdy*blockDim.y*dimX - dimX + blIdx*blockDim.x - 1 + thrj+1 ];
-        else
-            sArray[0][thrj+1] = std::numeric_limits< Real >::max();
+      if( blockIdx.y != 0 && thrj+1 < xkolik )
+        sArray[0*sizeSArray + thrj+1] = aux[ blockIdx.y*blockDim.y*dimX - dimX + blockIdx.x*blockDim.x - 1 + thrj+1 ];
+      else
+        sArray[0*sizeSArray + thrj+1] = std::numeric_limits< Real >::max();
     }
     
-        
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() )
+    if( i < dimX && j < dimY )
     {    
-        sArray[thrj+1][thri+1] = aux[ j*mesh.getDimensions().x() + i ];
+      sArray[(thrj+1)*sizeSArray + thri+1] = aux[ j*dimX + i ];
     }
     __syncthreads();  
-
+    
     while( changed[ 0 ] )
     {
-        __syncthreads();
-        
-        changed[ currentIndex] = false;
-        
-    //calculation of update cell
-        if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() )
-        {
-            if( ! interfaceMap[ j * mesh.getDimensions().x() + i ] )
-            {
-                changed[ currentIndex ] = ptr.updateCell( sArray, thri+1, thrj+1, hx,hy);
-            }
-        }
-        __syncthreads();
-        
-    //pyramid reduction
-        if( blockDim.x*blockDim.y == 1024 )
+      __syncthreads();
+      
+      changed[ currentIndex] = false;
+      
+      //calculation of update cell
+      if( i < dimX && j < dimY )
+      {
+        if( ! interfaceMap[ j * dimX + i ] )
         {
-            if( currentIndex < 512 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 512 ];
-            }
+          changed[ currentIndex ] = ptr.updateCell<sizeSArray>( sArray, thri+1, thrj+1, hx,hy);
         }
-        __syncthreads();
-        if( blockDim.x*blockDim.y >= 512 )
+      }
+      __syncthreads();
+      
+      //pyramid reduction
+      if( blockDim.x*blockDim.y == 1024 )
+      {
+        if( currentIndex < 512 )
         {
-            if( currentIndex < 256 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 256 ];
-            }
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 512 ];
         }
-        __syncthreads();
-        if( blockDim.x*blockDim.y >= 256 )
+      }
+      __syncthreads();
+      if( blockDim.x*blockDim.y >= 512 )
+      {
+        if( currentIndex < 256 )
         {
-            if( currentIndex < 128 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 128 ];
-            }
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 256 ];
         }
-        __syncthreads();
-        if( blockDim.x*blockDim.y >= 128 )
+      }
+      __syncthreads();
+      if( blockDim.x*blockDim.y >= 256 )
+      {
+        if( currentIndex < 128 )
         {
-            if( currentIndex < 64 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 64 ];
-            }
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 128 ];
         }
-        __syncthreads();
-        if( currentIndex < 32 ) //POUZE IF JSOU SINCHRONNI NA JEDNOM WARPU
+      }
+      __syncthreads();
+      if( blockDim.x*blockDim.y >= 128 )
+      {
+        if( currentIndex < 64 )
         {
-            if( true ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 32 ];
-            if( currentIndex < 16 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 16 ];
-            if( currentIndex < 8 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 8 ];
-            if( currentIndex < 4 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 4 ];
-            if( currentIndex < 2 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 2 ];
-            if( currentIndex < 1 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 1 ];
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 64 ];
         }
-        if( changed[ 0 ] && thri == 0 && thrj == 0 )
-            BlockIterDevice[ blIdy * numOfBlockx + blIdx ] = 1;
-        __syncthreads();
+      }
+      __syncthreads();
+      if( currentIndex < 32 ) 
+      {
+        if( true ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 32 ];
+        if( currentIndex < 16 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 16 ];
+        if( currentIndex < 8 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 8 ];
+        if( currentIndex < 4 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 4 ];
+        if( currentIndex < 2 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 2 ];
+        if( currentIndex < 1 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 1 ];
+      }
+      if( thri == 0 && thrj == 0 && changed[ 0 ] ){
+        BlockIterDevice[ blockIdx.y * gridDim.x + blockIdx.x ] = 1;
+      }
+      /*if( thri==0 && thrj == 0 && blockIdx.x == 0 && blockIdx.y == 0 )
+       {
+       for( int k = 15; k>-1; k-- ){
+       for( int l = 0; l < 16; l++ )
+       printf( "%f\t", sArray[k * 16 + l]);
+       printf( "\n");
+       }
+       printf( "\n");
+       }*/
+      __syncthreads();
     }
-  
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && (!interfaceMap[ j * mesh.getDimensions().x() + i ]) )
-        aux[ j * mesh.getDimensions().x() + i ] = sArray[ thrj + 1 ][ thri + 1 ];
+    if( i < dimX && j < dimY )
+      helpFunc[ j * dimX + i ] = sArray[ ( thrj + 1 ) * sizeSArray + thri + 1 ];
+    
+  } 
 }
 #endif
diff --git a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod3D_impl.h b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod3D_impl.h
index b024979cc6247022bd3ee156c877c2b47f71f99a..5af33cf29605ce983d75b61846ceeafeada7fde0 100644
--- a/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod3D_impl.h
+++ b/src/TNL/Experimental/Hamilton-Jacobi/Solvers/hamilton-jacobi/tnlFastSweepingMethod3D_impl.h
@@ -16,496 +16,649 @@
 #include "tnlFastSweepingMethod.h"
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >::
 FastSweepingMethod()
 : maxIterations( 1 )
 {
-   
+  
 }
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 const Index&
 FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >::
 getMaxIterations() const
 {
-   
+  
 }
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 void
 FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >::
 setMaxIterations( const IndexType& maxIterations )
 {
-   
+  
 }
 
 template< typename Real,
-          typename Device,
-          typename Index,
-          typename Anisotropy >
+        typename Device,
+        typename Index,
+        typename Anisotropy >
 void
 FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Anisotropy >::
 solve( const MeshPointer& mesh,
-       const AnisotropyPointer& anisotropy,
-       MeshFunctionPointer& u )
+        const AnisotropyPointer& anisotropy,
+        MeshFunctionPointer& u )
 {
-   MeshFunctionPointer auxPtr;
-   InterfaceMapPointer interfaceMapPtr;
-   auxPtr->setMesh( mesh );
-   interfaceMapPtr->setMesh( mesh );
-   std::cout << "Initiating the interface cells ..." << std::endl;
-   BaseType::initInterface( u, auxPtr, interfaceMapPtr );
-#ifdef HAVE_CUDA
-   cudaDeviceSynchronize();
-#endif
-   auxPtr->save( "aux-ini.tnl" );   
-   
-   typename MeshType::Cell cell( *mesh );
-   
-   IndexType iteration( 0 );
-   MeshFunctionType aux = *auxPtr;
-   InterfaceMapType interfaceMap = * interfaceMapPtr;
-    while( iteration < this->maxIterations )
+  MeshFunctionPointer auxPtr;
+  InterfaceMapPointer interfaceMapPtr;
+  auxPtr->setMesh( mesh );
+  interfaceMapPtr->setMesh( mesh );
+  std::cout << "Initiating the interface cells ..." << std::endl;
+  BaseType::initInterface( u, auxPtr, interfaceMapPtr );
+  auxPtr->save( "aux-ini.tnl" );   
+  
+  typename MeshType::Cell cell( *mesh );
+  
+  IndexType iteration( 0 );
+  MeshFunctionType aux = *auxPtr;
+  InterfaceMapType interfaceMap = * interfaceMapPtr;
+  while( iteration < this->maxIterations )
+  {
+    if( std::is_same< DeviceType, Devices::Host >::value )
     {
-        if( std::is_same< DeviceType, Devices::Host >::value )
-        {
-           for( cell.getCoordinates().z() = 0;
-                cell.getCoordinates().z() < mesh->getDimensions().z();
-                cell.getCoordinates().z()++ )
-           {
-              for( cell.getCoordinates().y() = 0;
-                   cell.getCoordinates().y() < mesh->getDimensions().y();
-                   cell.getCoordinates().y()++ )
-              {
-                 for( cell.getCoordinates().x() = 0;
-                      cell.getCoordinates().x() < mesh->getDimensions().x();
-                      cell.getCoordinates().x()++ )
-                 {
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-           //aux.save( "aux-1.tnl" );
-
-           for( cell.getCoordinates().z() = 0;
-                cell.getCoordinates().z() < mesh->getDimensions().z();
-                cell.getCoordinates().z()++ )
-           {
-              for( cell.getCoordinates().y() = 0;
-                   cell.getCoordinates().y() < mesh->getDimensions().y();
-                   cell.getCoordinates().y()++ )
-              {
-                 for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
-                      cell.getCoordinates().x() >= 0 ;
-                      cell.getCoordinates().x()-- )		
-                 {
-                    //std::cerr << "2 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )            
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-           //aux.save( "aux-2.tnl" );
-           for( cell.getCoordinates().z() = 0;
-                cell.getCoordinates().z() < mesh->getDimensions().z();
-                cell.getCoordinates().z()++ )
-           {
-              for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
-                   cell.getCoordinates().y() >= 0 ;
-                   cell.getCoordinates().y()-- )
-              {
-                 for( cell.getCoordinates().x() = 0;
-                      cell.getCoordinates().x() < mesh->getDimensions().x();
-                      cell.getCoordinates().x()++ )
-                 {
-                    //std::cerr << "3 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )            
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-           //aux.save( "aux-3.tnl" );
-
-           for( cell.getCoordinates().z() = 0;
-                cell.getCoordinates().z() < mesh->getDimensions().z();
-                cell.getCoordinates().z()++ )
-           {
-              for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
-                   cell.getCoordinates().y() >= 0;
-                   cell.getCoordinates().y()-- )
-              {
-                 for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
-                      cell.getCoordinates().x() >= 0 ;
-                      cell.getCoordinates().x()-- )		
-                 {
-                    //std::cerr << "4 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )            
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }     
-           //aux.save( "aux-4.tnl" );
-
-           for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
-                cell.getCoordinates().z() >= 0;
-                cell.getCoordinates().z()-- )
-           {
-              for( cell.getCoordinates().y() = 0;
-                   cell.getCoordinates().y() < mesh->getDimensions().y();
-                   cell.getCoordinates().y()++ )
-              {
-                 for( cell.getCoordinates().x() = 0;
-                      cell.getCoordinates().x() < mesh->getDimensions().x();
-                      cell.getCoordinates().x()++ )
-                 {
-                    //std::cerr << "5 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-           //aux.save( "aux-5.tnl" );
-
-           for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
-                cell.getCoordinates().z() >= 0;
-                cell.getCoordinates().z()-- )
-           {
-              for( cell.getCoordinates().y() = 0;
-                   cell.getCoordinates().y() < mesh->getDimensions().y();
-                   cell.getCoordinates().y()++ )
-              {
-                 for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
-                      cell.getCoordinates().x() >= 0 ;
-                      cell.getCoordinates().x()-- )		
-                 {
-                    //std::cerr << "6 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )            
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-           //aux.save( "aux-6.tnl" );
-
-           for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
-                cell.getCoordinates().z() >= 0;
-                cell.getCoordinates().z()-- )
-           {
-              for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
-                   cell.getCoordinates().y() >= 0 ;
-                   cell.getCoordinates().y()-- )
-              {
-                 for( cell.getCoordinates().x() = 0;
-                      cell.getCoordinates().x() < mesh->getDimensions().x();
-                      cell.getCoordinates().x()++ )
-                 {
-                    //std::cerr << "7 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )            
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-           //aux.save( "aux-7.tnl" );
-
-           for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
-                cell.getCoordinates().z() >= 0;
-                cell.getCoordinates().z()-- )
-           {
-              for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
-                   cell.getCoordinates().y() >= 0;
-                   cell.getCoordinates().y()-- )
-              {
-                 for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
-                      cell.getCoordinates().x() >= 0 ;
-                      cell.getCoordinates().x()-- )		
-                 {
-                    //std::cerr << "8 -> ";
-                    cell.refresh();
-                    if( ! interfaceMap( cell ) )            
-                       this->updateCell( aux, cell );
-                 }
-              }
-           }
-      }
-      if( std::is_same< DeviceType, Devices::Cuda >::value )
-      {
-         // TODO: CUDA code
-#ifdef HAVE_CUDA
-          const int cudaBlockSize( 8 );
-          int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().x(), cudaBlockSize );
-          int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().y(), cudaBlockSize );
-          int numBlocksZ = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().z(), cudaBlockSize ); 
-          if( cudaBlockSize * cudaBlockSize * cudaBlockSize > 1024 || numBlocksX > 1024 || numBlocksY > 1024 || numBlocksZ > 64 )
-              std::cout << "Invalid kernel call. Dimensions of grid are max: [1024,1024,64], and maximum threads per block are 1024!" << std::endl;
-          dim3 blockSize( cudaBlockSize, cudaBlockSize, cudaBlockSize );
-          dim3 gridSize( numBlocksX, numBlocksY, numBlocksZ );
-                 
-          tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > ptr;
-          
-          int *BlockIterDevice;
-          int BlockIterD = 1;
-          
-          cudaMalloc(&BlockIterDevice, ( numBlocksX * numBlocksY * numBlocksZ ) * sizeof( int ) );
-          int nBlocks = ( numBlocksX * numBlocksY * numBlocksZ )/512 + ((( numBlocksX * numBlocksY * numBlocksZ )%512 != 0) ? 1:0);
-          int *dBlock;
-          cudaMalloc(&dBlock, nBlocks * sizeof( int ) );
-          
-          while( BlockIterD )
-          {
-             CudaUpdateCellCaller<<< gridSize, blockSize >>>( ptr,
-                                                              interfaceMapPtr.template getData< Device >(),
-                                                              auxPtr.template modifyData< Device>(),
-                                                              BlockIterDevice );
-            CudaParallelReduc<<< nBlocks , 512 >>>( BlockIterDevice, dBlock, ( numBlocksX * numBlocksY * numBlocksZ ) );
-            CudaParallelReduc<<< 1, nBlocks >>>( dBlock, dBlock, nBlocks );
-            
-            cudaMemcpy(&BlockIterD, &dBlock[0], sizeof( int ), cudaMemcpyDeviceToHost);
-                                   
-            /*for( int i = 1; i < numBlocksX * numBlocksY; i++ )
-                BlockIter[ 0 ] = BlockIter[ 0 ] || BlockIter[ i ];*/
-            
+      int numThreadsPerBlock = 64;
+      
+      
+      int numBlocksX = mesh->getDimensions().x() / numThreadsPerBlock + (mesh->getDimensions().x() % numThreadsPerBlock != 0 ? 1:0);
+      int numBlocksY = mesh->getDimensions().y() / numThreadsPerBlock + (mesh->getDimensions().y() % numThreadsPerBlock != 0 ? 1:0);
+      int numBlocksZ = mesh->getDimensions().z() / numThreadsPerBlock + (mesh->getDimensions().z() % numThreadsPerBlock != 0 ? 1:0);
+      //std::cout << "numBlocksX = " << numBlocksX << std::endl;
+      
+      /*Real **sArray = new Real*[numBlocksX*numBlocksY];
+       for( int i = 0; i < numBlocksX * numBlocksY; i++ )
+       sArray[ i ] = new Real [ (numThreadsPerBlock + 2)*(numThreadsPerBlock + 2)];*/
+      
+      ArrayContainer BlockIterHost;
+      BlockIterHost.setSize( numBlocksX * numBlocksY * numBlocksZ );
+      BlockIterHost.setValue( 1 );
+      int IsCalculationDone = 1;
+      
+      MeshFunctionPointer helpFunc( mesh );
+      MeshFunctionPointer helpFunc1( mesh );
+      helpFunc1 = auxPtr;
+      auxPtr = helpFunc;
+      helpFunc = helpFunc1;
+      //std::cout<< "Size = " << BlockIterHost.getSize() << std::endl;
+      /*for( int k = numBlocksX-1; k >-1; k-- ){
+       for( int l = 0; l < numBlocksY; l++ ){
+       std::cout<< BlockIterHost[ l*numBlocksX  + k ];
+       }
+       std::cout<<std::endl;
+       }
+       std::cout<<std::endl;*/
+      unsigned int numWhile = 0;
+      while( IsCalculationDone  )
+      {      
+        IsCalculationDone = 0;
+        helpFunc1 = auxPtr;
+        auxPtr = helpFunc;
+        helpFunc = helpFunc1;
+        this->template updateBlocks< 66 >( interfaceMap, *auxPtr, *helpFunc, BlockIterHost, numThreadsPerBlock/*, sArray*/ );
+        
+        //Reduction      
+        for( int i = 0; i < BlockIterHost.getSize(); i++ ){
+          if( IsCalculationDone == 0 ){
+            IsCalculationDone = IsCalculationDone || BlockIterHost[ i ];
+            //break;
           }
-          cudaFree( BlockIterDevice );
-          cudaFree( dBlock );
-          cudaDeviceSynchronize();
-          TNL_CHECK_CUDA_DEVICE;
-          aux = *auxPtr;
-          interfaceMap = *interfaceMapPtr;
-#endif
-      }
+        }
+        numWhile++;
+        std::cout <<"numWhile = "<< numWhile <<std::endl;
+        /*for( int k = 0; k < numBlocksZ; k++ ){
+          for( int j = numBlocksY-1; j>-1; j-- ){
+            for( int i = 0; i < numBlocksX; i++ ){
+              //std::cout << (*auxPtr)[ k * numBlocksX * numBlocksY + j * numBlocksX + i ] << " ";
+              std::cout << BlockIterHost[ k * numBlocksX * numBlocksY + j * numBlocksX + i ];
+            }
+            std::cout << std::endl;
+          }
+          std::cout << std::endl;
+        }
+        std::cout << std::endl;*/
+        
+        this->getNeighbours( BlockIterHost, numBlocksX, numBlocksY, numBlocksZ );
         
-      //aux.save( "aux-8.tnl" );
-      iteration++;
+        /*for( int k = 0; k < numBlocksZ; k++ ){
+          for( int j = numBlocksY-1; j>-1; j-- ){
+            for( int i = 0; i < numBlocksX; i++ ){
+              //std::cout << (*auxPtr)[ k * numBlocksX * numBlocksY + j * numBlocksX + i ] << " ";
+              std::cout << BlockIterHost[ k * numBlocksX * numBlocksY + j * numBlocksX + i ];
+            }
+            std::cout << std::endl;
+          }
+          std::cout << std::endl;
+        }*/
+        
+        /*for( int j = numBlocksY-1; j>-1; j-- ){
+         for( int i = 0; i < numBlocksX; i++ )
+         std::cout << "BlockIterHost = "<< j*numBlocksX + i<< " ," << BlockIterHost[ j * numBlocksX + i ];
+         std::cout << std::endl;
+         }
+         std::cout << std::endl;*/
+        
+        //std::cout<<std::endl;
+        //string s( "aux-"+ std::to_string(numWhile) + ".tnl");
+        //aux.save( s );
+      }
+      if( numWhile == 1 ){
+        auxPtr = helpFunc;
+      }
+      aux = *auxPtr;
+      
+      /*for( cell.getCoordinates().z() = 0;
+       cell.getCoordinates().z() < mesh->getDimensions().z();
+       cell.getCoordinates().z()++ )
+       {
+       for( cell.getCoordinates().y() = 0;
+       cell.getCoordinates().y() < mesh->getDimensions().y();
+       cell.getCoordinates().y()++ )
+       {
+       for( cell.getCoordinates().x() = 0;
+       cell.getCoordinates().x() < mesh->getDimensions().x();
+       cell.getCoordinates().x()++ )
+       {
+       cell.refresh();
+       if( ! interfaceMap( cell ) )
+       this->updateCell( aux, cell );
+       }
+       }
+       }
+       //aux.save( "aux-1.tnl" );
+       
+       for( cell.getCoordinates().z() = 0;
+       cell.getCoordinates().z() < mesh->getDimensions().z();
+       cell.getCoordinates().z()++ )
+       {
+       for( cell.getCoordinates().y() = 0;
+       cell.getCoordinates().y() < mesh->getDimensions().y();
+       cell.getCoordinates().y()++ )
+       {
+       for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
+       cell.getCoordinates().x() >= 0 ;
+       cell.getCoordinates().x()-- )		
+       {
+       //std::cerr << "2 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       }
+       //aux.save( "aux-2.tnl" );
+       for( cell.getCoordinates().z() = 0;
+       cell.getCoordinates().z() < mesh->getDimensions().z();
+       cell.getCoordinates().z()++ )
+       {
+       for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
+       cell.getCoordinates().y() >= 0 ;
+       cell.getCoordinates().y()-- )
+       {
+       for( cell.getCoordinates().x() = 0;
+       cell.getCoordinates().x() < mesh->getDimensions().x();
+       cell.getCoordinates().x()++ )
+       {
+       //std::cerr << "3 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       }
+       //aux.save( "aux-3.tnl" );
+       
+       for( cell.getCoordinates().z() = 0;
+       cell.getCoordinates().z() < mesh->getDimensions().z();
+       cell.getCoordinates().z()++ )
+       {
+       for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
+       cell.getCoordinates().y() >= 0;
+       cell.getCoordinates().y()-- )
+       {
+       for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
+       cell.getCoordinates().x() >= 0 ;
+       cell.getCoordinates().x()-- )		
+       {
+       //std::cerr << "4 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       }     
+       //aux.save( "aux-4.tnl" );
+       
+       for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
+       cell.getCoordinates().z() >= 0;
+       cell.getCoordinates().z()-- )
+       {
+       for( cell.getCoordinates().y() = 0;
+       cell.getCoordinates().y() < mesh->getDimensions().y();
+       cell.getCoordinates().y()++ )
+       {
+       for( cell.getCoordinates().x() = 0;
+       cell.getCoordinates().x() < mesh->getDimensions().x();
+       cell.getCoordinates().x()++ )
+       {
+       //std::cerr << "5 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )
+       this->updateCell( aux, cell );
+       }
+       }
+       }
+       //aux.save( "aux-5.tnl" );
+       
+       for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
+       cell.getCoordinates().z() >= 0;
+       cell.getCoordinates().z()-- )
+       {
+       for( cell.getCoordinates().y() = 0;
+       cell.getCoordinates().y() < mesh->getDimensions().y();
+       cell.getCoordinates().y()++ )
+       {
+       for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
+       cell.getCoordinates().x() >= 0 ;
+       cell.getCoordinates().x()-- )		
+       {
+       //std::cerr << "6 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       }
+       //aux.save( "aux-6.tnl" );
+       
+       for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
+       cell.getCoordinates().z() >= 0;
+       cell.getCoordinates().z()-- )
+       {
+       for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
+       cell.getCoordinates().y() >= 0 ;
+       cell.getCoordinates().y()-- )
+       {
+       for( cell.getCoordinates().x() = 0;
+       cell.getCoordinates().x() < mesh->getDimensions().x();
+       cell.getCoordinates().x()++ )
+       {
+       //std::cerr << "7 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       }
+       //aux.save( "aux-7.tnl" );
+       
+       for( cell.getCoordinates().z() = mesh->getDimensions().z() - 1;
+       cell.getCoordinates().z() >= 0;
+       cell.getCoordinates().z()-- )
+       {
+       for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
+       cell.getCoordinates().y() >= 0;
+       cell.getCoordinates().y()-- )
+       {
+       for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
+       cell.getCoordinates().x() >= 0 ;
+       cell.getCoordinates().x()-- )		
+       {
+       //std::cerr << "8 -> ";
+       cell.refresh();
+       if( ! interfaceMap( cell ) )            
+       this->updateCell( aux, cell );
+       }
+       }
+       }*/
+    }
+    if( std::is_same< DeviceType, Devices::Cuda >::value )
+    {
+      // TODO: CUDA code
+#ifdef HAVE_CUDA
+      const int cudaBlockSize( 8 );
+      int numBlocksX = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().x(), cudaBlockSize );
+      int numBlocksY = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().y(), cudaBlockSize );
+      int numBlocksZ = Devices::Cuda::getNumberOfBlocks( mesh->getDimensions().z(), cudaBlockSize ); 
+      if( cudaBlockSize * cudaBlockSize * cudaBlockSize > 1024 || numBlocksX > 1024 || numBlocksY > 1024 || numBlocksZ > 64 )
+        std::cout << "Invalid kernel call. Dimensions of grid are max: [1024,1024,64], and maximum threads per block are 1024!" << std::endl;
+      dim3 blockSize( cudaBlockSize, cudaBlockSize, cudaBlockSize );
+      dim3 gridSize( numBlocksX, numBlocksY, numBlocksZ );
+      
+      tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > ptr;
+      
+      
+      int BlockIterD = 1;
+      
+      TNL::Containers::Array< int, Devices::Cuda, IndexType > BlockIterDevice;
+      BlockIterDevice.setSize( numBlocksX * numBlocksY * numBlocksZ );
+      BlockIterDevice.setValue( 1 );
+      TNL::Containers::Array< int, Devices::Cuda, IndexType > BlockIterPom;
+      BlockIterPom.setSize( numBlocksX * numBlocksY * numBlocksZ );
+      BlockIterPom.setValue( 0 );
+      /*int *BlockIterDevice;
+       cudaMalloc(&BlockIterDevice, ( numBlocksX * numBlocksY * numBlocksZ ) * sizeof( int ) );*/
+      int nBlocks = ( numBlocksX * numBlocksY * numBlocksZ )/512 + ((( numBlocksX * numBlocksY * numBlocksZ )%512 != 0) ? 1:0);
       
-   }
-   aux.save("aux-final.tnl");
+      TNL::Containers::Array< int, Devices::Cuda, IndexType > dBlock;
+      dBlock.setSize( nBlocks );
+      dBlock.setValue( 0 );
+      
+      int nBlocksNeigh = ( numBlocksX * numBlocksY * numBlocksZ )/1024 + ((( numBlocksX * numBlocksY * numBlocksZ )%1024 != 0) ? 1:0);
+      /*int *dBlock;
+       cudaMalloc(&dBlock, nBlocks * sizeof( int ) );*/
+      MeshFunctionPointer helpFunc1( mesh );      
+      MeshFunctionPointer helpFunc( mesh );
+      
+      helpFunc1 = auxPtr;
+      auxPtr = helpFunc;
+      helpFunc = helpFunc1;
+      int numIter = 0;
+      
+      while( BlockIterD )
+      {
+        helpFunc1 = auxPtr;
+        auxPtr = helpFunc;
+        helpFunc = helpFunc1;
+        TNL_CHECK_CUDA_DEVICE;
+        
+        CudaUpdateCellCaller< 10 ><<< gridSize, blockSize >>>( ptr,
+                interfaceMapPtr.template getData< Device >(),
+                auxPtr.template getData< Device>(),
+                helpFunc.template modifyData< Device>(),
+                BlockIterDevice );
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        
+        GetNeighbours3D<<< nBlocksNeigh, 1024 >>>( BlockIterDevice, BlockIterPom, numBlocksX, numBlocksY, numBlocksZ );
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        BlockIterDevice = BlockIterPom;
+        
+        CudaParallelReduc<<< nBlocks , 512 >>>( BlockIterDevice, dBlock, ( numBlocksX * numBlocksY * numBlocksZ ) );
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        
+        CudaParallelReduc<<< 1, nBlocks >>>( dBlock, dBlock, nBlocks );
+        cudaDeviceSynchronize();
+        TNL_CHECK_CUDA_DEVICE;
+        cudaMemcpy(&BlockIterD, &dBlock[0], sizeof( int ), cudaMemcpyDeviceToHost);
+        numIter++;
+        /*for( int i = 1; i < numBlocksX * numBlocksY; i++ )
+         BlockIter[ 0 ] = BlockIter[ 0 ] || BlockIter[ i ];*/
+        
+      }
+      if( numIter == 1 ){
+        auxPtr = helpFunc;
+      }
+      //cudaFree( BlockIterDevice );
+      //cudaFree( dBlock );
+      cudaDeviceSynchronize();
+      TNL_CHECK_CUDA_DEVICE;
+      aux = *auxPtr;
+      interfaceMap = *interfaceMapPtr;
+#endif
+    }
+    
+    //aux.save( "aux-8.tnl" );
+    iteration++;
+    
+  }
+  aux.save("aux-final.tnl");
 }
 
 #ifdef HAVE_CUDA
-template < typename Real, typename Device, typename Index >
+template < typename Index >
+__global__ void GetNeighbours3D( TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterPom,
+        int numBlockX, int numBlockY, int numBlockZ )
+{
+  int i = blockIdx.x * 1024 + threadIdx.x;
+  
+  if( i < numBlockX * numBlockY * numBlockZ )
+  {
+    int pom = 0;//BlockIterPom[ i ] = 0;
+    int m=0, l=0, k=0;
+    l = i/( numBlockX * numBlockY );
+    k = (i-l*numBlockX * numBlockY )/(numBlockX );
+    m = (i-l*numBlockX * numBlockY )%( numBlockX );
+    if( m > 0 && BlockIterDevice[ i - 1 ] ){
+      pom = 1;//BlockIterPom[ i ] = 1;
+    }else if( m < numBlockX -1 && BlockIterDevice[ i + 1 ] ){
+      pom = 1;//BlockIterPom[ i ] = 1;
+    }else if( k > 0 && BlockIterDevice[ i - numBlockX ] ){
+      pom = 1;// BlockIterPom[ i ] = 1;
+    }else if( k < numBlockY -1 && BlockIterDevice[ i + numBlockX ] ){
+      pom = 1;//BlockIterPom[ i ] = 1;
+    }else if( l > 0 && BlockIterDevice[ i - numBlockX*numBlockY ] ){
+      pom = 1;
+    }else if( l < numBlockZ-1 && BlockIterDevice[ i + numBlockX*numBlockY ] ){
+      pom = 1;
+    }
+    
+    BlockIterPom[ i ] = pom;//BlockIterPom[ i ];
+  }
+}
+
+template < int sizeSArray, typename Real, typename Device, typename Index >
 __global__ void CudaUpdateCellCaller( tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > ptr,
-                                      const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap,
-                                      Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& aux,
-                                      int *BlockIterDevice )
+        const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap,
+        const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& aux,
+        Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& helpFunc,
+        TNL::Containers::Array< int, Devices::Cuda, Index > BlockIterDevice )
 {
-    int thri = threadIdx.x; int thrj = threadIdx.y; int thrk = threadIdx.z;
-    int blIdx = blockIdx.x; int blIdy = blockIdx.y; int blIdz = blockIdx.z;
-    int i = threadIdx.x + blockDim.x*blockIdx.x;
-    int j = blockDim.y*blockIdx.y + threadIdx.y;
-    int k = blockDim.z*blockIdx.z + threadIdx.z;
-    int currentIndex = thrk * blockDim.x * blockDim.y + thrj * blockDim.x + thri;
+  int thri = threadIdx.x; int thrj = threadIdx.y; int thrk = threadIdx.z;
+  int blIdx = blockIdx.x; int blIdy = blockIdx.y; int blIdz = blockIdx.z;
+  int i = threadIdx.x + blockDim.x*blockIdx.x;
+  int j = blockDim.y*blockIdx.y + threadIdx.y;
+  int k = blockDim.z*blockIdx.z + threadIdx.z;
+  int currentIndex = thrk * blockDim.x * blockDim.y + thrj * blockDim.x + thri;
+  
+  if( BlockIterDevice[ blockIdx.z * gridDim.x * gridDim.y + blockIdx.y * gridDim.x + blockIdx.x ] )
+  {
+    __syncthreads();
     
-    __shared__ volatile bool changed[8*8*8];
-    changed[ currentIndex ] = false;
+    __shared__ volatile bool changed[ 8*8*8/*(sizeSArray - 2)*(sizeSArray - 2)*(sizeSArray - 2)*/];
     
+    changed[ currentIndex ] = false;
     if( thrj == 0 && thri == 0 && thrk == 0 )
-        changed[ 0 ] = true;
+      changed[ 0 ] = true;
     
     const Meshes::Grid< 3, Real, Device, Index >& mesh = interfaceMap.template getMesh< Devices::Cuda >();
-    __shared__ Real hx;
-    __shared__ Real hy;
-    __shared__ Real hz;
+    __shared__ Real hx; __shared__ int dimX;
+    __shared__ Real hy; __shared__ int dimY;
+    __shared__ Real hz; __shared__ int dimZ;
+    
     if( thrj == 1 && thri == 1 && thrk == 1 )
     {
-        hx = mesh.getSpaceSteps().x();
-        hy = mesh.getSpaceSteps().y();
-        hz = mesh.getSpaceSteps().z();
+      //printf( "We are in the calculation. Block = %d.\n",blockIdx.z * gridDim.x * gridDim.y + blockIdx.y * gridDim.x + blockIdx.x  );
+      hx = mesh.getSpaceSteps().x();
+      hy = mesh.getSpaceSteps().y();
+      hz = mesh.getSpaceSteps().z();
+      dimX = mesh.getDimensions().x();
+      dimY = mesh.getDimensions().y();
+      dimZ = mesh.getDimensions().z();
+      BlockIterDevice[ blockIdx.z * gridDim.x * gridDim.y + blockIdx.y * gridDim.x + blockIdx.x ] = 0;
     }
-    __shared__ volatile Real sArray[10][10][10];
-    sArray[thrk][thrj][thri] = std::numeric_limits< Real >::max();
-    if(thri == 0 )
-    {
-        sArray[8][thrj+1][thrk+1] = std::numeric_limits< Real >::max();
-        sArray[9][thrj+1][thrk+1] = std::numeric_limits< Real >::max();
-        sArray[thrk+1][thrj+1][8] = std::numeric_limits< Real >::max();
-        sArray[thrk+1][thrj+1][9] = std::numeric_limits< Real >::max();
-        sArray[thrj+1][8][thrk+1] = std::numeric_limits< Real >::max();
-        sArray[thrj+1][9][thrk+1] = std::numeric_limits< Real >::max();
-    }
-            
+    __shared__ volatile Real sArray[ 10*10*10/*sizeSArray * sizeSArray * sizeSArray*/ ];
+    sArray[(thrk+1)* sizeSArray * sizeSArray + (thrj+1) *sizeSArray + thri+1] = std::numeric_limits< Real >::max();
+    
     //filling sArray edges
-    int dimX = mesh.getDimensions().x(); int dimY = mesh.getDimensions().y();
-    int dimZ = mesh.getDimensions().z();
-    __shared__ volatile int numOfBlockx;
-    __shared__ volatile int numOfBlocky;
-    __shared__ volatile int numOfBlockz;
-    __shared__ int xkolik;
-    __shared__ int ykolik;
-    __shared__ int zkolik;
-    if( thri == 0 && thrj == 0 && thrk == 0 )
-    {
-        xkolik = blockDim.x + 1;
-        ykolik = blockDim.y + 1;
-        zkolik = blockDim.z + 1;
-        numOfBlocky = dimY/blockDim.y + ((dimY%blockDim.y != 0) ? 1:0);
-        numOfBlockx = dimX/blockDim.x + ((dimX%blockDim.x != 0) ? 1:0);
-        numOfBlockz = dimZ/blockDim.z + ((dimZ%blockDim.z != 0) ? 1:0);
-        
-        if( numOfBlockx - 1 == blIdx )
-            xkolik = dimX - (blIdx)*blockDim.x+1;
-
-        if( numOfBlocky -1 == blIdy )
-            ykolik = dimY - (blIdy)*blockDim.y+1;
-        if( numOfBlockz-1 == blIdz )
-            zkolik = dimZ - (blIdz)*blockDim.z+1;
-        
-        BlockIterDevice[ blIdz * numOfBlockx * numOfBlocky + blIdy * numOfBlockx + blIdx ] = 0;
-    }
+    int numOfBlockx;
+    int numOfBlocky;
+    int numOfBlockz;
+    int xkolik;
+    int ykolik;
+    int zkolik;
+    xkolik = blockDim.x + 1;
+    ykolik = blockDim.y + 1;
+    zkolik = blockDim.z + 1;
+    numOfBlockx = gridDim.x;
+    numOfBlocky = gridDim.y;
+    numOfBlockz = gridDim.z;
+    __syncthreads();
+    
+    if( numOfBlockx - 1 == blIdx )
+      xkolik = dimX - (blIdx)*blockDim.x+1;
+    if( numOfBlocky -1 == blIdy )
+      ykolik = dimY - (blIdy)*blockDim.y+1;
+    if( numOfBlockz-1 == blIdz )
+      zkolik = dimZ - (blIdz)*blockDim.z+1;
     __syncthreads();
     
     if( thri == 0 )
     {        
-        if( blIdx != 0 && thrj+1 < ykolik && thrk+1 < zkolik )
-            sArray[thrk+1][thrj+1][0] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x + thrj * dimX -1 + thrk*dimX*dimY ];
-        else
-            sArray[thrk+1][thrj+1][0] = std::numeric_limits< Real >::max();
+      if( blIdx != 0 && thrj+1 < ykolik && thrk+1 < zkolik )
+        sArray[(thrk+1 )* sizeSArray * sizeSArray + (thrj+1)*sizeSArray + 0] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x + thrj * dimX -1 + thrk*dimX*dimY ];
+      else
+        sArray[(thrk+1)* sizeSArray * sizeSArray + (thrj+1)*sizeSArray + 0] = std::numeric_limits< Real >::max();
     }
     
     if( thri == 1 )
     {
-        if( dimX > (blIdx+1) * blockDim.x && thrj+1 < ykolik && thrk+1 < zkolik )
-            sArray[thrk+1][thrj+1][9] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy *blockDim.y*dimX+ blIdx*blockDim.x + blockDim.x + thrj * dimX + thrk*dimX*dimY ];
-        else
-            sArray[thrk+1][thrj+1][9] = std::numeric_limits< Real >::max();
+      if( dimX > (blIdx+1) * blockDim.x && thrj+1 < ykolik && thrk+1 < zkolik )
+        sArray[ (thrk+1) * sizeSArray * sizeSArray + (thrj+1) *sizeSArray + xkolik ] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy *blockDim.y*dimX+ blIdx*blockDim.x + blockDim.x + thrj * dimX + thrk*dimX*dimY ];
+      else
+        sArray[ (thrk+1) * sizeSArray * sizeSArray + (thrj+1)*sizeSArray + xkolik] = std::numeric_limits< Real >::max();
     }
     if( thri == 2 )
     {        
-        if( blIdy != 0 && thrj+1 < xkolik && thrk+1 < zkolik )
-            sArray[thrk+1][0][thrj+1] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x - dimX + thrj + thrk*dimX*dimY ];
-        else
-            sArray[thrk+1][0][thrj+1] = std::numeric_limits< Real >::max();
+      if( blIdy != 0 && thrj+1 < xkolik && thrk+1 < zkolik )
+        sArray[ (thrk+1) * sizeSArray * sizeSArray +0*sizeSArray + thrj+1] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x - dimX + thrj + thrk*dimX*dimY ];
+      else
+        sArray[ (thrk+1) * sizeSArray * sizeSArray + 0*sizeSArray + thrj+1] = std::numeric_limits< Real >::max();
     }
     
     if( thri == 3 )
     {
-        if( dimY > (blIdy+1) * blockDim.y && thrj+1 < xkolik && thrk+1 < zkolik )
-            sArray[thrk+1][9][thrj+1] = aux[ blIdz*blockDim.z * dimX * dimY + (blIdy+1) * blockDim.y*dimX + blIdx*blockDim.x + thrj + thrk*dimX*dimY ];
-        else
-            sArray[thrk+1][9][thrj+1] = std::numeric_limits< Real >::max();
+      if( dimY > (blIdy+1) * blockDim.y && thrj+1 < xkolik && thrk+1 < zkolik )
+        sArray[ (thrk+1) * sizeSArray * sizeSArray + ykolik*sizeSArray + thrj+1] = aux[ blIdz*blockDim.z * dimX * dimY + (blIdy+1) * blockDim.y*dimX + blIdx*blockDim.x + thrj + thrk*dimX*dimY ];
+      else
+        sArray[ (thrk+1) * sizeSArray * sizeSArray + ykolik*sizeSArray + thrj+1] = std::numeric_limits< Real >::max();
     }
     if( thri == 4 )
     {        
-        if( blIdz != 0 && thrj+1 < ykolik && thrk+1 < xkolik )
-            sArray[0][thrj+1][thrk+1] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x - dimX * dimY + thrj * dimX + thrk ];
-        else
-            sArray[0][thrj+1][thrk+1] = std::numeric_limits< Real >::max();
+      if( blIdz != 0 && thrj+1 < ykolik && thrk+1 < xkolik )
+        sArray[ 0 * sizeSArray * sizeSArray +(thrj+1 )* sizeSArray + thrk+1] = aux[ blIdz*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x - dimX * dimY + thrj * dimX + thrk ];
+      else
+        sArray[0 * sizeSArray * sizeSArray + (thrj+1) *sizeSArray + thrk+1] = std::numeric_limits< Real >::max();
     }
     
     if( thri == 5 )
     {
-        if( dimZ > (blIdz+1) * blockDim.z && thrj+1 < ykolik && thrk+1 < xkolik )
-            sArray[9][thrj+1][thrk+1] = aux[ (blIdz+1)*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x + thrj * dimX + thrk ];
-        else
-            sArray[9][thrj+1][thrk+1] = std::numeric_limits< Real >::max();
+      if( dimZ > (blIdz+1) * blockDim.z && thrj+1 < ykolik && thrk+1 < xkolik )
+        sArray[zkolik * sizeSArray * sizeSArray + (thrj+1) * sizeSArray + thrk+1] = aux[ (blIdz+1)*blockDim.z * dimX * dimY + blIdy * blockDim.y*dimX + blIdx*blockDim.x + thrj * dimX + thrk ];
+      else
+        sArray[zkolik * sizeSArray * sizeSArray + (thrj+1) * sizeSArray + thrk+1] = std::numeric_limits< Real >::max();
     }
     
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && k < mesh.getDimensions().z() )
+    if( i < dimX && j < dimY && k < dimZ )
     {
-        sArray[thrk+1][thrj+1][thri+1] = aux[ k*dimX*dimY + j*dimX + i ];
+      sArray[(thrk+1) * sizeSArray * sizeSArray + (thrj+1) *sizeSArray + thri+1] = aux[ k*dimX*dimY + j*dimX + i ];
     }
-    __shared__ volatile int loopcounter;
-    loopcounter = 0;
     __syncthreads(); 
+    
     while( changed[ 0 ] )
     {
-        __syncthreads();
-        
-        changed[ currentIndex ] = false;
-        
-    //calculation of update cell
-        if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && k < dimZ )
-        {
-            if( ! interfaceMap[ k*dimX*dimY + j * mesh.getDimensions().x() + i ] )
-            {
-                changed[ currentIndex ] = ptr.updateCell( sArray, thri+1, thrj+1, thrk+1, hx,hy,hz);
-            }
-        }
-        __syncthreads();
-        
-    //pyramid reduction
-        if( blockDim.x*blockDim.y*blockDim.z == 1024 )
-        {
-            if( currentIndex < 512 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 512 ];
-            }
-        }
-        __syncthreads();
-        if( blockDim.x*blockDim.y*blockDim.z >= 512 )
+      __syncthreads();
+      
+      changed[ currentIndex ] = false;
+      
+      //calculation of update cell
+      if( i < dimX && j < dimY && k < dimZ )
+      {
+        if( ! interfaceMap[ k*dimX*dimY + j * dimX + i ] )
         {
-            if( currentIndex < 256 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 256 ];
-            }
+          changed[ currentIndex ] = ptr.updateCell3D< sizeSArray >( sArray, thri+1, thrj+1, thrk+1, hx,hy,hz);
         }
-        __syncthreads();
-        if( blockDim.x*blockDim.y*blockDim.z >= 256 )
+      }
+      __syncthreads();
+      
+      //pyramid reduction
+      if( blockDim.x*blockDim.y*blockDim.z == 1024 )
+      {
+        if( currentIndex < 512 )
         {
-            if( currentIndex < 128 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 128 ];
-            }
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 512 ];
         }
-        __syncthreads();
-        if( blockDim.x*blockDim.y*blockDim.z >= 128 )
+      }
+      __syncthreads();
+      if( blockDim.x*blockDim.y*blockDim.z >= 512 )
+      {
+        if( currentIndex < 256 )
         {
-            if( currentIndex < 64 )
-            {
-                changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 64 ];
-            }
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 256 ];
         }
-        __syncthreads();
-        if( currentIndex < 32 ) //POUZE IF JSOU SINCHRONNI NA JEDNOM WARPU
+      }
+      __syncthreads();
+      if( blockDim.x*blockDim.y*blockDim.z >= 256 )
+      {
+        if( currentIndex < 128 )
         {
-            if( true ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 32 ];
-            if( currentIndex < 16 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 16 ];
-            if( currentIndex < 8 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 8 ];
-            if( currentIndex < 4 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 4 ];
-            if( currentIndex < 2 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 2 ];
-            if( currentIndex < 1 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 1 ];
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 128 ];
         }
-        __syncthreads();
-        
-        /*if(thri == 0 && thrj ==0 && thrk ==0 && blIdx == 0 && blIdy == 0 && blIdz == 0)
-        {
-            for(int m = 0; m < 8; m++){
-                for(int n = 0; n<8; n++){
-                    for(int b=0; b<8; b++)
-                        printf(" %i ", changed[m*64 + n*8 + b]);
-                    printf("\n");
-                }
-                printf("\n \n");
-            }
-        }*/
-        if( changed[ 0 ] && thri == 0 && thrj == 0 && thrk == 0 )
+      }
+      __syncthreads();
+      if( blockDim.x*blockDim.y*blockDim.z >= 128 )
+      {
+        if( currentIndex < 64 )
         {
-            //loopcounter++;
-            BlockIterDevice[ blIdz * numOfBlockx * numOfBlocky + blIdy * numOfBlockx + blIdx ] = 1;
+          changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 64 ];
         }
-        __syncthreads();
-        /*if(thri == 0 && thrj==0 && thrk==0)
-            printf("%i \n",loopcounter);
-        if(loopcounter == 500)
-            break;*/
+      }
+      __syncthreads();
+      if( currentIndex < 32 )
+      {
+        if( true ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 32 ];
+        if( currentIndex < 16 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 16 ];
+        if( currentIndex < 8 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 8 ];
+        if( currentIndex < 4 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 4 ];
+        if( currentIndex < 2 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 2 ];
+        if( currentIndex < 1 ) changed[ currentIndex ] = changed[ currentIndex ] || changed[ currentIndex + 1 ];
+      }
+      __syncthreads();
+      
+      /*if(thri == 0 && thrj ==0 && thrk ==0 && blIdx == 0 && blIdy == 0 && blIdz == 0)
+       {
+       //for(int m = 0; m < 8; m++){
+       int m = 4;
+       for(int n = 0; n<8; n++){
+       for(int b=0; b<8; b++)
+       printf(" %i ", changed[m*64 + n*8 + b]);
+       printf("\n");
+       }
+       printf("\n \n");
+       }
+       //}*/
+      
+      if( changed[ 0 ] && thri == 0 && thrj == 0 && thrk == 0 )
+      {
+        //printf( "Setting block calculation. Block = %d.\n",blockIdx.z * gridDim.x * gridDim.y + blockIdx.y * gridDim.x + blockIdx.x  );
+        BlockIterDevice[ blIdz * gridDim.x * gridDim.y + blIdy * gridDim.x + blIdx ] = 1;
+      }
+      __syncthreads();
     }
-  
-    if( i < mesh.getDimensions().x() && j < mesh.getDimensions().y() && k < dimZ && (!interfaceMap[ k*dimX*dimY+j * mesh.getDimensions().x() + i ]) )
-        aux[ k*dimX*dimY + j * mesh.getDimensions().x() + i ] = sArray[thrk+1][ thrj + 1 ][ thri + 1 ];
-}   
+    
+    if( i < dimX && j < dimY && k < dimZ )
+      helpFunc[ k*dimX*dimY + j * dimX + i ] = sArray[ (thrk+1) * sizeSArray * sizeSArray + (thrj+1) * sizeSArray + thri+1 ];
+    
+  } 
+}  
 #endif
diff --git a/src/TNL/FileName.cpp b/src/TNL/FileName.cpp
index 8e47282ddb5b308aaa72b567e91dc6bb3ac4e2bd..ecbe0a664bb30c254067c20619e3b6370f83d3b5 100644
--- a/src/TNL/FileName.cpp
+++ b/src/TNL/FileName.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          mfilename.cpp  -  description
+                          FileName.cpp  -  description
                              -------------------
     begin                : 2007/06/18
     copyright            : (C) 2007 by Tomas Oberhuber
@@ -22,6 +22,22 @@ FileName::FileName()
 : index( 0 ), digitsCount( 5 )
 {
 }
+
+FileName::FileName( const String& fileNameBase )
+: fileNameBase( fileNameBase ),
+   index( 0 ),
+   digitsCount( 5 )
+{
+}
+
+FileName::FileName( const String& fileNameBase, 
+                    const String& extension )
+: fileNameBase( fileNameBase ),
+   extension( extension ),
+   index( 0 ),
+   digitsCount( 5 )
+{
+}
       
 void FileName::setFileNameBase( const String& fileNameBase )
 {
@@ -43,38 +59,24 @@ void FileName::setDigitsCount( const int digitsCount )
    this->digitsCount = digitsCount;
 }
 
+void FileName::setDistributedSystemNodeId( int nodeId )
+{
+   this->distributedSystemNodeId = "-";
+   this->distributedSystemNodeId += convertToString( nodeId );
+}
+
 String FileName::getFileName()
 {
    std::stringstream stream;
    stream << this->fileNameBase 
           << std::setw( this->digitsCount )
           << std::setfill( '0' )
-          << index
+          << this->index
+          << this->distributedSystemNodeId
           << "." << this->extension;
    return String( stream.str().data() );
 }
 
-/*void FileNameBaseNumberEnding( const char* base_name,
-                               int number,
-                               int index_size,
-                               const char* ending,
-                               String& file_name )
-{
-   file_name. setString( base_name );
-   char snumber[ 1024 ], zeros[ 1024 ];;
-   sprintf( snumber, "%d", number );
-   int len = strlen( snumber );
-
-   const int k = min( 1024, index_size );
-   int i;
-   for( i = len; i < k ; i ++ )
-      zeros[ i - len ] = '0';
-   zeros[ k - len ] = 0;
-   file_name += zeros;
-   file_name += snumber;
-   file_name += ending;
-}*/
-
 String getFileExtension( const String fileName )
 {
    int size = fileName. getLength();
@@ -93,4 +95,4 @@ void removeFileExtension( String& fileName )
    fileName. setString( fileName. getString(), 0, i );
 }
 
-} // namespace TNL
\ No newline at end of file
+} // namespace TNL
diff --git a/src/TNL/FileName.h b/src/TNL/FileName.h
index 312f2f34e477eac87e756472f1bc84a842900204..3dae01c5407153357d91a45e74b73382cc3559e0 100644
--- a/src/TNL/FileName.h
+++ b/src/TNL/FileName.h
@@ -1,5 +1,5 @@
 /***************************************************************************
-                          mfilename.h  -  description
+                          FileName.h  -  description
                              -------------------
     begin                : 2007/06/18
     copyright            : (C) 2007 by Tomas Oberhuber
@@ -14,12 +14,6 @@
 
 namespace TNL {
 
-/*void FileNameBaseNumberEnding( const char* base_name,
-                               int number,
-                               int index_size,
-                               const char* ending,
-                               String& file_name );*/
-
 String getFileExtension( const String fileName );
 
 void removeFileExtension( String& file_name );
@@ -35,7 +29,12 @@ class FileName
       ///
       /// Constructs an empty filename object.
       FileName();
-
+      
+      FileName( const String& fileNameBase );
+      
+      FileName( const String& fileNameBase, 
+                const String& extension );
+      
       /// \brief Sets the base name of given file.
       ///
       /// Sets \e fileNameBase as the base name of given file.
@@ -61,6 +60,11 @@ class FileName
       /// @param digitsCount Integer - number of digits.
       void setDigitsCount( const int digitsCount );
       
+      void setDistributedSystemNodeId( int nodeId );
+      
+      template< typename Coordinates >
+      void setDistributedSystemNodeId( const Coordinates& nodeId );
+      
       /// \brief Creates appropriate name for given file.
       ///
       /// Creates particular file name using \e fileNameBase, \e digitsCount,
@@ -69,10 +73,12 @@ class FileName
       
    protected:
    
-      String fileNameBase, extension;
+      String fileNameBase, extension, distributedSystemNodeId;
       
       int index, digitsCount;
    
 };
 
 } // namespace TNL
+
+#include <TNL/FileName.hpp>
diff --git a/src/TNL/FileName.hpp b/src/TNL/FileName.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..4f1628df54c808322e61d30ad7c2210c67ee507d
--- /dev/null
+++ b/src/TNL/FileName.hpp
@@ -0,0 +1,29 @@
+/***************************************************************************
+                          FileName.hpp  -  description
+                             -------------------
+    begin                : Sep 28, 2018
+    copyright            : (C) 2018 by Tomas Oberhuber
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#include <TNL/FileName.h>
+
+namespace TNL {
+
+template< typename Coordinates >
+void
+FileName::
+setDistributedSystemNodeId( const Coordinates& nodeId )
+{
+   this->distributedSystemNodeId = "-";
+   this->distributedSystemNodeId += convertToString( nodeId[ 0 ] );
+   for( int i = 1; i < nodeId.getSize(); i++ )
+   {
+      this->distributedSystemNodeId += "-";
+      this->distributedSystemNodeId += convertToString( nodeId[ i ] );
+   }
+}
+
+} // namespace TNL
diff --git a/src/TNL/Functions/MeshFunctionGnuplotWriter.h b/src/TNL/Functions/MeshFunctionGnuplotWriter.h
index 4b9b6d085ff7a69c0139fce319d3e3cb4d540f78..11470965ee6fe4a90dd7db3784c132824ea966c4 100644
--- a/src/TNL/Functions/MeshFunctionGnuplotWriter.h
+++ b/src/TNL/Functions/MeshFunctionGnuplotWriter.h
@@ -20,50 +20,59 @@ namespace Meshes {
 
 namespace Functions {
 
-template< typename MeshFunction >
-class MeshFunctionGnuplotWriter
+class MeshFunctionGnuplotWriterBase
 {
-   using MeshType = typename MeshFunction::MeshType;
-   using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
-   using GlobalIndex = typename MeshType::GlobalIndexType;
+   protected:
 
-   template< typename Entity, int dim = Entity::getEntityDimension() >
-   struct center
-   {
-      static auto get( const Entity& entity ) -> decltype(entity.getCenter())
+      template< typename Entity, int dim = Entity::getEntityDimension() >
+      struct center
       {
-         return entity.getCenter();
-      }
-   };
+         static auto get( const Entity& entity ) -> decltype(entity.getCenter())
+         {
+            return entity.getCenter();
+         }
+      };
 
-   template< typename Entity >
-   struct center< Entity, 0 >
-   {
-      static auto get( const Entity& entity ) -> decltype(entity.getPoint())
+      template< typename Entity >
+      struct center< Entity, 0 >
       {
-         return entity.getPoint();
-      }
-   };
+         static auto get( const Entity& entity ) -> decltype(entity.getPoint())
+         {
+            return entity.getPoint();
+         }
+      };
 
-   template< typename MeshConfig, typename Device, typename Topology, int dim >
-   struct center< TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >, dim >
-   {
-      static int get( const TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >& entity )
+      template< typename MeshConfig, typename Device, typename Topology, int dim >
+      struct center< TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >, dim >
       {
-         throw "not implemented";
-      }
-   };
+         static int get( const TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >& entity )
+         {
+            throw "not implemented";
+         }
+      };
 
-   template< typename MeshConfig, typename Device, typename Topology >
-   struct center< TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >, 0 >
-   {
-      static int get( const TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >& entity )
+      template< typename MeshConfig, typename Device, typename Topology >
+      struct center< TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >, 0 >
       {
-         throw "not implemented";
-      }
-   };
+         static int get( const TNL::Meshes::MeshEntity< MeshConfig, Device, Topology >& entity )
+         {
+            throw "not implemented";
+         }
+      };
+};
+
+template< typename MeshFunction,
+          typename Mesh = typename MeshFunction::MeshType,
+          int EntitiesDimension = MeshFunction::getEntitiesDimension() >
+class MeshFunctionGnuplotWriter
+: public MeshFunctionGnuplotWriterBase
+{
+   public:
+
+      using MeshType = typename MeshFunction::MeshType;
+      using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
+      using GlobalIndex = typename MeshType::GlobalIndexType;
 
-public:
    static bool write( const MeshFunction& function,
                       std::ostream& str,
                       const double& scale = 1.0 )
@@ -81,5 +90,82 @@ public:
    }
 };
 
+template< typename MeshFunction,
+   typename Real,
+   typename Device,
+   typename Index,
+   int EntityDimension >
+class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 2, Real, Device, Index >, EntityDimension >
+: public MeshFunctionGnuplotWriterBase
+{
+   public:
+
+      using MeshType = typename MeshFunction::MeshType;
+      using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
+      using GlobalIndex = typename MeshType::GlobalIndexType;
+
+   static bool write( const MeshFunction& function,
+                      std::ostream& str,
+                      const double& scale = 1.0 )
+   {
+      const MeshType& grid = function.getMesh();
+      EntityType entity( grid );
+      auto& c = entity.getCoordinates();
+      for( c.y() = 0; c.y() < grid.getDimensions().y(); c.y()++ )
+      {
+         for( c.x() = 0; c.x() < grid.getDimensions().x(); c.x()++ )
+         {
+            entity.refresh();
+            typename MeshType::PointType v = center< EntityType >::get( entity );
+            //std::cerr << entity.getCoordinates() << " -> " << v << std::endl;
+            for( int j = 0; j < v.getSize(); j++ )
+               str << v[ j ] << " ";
+            str << scale * function.getData().getElement( entity.getIndex() ) << "\n";
+         }
+         str << "\n";
+      }
+      return true;
+   }
+};
+
+template< typename MeshFunction,
+   typename Real,
+   typename Device,
+   typename Index,
+   int EntityDimension >
+class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 3, Real, Device, Index >, EntityDimension >
+: public MeshFunctionGnuplotWriterBase
+{
+   public:
+
+      using MeshType = typename MeshFunction::MeshType;
+      using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
+      using GlobalIndex = typename MeshType::GlobalIndexType;
+
+   static bool write( const MeshFunction& function,
+                      std::ostream& str,
+                      const double& scale = 1.0 )
+   {
+      const MeshType& grid = function.getMesh();
+      EntityType entity( grid );
+      auto& c = entity.getCoordinates();
+      for( c.z() = 0; c.z() < grid.getDimensions().z(); c.z()++ )
+         for( c.y() = 0; c.y() < grid.getDimensions().y(); c.y()++ )
+         {
+            for( c.x() = 0; c.x() < grid.getDimensions().x(); c.x()++ )
+            {
+               entity.refresh();
+               typename MeshType::PointType v = center< EntityType >::get( entity );
+               for( int j = 0; j < v.getSize(); j++ )
+                  str << v[ j ] << " ";
+               str << scale * function.getData().getElement( entity.getIndex() ) << "\n";
+            }
+            str << "\n";
+         }
+      return true;
+   }
+};
+
+
 } // namespace Functions
 } // namespace TNL
diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGrid.hpp b/src/TNL/Meshes/DistributedMeshes/DistributedGrid.hpp
index 726f82f2bcf604045ce1ff7f44980f4b0940a751..1fbbe12aa5b6815de77aad583b6126e9e0cce7d2 100644
--- a/src/TNL/Meshes/DistributedMeshes/DistributedGrid.hpp
+++ b/src/TNL/Meshes/DistributedMeshes/DistributedGrid.hpp
@@ -51,11 +51,11 @@ DistributedMesh< Grid< Dimension, Real, Device, Index > >::
 setup( const Config::ParameterContainer& parameters,
        const String& prefix )
 {
-   this->domainDecomposition.x() = parameters.getParameter< int >( "grid-domain-decomposition-x" );
+   this->domainDecomposition[ 0 ] = parameters.getParameter< int >( "grid-domain-decomposition-x" );
    if( Dimension > 1 )
-      this->domainDecomposition.y() = parameters.getParameter< int >( "grid-domain-decomposition-y" );
+      this->domainDecomposition[ 1 ] = parameters.getParameter< int >( "grid-domain-decomposition-y" );
    if( Dimension > 2 )
-      this->domainDecomposition.z() = parameters.getParameter< int >( "grid-domain-decomposition-z" );
+      this->domainDecomposition[ 2 ] = parameters.getParameter< int >( "grid-domain-decomposition-z" );
    return true;
 }
 
@@ -521,7 +521,10 @@ String
 DistributedMesh< Grid< Dimension, Real, Device, Index > >::
 printProcessDistr() const
 {
-   return convertToString(this->domainDecomposition[0])+String("-")+convertToString(this->domainDecomposition[1])+String("-")+convertToString(this->domainDecomposition[2]);
+   String res = convertToString(this->domainDecomposition[0]);
+   for(int i=1; i<Dimension; i++)
+        res=res+String("-")+convertToString(this->domainDecomposition[i]);
+   return res;
 };  
 
 template< int Dimension, typename Real, typename Device, typename Index >
diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_1D.h b/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_1D.h
index e7968ba243c74845158605218acf669d501f3bfc..2aaa47bab1509a61e42e87578a7c6af4752039af 100644
--- a/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_1D.h
+++ b/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_1D.h
@@ -126,30 +126,30 @@ class DistributedMeshSynchronizer< Functions::MeshFunction< Grid< 1, GridReal, D
          {
             TNL_ASSERT_GE( sendBuffers[ Left ].getSize(), lowerOverlap.x(), "" );
             TNL_ASSERT_GE( receiveBuffers[ Left ].getSize(), lowerOverlap.x(), "" );
-            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Left ].getData(), lowerOverlap.x(), neighbors[ Left ], group );
-            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Left ].getData(), lowerOverlap.x(), neighbors[ Left ], group );
+            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Left ].getData(), lowerOverlap.x(), neighbors[ Left ], 0, group );
+            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Left ].getData(), lowerOverlap.x(), neighbors[ Left ], 0, group );
          }
          else if( periodicBoundaries )
          {
             TNL_ASSERT_GE( sendBuffers[ Left ].getSize(), lowerOverlap.x(), "" );
             TNL_ASSERT_GE( receiveBuffers[ Left ].getSize(), lowerOverlap.x(), "" );            
-            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Left ].getData(), lowerOverlap.x(), periodicNeighbors[ Left ], group );
-            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Left ].getData(), lowerOverlap.x(), periodicNeighbors[ Left ], group );
+            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Left ].getData(), lowerOverlap.x(), periodicNeighbors[ Left ], 1, group );
+            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Left ].getData(), lowerOverlap.x(), periodicNeighbors[ Left ], 1, group );
          }        
 
          if( neighbors[ Right ] != -1 )
          {
             TNL_ASSERT_GE( sendBuffers[ Right ].getSize(), upperOverlap.x(), "" );
             TNL_ASSERT_GE( receiveBuffers[ Right ].getSize(), upperOverlap.x(), "" );
-            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Right ].getData(), upperOverlap.x(), neighbors[ Right ], group );
-            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Right ].getData(), upperOverlap.x(), neighbors[ Right ], group );
+            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Right ].getData(), upperOverlap.x(), neighbors[ Right ], 0, group );
+            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Right ].getData(), upperOverlap.x(), neighbors[ Right ], 0, group );
          }
          else if( periodicBoundaries )
          {
             TNL_ASSERT_GE( sendBuffers[ Right ].getSize(), upperOverlap.x(), "" );
             TNL_ASSERT_GE( receiveBuffers[ Right ].getSize(), upperOverlap.x(), "" );
-            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Right ].getData(), upperOverlap.x(), periodicNeighbors[ Right ], group );
-            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Right ].getData(), upperOverlap.x(), periodicNeighbors[ Right ], group );
+            requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ Right ].getData(), upperOverlap.x(), periodicNeighbors[ Right ], 1, group );
+            requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ Right ].getData(), upperOverlap.x(), periodicNeighbors[ Right ], 1, group );
          }
          
          //wait until send and receive is done
diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_2D.h b/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_2D.h
index ba61f2b3d0190a3b7baabea1e094f7b475713d55..51c2aef56fa824aa9f7ccac86f5f279d0e5b56c4 100644
--- a/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_2D.h
+++ b/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_2D.h
@@ -148,16 +148,18 @@ class DistributedMeshSynchronizer< Functions::MeshFunction< Grid< 2, GridReal, D
          
          //send everything, receive everything 
          for( int i = 0; i < 8; i++ )
+         {
             if( neighbors[ i ] != -1 )
             {
-               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(), sizes[ i ], neighbors[ i ], group );
-               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(), sizes[ i ], neighbors[ i ], group );
+               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(), sizes[ i ], neighbors[ i ], 0, group );
+               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(), sizes[ i ], neighbors[ i ], 0, group );
             }
             else if( periodicBoundaries )
             {
-               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(), sizes[ i ], periodicNeighbors[ i ], group );
-               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(), sizes[ i ], periodicNeighbors[ i ], group );
+               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(), sizes[ i ], periodicNeighbors[ i ], 1, group );
+               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(), sizes[ i ], periodicNeighbors[ i ], 1, group );
             }
+         }
 
          //wait until send is done
          CommunicatorType::WaitAll( requests, requestsCount );
diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_3D.h b/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_3D.h
index 8715ef359d42a857c18143ddb4cb4d10aba3105e..047cf982298f8098425a91106913212fe2a0f425 100644
--- a/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_3D.h
+++ b/src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer_3D.h
@@ -172,17 +172,17 @@ class DistributedMeshSynchronizer< Functions::MeshFunction< Grid< 3, GridReal, D
          group=*((typename CommunicatorType::CommunicationGroup *)(distributedGrid->getCommunicationGroup()));
          int requestsCount( 0 );
 		                
-         //send everything, recieve everything 
-         for( int i=0; i<26; i++ )
+         //send everything, receive everything
+         for( int i = 0; i <  26; i++ )
             if( neighbors[ i ] != -1 )
             {
-               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(),  sizes[ i ], neighbors[ i ], group );
-               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(),  sizes[ i ], neighbors[ i ], group );
+               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(),  sizes[ i ], neighbors[ i ], 0, group );
+               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(),  sizes[ i ], neighbors[ i ], 0, group );
             }
             else if( periodicBoundaries )
       	   {
-               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(),  sizes[ i ], periodicNeighbors[ i ], group );
-               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(),  sizes[ i ], periodicNeighbors[ i ], group );
+               requests[ requestsCount++ ] = CommunicatorType::ISend( sendBuffers[ i ].getData(),  sizes[ i ], periodicNeighbors[ i ], 1, group );
+               requests[ requestsCount++ ] = CommunicatorType::IRecv( receiveBuffers[ i ].getData(),  sizes[ i ], periodicNeighbors[ i ], 1, group );
             }
 
         //wait until send is done
diff --git a/src/TNL/Meshes/Writers/VTKWriter_impl.h b/src/TNL/Meshes/Writers/VTKWriter_impl.h
index 456429a5a083c58428e5c45b89015d5261e58826..b3f1723b7444f60aabf445466a5829256c692d9c 100644
--- a/src/TNL/Meshes/Writers/VTKWriter_impl.h
+++ b/src/TNL/Meshes/Writers/VTKWriter_impl.h
@@ -10,6 +10,8 @@
 
 #pragma once
 
+#include <type_traits>
+
 #include <TNL/Meshes/Writers/VTKWriter.h>
 #include <TNL/Meshes/Readers/EntityShape.h>
 
@@ -19,68 +21,63 @@ namespace Writers {
 
 namespace __impl {
 
-template< typename Entity >
-struct VerticesPerEntity
+template< typename T, typename R = void >
+struct enable_if_type
 {
-   static constexpr int count = Entity::getVerticesCount();
+   using type = R;
 };
 
-template< typename MeshConfig, typename Device >
-struct VerticesPerEntity< MeshEntity< MeshConfig, Device, Topologies::Vertex > >
-{
-   static constexpr int count = 1;
-};
+template< typename T, typename Enable = void >
+struct has_entity_topology : std::false_type {};
 
-template< typename Grid, typename Config >
-struct VerticesPerEntity< GridEntity< Grid, 0, Config > >
-{
-   static constexpr int count = 1;
-};
+template< typename T >
+struct has_entity_topology< T, typename enable_if_type< typename T::EntityTopology >::type >
+: std::true_type
+{};
 
-template< typename Grid, typename Config >
-struct VerticesPerEntity< GridEntity< Grid, 1, Config > >
-{
-   static constexpr int count = 2;
-};
 
-template< typename Grid, typename Config >
-struct VerticesPerEntity< GridEntity< Grid, 2, Config > >
+template< typename Entity,
+          bool _is_mesh_entity = has_entity_topology< Entity >::value >
+struct VerticesPerEntity
 {
-   static constexpr int count = 4;
+   static constexpr int count = Entity::getVerticesCount();
 };
 
-template< typename Grid, typename Config >
-struct VerticesPerEntity< GridEntity< Grid, 3, Config > >
+template< typename MeshConfig, typename Device >
+struct VerticesPerEntity< MeshEntity< MeshConfig, Device, Topologies::Vertex >, true >
 {
-   static constexpr int count = 8;
+   static constexpr int count = 1;
 };
 
-
 template< typename GridEntity >
-struct GridEntityShape {};
-
-template< typename Grid, typename Config >
-struct GridEntityShape< GridEntity< Grid, 0, Config > >
+struct VerticesPerEntity< GridEntity, false >
 {
-   static constexpr Readers::EntityShape shape = Readers::EntityShape::Vertex;
+private:
+   static constexpr int dim = GridEntity::getEntityDimension();
+   static_assert( dim >= 0 && dim <= 3, "unexpected dimension of the grid entity" );
+
+public:
+   static constexpr int count =
+      (dim == 0) ? 1 :
+      (dim == 1) ? 2 :
+      (dim == 2) ? 4 :
+                   8;
 };
 
-template< typename Grid, typename Config >
-struct GridEntityShape< GridEntity< Grid, 1, Config > >
-{
-   static constexpr Readers::EntityShape shape = Readers::EntityShape::Line;
-};
-
-template< typename Grid, typename Config >
-struct GridEntityShape< GridEntity< Grid, 2, Config > >
-{
-   static constexpr Readers::EntityShape shape = Readers::EntityShape::Pixel;
-};
 
-template< typename Grid, typename Config >
-struct GridEntityShape< GridEntity< Grid, 3, Config > >
+template< typename GridEntity >
+struct GridEntityShape
 {
-   static constexpr Readers::EntityShape shape = Readers::EntityShape::Voxel;
+private:
+   static constexpr int dim = GridEntity::getEntityDimension();
+   static_assert( dim >= 0 && dim <= 3, "unexpected dimension of the grid entity" );
+
+public:
+   static constexpr Readers::EntityShape shape =
+      (dim == 0) ? Readers::EntityShape::Vertex :
+      (dim == 1) ? Readers::EntityShape::Line :
+      (dim == 2) ? Readers::EntityShape::Pixel :
+                   Readers::EntityShape::Voxel;
 };
 
 
diff --git a/src/TNL/Solvers/Linear/CMakeLists.txt b/src/TNL/Solvers/Linear/CMakeLists.txt
index 2e33af0b8e081c2374990cbe6ff1eb70a0a897d0..f5815d34f7f161d1082779eadffe565249a6a9ed 100644
--- a/src/TNL/Solvers/Linear/CMakeLists.txt
+++ b/src/TNL/Solvers/Linear/CMakeLists.txt
@@ -16,6 +16,7 @@ SET( headers BICGStab.h
              SOR_impl.h
              TFQMR.h
              TFQMR_impl.h
+             Traits.h
              UmfpackWrapper.h
              UmfpackWrapper_impl.h
    )
diff --git a/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h b/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h
index 2efc01001b9bb5438f2c6613409065c03bf79164..58ab8c682bfaff5adc368c075b8e7e7fa576633f 100644
--- a/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h
+++ b/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h
@@ -15,6 +15,7 @@
 #include <TNL/Containers/VectorView.h>
 #include <TNL/Pointers/SharedPointer.h>
 #include <TNL/Config/ParameterContainer.h>
+#include <TNL/Solvers/Linear/Traits.h>
 
 #include "../Traits.h"
 
diff --git a/src/TNL/Solvers/PDE/TimeDependentPDESolver.h b/src/TNL/Solvers/PDE/TimeDependentPDESolver.h
index 712e288996096ab4f1ff5c2580a073c43965c03c..58f4c5cc501592ce041ba4bfcb79ba84759e4389 100644
--- a/src/TNL/Solvers/PDE/TimeDependentPDESolver.h
+++ b/src/TNL/Solvers/PDE/TimeDependentPDESolver.h
@@ -86,7 +86,7 @@ class TimeDependentPDESolver
 
       MeshPointer meshPointer;
 
-      Meshes::DistributedMeshes::DistributedMesh<MeshType> distrMesh;
+      Meshes::DistributedMeshes::DistributedMesh<MeshType> distributedMesh;
 
       DofVectorPointer dofsPointer;
 
diff --git a/src/TNL/Solvers/PDE/TimeDependentPDESolver_impl.h b/src/TNL/Solvers/PDE/TimeDependentPDESolver_impl.h
index 78c9a6912ddd7fb9651ceab3035873843fab2348..045734c4aaae2117fdb792acd298ac27d221fd7e 100644
--- a/src/TNL/Solvers/PDE/TimeDependentPDESolver_impl.h
+++ b/src/TNL/Solvers/PDE/TimeDependentPDESolver_impl.h
@@ -56,13 +56,14 @@ setup( const Config::ParameterContainer& parameters,
    
    BaseType::setup( parameters, prefix );
    
-   /****
-    * Load the mesh from the mesh file
-    */
+   /////
+   // Load the mesh from the mesh file
+   //
    const String& meshFile = parameters.getParameter< String >( "mesh" );
-   if( ! Meshes::loadMesh< typename Problem::CommunicatorType >( meshFile, *this->meshPointer, distrMesh ) )
+   this->distributedMesh.setup( parameters, prefix );
+   if( ! Meshes::loadMesh< typename Problem::CommunicatorType >( meshFile, *this->meshPointer, distributedMesh ) )
       return false;
-   if( ! Meshes::decomposeMesh< Problem >( parameters, prefix, *this->meshPointer, distrMesh, *problem ) )
+   if( ! Meshes::decomposeMesh< Problem >( parameters, prefix, *this->meshPointer, distributedMesh, *problem ) )
       return false;
    
    problem->setMesh( this->meshPointer );
diff --git a/src/TNL/Solvers/PDE/TimeIndependentPDESolver.h b/src/TNL/Solvers/PDE/TimeIndependentPDESolver.h
index 5711ec82e7ed2379d194cc3ba88eb2f3c5cf4463..e4a5f9778d3bf14b2a42df0819a3b71de028547b 100644
--- a/src/TNL/Solvers/PDE/TimeIndependentPDESolver.h
+++ b/src/TNL/Solvers/PDE/TimeIndependentPDESolver.h
@@ -67,7 +67,9 @@ class TimeIndependentPDESolver : public PDESolver< typename Problem::RealType,
 
    protected:
 
-      MeshPointer mesh;
+      MeshPointer meshPointer;
+
+      Meshes::DistributedMeshes::DistributedMesh<MeshType> distributedMesh;
 
       CommonDataPointer commonDataPointer;
 
diff --git a/src/TNL/Solvers/PDE/TimeIndependentPDESolver_impl.h b/src/TNL/Solvers/PDE/TimeIndependentPDESolver_impl.h
index f53a989060e5b34a40f0bd7fe24b9700c15901ad..d676c8af05225119aa502fa13838d96e1f9926d1 100644
--- a/src/TNL/Solvers/PDE/TimeIndependentPDESolver_impl.h
+++ b/src/TNL/Solvers/PDE/TimeIndependentPDESolver_impl.h
@@ -45,21 +45,17 @@ TimeIndependentPDESolver< Problem >::
 setup( const Config::ParameterContainer& parameters,
        const String& prefix )
 {
-   /****
-    * Load the mesh from the mesh file
-    */
+   /////
+   // Load the mesh from the mesh file
+   //
    const String& meshFile = parameters.getParameter< String >( "mesh" );
-   std::cout << "Loading a mesh from the file " << meshFile << "...";
-   if( ! this->mesh->load( meshFile ) )
-   {
-      std::cerr << std::endl;
-      std::cerr << "I am not able to load the mesh from the file " << meshFile << "." << std::endl;
-      std::cerr << " You may create it with tools like tnl-grid-setup or tnl-mesh-convert." << std::endl;
+   this->distributedMesh.setup( parameters, prefix );
+   if( ! Meshes::loadMesh< typename Problem::CommunicatorType >( meshFile, *this->meshPointer, distributedMesh ) )
+      return false;
+   if( ! Meshes::decomposeMesh< Problem >( parameters, prefix, *this->meshPointer, distributedMesh, *problem ) )
       return false;
-   }
-   std::cout << " [ OK ] " << std::endl;
    
-   problem->setMesh( this->mesh );
+   problem->setMesh( this->meshPointer );
 
    /****
     * Set-up common data
@@ -110,7 +106,7 @@ writeProlog( Logger& logger,
    logger.writeHeader( problem->getPrologHeader() );
    problem->writeProlog( logger, parameters );
    logger.writeSeparator();
-   mesh->writeProlog( logger );
+   meshPointer->writeProlog( logger );
    logger.writeSeparator();
    const String& solverName = parameters. getParameter< String >( "discrete-solver" );
    logger.writeParameter< String >( "Discrete solver:", "discrete-solver", parameters );
diff --git a/src/TNL/String.cpp b/src/TNL/String.cpp
index 3f733526d935e12f0d6534de22e9d06cdbe91058..817c62cca36af2362d8cde9da295ce5730fecc41 100644
--- a/src/TNL/String.cpp
+++ b/src/TNL/String.cpp
@@ -29,12 +29,6 @@ String::String()
    setString( nullptr );
 }
 
-String::String( char* c, int prefix_cut_off, int sufix_cut_off )
-   : string( nullptr ), length( 0 )
-{
-   setString( c, prefix_cut_off, sufix_cut_off );
-}
-
 String::String( const char* c, int prefix_cut_off, int sufix_cut_off )
    : string( nullptr ), length( 0 )
 {
diff --git a/src/TNL/String.h b/src/TNL/String.h
index 838b27e983bde72a524bede9bea028dba032f5e7..a580cc4ae012a3f7c184807de2961bd5d33861f8 100644
--- a/src/TNL/String.h
+++ b/src/TNL/String.h
@@ -57,11 +57,6 @@ class String
               int prefix_cut_off = 0,
               int sufix_cut_off = 0 );
 
-      /// Odstranit???
-      String( char* c,
-              int prefix_cut_off = 0,
-              int sufix_cut_off = 0 );
-
       /// \brief Returns type of string - String.
       static String getType();
 
@@ -78,6 +73,7 @@ class String
       /// @tparam T is a type of a value to be converted
       /// @param value Word of any type (e.g. int, bool, double,...).
       template< typename T >
+      explicit
       String( T value )
          : string( nullptr ), length( 0 )
       {
diff --git a/src/Tools/CMakeLists.txt b/src/Tools/CMakeLists.txt
index 79aa6243008c41f37856c1a0762e45098be52b6e..3dc914c9d0ed8e3feac4c463cd3ab23e05a32833 100644
--- a/src/Tools/CMakeLists.txt
+++ b/src/Tools/CMakeLists.txt
@@ -31,9 +31,6 @@ target_link_libraries (tnl-dicom-reader tnl ${DCMTK_LIBRARIES} )
 ADD_EXECUTABLE(tnl-lattice-init tnl-lattice-init.cpp )
 target_link_libraries (tnl-lattice-init tnl )
 
-ADD_EXECUTABLE( tnl-functions-benchmark functions-benchmark.cpp )
-target_link_libraries( tnl-functions-benchmark tnl )
-
 IF( BUILD_CUDA )
    CUDA_ADD_EXECUTABLE( tnl-cuda-arch tnl-cuda-arch.cu )
    INSTALL( TARGETS tnl-cuda-arch
@@ -55,9 +52,7 @@ INSTALL( TARGETS tnl-init
 INSTALL( FILES ${PROJECT_TOOLS_PATH}/tnl-bindir
                ${PROJECT_TOOLS_PATH}/tnl-compile
                ${PROJECT_TOOLS_PATH}/tnl-link
-               tnl-time-series2png
                tnl-err2eoc
-               tnl-eoc-test-log
                tnl-log-to-html.py
          DESTINATION bin
          PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
diff --git a/src/Tools/functions-benchmark.cpp b/src/Tools/functions-benchmark.cpp
deleted file mode 100644
index a47dcced31b33c61052a68331d89e9df746fe552..0000000000000000000000000000000000000000
--- a/src/Tools/functions-benchmark.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/***************************************************************************
-                          functions-benchmark.cpp  -  description
-                             -------------------
-    begin                : Jul 4, 2010
-    copyright            : (C) 2010 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/* See Copyright Notice in tnl/Copyright */
-
-#include "functions-benchmark.h"
-
-int main( int argc, char* argv[] )
-{
-   const long int loops = 1 << 24;
-
-   std::cout << "Runnning benchmarks in single precision on CPU ... " << std::endl;
-   benchmarkAddition< float >( loops );
-   benchmarkMultiplication< float >( loops );
-   benchmarkDivision< float >( loops );
-   benchmarkSqrt< float >( loops );
-   benchmarkSin< float >( loops );
-   benchmarkExp< float >( loops );
-   benchmarkPow< float >( loops );
-
-   std::cout << "Runnning benchmarks in double precision on CPU ... " << std::endl;
-   benchmarkAddition< double >( loops );
-   benchmarkMultiplication< float >( loops );
-   benchmarkDivision< double >( loops );
-   benchmarkSqrt< double >( loops );
-   benchmarkSin< double >( loops );
-   benchmarkExp< double >( loops );
-   benchmarkPow< double >( loops );
-
-
-
-   return EXIT_SUCCESS;
-}
diff --git a/src/Tools/functions-benchmark.h b/src/Tools/functions-benchmark.h
deleted file mode 100644
index 2f04f6fbeb8577e9af131c76a0f6bf8c8b100b68..0000000000000000000000000000000000000000
--- a/src/Tools/functions-benchmark.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/***************************************************************************
-                          functions-benchmark.h  -  description
-                             -------------------
-    begin                : Jul 4, 2010
-    copyright            : (C) 2010 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/* See Copyright Notice in tnl/Copyright */
-
-#ifndef FUNCTIONSBENCHMARK_H_
-#define FUNCTIONSBENCHMARK_H_
-
-#include <iostream>
-#include <math.h>
-
-#include <TNL/Timer.h>
-
-using namespace TNL;
-
-template< typename REAL > void benchmarkAddition( long int loops )
-{
-   std::cout << "Benchmarking addition on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1 = 1.2;
-   REAL a2 = 1.2;
-   REAL a3 = 1.2;
-   REAL a4 = 1.2;
-   for( long int i = 0; i < loops; i ++ )
-   {
-      a1 += REAL( 0.1 );
-      a2 += REAL( 0.1 );
-      a3 += REAL( 0.1 );
-      a4 += REAL( 0.1 );
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 + a2 + a3 + a4 << " ) " <<  cpu_time << "secs. " << 4.0 * ( ( double ) loops ) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-template< typename REAL > void benchmarkMultiplication( const long int loops )
-{
-   std::cout << "Benchmarking multiplication on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1 = 1.0e9;
-   REAL a2 = 1.0e9;
-   REAL a3 = 1.0e9;
-   REAL a4 = 1.0e9;
-   for( long int i = 0; i < loops; i ++ )
-   {
-      {
-         a1 *= REAL( 0.99 );
-         a2 *= REAL( 0.99 );
-         a3 *= REAL( 0.99 );
-         a4 *= REAL( 0.99 );
-         if( a1 < REAL( 0.01 ) ) a1 = a2 = a3 = a4 = REAL( 1.0e9 );
-      }
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 * a2 * a3 * a4 << " ) " <<  cpu_time << "secs. " << 4.0 * ( ( double ) loops ) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-template< typename REAL > void benchmarkDivision( long int loops )
-{
-   std::cout << "Benchmarking division on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1( 1.0e9 );
-   REAL a2( 1.0e9 );
-   REAL a3( 1.0e9 );
-   REAL a4( 1.0e9 );
-   for( long int i = 0; i < loops; i ++ )
-   {
-      a1 /= REAL( 1.1 );
-      a2 /= REAL( 1.1 );
-      a3 /= REAL( 1.1 );
-      a4 /= REAL( 1.1 );
-      if( a1 < REAL( 0.01 ) ) a1 = a2 = a3 = a4 = REAL( 1.0e9 );
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 / a2 / a3 / a4 << " ) " << cpu_time << "secs. " << 4.0 * ( ( double ) loops / 2 ) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-template< typename REAL > void benchmarkSqrt( long int loops )
-{
-   std::cout << "Benchmarking sqrt on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1( 1.0e9 );
-   REAL a2( 1.0e9 );
-   REAL a3( 1.0e9 );
-   REAL a4( 1.0e9 );
-   for( long int i = 0; i < loops; i ++ )
-   {
-      a1 = ::sqrt( a1 );
-      a2 = ::sqrt( a2 );
-      a3 = ::sqrt( a3 );
-      a4 = ::sqrt( a4 );
-      if( a1 < REAL( 100.0 ) ) a1 = a2 = a3 = a4 = REAL( 1.0e9 );
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 + a2 + a3 + a4 << " ) " << cpu_time << "secs. " << 4.0 * ( ( double ) loops / 2 ) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-template< typename REAL > void benchmarkSin( long int loops )
-{
-   std::cout << "Benchmarking sin on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1( 1.0e9 );
-   REAL a2( 1.0e9 );
-   REAL a3( 1.0e9 );
-   REAL a4( 1.0e9 );
-   for( long int i = 0; i < loops; i ++ )
-   {
-      a1 = ::sin( a1 );
-      a2 = ::sin( a2 );
-      a3 = ::sin( a3 );
-      a4 = ::sin( a4 );
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 + a2 + a3 + a4 << " ) " << cpu_time << "secs. " << 4.0 * ( ( double ) loops ) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-template< typename REAL > void benchmarkExp( long int loops )
-{
-   std::cout << "Benchmarking exp on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1( 1.1 );
-   REAL a2( 1.1 );
-   REAL a3( 1.1 );
-   REAL a4( 1.1 );
-   for( long int i = 0; i < loops; i ++ )
-   {
-      a1 = exp( a1 );
-      a2 = exp( a2 );
-      a3 = exp( a3 );
-      a4 = exp( a4 );
-      if( a1 > REAL( 1.0e9 ) ) a1 = a2 = a3 = a4 = REAL( 1.1 );
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 + a2 + a3 + a4 << " ) " << cpu_time << "secs. " << 4.0 * ( ( double ) loops) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-template< typename REAL > void benchmarkPow( long int loops )
-{
-   std::cout << "Benchmarking pow on CPU ( " << loops << " loops ) ... " << std::flush;
-   Timer timer;
-   timer.start();
-
-   REAL a1( 1.0e9 );
-   REAL a2( 1.0e9 );
-   REAL a3( 1.0e9 );
-   REAL a4( 1.0e9 );
-   for( long int i = 0; i < loops; i ++ )
-   {
-      a1 = ::pow( a1, REAL( 0.9 ) );
-      a2 = ::pow( a2, REAL( 0.9 ) );
-      a3 = ::pow( a3, REAL( 0.9 ) );
-      a4 = ::pow( a4, REAL( 0.9 ) );
-      if( a1 < REAL( 1.0 ) ) a1 = a2 = a3 = a4 = REAL( 1.0e9 );
-   }
-
-   double cpu_time = timer.getCPUTime();
-   std::cout << " ( " << a1 + a2 + a3 + a4 << " ) " << cpu_time << "secs. " << 4.0 * ( ( double ) loops) / cpu_time * 1.0e-9 << " GFLOPS." << std::endl;
-}
-
-
-#endif /* FUNCTIONSBENCHMARK_H_ */
diff --git a/src/Tools/polygonizer.cpp b/src/Tools/polygonizer.cpp
deleted file mode 100644
index c80a72b286c7048c5b13a507d108bf4217c07022..0000000000000000000000000000000000000000
--- a/src/Tools/polygonizer.cpp
+++ /dev/null
@@ -1,489 +0,0 @@
-/***************************************************************************
-                          polygonizer.cpp  -  description
-                             -------------------
-    begin                : Mon Feb 11 2002
-    copyright            : (C) 2002 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/* See Copyright Notice in tnl/Copyright */
-
-#include <string.h>
-#include "polygonizer.h"
-#include "../solids/reciever.h"
-#include "../solids/solid.h"
-#include "hash.h"
-
-POLYGONIZER polygonizer;
-
-static int corner1[ 12 ] =
-   { LBN, LTN, LBN, LBF, RBN, RTN, RBN, RBF, LBN, LBF, LTN, LTF };
-
-static int corner2[ 12 ] =
-   { LBF, LTF, LTN, LTF, RBF, RTF, RTN, RTF, RBN, RBF, RTN, RTF };
-
-// these are fields of corners for edges in order
-//   LB,  LT,  LN,  LF,  RB,  RT,  RN,  RF,  BN,  BF,  TN,  TF
-
-static int left_face[ 12 ] =
-   { B, L, L, F, R, T, N, R, N, B, T, F };
-// face on left when going corner1 to corner2
-
-static int right_face[ 12 ] =
-   { L, T, N, L, B, R, R, F, B, F, N, T };
-// face on right when going coner1 to corner2
-
-//---------------------------------------------------------------------------
-CUBE :: CUBE( int _i, int _j, int _k )
-      : i( _i ), j( _j ), k( _k )
-{
-   bzero( corners, 8 * sizeof( CORNER* ) );
-}
-//---------------------------------------------------------------------------
-POLYGONIZER :: POLYGONIZER()
-{
-   edge_hash = new ( list< EDGE* >* )[ 2 * hash_size ];
-   bzero( edge_hash, 2 * hash_size * sizeof( list< EDGE* >* ) );
-   corner_hash = new ( list< CORNER* >* )[ 2 * hash_size ];
-   bzero( corner_hash, 2 * hash_size * sizeof( list< CORNER* >* ) );
-   center_hash = new ( list< CENTER* >* )[ 2 * hash_size ];
-   bzero( center_hash, 2 * hash_size * sizeof( list< CENTER* >* ) );
-   Make_Cube_Table();
-}
-//---------------------------------------------------------------------------
-POLYGONIZER :: ~POLYGONIZER()
-{
-   assert( edge_hash );
-   delete[] edge_hash;
-   assert( corner_hash );
-   delete[] corner_hash;
-   assert( center_hash );
-   delete[] center_hash;
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Parametric( const SOLID* sld, RECIEVER* reciever,
-                               const unsigned int slices, const unsigned int stacks)
-{
-   assert( slices && stacks );
-   const double x_step = 1.0 / slices;
-   const double y_step = 1.0 / stacks;
-   for( unsigned int i = 0; i < stacks; i ++ )
-      for( unsigned int j = 0; j < slices; j ++ )
-      {
-         double x = j * x_step;
-         double y = i * y_step;
-         VECTOR n1, n2, n3, n4;
-         VECTOR u1 = sld -> Surface_Point( x, y, &n1 );
-         VECTOR u2 = sld -> Surface_Point( x + x_step, y, &n2 );
-         VECTOR u3 = sld -> Surface_Point( x + x_step, y + y_step, &n3 );
-         VECTOR u4 = sld -> Surface_Point( x, y + y_step, &n4 );
-
-         VERTEX v1( u1, n1 );
-         VERTEX v2( u2, n2 );
-         VERTEX v3( u3, n3 );
-         VERTEX v4( u4, n4 );
-
-         /*TRIANGLE* t1 = new TRIANGLE( new VERTEX( v1 ),
-                                      new VERTEX( v4 ),
-                                      new VERTEX( v2 ) ) ;
-         TRIANGLE* t2 = new TRIANGLE( new VERTEX( v3 ),
-                                      new VERTEX( v2 ),
-                                      new VERTEX( v4 ) ) ;*/
-
-          if( ! reciever -> Insert_Triangle( v1, v4, v2 ) ) return 0;
-          if( ! reciever -> Insert_Triangle( v3, v2, v4 ) ) return 0;
-      }
-   return 1;
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Init( const VECTOR& pos, const SOLID* sld, const double& cb_sz )
-{
-   cube_size = cb_sz;
-   solid = sld;
-   VECTOR in( pos ), out( pos );
-   if( ! Find_Point( 1, in, 1.0, solid ) ||
-       ! Find_Point( 0, out, 1.0, solid ) ) return 0;
-   CUBE *c = NULL;
-   if( cube_stack. empty() ) // this is the initial cube
-   {
-      position = Compute_Surface_Point( in, out, solid -> Continuous_Function( in ) );
-      c = new CUBE( 0, 0, 0 );
-   }
-   else
-   {
-      VECTOR _pos = Compute_Surface_Point( in, out, solid -> Continuous_Function( in ) ) - position;
-      _pos *= 1.0 / cube_size;
-      int i( ( int ) _pos. x ),
-          j( ( int ) _pos. y ),
-          k( ( int ) _pos. z );
-      if( Set_Center( i, j, k ) ) return 1; //we have already found this cube
-      c = new CUBE( i, j, k );
-   }
-   for( int i = 0; i < 8; i ++ ) c -> corners[ i ] =
-      Set_Corner( ( i >> 2 ) & 1, ( i >> 1 ) & 1, i & 1 );
-
-   cube_stack. push( c );
-   return 1;
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Implicit( const SOLID* sld, RECIEVER* _reciever,
-                             const VECTOR& ps, const VECTOR& cr,
-                             const double& cb_size, int mode )
-{
-   solid = sld;
-   reciever = _reciever;
-   cube_size = cb_size;
-   bound_ps = ps;
-   bound_cr = cr;
-   if( cube_stack. empty() && ! Init( solid -> Position(), solid, cb_size ) )
-   {
-      std::cerr << "Can not find initial points for polygonization" << std::endl;
-      return 0;
-   }
-   std::cout << "Starting polygonizer ... " << std::endl;
-   /*VECTOR in( sld -> Position() ), out( sld -> Position() );
-   if( ! Find_Point( 1, in, 1.0 ) ||
-       ! Find_Point( 0, out, 1.0 ) )
-      {
-         std::cerr << "Can not find initial points for polygonization" << std::endl;
-         return 0;
-      }
-   std::cout << "Starting polygonizer ... " << std::endl;
-   position = Compute_Surface_Point( in, out, solid -> Continuous_Function( in ) );
-
-   CUBE *c = new CUBE( 0, 0, 0 );
-   for( int i = 0; i < 8; i ++ ) c -> corners[ i ] =
-      Set_Corner( ( i >> 2 ) & 1, ( i >> 1 ) & 1, i & 1 );
-
-   cube_stack. push( c );*/
-   int jkl;
-   CUBE* c;
-   while( ! cube_stack. empty() )
-   {
-      c = cube_stack. top();
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-      cube_stack. pop();
-      jkl = cube_stack. size();
-      if( ! Triangulate_Cube( c ) )
-      {
-         Free_Memory();
-         return 0;
-      }
-      Test_Face( c -> i - 1, c -> j, c -> k, c, L, LBN, LBF, LTN, LTF );
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-      Test_Face( c -> i + 1, c -> j, c -> k, c, R, RBN, RBF, RTN, RTF );
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-      Test_Face( c -> i, c -> j - 1, c -> k, c, B, LBN, LBF, RBN, RBF );
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-      Test_Face( c -> i, c -> j + 1, c -> k, c, T, LTN, LTF, RTN, RTF );
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-      Test_Face( c -> i, c -> j, c -> k - 1, c, N, LBN, LTN, RBN, RTN );
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-      Test_Face( c -> i, c -> j, c -> k + 1, c, F, LBF, LTF, RBF, RTF );
-      std::cout << "Current stack size is " << cube_stack. size() << " cubes. " << '\r' << std::flush;
-   }
-   std::cout << std::endl;
-   Free_Memory();
-   return 1;
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Triangulate_Cube( CUBE* cube )
-{
-   #ifdef DBG_POLYGONIZER
-   std::cout << "Cube polygonize: " << cube -> i << " " << cube -> j << " " << cube -> k << std::endl;;
-   #endif
-   int index = 0;
-   // this is a index of cube in cube_table, it will be count by
-   // the signs of function in corners
-   for( int i = 0; i < 8; i ++ )
-      if( cube -> corners[ i ] -> value > 0.0 ) index += ( 1 << i );
-   for( size_t i = 0; i < cube_table[ index ]. size(); i ++ )
-   {
-      vector< int >& edges_vector = ( cube_table[ index ] )[ i ];
-      VERTEX *v1( 0 ), *v2( 0 ), *v3( 0 );
-      for( size_t j = 0; j < edges_vector. size(); j ++ )
-      {
-         CORNER* c1 = cube -> corners[ corner1[ edges_vector[ j ] ] ];
-         CORNER* c2 = cube -> corners[ corner2[ edges_vector[ j ] ] ];
-         VERTEX* c = Get_Vertex( c1, c2 );
-         if( j == 0 ) v1 = c;
-         if( j == 1 ) v2 = c;
-         if( j > 1 )
-         {
-            v3 = c;
-            if( ! reciever -> Insert_Triangle( *v1, *v3, *v2 ) ) return 0;
-            v2 = v3;
-         }
-      }
-   }
-   return 1;
-}
-//---------------------------------------------------------------------------
-VERTEX* POLYGONIZER :: Get_Vertex( CORNER* c1, CORNER* c2 )
-{
-   VERTEX* vertex;
-   if( Check_Edge( c1, c2, vertex ) ) return vertex;
-   // the vertex has been already computed
-   VECTOR p = Compute_Surface_Point( c1 -> position, c2 -> position, c1 -> value );
-   vertex = new VERTEX( p, solid -> Normal( p ) );
-   Set_Edge( c1, c2, vertex );
-   return vertex;
-}
-//---------------------------------------------------------------------------
-VECTOR POLYGONIZER :: Compute_Surface_Point( const VECTOR& v1, const VECTOR& v2, const double& val )
-{
-   VECTOR pos, neg, p;
-   if( val < 0.0 )
-   {
-      pos = v2; neg = v1;
-   }
-   else
-   {
-      pos = v1; neg = v2;
-   }
-   int i = 0;
-   while( i ++ < max_iter )
-   {
-      p = 0.5 * ( pos + neg );
-      if( solid -> Continuous_Function( p ) > 0 ) pos = p;
-      else neg = p;
-   }
-   return p;
-}
-//---------------------------------------------------------------------------
-void POLYGONIZER :: Set_Edge( CORNER* c1, CORNER* c2, VERTEX* v )
-{
-   int& i1 = c1 -> i;
-   int& j1 = c1 -> j;
-   int& k1 = c1 -> k;
-   int& i2 = c2 -> i;
-   int& j2 = c2 -> j;
-   int& k2 = c2 -> k;
-   if( i1 > i2 || ( i1 == i2 && ( j1 > j2 || ( j1 == j2  && k1 > k2 ) ) ) )
-   {
-      CORNER* c = c1; c1 = c2; c2 = c;
-   }
-   unsigned int index = hash_index( i1, j1, k1 ) + hash_index( i2, j2, k2 );
-   if( ! edge_hash[ index ] ) edge_hash[ index ] = new list< EDGE* >;
-   edge_hash[ index ] -> push_back( new EDGE( c1, c2, v ) );
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Check_Edge( CORNER* c1, CORNER* c2, VERTEX*& vertex )
-{
-   int& i1 = c1 -> i;
-   int& j1 = c1 -> j;
-   int& k1 = c1 -> k;
-   int& i2 = c2 -> i;
-   int& j2 = c2 -> j;
-   int& k2 = c2 -> k;
-   if( i1 > i2 || ( i1 == i2 && ( j1 > j2 || ( j1 == j2  && k1 > k2 ) ) ) )
-   {
-      CORNER* c = c1; c1 = c2; c2 = c;
-   }
-   list< EDGE* >* el = edge_hash[ hash_index( i1, j1, k1 ) + hash_index( i2, j2, k2 ) ];
-   if( ! el ) return 0;
-   list< EDGE* > :: iterator it = el -> begin();
-   while( it != el -> end() )
-   {
-      EDGE* e = * it ++;
-      if( e -> corners[ 0 ] == c1 && e -> corners[ 1 ] == c2 )
-      {
-         vertex = e -> vertex;
-         return 1;
-      }
-   }
-   return 0;
-}
-//---------------------------------------------------------------------------
-CORNER* POLYGONIZER :: Set_Corner( int i, int j, int k )
-{
-   #ifdef DBG_POLYGONIZER
-      std::cout << "Set Corner index: " << i << " " << j << " " << k << std::endl;
-   #endif
-   int index = hash_index( i, j, k );
-   list< CORNER* >*& cl = corner_hash[ index ];
-   if( ! cl ) cl = new list< CORNER* >;
-   list< CORNER* > :: iterator it = cl -> begin();
-   CORNER* cr;
-   while( it != cl -> end() )
-   {
-      cr = * it ++;
-      if( ( cr -> i == i ) && ( cr -> j == j ) && ( cr -> k == k ) ) return cr;
-   }
-   VECTOR tmp = ( VECTOR( i, j, k ) - VECTOR( 0.5 ) );
-   VECTOR p = position + cube_size * tmp;
-   double val = solid -> Continuous_Function( p );
-   #ifdef DBG_POLYGONIZER
-   std::cout << "Set Corer: value " << val << std::endl;
-   #endif
-   cr = new CORNER( i, j, k, p, val );
-   cl -> push_back( cr );
-   return cr;
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Set_Center( int i, int j, int k )
-{
-   #ifdef DBG_POLYGONIZER
-   std::cout << "Set Center: " << i << " " << j << " " << k << std::endl;
-   #endif
-   list< CENTER* >*& cl = center_hash[ hash_index( i, j, k ) ];
-   if( ! cl ) cl = new list< CENTER* >;
-   list< CENTER* > :: iterator it = cl -> begin();
-   while( it != cl -> end() )
-   {
-      CENTER* cr = * it ++;
-      if( cr -> i == i && cr -> j == j && cr -> k == k ) return 1;
-   }
-   cl -> push_back( new CENTER( i, j, k ) );
-   return 0;
-}
-//---------------------------------------------------------------------------
-void POLYGONIZER :: Make_Cube_Table()
-{
-   int done_edges[ 12 ], positive[ 8 ];
-   // we have 256 different possibilities to sign all 8 corners of a cube
-   // they are describe here in cube_table
-   for( int i = 0; i < 256; i ++ )
-   {
-      for( int e = 0; e < 12; e ++ ) done_edges[ e ] = 0;
-      for( int c = 0; c < 8; c ++ ) positive[ c ] = ( i >> c ) & 1;
-      // each bit in 'i' represent one corner of cube and sign of function value
-      // '1' means positive value, '0' means negative value
-      for( int e = 0; e < 12; e ++ )
-      {
-         if( ! done_edges[ e ] &&
-             // we didn't process this edge yet ...
-             ( positive[ corner1[ e ] ] != positive[ corner2[ e ] ] ) )
-             // ... and corners of this edge have different sign
-            {
-               int start = e;
-               int edge = e;
-               int face = positive[ corner1[ e ] ] ? right_face[ e ] : left_face[ e ];
-               // get face that is to right of edge from positive to negatve corner
-               vector< int > temp_vector;
-               while( 1 )
-               {
-                  edge = Next_Clockwise_Edge( edge, face );
-                  done_edges[ edge ] = 1;
-                  if( positive[ corner1[ edge ] ] != positive[ corner2[ edge ] ] )
-                  {
-                     temp_vector. push_back( edge );
-                     if( edge == start ) break;
-                     face = Other_Face( edge, face );
-                  }
-               }
-               cube_table[ i ]. push_back( temp_vector );
-            }
-      }
-   }
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Next_Clockwise_Edge( int edge, int face )
-{
-   switch( edge )
-   {
-      case LB: return ( face == L ) ? LF : BN;
-      case LT: return ( face == L ) ? LN : TF;
-      case LN: return ( face == L ) ? LB : TN;
-      case LF: return ( face == L ) ? LT : BF;
-      case RB: return ( face == R ) ? RN : BF;
-      case RT: return ( face == R ) ? RF : TN;
-      case RN: return ( face == R ) ? RT : BN;
-      case RF: return ( face == R ) ? RB : TF;
-      case BN: return ( face == B ) ? RB : LN;
-      case BF: return ( face == B ) ? LB : RF;
-      case TN: return ( face == T ) ? LT : RN;
-      case TF: return ( face == T ) ? RT : LF;
-   }
-   return 0; // this is just for avoiding compiler warning
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Other_Face( int edge, int face )
-{
-   int other_face = left_face[ edge ];
-   return face == other_face ? right_face[ edge ] : other_face;
-}
-//---------------------------------------------------------------------------
-void POLYGONIZER :: Test_Face( int i, int j, int k, CUBE* old, int face,
-                               int c1, int c2, int c3, int c4 )
-{
-   static int face_bit[ 6 ] = { 2, 2, 1, 1, 0, 0 };
-   int bit = face_bit[ face ];
-   int pos = old -> corners[ c1 ] -> value > 0.0 ? 1 : 0;
-   // test id no surface crossing, cube out of bounds, or already visited
-   if( ( old -> corners[ c2 ] -> value > 0.0 ) == pos &&
-       ( old -> corners[ c3 ] -> value > 0.0 ) == pos &&
-       ( old -> corners[ c4 ] -> value > 0.0 ) == pos ) return;
-   // test bounds
-   if( bound_ps < bound_cr )
-   {
-      VECTOR p( position + cube_size * VECTOR( ( double ) i, ( double ) j, ( double ) k ) );
-      if( ! ( p >= bound_ps && p <= bound_cr ) ) return;
-   }
-   else
-      if( abs( i ) > 50 || abs( j ) > 50 || abs( k ) > 50 ) return;
-   if( Set_Center( i, j, k ) ) return;
-   CUBE* new_cube = new CUBE( i, j, k );
-   // given face of old cube is the same as the opposite face of new_cube
-   new_cube -> corners[ flip_bit( c1, bit ) ] = old -> corners[ c1 ];
-   new_cube -> corners[ flip_bit( c2, bit ) ] = old -> corners[ c2 ];
-   new_cube -> corners[ flip_bit( c3, bit ) ] = old -> corners[ c3 ];
-   new_cube -> corners[ flip_bit( c4, bit ) ] = old -> corners[ c4 ];
-   #ifdef DBG_POLYGONIZER
-   std::cout << "Test Face indexes: " << i << " " << j << " " << k << std::endl;
-   #endif
-   for( int n = 0; n < 8; n ++ )
-      if( ! new_cube -> corners[ n ] )
-         new_cube -> corners[ n ] = Set_Corner( i + ( ( n >> 2 ) & 1 ),
-                                                j + ( ( n >> 1 ) & 1 ),
-                                                k + ( n & 1 ) );
-   cube_stack. push( new_cube );
-}
-//---------------------------------------------------------------------------
-int POLYGONIZER :: Find_Point( int sign, VECTOR& point, double size, const SOLID* sld )
-{
-   VECTOR init = point;
-   VECTOR ps( -0.5 );
-   VECTOR cr(  0.5 );
-   for( int i = 0; i < 10000; i ++ )
-   {
-      point = init + size * Random_Vector( ps, cr );
-      //cout << point << " - " << sld -> Continuous_Function( point ) << std::endl;
-      if( sign == ( sld -> Sign_Function( point ) == 1 ) )
-         return 1;
-      size *= 1.005;
-   }
-   return 0;
-}
-//---------------------------------------------------------------------------
-void POLYGONIZER :: Free_Memory()
-{
-   // clear hashes
-   for( size_t i = 0; i < 2 * hash_size; i ++ )
-   {
-      if( edge_hash[ i ] )
-      {
-         list< EDGE* > :: iterator it = edge_hash[ i ] -> begin();
-         while( it != edge_hash[ i ] -> end() ) delete * it ++;
-         delete edge_hash[ i ];
-         edge_hash[ i ] = NULL;
-
-      }
-
-      if( corner_hash[ i ] )
-      {
-         list< CORNER* > :: iterator it = corner_hash[ i ] -> begin();
-         while( it != corner_hash[ i ] -> end() ) delete * it ++;
-         delete corner_hash[ i ];
-         corner_hash[ i ] = NULL;
-      }
-      if( center_hash[ i ] )
-      {
-         list< CENTER* > :: iterator it = center_hash[ i ] -> begin();
-         while( it != center_hash[ i ] -> end() ) delete * it ++;
-         delete center_hash[ i ];
-         center_hash[ i ] = NULL;
-      }
-   }
-}
-
diff --git a/src/Tools/polygonizer.h b/src/Tools/polygonizer.h
deleted file mode 100644
index d0d9e6df5f16528533e8a4eef519f4657a5275fb..0000000000000000000000000000000000000000
--- a/src/Tools/polygonizer.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/***************************************************************************
-                          polygonizer.h  -  description
-                             -------------------
-    begin                : Mon Feb 11 2002
-    copyright            : (C) 2002 by Tomas Oberhuber
-    email                : tomas.oberhuber@fjfi.cvut.cz
- ***************************************************************************/
-
-/* See Copyright Notice in tnl/Copyright */
-
-#ifndef POLYGONIZER_H
-#define POLYGONIZER_H
-
-
-/**
-  *@author Tomas Oberhuber
-  *
-  * this class is rewritten polygonizer by Jules Bloomenthal, Xerox PARC.
-  * Copyright of original code (c) Xerox Corporation, 1991.
-  * See 'implicit.eecs.wsu.edu'.
-  *
-  */
-
-#include <list.h>
-#include <stack.h>
-#include <vector.h>
-#include "vctr.h"
-#include "vertex.h"
-
-//using namespace :: std;
-
-class SOLID;
-class RECIEVER;
-
-enum { poly_parametric, poly_implicit_cube, poly_implicit_tetrahedron };
-
-const int max_iter = 10;
-inline int flip_bit( int i, int bit )
-   { return i ^ 1 << bit; };
-
-
-enum { L = 0,  // left direction   - x
-       R,      // right direction  + x
-       B,      // bottom direction - y
-       T,      // top direction    + y
-       N,      // near direction   - z
-       F       // far direction    + z
-       };
-enum { LB = 0, // left bottom edge
-       LT,     // left top edge
-       LN,     // left near edge
-       LF,     // left far edge
-       RB,     // right bottom edge
-       RT,     // right top edge
-       RN,     // right near edge
-       RF,     // right far edge
-       BN,     // bottom near edge
-       BF,     // bottom far edge
-       TN,     // top near edge
-       TF      // top far edge
-       };
-
-enum { LBN = 0,   // left bottom near corner
-       LBF,       // left bottom far corner
-       LTN,       // left top near corner
-       LTF,       // left top far corner
-       RBN,       // right bottom near corner
-       RBF,       // right bottom far corner
-       RTN,       // right top near corner
-       RTF        // right top far corner
-       };
-
-struct CORNER
-{
-   int i, j, k;
-   VECTOR position;
-   double value;
-   CORNER( int _i, int _j, int _k, const VECTOR& p, const double& val )
-      :i( _i ), j( _j ), k( _k ), position( p ), value( val ){};
-};
-
-struct EDGE
-{
-   CORNER* corners[ 2 ];
-   VERTEX* vertex;
-   EDGE( CORNER* c1, CORNER* c2, VERTEX* v )
-      : vertex( v ){ corners[ 0 ] = c1; corners[ 1 ] = c2;};
-   ~EDGE() { assert( vertex ); delete vertex; };
-};
-
-struct CUBE
-{
-   int i, j, k;
-   // cube lattice
-   CORNER* corners[ 8 ];
-   CUBE( int, int, int );
-};
-
-struct CENTER
-{
-   int i, j, k;
-   CENTER( int _i, int _j, int _k )
-      : i( _i ), j( _j ), k( _k ){};
-};
-
-class POLYGONIZER
-{
-   public:
-   POLYGONIZER();
-   ~POLYGONIZER();
-
-   //! Creates initial cubes for implicite polygonizer
-   /*! We need to call this method several times in case of
-       non-connected surfaces. It si at least once called automaticly
-       if it was not called before starting the process of tesselation.
-    */
-   int Init( const VECTOR& pos, const SOLID* sld, const double& cb_sz );
-
-   //! Method for implicite surfaces
-   /*! start polygonizer with given SOLID, triangles are inserted into TRIANGLES
-    two const VECTOR&s define the bound for polygonizations
-    const double& is size of elementar cube
-    int is poligonization mode - polygonize cube or tetrahedrons
-    */
-   int Implicit( const SOLID*, RECIEVER*, const VECTOR&, const VECTOR&, const double&, int );
- 
-   int Parametric( const SOLID*, RECIEVER*, const unsigned int, const unsigned int );
-   protected:
- 
-   //! This solid will be polygonized using method SOLID :: Solid_Function( const VECTOR& );
-   const SOLID* solid;
-
-   //! Reciver of emitted triangles
-   RECIEVER* reciever;
-
-   //! Position of the first cube
-   /*! Thus, it is also position of the origin for cubes indexing
-    */
-   VECTOR position;
- 
-   //! Bounds for polygonizer
-   /*! All coubes outside culled.
-    */
-   VECTOR bound_ps, bound_cr;
-
-   //! Size of the cube and
-   double cube_size;
-
-   stack< CUBE* > cube_stack;
-   vector< vector< int > > cube_table[ 256 ];
-   list< EDGE* >** edge_hash;
-   // hash field of edges lists
-   list< CORNER* >** corner_hash;
-   // another hash for corners
-   list< CENTER* >** center_hash;
-   // yet another hash for cube centers
-
-   int Triangulate_Cube( CUBE* );
-   // triangulate the cube directly, without decomposition
-   VERTEX* Get_Vertex( CORNER*, CORNER* );
-   // return vertex for given edge using edge hash table ( Get_Edge method )
-   // both corners values are presumed of different sign
-   VECTOR Compute_Surface_Point( const VECTOR&, const VECTOR&, const double& );
-   // compute vertex on given edge using solid function of given solid
-   void Set_Edge( CORNER*, CORNER*, VERTEX* );
-   // insert edge to hash table
-   int Check_Edge( CORNER*, CORNER*, VERTEX*& );
-   // get vertex on edge from hash table
-   // return 1 if edge is in hash table
-   //        0 if edge is not in hash table
-   CORNER* Set_Corner( int, int, int );
-   // return corner with given lattice location
-   // set and cache its function value
-   int Set_Center( int, int, int );
-   // set ( i, j, k ) entry to center_hash table
-   // return 1 if already set; otherwise set and return 0
-   void Make_Cube_Table();
-   // create cube_table
-   int Next_Clockwise_Edge( int, int );
-   // return next clockwise edge from given edge around given face
-   int Other_Face( int, int );
-   // return face adjoining edge is not the given face
-   void Test_Face( int, int, int, CUBE*, int, int, int, int, int );
-   // given cube at lattice ( i, j, k ) and four corners of face,
-   // if surface crosses face, compute other four corners of adjacent cube
-   // and add new cube to cube stack
-   int Find_Point( int, VECTOR&, double, const SOLID* sld );
-   // find point with given value sign
-   void Free_Memory();
-};
-
-extern POLYGONIZER polygonizer;
-
-#endif
diff --git a/src/Tools/tnl-compile.in b/src/Tools/tnl-compile.in
index 1a813fe2f41d1bb5ed6a9a60e5baff3cfeb038ce..b106c613c368681841bcf36f0388657d553da942 100644
--- a/src/Tools/tnl-compile.in
+++ b/src/Tools/tnl-compile.in
@@ -12,5 +12,5 @@ do
     esac
 done
 
-echo -I@CMAKE_INSTALL_PREFIX@/@TNL_TARGET_INCLUDE_DIRECTORY@ ${CUDA_FLAGS} ${CXX_STD_FLAGS} ${DEBUG_FLAGS}
+echo -I@CMAKE_INSTALL_PREFIX@/include ${CUDA_FLAGS} ${CXX_STD_FLAGS} ${DEBUG_FLAGS}
 
diff --git a/src/Tools/tnl-eoc-test-log b/src/Tools/tnl-eoc-test-log
deleted file mode 100644
index c89d141eb32d707a1e1ade87c0692442d6a3e2cb..0000000000000000000000000000000000000000
--- a/src/Tools/tnl-eoc-test-log
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env python
-
-import sys, string, math
-
diff --git a/src/Tools/tnl-quickstart/build-config-tag.h.in b/src/Tools/tnl-quickstart/build-config-tag.h.in
index c72d8c1b9dd30c104ff3530cef8c715c04a0e7ee..f507baf061cbd1d76c187cba42d54dcc3c765cdb 100644
--- a/src/Tools/tnl-quickstart/build-config-tag.h.in
+++ b/src/Tools/tnl-quickstart/build-config-tag.h.in
@@ -20,31 +20,21 @@ template<> struct ConfigTagIndex< {problemBaseName}BuildConfigTag, short int >{{
 template<> struct ConfigTagIndex< {problemBaseName}BuildConfigTag, long int >{{ enum {{ enabled = false }}; }};
     
 /****
- * With how many dimensions may have the problem to be solved...
- */    
-template< int Dimension > struct ConfigTagDimension< {problemBaseName}BuildConfigTag, Dimension >{{ enum {{ enabled = ( Dimension == 1 ) }}; }};
-
-/****
- * Use of Meshes::Grid is enabled for allowed dimensions and Real, Device and Index types.
+ * The mesh type will be resolved by the Solver by default.
+ * (The detailed mesh configuration is in TNL/Meshes/BuildConfigTags.h)
  */
-template< int Dimension, typename Real, typename Device, typename Index >
-   struct ConfigTagMesh< {problemBaseName}BuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > >
-      {{ enum {{ enabled = ConfigTagDimension< {problemBaseName}BuildConfigTag, Dimension >::enabled  &&
-                         ConfigTagReal< {problemBaseName}BuildConfigTag, Real >::enabled &&
-                         ConfigTagDevice< {problemBaseName}BuildConfigTag, Device >::enabled &&
-                         ConfigTagIndex< {problemBaseName}BuildConfigTag, Index >::enabled }}; }};
+template<> struct ConfigTagMeshResolve< {problemBaseName}BuildConfigTag >{{ enum {{ enabled = true }}; }};
 
 /****
- * Please, chose your preferred time discretization  here.
+ * All time discretisations (explicit, semi-impicit and implicit ) are
+ * enabled by default.
  */
-template<> struct ConfigTagTimeDiscretisation< {problemBaseName}BuildConfigTag, ExplicitTimeDiscretisationTag >{{ enum {{ enabled = true }}; }};
-template<> struct ConfigTagTimeDiscretisation< {problemBaseName}BuildConfigTag, SemiImplicitTimeDiscretisationTag >{{ enum {{ enabled = true }}; }};
-template<> struct ConfigTagTimeDiscretisation< {problemBaseName}BuildConfigTag, ImplicitTimeDiscretisationTag >{{ enum {{ enabled = false }}; }};
+template< typename TimeDiscretisation > struct ConfigTagTimeDiscretisation< {problemBaseName}BuildConfigTag, TimeDiscretisation >{{ enum {{ enabled = true }}; }};
 
 /****
- * Only the Runge-Kutta-Merson solver is enabled by default.
+ * All explicit solvers are enabled by default
  */
-template<> struct ConfigTagExplicitSolver< {problemBaseName}BuildConfigTag, ExplicitEulerSolverTag >{{ enum {{ enabled = false }}; }};
+template< typename ExplicitSolver > struct ConfigTagExplicitSolver< {problemBaseName}BuildConfigTag, ExplicitSolver >{{ enum {{ enabled = true }}; }};
 
 }} // namespace Solvers
-}} // namespace TNL
\ No newline at end of file
+}} // namespace TNL
diff --git a/src/Tools/tnl-quickstart/main.h.in b/src/Tools/tnl-quickstart/main.h.in
index f836967c83ccc88fed8898a0c344a9ea08e40906..305f59e1a21757db59c91a2ca80d8e9772c11f72 100644
--- a/src/Tools/tnl-quickstart/main.h.in
+++ b/src/Tools/tnl-quickstart/main.h.in
@@ -47,7 +47,8 @@ template< typename Real,
           typename Index,
           typename MeshType,
           typename ConfigTag,
-          typename SolverStarter >
+          typename SolverStarter,
+          typename Communicator >
 class {problemBaseName}Setter
 {{
    public:
@@ -75,12 +76,12 @@ class {problemBaseName}Setter
              if( boundaryConditionsType == "dirichlet" )
              {{
                 typedef Operators::DirichletBoundaryConditions< MeshType, ConstantFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions;
-                typedef {problemBaseName}Problem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
+                typedef {problemBaseName}Problem< MeshType, Communicator, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
                 SolverStarter solverStarter;
                 return solverStarter.template run< Problem >( parameters );
              }}
              typedef Operators::NeumannBoundaryConditions< MeshType, ConstantFunction, Real, Index > BoundaryConditions;
-             typedef {problemBaseName}Problem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
+             typedef {problemBaseName}Problem< MeshType, Communicator, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
              SolverStarter solverStarter;
              return solverStarter.template run< Problem >( parameters );
           }}
@@ -88,12 +89,12 @@ class {problemBaseName}Setter
           if( boundaryConditionsType == "dirichlet" )
           {{    
              typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions;
-             typedef {problemBaseName}Problem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
+             typedef {problemBaseName}Problem< MeshType, Communicator, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
              SolverStarter solverStarter;
              return solverStarter.template run< Problem >( parameters );
           }}
           typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions;
-          typedef {problemBaseName}Problem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
+          typedef {problemBaseName}Problem< MeshType, Communicator, BoundaryConditions, RightHandSide, ApproximateOperator > Problem;
           SolverStarter solverStarter;
           return solverStarter.template run< Problem >( parameters );
       }}
diff --git a/src/Tools/tnl-quickstart/operator-grid-specialization_impl.h.in b/src/Tools/tnl-quickstart/operator-grid-specialization_impl.h.in
index 3e7d0d670f5de48659c146bbf7b1fb62287e4a38..da4da6d635d10d1681d689972d5e93695e47b4dd 100644
--- a/src/Tools/tnl-quickstart/operator-grid-specialization_impl.h.in
+++ b/src/Tools/tnl-quickstart/operator-grid-specialization_impl.h.in
@@ -34,7 +34,7 @@ operator()( const MeshFunction& u,
     * The following example is the Laplace operator approximated 
     * by the Finite difference method.
     */  
-   static_assert( MeshEntity::entityDimension == {meshDimension}, "Wrong mesh entity dimensions." );
+   static_assert( MeshEntity::getEntityDimension() == {meshDimension}, "Wrong mesh entity dimensions." );
    static_assert( MeshFunction::getEntitiesDimension() == {meshDimension}, "Wrong preimage function" );
    const typename MeshEntity::template NeighborEntities< {meshDimension} >& neighborEntities = entity.getNeighborEntities(); 
 
@@ -84,7 +84,7 @@ setMatrixElements( const PreimageFunction& u,
                    Matrix& matrix,
                    Vector& b ) const
 {{
-   static_assert( MeshEntity::entityDimension == {meshDimension}, "Wrong mesh entity dimensions." );
+   static_assert( MeshEntity::getEntityDimension() == {meshDimension}, "Wrong mesh entity dimensions." );
    static_assert( PreimageFunction::getEntitiesDimension() == {meshDimension}, "Wrong preimage function" );
 
    /****
diff --git a/src/Tools/tnl-quickstart/problem.h.in b/src/Tools/tnl-quickstart/problem.h.in
index dd53ffe43f77e58a5dd49cdc51306820a0b07249..9006f7cf7c5f1e39e5b59333fe888e5d56b479d5 100644
--- a/src/Tools/tnl-quickstart/problem.h.in
+++ b/src/Tools/tnl-quickstart/problem.h.in
@@ -8,33 +8,35 @@
 
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 class {problemBaseName}Problem:
    public TNL::Problems::PDEProblem< Mesh,
-                         typename DifferentialOperator::RealType,
-                         typename Mesh::DeviceType,
-                         typename DifferentialOperator::IndexType >
+                                     Communicator,
+                                     typename DifferentialOperator::RealType,
+                                     typename Mesh::DeviceType,
+                                     typename Mesh::IndexType >
 {{
    public:
 
       typedef typename DifferentialOperator::RealType RealType;
       typedef typename Mesh::DeviceType DeviceType;
-      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;
+      typedef typename Mesh::IndexType IndexType;
+      typedef TNL::Functions::MeshFunction< Mesh, Mesh::getMeshDimension(), RealType > MeshFunctionType;
+      typedef TNL::Problems::PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType;
+      typedef TNL::Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer;
+      typedef TNL::Pointers::SharedPointer< DifferentialOperator > DifferentialOperatorPointer;
+      typedef TNL::Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer;
+      typedef TNL::Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer;
 
       using typename BaseType::MeshType;
       using typename BaseType::MeshPointer;
       using typename BaseType::DofVectorType;
       using typename BaseType::DofVectorPointer;
-      using typename BaseType::MeshDependentDataType;
-      using typename BaseType::MeshDependentDataPointer;
 
+      using CommunicatorType = Communicator;
 
       static TNL::String getTypeStatic();
 
@@ -43,51 +45,42 @@ class {problemBaseName}Problem:
       void writeProlog( TNL::Logger& logger,
                         const TNL::Config::ParameterContainer& parameters ) const;
 
-      bool setup( const MeshPointer& meshPointer,
-                  const TNL::Config::ParameterContainer& parameters,
+      bool setup( const TNL::Config::ParameterContainer& parameters,
                   const TNL::String& prefix );
 
 
       bool setInitialCondition( const TNL::Config::ParameterContainer& parameters,
-                                const MeshPointer& mesh,
-                                DofVectorPointer& dofs,
-                                MeshDependentDataPointer& meshDependentData );
+                                DofVectorPointer& dofs );
 
       template< typename MatrixPointer >
-      bool setupLinearSystem( const MeshPointer& mesh,
-                              MatrixPointer& matrixPointer );
+      bool setupLinearSystem( MatrixPointer& matrixPointer );
 
       bool makeSnapshot( const RealType& time,
                          const IndexType& step,
-                         const MeshPointer& mesh,
-                         DofVectorPointer& dofs,
-                         MeshDependentDataPointer& meshDependentData );
+                         DofVectorPointer& dofs );
 
-      IndexType getDofs( const MeshPointer& mesh ) const;
+      IndexType getDofs() const;
 
-      void bindDofs( const MeshPointer& mesh,
-                     DofVectorPointer& dofs );
+      void bindDofs( DofVectorPointer& dofs );
 
       void getExplicitUpdate( const RealType& time,
                               const RealType& tau,
-                              const MeshPointer& mesh,
                               DofVectorPointer& _u,
-                              DofVectorPointer& _fu,
-                              MeshDependentDataPointer& meshDependentData );
+                              DofVectorPointer& _fu );
 
       template< typename MatrixPointer >
       void assemblyLinearSystem( const RealType& time,
                                  const RealType& tau,
-                                 const MeshPointer& mesh,
                                  DofVectorPointer& dofs,
                                  MatrixPointer& matrixPointer,
-                                 DofVectorPointer& rightHandSide,
-                                 MeshDependentDataPointer& meshDependentData );
+                                 DofVectorPointer& rightHandSide );
 
    protected:
     
       DifferentialOperatorPointer differentialOperator;
+
       BoundaryConditionPointer boundaryCondition;
+
       RightHandSidePointer rightHandSide;
    
       TNL::Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, DifferentialOperator, BoundaryCondition, RightHandSide > explicitUpdater;
diff --git a/src/Tools/tnl-quickstart/problem_impl.h.in b/src/Tools/tnl-quickstart/problem_impl.h.in
index d0b1162383eea26cf35282ecb78b9b5143f4abdb..f196ebcec1922b51539ca2f5794ba8b8324be368 100644
--- a/src/Tools/tnl-quickstart/problem_impl.h.in
+++ b/src/Tools/tnl-quickstart/problem_impl.h.in
@@ -8,33 +8,36 @@
 #include <TNL/Solvers/PDE/BackwardTimeDiscretisation.h>
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 TNL::String
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
 getTypeStatic()
 {{
    return TNL::String( "{problemBaseName}Problem< " ) + Mesh :: getTypeStatic() + " >";
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 TNL::String 
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
 getPrologHeader() const
 {{    
    return TNL::String( "{problemName}" );
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 void
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::    
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::    
 writeProlog( TNL::Logger& logger, const TNL::Config::ParameterContainer& parameters ) const
 {{
    /****
@@ -44,60 +47,60 @@ writeProlog( TNL::Logger& logger, const TNL::Config::ParameterContainer& paramet
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 bool
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::        
-setup( const MeshPointer& meshPointer,
-       const TNL::Config::ParameterContainer& parameters,
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::        
+setup( const TNL::Config::ParameterContainer& parameters,
        const TNL::String& prefix )
 {{
-   if( ! this->boundaryCondition->setup( meshPointer, parameters, "boundary-conditions-" ) ||
+   if( ! this->boundaryCondition->setup( this->getMesh(), parameters, "boundary-conditions-" ) ||
        ! this->rightHandSide->setup( parameters, "right-hand-side-" ) )
       return false;
    return true;
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
-typename {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::IndexType
-    {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::            
-getDofs( const MeshPointer& mesh ) const
+typename {problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::IndexType
+    {problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::            
+getDofs() 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 this->getMesh()->template getEntitiesCount< typename MeshType::Cell >();
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 void
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::            
-bindDofs( const MeshPointer& mesh,
-          DofVectorPointer& dofVector )    
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::            
+bindDofs( DofVectorPointer& dofVector )    
 {{
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 bool
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::            
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::            
 setInitialCondition( const TNL::Config::ParameterContainer& parameters,    
-                     const MeshPointer& mesh,
-                     DofVectorPointer& dofs,
-                     MeshDependentDataPointer& meshDependentData )
+                     DofVectorPointer& dofs )
 {{
    const TNL::String& initialConditionFile = parameters.getParameter< TNL::String >( "initial-condition" );
-   TNL::Functions::MeshFunction< Mesh > u( mesh, dofs );
+   MeshFunctionType u( this->getMesh(), dofs );
    if( ! u.boundLoad( initialConditionFile ) )
    {{
       std::cerr << "I am not able to load the initial condition from the file " << initialConditionFile << "." << std::endl;
@@ -107,45 +110,42 @@ setInitialCondition( const TNL::Config::ParameterContainer& parameters,
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
    template< typename MatrixPointer >
 bool
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::                
-setupLinearSystem( const MeshPointer& meshPointer,
-                   MatrixPointer& matrixPointer )
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::                
+setupLinearSystem( MatrixPointer& matrixPointer )
 {{
-   const IndexType dofs = this->getDofs( meshPointer );
+   const IndexType dofs = this->getDofs();
    typedef typename MatrixPointer::ObjectType::CompressedRowLengthsVector CompressedRowLengthsVectorType;
-   TNL::SharedPointer< CompressedRowLengthsVectorType > rowLengthsPointer;
-   if( ! rowLengthsPointer->setSize( dofs ) )
-      return false;
+   TNL::Pointers::SharedPointer< CompressedRowLengthsVectorType > rowLengthsPointer;
+   rowLengthsPointer->setSize( dofs );
    TNL::Matrices::MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter;
-   matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( meshPointer,
+   matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( this->getMesh(),
                                                                          differentialOperator,
                                                                          boundaryCondition,
                                                                          rowLengthsPointer );
    matrixPointer->setDimensions( dofs, dofs );
-   if( ! matrixPointer->setCompressedRowLengths( *rowLengthsPointer ) )
-      return false;
+   matrixPointer->setCompressedRowLengths( *rowLengthsPointer );
    return true;
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 bool
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::                    
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::                    
 makeSnapshot( const RealType& time,
               const IndexType& step,
-              const MeshPointer& mesh,
-              DofVectorPointer& dofs,
-              MeshDependentDataPointer& meshDependentData )
+              DofVectorPointer& dofs )
 {{
    std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl;
-   this->bindDofs( mesh, dofs );
+   this->bindDofs( dofs );
    TNL::FileName fileName;
    fileName.setFileNameBase( "u-" );
    fileName.setExtension( "tnl" );
@@ -156,17 +156,16 @@ makeSnapshot( const RealType& time,
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
 void
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::                    
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::                    
 getExplicitUpdate( const RealType& time,
                    const RealType& tau,
-                   const MeshPointer& mesh,
                    DofVectorPointer& _u,
-                   DofVectorPointer& _fu,
-                   MeshDependentDataPointer& meshDependentData )
+                   DofVectorPointer& _fu )
 {{
    /****
     * If you use an explicit solver like EulerSolver or MersonSolver, you
@@ -177,28 +176,27 @@ getExplicitUpdate( const RealType& time,
     * You may use supporting mesh dependent data if you need.
     */
 
-   TNL::SharedPointer< MeshFunctionType > uPointer( mesh, _u ); 
-   TNL::SharedPointer< MeshFunctionType > fuPointer( mesh, _fu ); 
-   this->explicitUpdater.setDifferentialOperator( this->differentialOperator ),
-   this->explicitUpdater.setBoundaryConditions( this->boundaryCondition ),
-   this->explicitUpdater.setRightHandSide( this->rightHandSide ),
-   this->explicitUpdater.template update< typename Mesh::Cell >( time, tau, mesh, uPointer, fuPointer );
+   TNL::Pointers::SharedPointer< MeshFunctionType > uPointer( this->getMesh(), _u ); 
+   TNL::Pointers::SharedPointer< MeshFunctionType > fuPointer( this->getMesh(), _fu ); 
+   this->explicitUpdater.setDifferentialOperator( this->differentialOperator );
+   this->explicitUpdater.setBoundaryConditions( this->boundaryCondition );
+   this->explicitUpdater.setRightHandSide( this->rightHandSide );
+   this->explicitUpdater.template update< typename Mesh::Cell, CommunicatorType >( time, tau, this->getMesh(), uPointer, fuPointer );
 }}
 
 template< typename Mesh,
+          typename Communicator,
           typename BoundaryCondition,
           typename RightHandSide,
           typename DifferentialOperator >
    template< typename MatrixPointer >
 void
-{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::                
+{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::                
 assemblyLinearSystem( const RealType& time,
                       const RealType& tau,
-                      const MeshPointer& mesh,
                       DofVectorPointer& _u,
                       MatrixPointer& matrixPointer,
-                      DofVectorPointer& b,
-                      MeshDependentDataPointer& meshDependentData )
+                      DofVectorPointer& b )
 {{
    /****
     * If you implement a (semi-)implicit solver, this method is supposed
@@ -206,14 +204,14 @@ assemblyLinearSystem( const RealType& time,
     * You may use supporting mesh dependent data if you need.
     */
 
-   TNL::SharedPointer< TNL::Functions::MeshFunction< Mesh > > uPointer( mesh, _u );
+   MeshFunctionPointer uPointer( this->getMesh(), _u );
    this->systemAssembler.setDifferentialOperator( this->differentialOperator );
    this->systemAssembler.setBoundaryConditions( this->boundaryCondition );
    this->systemAssembler.setRightHandSide( this->rightHandSide );
    this->systemAssembler.template assembly< typename Mesh::Cell, typename MatrixPointer::ObjectType >( 
       time,
       tau,
-      mesh,
+      this->getMesh(),
       uPointer,
       matrixPointer,
       b );
diff --git a/src/Tools/tnl-quickstart/rhs.h.in b/src/Tools/tnl-quickstart/rhs.h.in
index ffd1b78813dbfcd2f17809fcea69f2d999e86b89..07a97832d03f62e45912a3f229b52f71a31db11f 100644
--- a/src/Tools/tnl-quickstart/rhs.h.in
+++ b/src/Tools/tnl-quickstart/rhs.h.in
@@ -4,7 +4,7 @@
 
 template< typename Mesh, typename Real >
 class {problemBaseName}Rhs
-  : public TNL::Functions::Domain< Mesh::meshDimension, TNL::Functions::MeshDomain >
+  : public TNL::Functions::Domain< Mesh::getMeshDimension(), TNL::Functions::MeshDomain >
 {{
    public:
 
diff --git a/src/Tools/tnl-time-series2png b/src/Tools/tnl-time-series2png
deleted file mode 100644
index 8d59b386b8f15536fb7d360e63d1b00c2d02f332..0000000000000000000000000000000000000000
--- a/src/Tools/tnl-time-series2png
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-
-class timeSerie:
-   def __init__( self, index, label ):
-      self.index = index
-      self.label = label
-
-inputFile = ""
-outputFile = ""
-verbose = "false"
-timeSeries = []
-
-i = 0
-while i < len( arguments ):
-   if arguments[ i ] == "--input-file":
-      refinement = arguments[ i + 1 ]
-      i = i + 2
-      continue
-   if arguments[ i ] == "--output-file":
-      output_file_name = arguments[ i + 1 ]
-      i = i + 2
-      continue
-   if arguments[ i ] == "--time-serie":
-      index = arguments[ i + 1 ]
-      label = arguments[ i + 2 ]
-      timeSeries.append( timeSerie( index, label ) )
-      i = i + 3
-      continue
-   if arguments[ i ] == "--verbose":
-       verbose = float( arguments[ i + 1 ] )
-       i = i +2
-       continue       
-   input_files. append( arguments[ i ] )
-   i = i + 1
-   
-
diff --git a/src/UnitTests/Containers/ListTest.cpp b/src/UnitTests/Containers/ListTest.cpp
index d326f98f41847896544148add8dfa8a2b1afab21..3b5fdaecf385dab8da032a020ef6b6511ccf0c18 100644
--- a/src/UnitTests/Containers/ListTest.cpp
+++ b/src/UnitTests/Containers/ListTest.cpp
@@ -41,16 +41,17 @@ TYPED_TEST_CASE( ListTest, ListTypes );
 TYPED_TEST( ListTest, constructor )
 {
    using ListType = typename TestFixture::ListType;
+   using ValueType = typename ListType::ValueType;
 
    ListType list;
    EXPECT_TRUE( list.isEmpty() );
    EXPECT_EQ( list.getSize(), 0 );
 
-   list.Append( 0 );
+   list.Append( ( ValueType ) 0 );
    EXPECT_EQ( list.getSize(), 1 );
 
    ListType copy( list );
-   list.Append( 0 );
+   list.Append( ( ValueType ) 0 );
    EXPECT_EQ( list.getSize(), 2 );
    EXPECT_EQ( copy.getSize(), 1 );
    EXPECT_EQ( copy[ 0 ], list[ 0 ] );
@@ -63,10 +64,10 @@ TYPED_TEST( ListTest, operations )
 
    ListType a, b;
 
-   a.Append( 0 );
-   a.Append( 1 );
-   a.Prepend( 2 );
-   a.Insert( 3, 1 );
+   a.Append( (ValueType) 0 );
+   a.Append( (ValueType) 1 );
+   a.Prepend( (ValueType) 2 );
+   a.Insert( (ValueType) 3, 1 );
    EXPECT_EQ( a.getSize(), 4 );
    EXPECT_EQ( a[ 0 ], (ValueType) 2 );
    EXPECT_EQ( a[ 1 ], (ValueType) 3 );
@@ -77,7 +78,7 @@ TYPED_TEST( ListTest, operations )
    EXPECT_EQ( b.getSize(), 4 );
    EXPECT_EQ( a, b );
 
-   b.Insert( 4, 4 );
+   b.Insert( ( ValueType ) 4, 4 );
    EXPECT_NE( a, b );
    EXPECT_EQ( b[ 4 ], (ValueType) 4 );
 
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp
index 38276dd5436d83200b75f69a5b6b5221f23e1126..b19b0f13db2cd70d4fe52451d726bb68c75d0adf 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp
@@ -614,7 +614,7 @@ TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithActiveM
    maskDofs.setValue( true );
    constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr );
    meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer );
-   
+
    if( rank == 0 )
    {
       SCOPED_TRACE( "Up Left" );