From 8a5890dd571ad9504b185d60e7694dfb39c30038 Mon Sep 17 00:00:00 2001
From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz>
Date: Wed, 28 Jan 2015 12:39:04 +0100
Subject: [PATCH] Creating incompressible Navier-Stokes solver in examples.

---
 .../CMakeLists.txt                            |  20 +++
 .../tnl-incompressible-navier-stokes.cpp      |  18 +++
 .../tnl-incompressible-navier-stokes.cu       |  18 +++
 .../tnl-incompressible-navier-stokes.h        | 116 ++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100755 examples/incompressible-navier-stokes/CMakeLists.txt
 create mode 100644 examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cpp
 create mode 100644 examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cu
 create mode 100644 examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.h

diff --git a/examples/incompressible-navier-stokes/CMakeLists.txt b/examples/incompressible-navier-stokes/CMakeLists.txt
new file mode 100755
index 0000000000..64baa1d5fe
--- /dev/null
+++ b/examples/incompressible-navier-stokes/CMakeLists.txt
@@ -0,0 +1,20 @@
+set( tnl_incompressible_navier_stokes_SOURCES     
+     tnl-incompressible-navier-stokes.cpp
+      )
+               
+IF( BUILD_CUDA )
+   CUDA_ADD_EXECUTABLE(tnl-incompressible-navier-stokes${debugExt} tnl-incompressible-navier-stokes.cu)
+   
+ELSE(  BUILD_CUDA )               
+   ADD_EXECUTABLE(tnl-incompressible-navier-stokes${debugExt} tnl-incompressible-navier-stokes.cpp)     
+   
+ENDIF( BUILD_CUDA )
+
+target_link_libraries (tnl-incompressible-navier-stokes${debugExt} tnl${debugExt}-${tnlVersion} )
+
+INSTALL( TARGETS tnl-incompressible-navier-stokes${debugExt}
+         RUNTIME DESTINATION bin
+         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
+        
+INSTALL( FILES tnl-run-incompressible-navier-stokes
+         DESTINATION share/tnl-${tnlVersion}/examples/incompressible-navier-stokes )
diff --git a/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cpp b/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cpp
new file mode 100644
index 0000000000..ce15dfa47e
--- /dev/null
+++ b/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cpp
@@ -0,0 +1,18 @@
+/***************************************************************************
+                          tnl-incompressible-navier-stokes.cpp  -  description
+                             -------------------
+    begin                : Jan 28, 2015
+    copyright            : (C) 2015 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "tnl-incompressible-navier-stokes.h"
diff --git a/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cu b/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cu
new file mode 100644
index 0000000000..b5cf257ca9
--- /dev/null
+++ b/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.cu
@@ -0,0 +1,18 @@
+/***************************************************************************
+                          tnl-incompressible-navier-stokes.cu  -  description
+                             -------------------
+    begin                : Jan 28, 2015
+    copyright            : (C) 2015 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "tnl-incompressible-navier-stokes.h"
\ No newline at end of file
diff --git a/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.h b/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.h
new file mode 100644
index 0000000000..25d90dafa0
--- /dev/null
+++ b/examples/incompressible-navier-stokes/tnl-incompressible-navier-stokes.h
@@ -0,0 +1,116 @@
+/***************************************************************************
+                          tnl-incompressible-navier-stokes.h  -  description
+                             -------------------
+    begin                : Jan 28, 2015
+    copyright            : (C) 2015 by 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 TNL_INCOMPRESSIBLE_NAVIER_STOKES_H_
+#define TNL_INCOMPRESSIBLE_NAVIER_STOKES_H_
+
+#include <solvers/tnlSolver.h>
+#include <solvers/tnlFastBuildConfig.h>
+#include <solvers/tnlConfigTags.h>
+#include <operators/diffusion/tnlLinearDiffusion.h>
+#include <operators/tnlAnalyticDirichletBoundaryConditions.h>
+#include <operators/tnlDirichletBoundaryConditions.h>
+#include <operators/tnlAnalyticNeumannBoundaryConditions.h>
+#include <operators/tnlNeumannBoundaryConditions.h>
+#include <functions/tnlConstantFunction.h>
+#include <problems/tnlHeatEquationProblem.h>
+
+//typedef tnlDefaultConfigTag BuildConfig;
+typedef tnlFastBuildConfig BuildConfig;
+
+template< typename ConfigTag >
+class tnlIncompressibleNavierStokesConfig
+{
+   public:
+      static void configSetup( tnlConfigDescription& config )
+      {
+         config.addDelimiter( "Incompressible Navier-Stokes solver settings:" );
+
+         /*config.addEntry< tnlString >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet");
+            config.addEntryEnum< tnlString >( "dirichlet" );
+            config.addEntryEnum< tnlString >( "neumann" );
+
+         config.addEntry< tnlString >( "boundary-conditions-file", "File with the values of the boundary conditions.", "boundary.tnl" );
+         config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." );
+         config.addEntry< double >( "right-hand-side-constant", "This sets a constant value for the right-hand side.", 0.0 );
+         config.addEntry< tnlString >( "initial-condition", "File with the initial condition.", "initial.tnl");*/
+      };
+};
+
+template< typename Real,
+          typename Device,
+          typename Index,
+          typename MeshType,
+          typename ConfigTag,
+          typename SolverStarter >
+class tnlIncompressibleNavierStokesSetter
+{
+   public:
+
+   typedef Real RealType;
+   typedef Device DeviceType;
+   typedef Index IndexType;
+
+   typedef tnlStaticVector< MeshType::Dimensions, Real > Vertex;
+
+   static bool run( const tnlParameterContainer& parameters )
+   {
+      enum { Dimensions = MeshType::Dimensions };
+      typedef tnlLinearDiffusion< MeshType, Real, Index > ApproximateOperator;
+      typedef tnlConstantFunction< Dimensions, Real > RightHandSide;
+      typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex;
+
+      /*tnlString boundaryConditionsType = parameters.getParameter< tnlString >( "boundary-conditions-type" );
+      if( parameters.checkParameter( "boundary-conditions-constant" ) )
+      {
+         typedef tnlConstantFunction< Dimensions, Real > ConstantFunction;
+         if( boundaryConditionsType == "dirichlet" )
+         {
+            typedef tnlAnalyticDirichletBoundaryConditions< MeshType, ConstantFunction, Real, Index > BoundaryConditions;
+            typedef tnlHeatEquationProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Solver;
+            SolverStarter solverStarter;
+            return solverStarter.template run< Solver >( parameters );
+         }
+         typedef tnlAnalyticNeumannBoundaryConditions< MeshType, ConstantFunction, Real, Index > BoundaryConditions;
+         typedef tnlHeatEquationProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Solver;
+         SolverStarter solverStarter;
+         return solverStarter.template run< Solver >( parameters );
+      }
+      typedef tnlVector< Real, Device, Index > VectorType;
+      if( boundaryConditionsType == "dirichlet" )
+      {
+         typedef tnlDirichletBoundaryConditions< MeshType, VectorType, Real, Index > BoundaryConditions;
+         typedef tnlHeatEquationProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Solver;
+         SolverStarter solverStarter;
+         return solverStarter.template run< Solver >( parameters );
+      }
+      typedef tnlNeumannBoundaryConditions< MeshType, VectorType, Real, Index > BoundaryConditions;
+      typedef tnlHeatEquationProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Solver;
+      SolverStarter solverStarter;
+      return solverStarter.template run< Solver >( parameters );*/
+   };
+};
+
+int main( int argc, char* argv[] )
+{
+   tnlSolver< tnlIncompressibleNavierStokesSetter, tnlIncompressibleNavierStokesConfig, BuildConfig > solver;
+   if( ! solver. run( argc, argv ) )
+      return EXIT_FAILURE;
+   return EXIT_SUCCESS;
+}
+
+#endif /* TNL_INCOMPRESSIBLE_NAVIER_STOKES_H_ */
-- 
GitLab