forked from FEniCS/fiat
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from firedrakeproject/wence/fix/serendipity-de…
…rivs Broadcast result of lambdify in Serendipity tabulation
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 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
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,32 @@ | ||
from FIAT.reference_element import UFCQuadrilateral | ||
from FIAT import Serendipity | ||
import numpy as np | ||
import sympy | ||
|
||
|
||
def test_serendipity_derivatives(): | ||
cell = UFCQuadrilateral() | ||
S = Serendipity(cell, 2) | ||
|
||
x = sympy.DeferredVector("X") | ||
X, Y = x[0], x[1] | ||
basis_functions = [ | ||
(1 - X)*(1 - Y), | ||
Y*(1 - X), | ||
X*(1 - Y), | ||
X*Y, | ||
Y*(1 - X)*(Y - 1), | ||
X*Y*(Y - 1), | ||
X*(1 - Y)*(X - 1), | ||
X*Y*(X - 1), | ||
] | ||
points = [[0.5, 0.5], [0.25, 0.75]] | ||
for alpha, actual in S.tabulate(2, points).items(): | ||
expect = list(sympy.diff(basis, *zip([X, Y], alpha)) | ||
for basis in basis_functions) | ||
expect = list([basis.subs(dict(zip([X, Y], point))) | ||
for point in points] | ||
for basis in expect) | ||
assert actual.shape == (8, 2) | ||
assert np.allclose(np.asarray(expect, dtype=float), | ||
actual.reshape(8, 2)) |