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 branch 'master' into pbrubeck/fix/gll-ordering
- Loading branch information
Showing
8 changed files
with
268 additions
and
145 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
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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
# Copyright (C) 2024 Pablo D. Brubeck | ||
# | ||
# This file is part of FIAT (https://www.fenicsproject.org) | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
# | ||
# Written by Pablo D. Brubeck ([email protected]), 2024 | ||
|
||
from FIAT.functional import (PointEvaluation, PointDerivative, | ||
IntegralMoment, | ||
IntegralMomentOfNormalDerivative) | ||
from FIAT import finite_element, dual_set, macro, polynomial_set | ||
from FIAT.reference_element import TRIANGLE, ufc_simplex | ||
from FIAT.quadrature import FacetQuadratureRule | ||
from FIAT.quadrature_schemes import create_quadrature | ||
from FIAT.jacobi import eval_jacobi | ||
from FIAT.jacobi import eval_jacobi, eval_jacobi_batch, eval_jacobi_deriv_batch | ||
|
||
|
||
class HCTDualSet(dual_set.DualSet): | ||
def __init__(self, ref_el, degree, reduced=False): | ||
if degree != 3: | ||
raise ValueError("HCT only defined for degree=3") | ||
def __init__(self, ref_complex, degree, reduced=False): | ||
if reduced and degree != 3: | ||
raise ValueError("Reduced HCT only defined for degree = 3") | ||
if degree < 3: | ||
raise ValueError("HCT only defined for degree >= 3") | ||
ref_el = ref_complex.get_parent() | ||
if ref_el.get_shape() != TRIANGLE: | ||
raise ValueError("HCT only defined on triangles") | ||
top = ref_el.get_topology() | ||
|
@@ -27,24 +40,49 @@ def __init__(self, ref_el, degree, reduced=False): | |
nodes.extend(PointDerivative(ref_el, pt, alpha) for alpha in alphas) | ||
entity_ids[0][v].extend(range(cur, len(nodes))) | ||
|
||
k = 2 if reduced else degree - 3 | ||
rline = ufc_simplex(1) | ||
k = 2 if reduced else 0 | ||
Q = create_quadrature(rline, degree-1+k) | ||
qpts = Q.get_points() | ||
x, = qpts.T | ||
f_at_qpts = eval_jacobi(0, 0, k, 2.0*x - 1) | ||
for e in sorted(top[1]): | ||
cur = len(nodes) | ||
nodes.append(IntegralMomentOfNormalDerivative(ref_el, e, Q, f_at_qpts)) | ||
entity_ids[1][e].extend(range(cur, len(nodes))) | ||
if reduced: | ||
x, = qpts.T | ||
f_at_qpts = eval_jacobi(0, 0, k, 2.0*x - 1) | ||
for e in sorted(top[1]): | ||
cur = len(nodes) | ||
nodes.append(IntegralMomentOfNormalDerivative(ref_el, e, Q, f_at_qpts)) | ||
entity_ids[1][e].extend(range(cur, len(nodes))) | ||
else: | ||
x = 2.0*qpts - 1 | ||
phis = eval_jacobi_batch(2, 2, k, x) | ||
dphis = eval_jacobi_deriv_batch(2, 2, k, x) | ||
for e in sorted(top[1]): | ||
Q_mapped = FacetQuadratureRule(ref_el, 1, e, Q) | ||
scale = 2 / Q_mapped.jacobian_determinant() | ||
cur = len(nodes) | ||
nodes.extend(IntegralMomentOfNormalDerivative(ref_el, e, Q, phi) for phi in phis) | ||
nodes.extend(IntegralMoment(ref_el, Q_mapped, dphi * scale) for dphi in dphis[1:]) | ||
entity_ids[1][e].extend(range(cur, len(nodes))) | ||
|
||
q = degree - 4 | ||
if q >= 0: | ||
Q = create_quadrature(ref_complex, degree + q) | ||
Pq = polynomial_set.ONPolynomialSet(ref_el, q, scale=1) | ||
phis = Pq.tabulate(Q.get_points())[(0,) * sd] | ||
scale = 1 / ref_el.volume() | ||
cur = len(nodes) | ||
nodes.extend(IntegralMoment(ref_el, Q, phi * scale) for phi in phis) | ||
entity_ids[sd][0] = list(range(cur, len(nodes))) | ||
|
||
super(HCTDualSet, self).__init__(nodes, ref_el, entity_ids) | ||
|
||
|
||
class HsiehCloughTocher(finite_element.CiarletElement): | ||
"""The HCT finite element.""" | ||
|
||
"""The HCT macroelement. For degree higher than 3, we implement the | ||
super-smooth C^1 space from Groselj and Knez (2022) on a barycentric split, | ||
although there the basis functions are positive on an incenter split. | ||
""" | ||
def __init__(self, ref_el, degree=3, reduced=False): | ||
dual = HCTDualSet(ref_el, degree, reduced=reduced) | ||
poly_set = macro.CkPolynomialSet(macro.AlfeldSplit(ref_el), degree, variant=None) | ||
ref_complex = macro.AlfeldSplit(ref_el) | ||
dual = HCTDualSet(ref_complex, degree, reduced=reduced) | ||
poly_set = macro.CkPolynomialSet(ref_complex, degree, order=1, vorder=degree-1, variant="bubble") | ||
super(HsiehCloughTocher, self).__init__(poly_set, dual, degree) |
Oops, something went wrong.