From 1c3b93bf70be68a579e8243b0bba68d345380860 Mon Sep 17 00:00:00 2001
From: Ben Sepanski <ben_sepanski@baylor.edu>
Date: Mon, 1 Jun 2020 11:16:46 -0500
Subject: [PATCH] Changed name of underlying structure from transporter to
 handler

---
 meshmode/interop/FInAT/__init__.py         |  2 +
 meshmode/interop/FInAT/lagrange_element.py | 18 ++---
 meshmode/interop/__init__.py               | 80 ++++++----------------
 meshmode/interop/fiat/simplex_cell.py      | 24 ++-----
 4 files changed, 34 insertions(+), 90 deletions(-)

diff --git a/meshmode/interop/FInAT/__init__.py b/meshmode/interop/FInAT/__init__.py
index f53a2135..3708afa4 100644
--- a/meshmode/interop/FInAT/__init__.py
+++ b/meshmode/interop/FInAT/__init__.py
@@ -20,4 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 """
 
+from meshmode.interop.FInAT.lagrange_element import FinatLagrangeElementImporter
+
 __all__ = ['FinatLagrangeElementImporter']
diff --git a/meshmode/interop/FInAT/lagrange_element.py b/meshmode/interop/FInAT/lagrange_element.py
index c74b2e53..ce71d6b7 100644
--- a/meshmode/interop/FInAT/lagrange_element.py
+++ b/meshmode/interop/FInAT/lagrange_element.py
@@ -2,7 +2,7 @@ import numpy as np
 import numpy.linalg as la
 import six
 
-from meshmode.interop import ExternalImporter
+from meshmode.interop import ExternalImportHandler
 from meshmode.interop.fiat import FIATSimplexCellImporter
 
 
@@ -12,16 +12,10 @@ __doc__ = """
 """
 
 
-class FinatLagrangeElementImporter(ExternalImporter):
+class FinatLagrangeElementImporter(ExternalImportHandler):
     """
     An importer for a FInAT element, usually instantiated from
     ``some_instantiated_firedrake_function_space.finat_element``
-
-    This importer does not have an obvious meshmode counterpart,
-    so is instead used for its method.
-    In particular, methods :meth:`import_data`
-    and :meth:`validate_to_data` are *NOT* implemented
-    and there is no :attr:`to_data` to be computed.
     """
     def __init__(self, finat_element):
         """
@@ -76,11 +70,11 @@ class FinatLagrangeElementImporter(ExternalImporter):
 
             # Get unit nodes
             for dim, element_nrs in six.iteritems(
-                    self.analog().entity_support_dofs()):
+                    self.data.entity_support_dofs()):
                 for element_nr, node_list in six.iteritems(element_nrs):
                     # Get the nodes on the element (in meshmode reference coords)
                     pts_on_element = self.cell_importer.make_points(
-                        dim, element_nr, self.analog().degree)
+                        dim, element_nr, self.data.degree)
                     # Record any new nodes
                     i = 0
                     for node_nr in node_list:
@@ -106,7 +100,7 @@ class FinatLagrangeElementImporter(ExternalImporter):
         """
         :return: The dimension of the FInAT element's cell
         """
-        return self.cell_importer.from_data.get_dimension()
+        return self.cell_importer.data.get_dimension()
 
     def unit_vertex_indices(self):
         """
@@ -162,7 +156,7 @@ class FinatLagrangeElementImporter(ExternalImporter):
             from modepy import resampling_matrix, simplex_best_available_basis
 
             flip_matrix = resampling_matrix(
-                simplex_best_available_basis(self.dim(), self.analog().degree),
+                simplex_best_available_basis(self.dim(), self.data.degree),
                 flipped_unit_nodes, self.unit_nodes())
 
             flip_matrix[np.abs(flip_matrix) < 1e-15] = 0
diff --git a/meshmode/interop/__init__.py b/meshmode/interop/__init__.py
index 91ddfd76..bd6d9257 100644
--- a/meshmode/interop/__init__.py
+++ b/meshmode/interop/__init__.py
@@ -25,97 +25,59 @@ from abc import ABC
 __doc__ = """
 Development Interface
 ---------------------
-.. autoclass:: ExternalTransporter
-.. autoclass:: ExternalImporter
-.. autoclass:: ExternalExporter
+.. autoclass:: ExternalDataHandler
+.. autoclass:: ExternalExportHandler
+.. autoclass:: ExternalImportHandler
 """
 
 
 # {{{ Generic, most abstract class for transporting meshmode <-> external
 
-class ExternalTransporter(ABC):
+class ExternalDataHandler(ABC):
     """
-    .. attribute:: from_data
+    A data handler takes data from meshmode and facilitates its use
+    in another package or the reverse: takes data from another package
+    and facilitates its use in meshmode.
 
-        The object which needs to be transported either to meshmode or
-        from meshmode
+    .. attribute:: data
 
-    .. attribute:: to_data
-
-        The "transported" object, i.e. the
-
-        This attribute does not exist at instantiation time.
-        If exporting (resp. importing) from meshmode
-        then we are using an :class:`ExternalExporter`
-        (resp. :class:`ExternalImporter`) instance. :attr:`to_data` is
-        computed with a call to :fun:`ExternalExporter.export_data`
-        (resp. :fun:`ExternalImporter.import_data`).
-
-        :raises ValueError: if :attr:`to_data` is accessed before creation.
-        :raises NotImplementedError: if :meth:`validate_to_data` is called
-                                     without an implementation.
+        The object which needs to be interfaced either into meshmode or
+        out of meshmode.
+        Should not be modified after creation.
     """
-    def __init__(self, from_data):
-        self.from_data = from_data
-
-    def validate_to_data(self):
-        """
-        Validate :attr:`to_data`
-
-        :return: *True* if :attr:`to_data` has been computed and is valid
-                 and *False* otherwise
-        """
-        raise NotImplementedError("*validate_to_data* method not implemented "
-                                  "for object of type %s" % type(self))
+    def __init__(self, data):
+        self.data = data
 
     def __hash__(self):
-        return hash((type(self), self.from_data))
+        return hash((type(self), self.data))
 
     def __eq__(self, other):
         return isinstance(other, type(self)) and \
                isinstance(self, type(other)) and \
-               self.from_data == other.from_data
+               self.data == other.data
 
     def __neq__(self, other):
         return not self.__eq__(other)
 
-    def __getattr__(self, attr):
-        if attr != 'to_data':
-            return super(ExternalTransporter, self).__getattr__(attr)
-        raise ValueError("Attribute *to_data* has not yet been computed. "
-                         "An object of class *ExternalExporter* (resp. "
-                         "*ExternalImporter*) must call *export_data()* "
-                         "(resp. *import_data()*) to compute attribute *to_data*")
-
 # }}}
 
 
 # {{{ Define specific classes for meshmode -> external and meshmode <- external
 
-class ExternalExporter(ExternalTransporter):
+class ExternalExportHandler(ExternalDataHandler):
     """
-    Subclass of :class:`ExternalTransporter` for meshmode -> external
+    Subclass of :class:`ExternalDataHandler` for meshmode -> external
     data transfer
     """
-    def export_data(self):
-        """
-        Compute :attr:`to_data` from :attr:`from_data`
-        """
-        raise NotImplementedError("*export_data* method not implemented "
-                                  "for type %s" % type(self))
+    pass
 
 
-class ExternalImporter(ExternalTransporter):
+class ExternalImportHandler(ExternalDataHandler):
     """
-    Subclass of :class:`ExternalTransporter` for external -> meshmode
+    Subclass of :class:`ExternalDataHandler` for external -> meshmode
     data transfer
     """
-    def import_data(self):
-        """
-        Compute :attr:`to_data` from :attr:`from_data`
-        """
-        raise NotImplementedError("*import_data* method not implemented "
-                                  "for type %s" % type(self))
+    pass
 
 # }}}
 
diff --git a/meshmode/interop/fiat/simplex_cell.py b/meshmode/interop/fiat/simplex_cell.py
index f2b8366b..bdcabd83 100644
--- a/meshmode/interop/fiat/simplex_cell.py
+++ b/meshmode/interop/fiat/simplex_cell.py
@@ -1,7 +1,7 @@
 import numpy as np
 import numpy.linalg as la
 
-from meshmode.interop import ExternalImporter
+from meshmode.interop import ExternalImportHandler
 
 
 __doc__ = """
@@ -54,27 +54,13 @@ def get_affine_mapping(reference_vects, vects):
 
 # {{{ Interoperator for FIAT's reference_element.Simplex
 
-class FIATSimplexCellImporter(ExternalImporter):
+class FIATSimplexCellImporter(ExternalImportHandler):
     """
-    Importer for a :mod:`FIAT` simplex cell.
+    Import handler for a :mod:`FIAT` simplex cell.
 
-    There is no obvious meshmode counterpart for :attr:`from_data`.
-    The data is simply used to obtain FIAT's reference
-    nodes according to :mod:`modepy`'s reference coordinates
-    using :meth:`make_points`.
-
-    In particular, methods
-    :meth:`import_data` and :meth:`validate_to_data`
-    are *NOT* implemented
-    and there is no :attr:`to_data` to be computed.
-
-    .. attribute:: from_data
+    .. attribute:: data
 
         An instance of :class:`fiat.FIAT.reference_element.Simplex`.
-
-    .. attribute:: to_data
-
-        :raises ValueError: If accessed.
     """
     def __init__(self, cell):
         """
@@ -116,7 +102,7 @@ class FIATSimplexCellImporter(ExternalImporter):
         :return: an *np.array* of shape *(dim, npoints)* holding the
                  coordinates of each of the ver
         """
-        points = self.from_data.make_points(dim, entity_id, order)
+        points = self.data.make_points(dim, entity_id, order)
         if not points:
             return points
         points = np.array(points)
-- 
GitLab