From 4c225c8292b98a75858a9cfd2209ca4b150389a6 Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Wed, 25 Sep 2019 13:08:10 +0200
Subject: [PATCH] Add AssignmentCollection.{free_fields,bound_fields}

---
 pystencils/simp/assignment_collection.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pystencils/simp/assignment_collection.py b/pystencils/simp/assignment_collection.py
index 1e9a4c47..82df31fb 100644
--- a/pystencils/simp/assignment_collection.py
+++ b/pystencils/simp/assignment_collection.py
@@ -111,6 +111,15 @@ class AssignmentCollection:
             "Not in SSA form - same symbol assigned multiple times"
         return bound_symbols_set
 
+    def free_fields(self):
+        """All fields accessed in the assignment collection, which do not occur as left hand sides in any assignment."""
+        return {s.field for s in self.free_symbols if hasattr(s, 'field')}
+
+    @property
+    def bound_fields(self):
+        """All field accessed on the left hand side of a main assignment or a subexpression."""
+        return {s.field for s in self.bound_symbols if hasattr(s, 'field')}
+
     @property
     def defined_symbols(self) -> Set[sp.Symbol]:
         """All symbols which occur as left-hand-sides of one of the main equations"""
-- 
GitLab