From 89646a2d0f08c7de6980c174a886b01d5ca3b993 Mon Sep 17 00:00:00 2001
From: Frederik Hennig <fredy.hng@gmail.com>
Date: Fri, 25 Sep 2020 14:43:17 +0200
Subject: [PATCH] undid that last fix, and removed the 'target' from
 optimization params

---
 .../codegen/02_LBMLatticeModelGeneration.dox  |  2 +-
 .../codegen/02_LBMLatticeModelGeneration.py   |  2 +-
 .../codegen/03_AdvancedLBMCodegen.py          | 94 +++++++++----------
 3 files changed, 46 insertions(+), 52 deletions(-)

diff --git a/apps/tutorials/codegen/02_LBMLatticeModelGeneration.dox b/apps/tutorials/codegen/02_LBMLatticeModelGeneration.dox
index 06271369f..3166cc500 100644
--- a/apps/tutorials/codegen/02_LBMLatticeModelGeneration.dox
+++ b/apps/tutorials/codegen/02_LBMLatticeModelGeneration.dox
@@ -31,7 +31,7 @@ from pystencils_walberla import CodeGeneration, generate_pack_info_from_kernel
 from lbmpy_walberla import generate_lattice_model
 \endcode
 
-First, we define a few general parameters. These include the stencil (D2Q9) and the memory layout (`fzyx`, see \ref tutorial_codegen01 ). We define a SymPy symbol for the relaxation rate \f$ \omega \f$. This means we can later set it to a specific value from the waLBerla code. A dictionary with optimization parameters is also set up. Here, we define the compilation target, enable global common subexpression elimination (`cse_global`) and set the PDF field's memory layout. In general, the target could be set to `gpu` to create a CUDA implementation, but this is currently not possible for creating a `LatticeModel` class.
+First, we define a few general parameters. These include the stencil (D2Q9) and the memory layout (`fzyx`, see \ref tutorial_codegen01 ). We define a SymPy symbol for the relaxation rate \f$ \omega \f$. This means we can later set it to a specific value from the waLBerla code. A dictionary with optimization parameters is also set up. Here, we enable global common subexpression elimination (`cse_global`) and set the PDF field's memory layout.
 \code
 stencil = 'D2Q9'
 omega = sp.Symbol('omega')
diff --git a/apps/tutorials/codegen/02_LBMLatticeModelGeneration.py b/apps/tutorials/codegen/02_LBMLatticeModelGeneration.py
index 97dd55b37..39deba33e 100644
--- a/apps/tutorials/codegen/02_LBMLatticeModelGeneration.py
+++ b/apps/tutorials/codegen/02_LBMLatticeModelGeneration.py
@@ -14,7 +14,7 @@ omega = sp.Symbol('omega')
 layout = 'fzyx'
 
 #   Optimizations to be used by the code generator
-optimizations = {'target': 'cpu', 'cse_global': True, 'field_layout': layout}
+optimizations = {'cse_global': True, 'field_layout': layout}
 
 #   ===========================
 #      SRT Method Definition
diff --git a/apps/tutorials/codegen/03_AdvancedLBMCodegen.py b/apps/tutorials/codegen/03_AdvancedLBMCodegen.py
index 400237e63..a39790980 100644
--- a/apps/tutorials/codegen/03_AdvancedLBMCodegen.py
+++ b/apps/tutorials/codegen/03_AdvancedLBMCodegen.py
@@ -9,70 +9,64 @@ from pystencils_walberla import CodeGeneration, generate_sweep, generate_pack_in
 from lbmpy_walberla import generate_boundary
 
 
-with CodeGeneration() as ctx:
-
-    #   ========================
-    #      Target Selection
-    #   ========================
-
-    if ctx.cuda:
-        target = 'gpu'
-    else:
-        target = 'cpu'
+#   ========================
+#      General Parameters
+#   ========================
 
-    #   ========================
-    #      General Parameters
-    #   ========================
+stencil = 'D2Q9'
+omega = sp.Symbol('omega')
+layout = 'fzyx'
 
-    stencil = 'D2Q9'
-    omega = sp.Symbol('omega')
-    layout = 'fzyx'
+#   PDF Fields
+pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
 
-    #   PDF Fields
-    pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
+#   Velocity Output Field
+velocity = ps.fields("velocity(2): [2D]", layout=layout)
+output = {'velocity': velocity}
 
-    #   Velocity Output Field
-    velocity = ps.fields("velocity(2): [2D]", layout=layout)
-    output = {'velocity': velocity}
+#   Optimization
+optimization = {'cse_global': True,
+                'symbolic_field': pdfs,
+                'symbolic_temporary_field': pdfs_tmp,
+                'field_layout': layout}
 
-    #   Optimization
-    optimization = {'target': target,
-                    'cse_global': True,
-                    'symbolic_field': pdfs,
-                    'symbolic_temporary_field': pdfs_tmp,
-                    'field_layout': layout}
 
+#   ==================
+#      Method Setup
+#   ==================
 
-    #   ==================
-    #      Method Setup
-    #   ==================
+lbm_params = {'stencil': stencil,
+              'method': 'mrt_raw',
+              'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
+              'cumulant': True,
+              'compressible': True}
 
-    lbm_params = {'stencil': stencil,
-                'method': 'mrt_raw',
-                'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
-                'cumulant': True,
-                'compressible': True}
+lbm_update_rule = create_lb_update_rule(optimization=optimization,
+                                        output=output,
+                                        **lbm_params)
 
-    lbm_update_rule = create_lb_update_rule(optimization=optimization,
-                                            output=output,
-                                            **lbm_params)
+lbm_method = lbm_update_rule.method
 
-    lbm_method = lbm_update_rule.method
+#   ========================
+#      PDF Initialization
+#   ========================
 
-    #   ========================
-    #      PDF Initialization
-    #   ========================
+initial_rho = sp.Symbol('rho_0')
 
-    initial_rho = sp.Symbol('rho_0')
+pdfs_setter = macroscopic_values_setter(lbm_method,
+                                        initial_rho,
+                                        velocity.center_vector,
+                                        pdfs.center_vector)
 
-    pdfs_setter = macroscopic_values_setter(lbm_method,
-                                            initial_rho,
-                                            velocity.center_vector,
-                                            pdfs.center_vector)
+#   =====================
+#      Code Generation
+#   =====================
 
-    #   =====================
-    #      Code Generation
-    #   =====================
+with CodeGeneration() as ctx:
+    if ctx.cuda:
+        target = 'gpu'
+    else:
+        target = 'cpu'
 
     #   LBM Sweep
     generate_sweep(ctx, "CumulantMRTSweep", lbm_update_rule, field_swaps=[(pdfs, pdfs_tmp)], target=target)
-- 
GitLab