| 1 | # Copyright (C) 2008-2012 Robert C. Kirby (Texas Tech University) |
| 2 | # Modified by Andrew T. T. McRae (Imperial College London) |
| 3 | # |
| 4 | # This file is part of FIAT (https://www.fenicsproject.org) |
| 5 | # |
| 6 | # SPDX-License-Identifier: LGPL-3.0-or-later |
| 7 | |
| 8 | from FIATscip-python python fenics-fiat 2019.2.0.dev0 FIAT/__init__: import (finite_elementscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/__init__:, quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/__init__:, functionalscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/__init__:, dual_setscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.dual_set`/__init__:, |
| 9 | polynomial_setscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/__init__:, nedelecscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.nedelec`/__init__:) |
| 10 | from FIAT.check_format_variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.check_format_variant`/__init__: import check_format_variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.check_format_variant`/check_format_variant(). |
| 11 | |
| 12 | |
| 13 | class BDMDualSetscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#(dual_setscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.dual_set`/__init__:.DualSetscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.dual_set`/DualSet#): |
| 14 | def __init__scip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(selfscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(self), ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree), variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(variant), quad_degscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(quad_deg)): |
| 15 | |
| 16 | # Initialize containers for map: mesh_entity -> dof number and |
| 17 | # dual basis |
| 18 | entity_ids = {} |
| 19 | nodes = [] |
| 20 | |
| 21 | sd = ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el).get_spatial_dimension() |
| 22 | t = ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el).get_topology() |
| 23 | |
| 24 | if variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(variant) == "integral": |
| 25 | facet = ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el).get_facet_element() |
| 26 | # Facet nodes are \int_F v\cdot n p ds where p \in P_{q-1} |
| 27 | # degree is q - 1 |
| 28 | Q = quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/__init__:.make_quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/make_quadrature().(facet, quad_degscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(quad_deg)) |
| 29 | Pq = polynomial_setscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/__init__:.ONPolynomialSetscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/ONPolynomialSet#(facet, degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree)) |
| 30 | Pq_at_qpts = Pq.tabulatescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/PolynomialSet#tabulate().(Q.get_pointsscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/QuadratureRule#get_points().())[tuplescip-python python python-stdlib 3.11 builtins/tuple#([0]*(sd - 1))] |
| 31 | for f in rangescip-python python python-stdlib 3.11 builtins/range#(len(t[sd - 1])): |
| 32 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(Pq_at_qpts.shape[0]): |
| 33 | phi = Pq_at_qpts[i, :] |
| 34 | nodes.appendscip-python python python-stdlib 3.11 builtins/list#append().(functionalscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/__init__:.IntegralMomentOfScaledNormalEvaluationscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/IntegralMomentOfScaledNormalEvaluation#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), Q, phi, f)) |
| 35 | |
| 36 | # internal nodes |
| 37 | if degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree) > 1: |
| 38 | Q = quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/__init__:.make_quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/make_quadrature().(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), quad_degscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(quad_deg)) |
| 39 | qpts = Q.get_pointsscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/QuadratureRule#get_points().() |
| 40 | Nedel = nedelecscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.nedelec`/__init__:.Nedelecscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.nedelec`/Nedelec#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree) - 1, variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(variant)) |
| 41 | Nedfs = Nedel.get_nodal_basisscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/CiarletElement#get_nodal_basis().() |
| 42 | zero_index = tuplescip-python python python-stdlib 3.11 builtins/tuple#([0 for i in rangescip-python python python-stdlib 3.11 builtins/range#(sd)]) |
| 43 | Ned_at_qpts = Nedfs.tabulatescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/PolynomialSet#tabulate().(qpts)[zero_index] |
| 44 | |
| 45 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(Ned_at_qpts)): |
| 46 | phi_cur = Ned_at_qpts[i, :] |
| 47 | l_cur = functionalscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/__init__:.FrobeniusIntegralMomentscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/FrobeniusIntegralMoment#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), Q, phi_cur) |
| 48 | nodes.appendscip-python python python-stdlib 3.11 builtins/list#append().(l_cur) |
| 49 | |
| 50 | elif variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(variant) == "point": |
| 51 | # Define each functional for the dual set |
| 52 | # codimension 1 facets |
| 53 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(t[sd - 1])): |
| 54 | pts_cur = ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el).make_points(sd - 1, i, sd + degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree)) |
| 55 | for j in rangescip-python python python-stdlib 3.11 builtins/range#(len(pts_cur)): |
| 56 | pt_cur = pts_cur[j] |
| 57 | f = functionalscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/__init__:.PointScaledNormalEvaluationscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/PointScaledNormalEvaluation#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), i, pt_cur) |
| 58 | nodes.appendscip-python python python-stdlib 3.11 builtins/list#append().(f) |
| 59 | |
| 60 | # internal nodes |
| 61 | if degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree) > 1: |
| 62 | Q = quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/__init__:.make_quadraturescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/make_quadrature().(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), 2 * (degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree) + 1)) |
| 63 | qpts = Q.get_pointsscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.quadrature`/QuadratureRule#get_points().() |
| 64 | Nedel = nedelecscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.nedelec`/__init__:.Nedelecscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.nedelec`/Nedelec#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree) - 1, variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(variant)) |
| 65 | Nedfs = Nedel.get_nodal_basisscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/CiarletElement#get_nodal_basis().() |
| 66 | zero_index = tuplescip-python python python-stdlib 3.11 builtins/tuple#([0 for i in rangescip-python python python-stdlib 3.11 builtins/range#(sd)]) |
| 67 | Ned_at_qpts = Nedfs.tabulatescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/PolynomialSet#tabulate().(qpts)[zero_index] |
| 68 | |
| 69 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(Ned_at_qpts)): |
| 70 | phi_cur = Ned_at_qpts[i, :] |
| 71 | l_cur = functionalscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/__init__:.FrobeniusIntegralMomentscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.functional`/FrobeniusIntegralMoment#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), Q, phi_cur) |
| 72 | nodes.appendscip-python python python-stdlib 3.11 builtins/list#append().(l_cur) |
| 73 | |
| 74 | # sets vertices (and in 3d, edges) to have no nodes |
| 75 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(sd - 1): |
| 76 | entity_ids[i] = {} |
| 77 | for j in rangescip-python python python-stdlib 3.11 builtins/range#(len(t[i])): |
| 78 | entity_ids[i][j] = [] |
| 79 | |
| 80 | cur = 0 |
| 81 | |
| 82 | # set codimension 1 (edges 2d, faces 3d) dof |
| 83 | pts_facet_0 = ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el).make_points(sd - 1, 0, sd + degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree)) |
| 84 | pts_per_facet = len(pts_facet_0) |
| 85 | |
| 86 | entity_ids[sd - 1] = {} |
| 87 | for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(t[sd - 1])): |
| 88 | entity_ids[sd - 1][i] = listscip-python python python-stdlib 3.11 builtins/list#(rangescip-python python python-stdlib 3.11 builtins/range#(cur, cur + pts_per_facet)) |
| 89 | cur += pts_per_facet |
| 90 | |
| 91 | # internal nodes, if applicable |
| 92 | entity_ids[sd] = {0: []} |
| 93 | |
| 94 | if degreescip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(degree) > 1: |
| 95 | num_internal_nodes = len(Ned_at_qpts) |
| 96 | entity_ids[sd][0] = listscip-python python python-stdlib 3.11 builtins/list#(rangescip-python python python-stdlib 3.11 builtins/range#(cur, cur + num_internal_nodes)) |
| 97 | |
| 98 | superscip-python python python-stdlib 3.11 builtins/super#(BDMDualSetscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#, selfscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(self)).__init__scip-python python fenics-fiat 2019.2.0.dev0 `FIAT.dual_set`/DualSet#__init__().(nodes, ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#__init__().(ref_el), entity_ids) |
| 99 | |
| 100 | |
| 101 | class BrezziDouglasMariniscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#(finite_elementscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/__init__:.CiarletElementscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/CiarletElement#): |
| 102 | """ |
| 103 | The BDM element |
| 104 | |
| 105 | :arg ref_el: The reference element. |
| 106 | :arg k: The degree. |
| 107 | :arg variant: optional variant specifying the types of nodes. |
| 108 | |
| 109 | variant can be chosen from ["point", "integral", "integral(quadrature_degree)"] |
| 110 | "point" -> dofs are evaluated by point evaluation. Note that this variant has suboptimal |
| 111 | convergence order in the H(div)-norm |
| 112 | "integral" -> dofs are evaluated by quadrature rule. The quadrature degree is chosen to integrate |
| 113 | polynomials of degree 5*k so that most expressions will be interpolated exactly. This is important |
| 114 | when you want to have (nearly) divergence-preserving interpolation. |
| 115 | "integral(quadrature_degree)" -> dofs are evaluated by quadrature rule of degree quadrature_degree |
| 116 | """ |
| 117 | |
| 118 | def __init__scip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(selfscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(self), ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(ref_el), kscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(k), variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(variant)=None): |
| 119 | |
| 120 | (variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(variant), quad_deg) = check_format_variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.check_format_variant`/check_format_variant().(variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(variant), kscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(k), "BDM") |
| 121 | |
| 122 | if kscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(k) < 1: |
| 123 | raise Exceptionscip-python python python-stdlib 3.11 builtins/Exception#("BDM_k elements only valid for k >= 1") |
| 124 | |
| 125 | sd = ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(ref_el).get_spatial_dimension() |
| 126 | poly_set = polynomial_setscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/__init__:.ONPolynomialSetscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.polynomial_set`/ONPolynomialSet#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(ref_el), kscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(k), (sd, )) |
| 127 | dual = BDMDualSetscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BDMDualSet#(ref_elscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(ref_el), kscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(k), variantscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(variant), quad_deg) |
| 128 | formdegree = sd - 1 # (n-1)-form |
| 129 | superscip-python python python-stdlib 3.11 builtins/super#(BrezziDouglasMariniscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#, selfscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(self)).__init__scip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/CiarletElement#__init__().(poly_set, dual, kscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.brezzi_douglas_marini`/BrezziDouglasMarini#__init__().(k), formdegree, |
| 130 | mappingscip-python python fenics-fiat 2019.2.0.dev0 `FIAT.finite_element`/CiarletElement#__init__().(mapping)="contravariant piola") |