From d845820714ff36d6674ae1929f2bf090b4319e1e Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Thu, 5 Nov 2020 18:40:25 +0100
Subject: [PATCH] Fix bug and use hack to packinfo stuff that does not use all
 direction of stencil

---
 pystencils_walberla/codegen.py                     |  1 +
 pystencils_walberla/jinja_filters.py               |  3 ++-
 pystencils_walberla/templates/CpuPackInfo.tmpl.cpp | 10 +++++-----
 pystencils_walberla/templates/GpuPackInfo.tmpl.cpp | 10 +++++-----
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/pystencils_walberla/codegen.py b/pystencils_walberla/codegen.py
index 6fa7039..b1e0a33 100644
--- a/pystencils_walberla/codegen.py
+++ b/pystencils_walberla/codegen.py
@@ -4,6 +4,7 @@ from typing import Dict, Optional, Sequence, Tuple
 
 from jinja2 import Environment, PackageLoader, StrictUndefined
 from pystencils_autodiff import AdjointField
+import warnings
 
 
 from pystencils import (
diff --git a/pystencils_walberla/jinja_filters.py b/pystencils_walberla/jinja_filters.py
index f8c0a42..16ecf27 100644
--- a/pystencils_walberla/jinja_filters.py
+++ b/pystencils_walberla/jinja_filters.py
@@ -147,7 +147,7 @@ def field_extraction_code(field, is_temporary, declaration_only=False,
 def generate_block_data_to_field_extraction(ctx, kernel_info, parameters_to_ignore=[], parameters=None,
                                             declarations_only=False, no_declarations=False):
     """Generates code that extracts all required fields of a kernel from a walberla block storage."""
-    parameters_to_ignore = itertools.chain(parameters_to_ignore, SPECIAL_SYMBOL_NAMES)
+    parameters_to_ignore = list(itertools.chain(parameters_to_ignore, SPECIAL_SYMBOL_NAMES))
     if parameters is not None:
         field_parameters = []
         for param in kernel_info.parameters:
@@ -158,6 +158,7 @@ def generate_block_data_to_field_extraction(ctx, kernel_info, parameters_to_igno
         for param in kernel_info.parameters:
             if param.is_field_pointer and param.field_name not in parameters_to_ignore:
                 field_parameters.append(param.fields[0])
+                assert 'indexVector' not in param.fields[0].name
 
     normal_fields = {f for f in field_parameters if f.name not in kernel_info.temporary_fields}
     temporary_fields = {f for f in field_parameters if f.name in kernel_info.temporary_fields}
diff --git a/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp b/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp
index 24fd293..c9ffcbb 100644
--- a/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp
+++ b/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp
@@ -43,8 +43,8 @@ void {{class_name}}::pack(Direction dir, unsigned char * byte_buffer, IBlock * b
         }
         {% endfor %}
 
-        default:
-            WALBERLA_ASSERT(false);
+        //default:
+          //  WALBERLA_ASSERT(false);
     }
 }
 
@@ -70,8 +70,8 @@ void {{class_name}}::unpack(Direction dir, unsigned char * byte_buffer, IBlock *
         }
         {% endfor %}
 
-        default:
-            WALBERLA_ASSERT(false);
+        //default:
+            //WALBERLA_ASSERT(false);
     }
 }
 
@@ -102,4 +102,4 @@ uint_t {{class_name}}::size(stencil::Direction dir, const IBlock * block) const
 
 
 } // namespace {{namespace}}
-} // namespace walberla
\ No newline at end of file
+} // namespace walberla
diff --git a/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp b/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp
index d2624b1..545e941 100644
--- a/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp
+++ b/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp
@@ -49,8 +49,8 @@ void {{class_name}}::pack(Direction dir, unsigned char * byte_buffer, IBlock * b
         }
         {% endfor %}
 
-        default:
-            WALBERLA_ASSERT(false);
+        //default:
+            //WALBERLA_ASSERT(false);
     }
 }
 
@@ -76,8 +76,8 @@ void {{class_name}}::unpack(Direction dir, unsigned char * byte_buffer, IBlock *
         }
         {% endfor %}
 
-        default:
-            WALBERLA_ASSERT(false);
+        //default:
+            //WALBERLA_ASSERT(false);
     }
 }
 
@@ -108,4 +108,4 @@ uint_t {{class_name}}::size(stencil::Direction dir, IBlock * block)
 
 
 } // namespace {{namespace}}
-} // namespace walberla
\ No newline at end of file
+} // namespace walberla
-- 
GitLab