Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cyl average edge #317

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
switch to extrap consistent with edge_curl assumption
jcapriot committed Apr 26, 2023
commit 1a634e55c77aff1201d4d2a1897d1efcf2244f7b
2 changes: 1 addition & 1 deletion discretize/cylindrical_mesh.py
Original file line number Diff line number Diff line change
@@ -1431,7 +1431,7 @@ def average_edge_to_face(self): # NOQA D102
nx, _, nz = self.shape_edges_y

e_to_fx = sp.kron(av(nz - 1), sp.eye(nx))
e_to_fz = sp.kron(sp.eye(nz), av_extrap(nx)[:-1])
e_to_fz = sp.kron(sp.eye(nz), av(nx).toarray()[:, 1:])

return sp.vstack([e_to_fx, e_to_fz])
else:
17 changes: 17 additions & 0 deletions tests/cyl/test_cylOperators.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

import discretize
from discretize import tests
import pytest

np.random.seed(16)

@@ -423,6 +424,22 @@ def test_order(self):
self.orderTest()


@pytest.mark.parametrize("mesh_type", MESHTYPES + ["uniform_symmetric_CylMesh"])
def test_ave_edge_to_face(mesh_type):
def get_error(n_cells):
mesh, h = tests.setup_mesh(mesh_type, n_cells, 3)

fun = lambda r, t, z: np.sin(np.pi * z) * np.sin(np.pi * r) * np.cos(t)
Ee = fun(*mesh.edges.T)

ave = mesh.average_edge_to_face @ Ee
ana = fun(*mesh.faces.T)
err = np.linalg.norm((ave - ana), np.inf)
return err, h

tests.assert_expected_order(get_error, [8, 16, 32, 64])


class EdgeInnerProductFctsIsotropic(object):
def fcts(self):
h = sympy.Matrix(