Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- committed Jun 10, 2020
1 parent cb9b8db commit 5278b42
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 52 deletions.
10 changes: 4 additions & 6 deletions FIAT/brezzi_douglas_marini.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ class BrezziDouglasMarini(finite_element.CiarletElement):
def __init__(self, ref_el, degree, variant=None):

if variant is None:
variant = "point"
print('Warning: Variant of BDM element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')
#Replace by the following in a month time
#variant = "integral"
variant = "point"
print('Warning: Variant of BDM element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')

if not (variant == "point" or "integral" in variant):
raise ValueError('Choose either variant="point" or variant="integral"'
Expand All @@ -119,7 +117,7 @@ def __init__(self, ref_el, degree, variant=None):
elif "integral" in variant:
try:
quad_deg = int(''.join(filter(str.isdigit, variant)))
except:
except ValueError:
raise ValueError("Wrong format for variant")
if quad_deg < degree + 1:
raise ValueError("Warning, quadrature degree should be at least %s" % (degree + 1))
Expand Down
22 changes: 7 additions & 15 deletions FIAT/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def tostr(self):


class IntegralMomentOfEdgeTangentEvaluation(Functional):

r"""
\int_e v\cdot t ds
Expand Down Expand Up @@ -430,11 +429,9 @@ def tostr(self):
return "(u.t%d)(%s)" % (self.tno, ','.join(x),)



class MonkIntegralMoment(Functional):
def __init__(self, ref_el, Q, P_at_qpts, facet):
sd = ref_el.get_spatial_dimension()
area = ref_el.volume_of_subcomplex(sd - 1, facet)
weights = Q.get_weights()
pt_dict = OrderedDict()
transform = ref_el.get_entity_transform(sd-1, facet)
Expand All @@ -445,7 +442,6 @@ def __init__(self, ref_el, Q, P_at_qpts, facet):


class IntegralMomentOfFaceTangentEvaluation(Functional):

r"""
\int_F v \times n \cdot p ds
Expand All @@ -457,7 +453,6 @@ class IntegralMomentOfFaceTangentEvaluation(Functional):
:arg facet: which facet.
"""
def __init__(self, ref_el, Q, P_at_qpts, facet):
#import ipdb; ipdb.set_trace()
P_at_qpts = [[P_at_qpts[0][i], P_at_qpts[1][i], P_at_qpts[2][i]]
for i in range(P_at_qpts.shape[1])]
n = ref_el.compute_scaled_normal(facet)
Expand All @@ -467,17 +462,15 @@ def __init__(self, ref_el, Q, P_at_qpts, facet):
weights = Q.get_weights()
pt_dict = OrderedDict()
for pt, wgt, phi in zip(pts, weights, P_at_qpts):
# pt_dict[pt] = [(wgt*(-n[2]*phi[1]+n[1]*phi[2]), (0, )),
# (wgt*(n[2]*phi[0]-n[0]*phi[2]), (1, )),
# (wgt*(-n[1]*phi[0]+n[0]*phi[1]), (2, ))]
phixn = [phi[1]*n[2] - phi[2]*n[1],
phi[2]*n[0] - phi[0]*n[2],
phi[0]*n[1] - phi[1]*n[0]]
pt_dict[pt] = [(wgt*(-n[2]*phixn[1]+n[1]*phixn[2]), (0, )),
(wgt*(n[2]*phixn[0]-n[0]*phixn[2]), (1, )),
(wgt*(-n[1]*phixn[0]+n[0]*phixn[1]), (2, ))]
phixn = [phi[1]*n[2] - phi[2]*n[1],
phi[2]*n[0] - phi[0]*n[2],
phi[0]*n[1] - phi[1]*n[0]]
pt_dict[pt] = [(wgt*(-n[2]*phixn[1]+n[1]*phixn[2]), (0, )),
(wgt*(n[2]*phixn[0]-n[0]*phixn[2]), (1, )),
(wgt*(-n[1]*phixn[0]+n[0]*phixn[1]), (2, ))]
super().__init__(ref_el, (sd, ), pt_dict, {}, "IntegralMomentOfFaceTangentEvaluation")


class PointScaledNormalEvaluation(Functional):
"""Implements the evaluation of the normal component of a vector at a
point on a facet of codimension 1, where the normal is scaled by
Expand All @@ -497,7 +490,6 @@ def tostr(self):


class IntegralMomentOfScaledNormalEvaluation(Functional):

r"""
\int_F v\cdot n p ds
Expand Down
22 changes: 10 additions & 12 deletions FIAT/nedelec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from itertools import chain
import numpy


def NedelecSpace2D(ref_el, k):
"""Constructs a basis for the 2d H(curl) space of the first kind
which is (P_k)^2 + P_k rot( x )"""
Expand Down Expand Up @@ -240,8 +241,8 @@ def __init__(self, ref_el, degree, variant, quad_deg):
t = ref_el.get_topology()

if variant == "integral":
#edge nodes are \int_F v\cdot t p ds where p \in P_{q-1}(edge)
#degree is q - 1
# edge nodes are \int_F v\cdot t p ds where p \in P_{q-1}(edge)
# degree is q - 1
edge = ref_el.get_facet_element().get_facet_element()
Q = quadrature.make_quadrature(edge, quad_deg)
Pq = polynomial_set.ONPolynomialSet(edge, degree)
Expand All @@ -261,17 +262,16 @@ def __init__(self, ref_el, degree, variant, quad_deg):
Pq_at_qpts = Pq.tabulate(Q.get_points())[tuple([0]*(2))]

for f in range(len(t[2])):
n = ref_el.compute_scaled_normal(f)
#R is used to map [1,0,0] to tangent1 and [0,1,0] to tangent2
# R is used to map [1,0,0] to tangent1 and [0,1,0] to tangent2
R = ref_el.compute_face_tangents(f)

#Skip last functionals because we only want p with p \cdot n = 0
# Skip last functionals because we only want p with p \cdot n = 0
for i in range(int(Pq_at_qpts.shape[0]/3)*2):
phi = Pq_at_qpts[i, ...]
phi = numpy.matmul(phi[:-1, ...].T, R)
nodes.append(functional.MonkIntegralMoment(ref_el, Q, phi, f))

#internal nodes. These are \int_T v \cdot p dx where p \in P_{q-3}^3(T)
# internal nodes. These are \int_T v \cdot p dx where p \in P_{q-3}^3(T)
if degree > 1:
Q = quadrature.make_quadrature(ref_el, quad_deg)
qpts = Q.get_points()
Expand Down Expand Up @@ -356,11 +356,9 @@ def __init__(self, ref_el, q, variant=None):
degree = q - 1

if variant is None:
variant = "point"
print('Warning: Variant of Nedelec element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')
#Replace by the following in a month time
#variant = "integral"
variant = "point"
print('Warning: Variant of Nedelec element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')

if not (variant == "point" or "integral" in variant):
raise ValueError('Choose either variant="point" or variant="integral"'
Expand All @@ -372,7 +370,7 @@ def __init__(self, ref_el, q, variant=None):
elif "integral" in variant:
try:
quad_deg = int(''.join(filter(str.isdigit, variant)))
except:
except ValueError:
raise ValueError("Wrong format for variant")
if quad_deg < degree + 1:
raise ValueError("Warning, quadrature degree should be at least %s" % (degree + 1))
Expand Down
23 changes: 10 additions & 13 deletions FIAT/nedelec_second_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from FIAT.quadrature import make_quadrature, UFCTetrahedronFaceQuadratureRule
from FIAT.reference_element import UFCTetrahedron

from FIAT import (polynomial_set, expansions, quadrature, dual_set,
finite_element, functional)
from FIAT import polynomial_set, quadrature, functional


class NedelecSecondKindDual(DualSet):
Expand Down Expand Up @@ -103,11 +102,11 @@ def _generate_edge_dofs(self, cell, degree, offset, variant, quad_deg):
Pq = polynomial_set.ONPolynomialSet(edge, degree)
Pq_at_qpts = Pq.tabulate(Q.get_points())[tuple([0]*(1))]
for e in range(len(cell.get_topology()[1])):
for i in range(Pq_at_qpts.shape[0]):
phi = Pq_at_qpts[i, :]
dofs.append(functional.IntegralMomentOfEdgeTangentEvaluation(cell, Q, phi, e))
jj = Pq_at_qpts.shape[0] * e
ids[e] = list(range(offset + jj, offset + jj + Pq_at_qpts.shape[0]))
for i in range(Pq_at_qpts.shape[0]):
phi = Pq_at_qpts[i, :]
dofs.append(functional.IntegralMomentOfEdgeTangentEvaluation(cell, Q, phi, e))
jj = Pq_at_qpts.shape[0] * e
ids[e] = list(range(offset + jj, offset + jj + Pq_at_qpts.shape[0]))

elif variant == "point":
for edge in range(len(cell.get_topology()[1])):
Expand Down Expand Up @@ -224,11 +223,9 @@ class NedelecSecondKind(CiarletElement):
def __init__(self, cell, degree, variant=None):

if variant is None:
variant = "point"
print('Warning: Variant of Nedelec 2nd kind element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')
#Replace by the following in a month time
#variant = "integral"
variant = "point"
print('Warning: Variant of Nedelec 2nd kind element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')

if not (variant == "point" or "integral" in variant):
raise ValueError('Choose either variant="point" or variant="integral"'
Expand All @@ -240,7 +237,7 @@ def __init__(self, cell, degree, variant=None):
elif "integral" in variant:
try:
quad_deg = int(''.join(filter(str.isdigit, variant)))
except:
except ValueError:
raise ValueError("Wrong format for variant")
if quad_deg < degree + 1:
raise ValueError("Warning, quadrature degree should be at least %s" % (degree + 1))
Expand Down
10 changes: 4 additions & 6 deletions FIAT/raviart_thomas.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ def __init__(self, ref_el, q, variant=None):
degree = q - 1

if variant is None:
variant = "point"
print('Warning: Variant of Raviart-Thomas element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')
#Replace by the following in a month time
#variant = "integral"
variant = "point"
print('Warning: Variant of Raviart-Thomas element will change from point evaluation to integral evaluation.'
'You should project into variant="integral"')

if not (variant == "point" or "integral" in variant):
raise ValueError('Choose either variant="point" or variant="integral"'
Expand All @@ -166,7 +164,7 @@ def __init__(self, ref_el, q, variant=None):
elif "integral" in variant:
try:
quad_deg = int(''.join(filter(str.isdigit, variant)))
except:
except ValueError:
raise ValueError("Wrong format for variant")
if quad_deg < degree + 1:
raise ValueError("Warning, quadrature degree should be at least %s" % (degree + 1))
Expand Down

0 comments on commit 5278b42

Please sign in to comment.