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 #44 from firedrakeproject/radau
Radau points
- Loading branch information
Showing
5 changed files
with
155 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
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,36 @@ | ||
# Copyright (C) 2015 Imperial College London and others. | ||
# | ||
# This file is part of FIAT (https://www.fenicsproject.org) | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
# | ||
# Written by Robert C. Kirby ([email protected]), 2020 | ||
|
||
|
||
from FIAT import finite_element, polynomial_set, dual_set, functional, quadrature | ||
from FIAT.reference_element import LINE | ||
|
||
|
||
class GaussRadauDualSet(dual_set.DualSet): | ||
"""The dual basis for 1D discontinuous elements with nodes at the | ||
Gauss-Radau points.""" | ||
def __init__(self, ref_el, degree, right=True): | ||
# Do DG connectivity because it's bonkers to do one-sided assembly even | ||
# though we have an endpoint in the point set! | ||
entity_ids = {0: {0: [], 1: []}, | ||
1: {0: list(range(0, degree+1))}} | ||
lr = quadrature.RadauQuadratureLineRule(ref_el, degree+1, right) | ||
nodes = [functional.PointEvaluation(ref_el, x) for x in lr.pts] | ||
|
||
super(GaussRadauDualSet, self).__init__(nodes, ref_el, entity_ids) | ||
|
||
|
||
class GaussRadau(finite_element.CiarletElement): | ||
"""1D discontinuous element with nodes at the Gauss-Radau points.""" | ||
def __init__(self, ref_el, degree): | ||
if ref_el.shape != LINE: | ||
raise ValueError("Gauss-Radau elements are only defined in one dimension.") | ||
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree) | ||
dual = GaussRadauDualSet(ref_el, degree) | ||
formdegree = ref_el.get_spatial_dimension() # n-form | ||
super(GaussRadau, self).__init__(poly_set, dual, degree, formdegree) |
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,48 @@ | ||
# Copyright (C) 2016 Imperial College London and others | ||
# | ||
# This file is part of FIAT. | ||
# | ||
# FIAT is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# FIAT is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with FIAT. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Authors: | ||
# | ||
# Robert Kirby, based on work of David A. Ham | ||
# | ||
|
||
import pytest | ||
import numpy as np | ||
|
||
|
||
@pytest.mark.parametrize("degree", range(1, 7)) | ||
def test_gll_basis_values(degree): | ||
"""Ensure that integrating a simple monomial produces the expected results.""" | ||
from FIAT import ufc_simplex, GaussRadau, make_quadrature | ||
|
||
s = ufc_simplex(1) | ||
q = make_quadrature(s, degree + 1) | ||
|
||
fe = GaussRadau(s, degree) | ||
tab = fe.tabulate(0, q.pts)[(0,)] | ||
|
||
for test_degree in range(degree + 1): | ||
coefs = [n(lambda x: x[0]**test_degree) for n in fe.dual.nodes] | ||
integral = np.dot(coefs, np.dot(tab, q.wts)) | ||
reference = np.dot([x[0]**test_degree | ||
for x in q.pts], q.wts) | ||
assert np.allclose(integral, reference, rtol=1e-14) | ||
|
||
|
||
if __name__ == '__main__': | ||
import os | ||
pytest.main(os.path.abspath(__file__)) |
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