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

Construct differentiation matrix without sympy #47

Merged
merged 80 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
f65112f
Tabulate Dubiner basis using Duffy transform
pbrubeck Oct 27, 2023
45b4385
test derivatives
pbrubeck Oct 27, 2023
fb37c22
Fixed some bugs
pbrubeck Oct 27, 2023
e6f2953
dmat without sympy
pbrubeck Oct 28, 2023
aa57e50
ExpansionSet base class with make_dmats method
pbrubeck Oct 28, 2023
cd9adca
Abstract ExpansionSet constructor
pbrubeck Oct 28, 2023
46cfb34
fix most tests
pbrubeck Oct 28, 2023
1ff2114
remove get_expansion_set from regression tests
pbrubeck Oct 28, 2023
b3a488d
remove math.prod, test up to degree 7 in 2D/3D
pbrubeck Oct 28, 2023
48b932a
style
pbrubeck Oct 28, 2023
11e3468
style
pbrubeck Oct 28, 2023
28d35bc
Lazy dmats
pbrubeck Oct 29, 2023
cc48c59
Unlazy dmats for NodalEnrichedElement
pbrubeck Oct 29, 2023
f48ea4f
NodalEnrichedElement only uses a single expansion set, the dmat can t…
pbrubeck Oct 29, 2023
daaab1e
super constructor for ExpansionSet
pbrubeck Oct 29, 2023
9064496
Common Duffy tabulation
pbrubeck Oct 29, 2023
7cfb083
DefaultPoint
pbrubeck Oct 29, 2023
f3bacd1
refactoring, some comments
pbrubeck Oct 29, 2023
02dcf7a
move derivative tabulation from PolynomialSet to ExpansionSet
pbrubeck Oct 30, 2023
c0067a7
restor form_matrix_product
pbrubeck Oct 31, 2023
220f221
Hand-written differentation of recurrence relations
pbrubeck Oct 31, 2023
2dd8670
derivative recursion, but wrong result
pbrubeck Oct 31, 2023
bac180c
Derivative recurrence passing tests
pbrubeck Oct 31, 2023
d213473
remove Duffy, tidy up
pbrubeck Oct 31, 2023
807e340
cleanup
pbrubeck Oct 31, 2023
f1024b1
Unify across dimension of simplex
pbrubeck Nov 1, 2023
b452e27
cleanup
pbrubeck Nov 1, 2023
404e30d
tidy up recurrence
pbrubeck Nov 1, 2023
f35b8fc
style
pbrubeck Nov 1, 2023
19d9536
refactoring
pbrubeck Nov 1, 2023
a3de199
GLL interpolation test
pbrubeck Nov 3, 2023
aec9a08
Docstrings
pbrubeck Nov 3, 2023
ea382db
cleanup
pbrubeck Nov 3, 2023
de881f5
Fix some broken tests
pbrubeck Nov 3, 2023
efd4132
Test with python 3.8-3.9
pbrubeck Nov 4, 2023
897f1d4
add recursivenodes as a dependency
pbrubeck Nov 4, 2023
26e2db4
typo
pbrubeck Nov 4, 2023
5f60e9b
fix tests
pbrubeck Nov 4, 2023
a5be097
tabulate_derivatives without _tabulate_dpts
pbrubeck Nov 4, 2023
7bbb3af
Fix tabulate_jet
pbrubeck Nov 5, 2023
2eae684
normalize inside recurrence()
pbrubeck Nov 5, 2023
c3690ce
Merge branch 'pbrubeck/recursive-nodes' into pbrubeck/dmat-without-sympy
pbrubeck Nov 5, 2023
21c429e
cleanup
pbrubeck Nov 5, 2023
eae8bf4
Test orthogonality, more unified recurrences
pbrubeck Nov 5, 2023
505e669
even more unified recurrence
pbrubeck Nov 6, 2023
375590a
unify factors
pbrubeck Nov 6, 2023
1eb4774
test a few expansion values
pbrubeck Nov 6, 2023
dc98d15
fully unified recurrences
pbrubeck Nov 6, 2023
0f1a101
variants for BDM, RT, and Nedelec?
pbrubeck Nov 6, 2023
c7d51b8
Extend lattice_iter to 0D
pbrubeck Nov 6, 2023
79a47d0
revert some changes
pbrubeck Nov 6, 2023
553673c
revert tests
pbrubeck Nov 6, 2023
85c505b
remove _tabulate_dpts
pbrubeck Nov 6, 2023
f9f88a7
untested hessian
pbrubeck Nov 6, 2023
890adb7
better reindexing
pbrubeck Nov 6, 2023
34f622c
fix tabulate_jet
pbrubeck Nov 7, 2023
8a86dbe
do not append empty tuples
pbrubeck Nov 7, 2023
35d527b
flake
pbrubeck Nov 7, 2023
28afe6a
fix some indices
pbrubeck Nov 7, 2023
6c9fb0d
fix more indices
pbrubeck Nov 7, 2023
127b26f
Add a test to catch np.linalg.solve silently producing a wrong answer
rckirby Nov 7, 2023
8b0382b
update tolerance so rest of tests pass
rckirby Nov 7, 2023
2b78af7
QR on dualmat makes illposed tests throw a singular matrix error, whi…
pbrubeck Nov 7, 2023
86a80b0
cleanup
pbrubeck Nov 8, 2023
4453505
cleanup test_expansion_values
pbrubeck Nov 8, 2023
d7f8f04
Assert that errors decrease exponentially
pbrubeck Nov 8, 2023
51e91ab
cleanup, fuse _tabulate and _tabulate_derivatives
pbrubeck Nov 8, 2023
dc2ea6c
Second derivative recurrence is working properly
pbrubeck Nov 8, 2023
5e4cb01
flake
pbrubeck Nov 8, 2023
5b8f4e4
restore point variant
pbrubeck Nov 9, 2023
163f6a3
merge conflict
pbrubeck Nov 9, 2023
94c6729
cleanup
pbrubeck Nov 9, 2023
d3c0a11
Test exponential convergence and for condition number growth
pbrubeck Nov 9, 2023
348585c
merge confict
pbrubeck Nov 9, 2023
d5bd556
QR on Vandermonde matrix to detect singular system
pbrubeck Nov 9, 2023
b0173d4
Solve Vandermonde with scipy LU
pbrubeck Nov 9, 2023
05d36c9
revert num_exp_function to use polynomial_dimension
pbrubeck Nov 9, 2023
68c57e8
test that DG(point, 1) raises ValueError
pbrubeck Nov 9, 2023
f628a01
avoid tiny roundoff error showing in CI
pbrubeck Nov 9, 2023
ae09667
Use ONPolynomialSet for equispaced Lagrange
pbrubeck Nov 10, 2023
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
32 changes: 17 additions & 15 deletions FIAT/barycentric_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class LagrangeLineExpansionSet(expansions.LineExpansionSet):
via the second barycentric interpolation formula. See Berrut and Trefethen (2004)
https://doi.org/10.1137/S0036144502417715 Eq. (4.2) & (9.4)
"""

def __init__(self, ref_el, pts):
self.nodes = numpy.array(pts).flatten()
self.dmat, self.weights = make_dmat(self.nodes)
Expand All @@ -37,6 +36,9 @@ def __init__(self, ref_el, pts):
def get_num_members(self, n):
return len(self.nodes)

def get_dmats(self, degree):
return [self.dmat.T]

def tabulate(self, n, pts):
assert n == len(self.nodes)-1
results = numpy.add.outer(-self.nodes, numpy.array(pts).flatten())
Expand All @@ -51,8 +53,15 @@ def tabulate(self, n, pts):
results = numpy.array(list(map(simplify, results)))
return results

def tabulate_derivatives(self, n, pts):
return numpy.dot(self.dmat, self.tabulate(n, pts))
def _tabulate(self, n, pts, order=0):
results = [self.tabulate(n, pts)]
for r in range(order):
results.append(numpy.dot(self.dmat, results[-1]))
for r in range(order+1):
shape = results[r].shape
shape = shape[:1] + (1,)*r + shape[1:]
results[r] = numpy.reshape(results[r], shape)
return results


class LagrangePolynomialSet(polynomial_set.PolynomialSet):
Expand All @@ -67,7 +76,10 @@ def __init__(self, ref_el, pts, shape=tuple()):
num_exp_functions = expansions.polynomial_dimension(ref_el, degree)
num_members = num_components * num_exp_functions
embedded_degree = degree
expansion_set = get_expansion_set(ref_el, pts)
if ref_el.get_shape() == reference_element.LINE:
expansion_set = LagrangeLineExpansionSet(ref_el, pts)
else:
raise ValueError("Invalid reference element type.")

# set up coefficients
if shape == tuple():
Expand All @@ -84,15 +96,5 @@ def __init__(self, ref_el, pts, shape=tuple()):
coeffs[cur_idx] = 1.0
cur_bf += 1

dmats = [numpy.transpose(expansion_set.dmat)]
super(LagrangePolynomialSet, self).__init__(ref_el, degree, embedded_degree,
expansion_set, coeffs, dmats)


def get_expansion_set(ref_el, pts):
"""Returns an ExpansionSet instance appopriate for the given
reference element."""
if ref_el.get_shape() == reference_element.LINE:
return LagrangeLineExpansionSet(ref_el, pts)
else:
raise ValueError("Invalid reference element type.")
expansion_set, coeffs)
3 changes: 1 addition & 2 deletions FIAT/brezzi_douglas_fortin_marini.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def BDFMSpace(ref_el, order):
order,
order,
vec_poly_set.get_expansion_set(),
new_coeffs,
vec_poly_set.get_dmats())
new_coeffs)

element_set = polynomial_set.polynomial_set_union_normalized(bubble_set, vec_poly_set)
return element_set
Expand Down
Loading
Loading