Skip to content

Commit d2d2d4b

Browse files
committed
tidy up
1 parent 37b6124 commit d2d2d4b

5 files changed

Lines changed: 28 additions & 12 deletions

File tree

fuse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from fuse.cells import Point, Edge, polygon, make_tetrahedron, constructCellComplex, TensorProductPoint
2+
from fuse.cells import Point, Edge, polygon, line, make_tetrahedron, constructCellComplex, TensorProductPoint
33
from fuse.groups import S1, S2, S3, D4, Z3, Z4, C3, C4, S4, A4, diff_C3, tet_edges, tet_faces, sq_edges, GroupRepresentation, PermutationSetRepresentation, get_cyc_group, get_sym_group
44
from fuse.dof import DeltaPairing, DOF, L2Pairing, FuseFunction, PointKernel, VectorKernel, PolynomialKernel, ComponentKernel
55
from fuse.triples import ElementTriple, DOFGenerator, immerse

fuse/cells.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,9 @@ def __call__(self, *x):
926926
if len(attach_comp.atoms(sp.Symbol)) <= len(x):
927927
res.append(sympy_to_numpy(attach_comp, syms, x))
928928
else:
929-
res.append(attach_comp.subs({syms[i]: x[i] for i in range(len(x))}))
929+
res_val = attach_comp.subs({syms[i]: x[i] for i in range(len(x))})
930+
res.append(res_val)
931+
930932
return tuple(res)
931933
return sympy_to_numpy(self.attachment, syms, x)
932934
return x
@@ -1046,7 +1048,7 @@ def construct_fuse_rep(self):
10461048
# of all combinations of point, take those where at least one changes and at least one is the same
10471049
if any(a[i] == b[i] for i in range(len(a))) and any(a[i] != b[i] for i in range(len(sub_cells))):
10481050
# ensure if they change, that edge exists in the existing topology
1049-
if all([a[i] == b[i] or (sub_cells[i].local_id(a[i]), sub_cells[i].local_id(b[i])) in list(sub_cells[i].topology[1].values()) for i in range(len(sub_cells))]):
1051+
if all([a[i] == b[i] or (sub_cells[i].local_id(a[i]), sub_cells[i].local_id(b[i])) in list(sub_cells[i]._topology[1].values()) for i in range(len(sub_cells))]):
10501052
edges.append((a, b))
10511053
# hasse level 1
10521054
edge_cls1 = {e: None for e in edges}

fuse/spaces/polynomial_spaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __init__(self, weights, spaces):
157157
self.weights = weights
158158
self.spaces = spaces
159159

160-
weight_degrees = [0 if not (isinstance(w, sp.Expr) or isinstance(w, sp.Matrix)) else max_deg_sp_mat(w) for w in self.weights]
160+
weight_degrees = [0 if not (isinstance(w, sp.Expr) or isinstance(w, sp.Matrix)) else max_deg_sp_expr(w) for w in self.weights]
161161

162162
maxdegree = max([space.maxdegree + w_deg for space, w_deg in zip(spaces, weight_degrees)])
163163
mindegree = min([space.mindegree + w_deg for space, w_deg in zip(spaces, weight_degrees)])

fuse/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def sympy_to_numpy(array, symbols, values):
2929
"""
3030
substituted = array.subs({symbols[i]: values[i] for i in range(len(values))})
3131

32-
if len(array.atoms(sp.Symbol)) == len(values) and all(not isinstance(v, sp.Expr) for v in values):
32+
if len(array.atoms(sp.Symbol)) <= len(values) and all(not isinstance(v, sp.Expr) for v in values):
3333
nparray = np.array(substituted).astype(np.float64)
3434

3535
if len(nparray.shape) > 1:

test/test_convert_to_fiat.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,13 +563,27 @@ def test_quad(elem_gen):
563563
assert (poisson_solve(r, ufl_elem, parameters={}, quadrilateral=True) < 1.e-9)
564564

565565

566-
# # @pytest.mark.xfail(reason="Issue with quad cell")
567-
# def test_non_tensor_quad():
568-
# elem = create_cg1_quad()
569-
# ufl_elem = elem.to_ufl()
570-
# print(elem.to_fiat().entity_permutations())
571-
# # elem.cell.hasse_diagram(filename="cg1quad.png")
572-
# assert (run_test_original(1, "CG", 1, parameters={}, quadrilateral=True) < 1.e-9)
566+
@pytest.mark.xfail(reason="Issue with quad cell")
567+
def test_non_tensor_quad():
568+
elem = create_cg1_quad()
569+
ufl_elem = elem.to_ufl()
570+
print(elem.to_fiat().entity_permutations())
571+
# elem.cell.hasse_diagram(filename="cg1quad.png")
572+
assert (run_test_original(1, "CG", 1, parameters={}, quadrilateral=True) < 1.e-9)
573+
574+
575+
def project(U, mesh, func):
576+
f = assemble(interpolate(func, U))
577+
578+
out = Function(U)
579+
u = TrialFunction(U)
580+
v = TestFunction(U)
581+
a = inner(u, v)*dx
582+
L = inner(f, v)*dx
583+
solve(a == L, out)
584+
585+
res = sqrt(assemble(dot(out - func, out - func) * dx))
586+
return res
573587

574588

575589
@pytest.mark.parametrize("elem_gen,elem_code,deg", [(create_cg2_tri, "CG", 2),

0 commit comments

Comments
 (0)