-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from firedrake import * | ||
import pytest | ||
|
||
|
||
rg = RandomGenerator(PCG64(seed=1)) | ||
|
||
|
||
@pytest.fixture(params=("square", "cube")) | ||
def mesh(request): | ||
if request.param == "square": | ||
return UnitSquareMesh(2, 2) | ||
elif request.param == "cube": | ||
return UnitCubeMesh(2, 2, 2) | ||
else: | ||
raise ValueError("Unrecognized mesh type") | ||
|
||
|
||
@pytest.mark.parametrize("degree", (0, 1, 2)) | ||
@pytest.mark.parametrize("family", ("Regge", "HHJ")) | ||
def test_tensor_continuity(mesh, family, degree): | ||
V = FunctionSpace(mesh, family, degree) | ||
u = rg.beta(V, 1.0, 2.0) | ||
|
||
dim = mesh.topological_dimension() | ||
n = FacetNormal(mesh) | ||
|
||
space = V.ufl_element().sobolev_space | ||
if space == HDivDiv: | ||
utrace = dot(n, dot(u, n)) | ||
elif space == HEin: | ||
if dim == 2: | ||
t = dot(as_matrix([[0, -1], [1, 0]]), n) | ||
utrace = dot(t, dot(u, t)) | ||
else: | ||
t = as_matrix([[0, n[2], -n[1]], [-n[2], 0, n[0]], [n[1], -n[0], 0]]) | ||
utrace = dot(t, dot(u, t.T)) | ||
|
||
ujump = utrace('+') - utrace('-') | ||
assert assemble(inner(ujump, ujump)*dS) < 1E-10 |