From 91cec6eb9b7e64153061bb205c089589c7b85bfa Mon Sep 17 00:00:00 2001 From: David Ham Date: Wed, 4 Nov 2015 14:22:29 +0000 Subject: [PATCH 1/5] Sed out the OuterProducts --- FIAT/__init__.py | 2 +- FIAT/reference_element.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FIAT/__init__.py b/FIAT/__init__.py index 6999f5797..3e63e410f 100644 --- a/FIAT/__init__.py +++ b/FIAT/__init__.py @@ -48,7 +48,7 @@ "Raviart-Thomas": RaviartThomas, "Regge": Regge, "EnrichedElement": EnrichedElement, - "OuterProductElement": TensorFiniteElement, + "TensorProductElement": TensorFiniteElement, "BrokenElement": DiscontinuousElement, "TraceElement": HDivTrace} diff --git a/FIAT/reference_element.py b/FIAT/reference_element.py index 1c32fe23b..53f5b316a 100644 --- a/FIAT/reference_element.py +++ b/FIAT/reference_element.py @@ -716,7 +716,7 @@ def ufc_cell( cell ): else: celltype = cell.cellname() - if celltype == "OuterProductCell": + if celltype == "TensorProductCell": # cell is a UFL cell return two_product_cell(ufc_cell(cell._A), ufc_cell(cell._B)) elif celltype == "quadrilateral": From 160446526f8d1742b9a0572d97094408890bb6fc Mon Sep 17 00:00:00 2001 From: David Ham Date: Sun, 8 Nov 2015 16:45:14 +0000 Subject: [PATCH 2/5] file rename --- FIAT/__init__.py | 2 +- FIAT/enriched.py | 2 +- FIAT/hdivcurl.py | 2 +- FIAT/{tensor_finite_element.py => tensor_product.py} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename FIAT/{tensor_finite_element.py => tensor_product.py} (100%) diff --git a/FIAT/__init__.py b/FIAT/__init__.py index 3e63e410f..a24682fc2 100644 --- a/FIAT/__init__.py +++ b/FIAT/__init__.py @@ -24,7 +24,7 @@ from FIAT.crouzeix_raviart import CrouzeixRaviart from FIAT.regge import Regge from FIAT.bubble import Bubble -from FIAT.tensor_finite_element import TensorFiniteElement +from FIAT.tensor_product import TensorFiniteElement from FIAT.enriched import EnrichedElement from FIAT.discontinuous import DiscontinuousElement from FIAT.trace_hdiv import HDivTrace diff --git a/FIAT/enriched.py b/FIAT/enriched.py index 13df00e3e..5a5b90e1f 100644 --- a/FIAT/enriched.py +++ b/FIAT/enriched.py @@ -18,7 +18,7 @@ import numpy from .finite_element import FiniteElement -from .tensor_finite_element import TensorFiniteElement +from .tensor_product import TensorFiniteElement from . import dual_set from copy import copy diff --git a/FIAT/hdivcurl.py b/FIAT/hdivcurl.py index 666bc9d74..10b194b63 100644 --- a/FIAT/hdivcurl.py +++ b/FIAT/hdivcurl.py @@ -17,7 +17,7 @@ import numpy import types -from .tensor_finite_element import TensorFiniteElement +from .tensor_product import TensorFiniteElement from . import functional diff --git a/FIAT/tensor_finite_element.py b/FIAT/tensor_product.py similarity index 100% rename from FIAT/tensor_finite_element.py rename to FIAT/tensor_product.py From 3b4db34b683a66523857a32b8b483bc73c5bb5c9 Mon Sep 17 00:00:00 2001 From: David Ham Date: Sun, 8 Nov 2015 16:49:08 +0000 Subject: [PATCH 3/5] Rename two_product_cell --- FIAT/finite_element.py | 4 ++-- FIAT/reference_element.py | 4 ++-- FIAT/tensor_product.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/FIAT/finite_element.py b/FIAT/finite_element.py index 187307535..b289e5bc1 100644 --- a/FIAT/finite_element.py +++ b/FIAT/finite_element.py @@ -21,7 +21,7 @@ import numpy from .polynomial_set import PolynomialSet from .quadrature import make_quadrature -from .reference_element import two_product_cell, LINE +from .reference_element import TensorProductCell, LINE class FiniteElement: """Class implementing Ciarlet's abstraction of a finite element @@ -194,7 +194,7 @@ def facet_support_dofs(elem): corresponding basis functions take non-zero values.""" if not hasattr(elem, "_facet_support_dofs"): # Non-extruded cells only - assert not isinstance(elem.ref_el, two_product_cell) + assert not isinstance(elem.ref_el, TensorProductCell) q = make_quadrature(elem.ref_el.get_facet_element(), max(2*elem.degree(), 1)) ft = lambda f: elem.ref_el.get_facet_transform(f) diff --git a/FIAT/reference_element.py b/FIAT/reference_element.py index 53f5b316a..ff7dcc372 100644 --- a/FIAT/reference_element.py +++ b/FIAT/reference_element.py @@ -597,7 +597,7 @@ def contains_point(self, point, epsilon=0): return result -class two_product_cell( ReferenceElement ): +class TensorProductCell( ReferenceElement ): """A cell that is the product of FIAT cells A and B""" def __init__( self, A, B ): self.A = A @@ -718,7 +718,7 @@ def ufc_cell( cell ): if celltype == "TensorProductCell": # cell is a UFL cell - return two_product_cell(ufc_cell(cell._A), ufc_cell(cell._B)) + return TensorProductCell(ufc_cell(cell._A), ufc_cell(cell._B)) elif celltype == "quadrilateral": return FiredrakeQuadrilateral() elif celltype == "interval": diff --git a/FIAT/tensor_product.py b/FIAT/tensor_product.py index e9a3af20e..cfc839fa2 100644 --- a/FIAT/tensor_product.py +++ b/FIAT/tensor_product.py @@ -18,7 +18,7 @@ import numpy from .finite_element import FiniteElement, _facet_support_dofs -from .reference_element import two_product_cell, LINE +from .reference_element import TensorProductCell, LINE from .polynomial_set import mis from .quadrature import make_quadrature from . import dual_set @@ -42,7 +42,7 @@ def __init__(self, A, B): self.formdegree = A.get_formdegree() + B.get_formdegree() # set up reference element - self.ref_el = two_product_cell(A.get_reference_element(), B.get_reference_element()) + self.ref_el = TensorProductCell(A.get_reference_element(), B.get_reference_element()) if A.mapping()[0] != "affine" and B.mapping()[0] == "affine": self._mapping = A.mapping()[0] @@ -341,7 +341,7 @@ def horiz_facet_support_dofs(elem): corresponding basis functions take non-zero values.""" if not hasattr(elem, "_horiz_facet_support_dofs"): # Extruded cells only - assert isinstance(elem.ref_el, two_product_cell) + assert isinstance(elem.ref_el, TensorProductCell) q = make_quadrature(elem.ref_el.A, max(2*elem.degree(), 1)) ft = lambda f: elem.ref_el.get_horiz_facet_transform(f) @@ -357,7 +357,7 @@ def vert_facet_support_dofs(elem): corresponding basis functions take non-zero values.""" if not hasattr(elem, "_vert_facet_support_dofs"): # Extruded cells only - assert isinstance(elem.ref_el, two_product_cell) + assert isinstance(elem.ref_el, TensorProductCell) deg = max(2*elem.degree(), 1) if elem.ref_el.A.get_shape() == LINE: @@ -366,7 +366,7 @@ def vert_facet_support_dofs(elem): # thus we need special treatment here. q = make_quadrature(elem.ref_el.B, deg) else: - vfacet_el = two_product_cell(elem.ref_el.A.get_facet_element(), + vfacet_el = TensorProductCell(elem.ref_el.A.get_facet_element(), elem.ref_el.B) q = make_quadrature(vfacet_el, (deg, deg)) ft = lambda f: elem.ref_el.get_vert_facet_transform(f) From a7cc5ec8ed822008d8fbc6b08e0686b1934f4b2a Mon Sep 17 00:00:00 2001 From: David Ham Date: Sun, 8 Nov 2015 17:02:03 +0000 Subject: [PATCH 4/5] Rename TensorFiniteElement --- FIAT/__init__.py | 4 ++-- FIAT/enriched.py | 2 +- FIAT/hdivcurl.py | 10 +++++----- FIAT/tensor_product.py | 6 +++--- FIAT/trace_hdiv.py | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/FIAT/__init__.py b/FIAT/__init__.py index a24682fc2..7af35cd66 100644 --- a/FIAT/__init__.py +++ b/FIAT/__init__.py @@ -24,7 +24,7 @@ from FIAT.crouzeix_raviart import CrouzeixRaviart from FIAT.regge import Regge from FIAT.bubble import Bubble -from FIAT.tensor_product import TensorFiniteElement +from FIAT.tensor_product import TensorProductElement from FIAT.enriched import EnrichedElement from FIAT.discontinuous import DiscontinuousElement from FIAT.trace_hdiv import HDivTrace @@ -48,7 +48,7 @@ "Raviart-Thomas": RaviartThomas, "Regge": Regge, "EnrichedElement": EnrichedElement, - "TensorProductElement": TensorFiniteElement, + "TensorProductElement": TensorProductElement, "BrokenElement": DiscontinuousElement, "TraceElement": HDivTrace} diff --git a/FIAT/enriched.py b/FIAT/enriched.py index 5a5b90e1f..46a34fd6e 100644 --- a/FIAT/enriched.py +++ b/FIAT/enriched.py @@ -18,7 +18,7 @@ import numpy from .finite_element import FiniteElement -from .tensor_product import TensorFiniteElement +from .tensor_product import TensorProductElement from . import dual_set from copy import copy diff --git a/FIAT/hdivcurl.py b/FIAT/hdivcurl.py index 10b194b63..2e145f112 100644 --- a/FIAT/hdivcurl.py +++ b/FIAT/hdivcurl.py @@ -17,12 +17,12 @@ import numpy import types -from .tensor_product import TensorFiniteElement +from .tensor_product import TensorProductElement from . import functional def Hdiv(element): - if not isinstance(element, TensorFiniteElement): + if not isinstance(element, TensorProductElement): raise NotImplementedError if element.A.get_formdegree() is None or element.B.get_formdegree() is None: @@ -31,7 +31,7 @@ def Hdiv(element): if not (formdegree == element.get_reference_element().get_spatial_dimension() - 1): raise ValueError("Tried to use Hdiv on a non-(n-1)-form element") - newelement = TensorFiniteElement(element.A, element.B) # make a copy to return + newelement = TensorProductElement(element.A, element.B) # make a copy to return # redefine value_shape() def value_shape(self): @@ -144,7 +144,7 @@ def tabulate(self, order, points): def Hcurl(element): - if not isinstance(element, TensorFiniteElement): + if not isinstance(element, TensorProductElement): raise NotImplementedError if element.A.get_formdegree() is None or element.B.get_formdegree() is None: @@ -153,7 +153,7 @@ def Hcurl(element): if not (formdegree == 1): raise ValueError("Tried to use Hcurl on a non-1-form element") - newelement = TensorFiniteElement(element.A, element.B) # make a copy to return + newelement = TensorProductElement(element.A, element.B) # make a copy to return # redefine value_shape() def value_shape(self): diff --git a/FIAT/tensor_product.py b/FIAT/tensor_product.py index cfc839fa2..efd2c65c6 100644 --- a/FIAT/tensor_product.py +++ b/FIAT/tensor_product.py @@ -25,7 +25,7 @@ from . import functional -class TensorFiniteElement(FiniteElement): +class TensorProductElement(FiniteElement): """Class implementing a finite element that is the tensor product of two existing finite elements.""" @@ -385,5 +385,5 @@ def vert_facet_support_dofs(elem): T = reference_element.UFCInterval() W = raviart_thomas.RaviartThomas(S, 1) X = lagrange.Lagrange(T, 3) - Y = TensorFiniteElement(W, X) - Z = TensorFiniteElement(Y, X) + Y = TensorProductElement(W, X) + Z = TensorProductElement(Y, X) diff --git a/FIAT/trace_hdiv.py b/FIAT/trace_hdiv.py index 60d59ac5f..674d96da3 100644 --- a/FIAT/trace_hdiv.py +++ b/FIAT/trace_hdiv.py @@ -19,7 +19,7 @@ from .finite_element import FiniteElement from . import functional from . import dual_set -from . import TensorFiniteElement +from . import TensorProductElement class HDivTrace(FiniteElement): @@ -33,7 +33,7 @@ def __init__(self, element): raise ValueError("Can only take trace of Hdiv element") # TPEs not supported yet - if isinstance(element, TensorFiniteElement): + if isinstance(element, TensorProductElement): raise NotImplementedError("Trace of TFEs not supported yet") # Otherwise, let's go... From 9434be8d8754bbf743a55237e3c4cbdf29449dd4 Mon Sep 17 00:00:00 2001 From: Miklos Homolya Date: Mon, 8 Feb 2016 16:48:32 +0000 Subject: [PATCH 5/5] fix ufc_cell --- FIAT/reference_element.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FIAT/reference_element.py b/FIAT/reference_element.py index ff7dcc372..3dd07d377 100644 --- a/FIAT/reference_element.py +++ b/FIAT/reference_element.py @@ -716,9 +716,9 @@ def ufc_cell( cell ): else: celltype = cell.cellname() - if celltype == "TensorProductCell": - # cell is a UFL cell - return TensorProductCell(ufc_cell(cell._A), ufc_cell(cell._B)) + if " * " in celltype: + # Tensor product cell + return TensorProductCell(*map(ufc_cell, celltype.split(" * "))) elif celltype == "quadrilateral": return FiredrakeQuadrilateral() elif celltype == "interval":