This file is indexed.

/usr/lib/python3/dist-packages/FIAT/enriched.py is in python3-fiat 2017.2.0.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Copyright (C) 2013 Andrew T. T. McRae, 2015-2016 Jan Blechta, 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/>.

from __future__ import absolute_import, print_function, division

from itertools import chain

import numpy

from FIAT.finite_element import FiniteElement
from FIAT.dual_set import DualSet
from FIAT.mixed import concatenate_entity_dofs


__all__ = ['EnrichedElement']


class EnrichedElement(FiniteElement):
    """Class implementing a finite element that combined the degrees of freedom
    of two existing finite elements.

    This is an implementation which does not care about orthogonality of
    primal and dual basis.
    """

    def __init__(self, *elements):
        # Firstly, check it makes sense to enrich.  Elements must have:
        # - same reference element
        # - same mapping
        # - same value shape
        if len(set(e.get_reference_element() for e in elements)) > 1:
            raise ValueError("Elements must be defined on the same reference element")
        if len(set(m for e in elements for m in e.mapping())) > 1:
            raise ValueError("Elements must have same mapping")
        if len(set(e.value_shape() for e in elements)) > 1:
            raise ValueError("Elements must have the same value shape")

        # order is at least max, possibly more, though getting this
        # right isn't important AFAIK
        order = max(e.get_order() for e in elements)
        # form degree is essentially max (not true for Hdiv/Hcurl,
        # but this will raise an error above anyway).
        # E.g. an H^1 function enriched with an L^2 is now just L^2.
        if any(e.get_formdegree() is None for e in elements):
            formdegree = None
        else:
            formdegree = max(e.get_formdegree() for e in elements)

        # set up reference element and mapping, following checks above
        ref_el, = set(e.get_reference_element() for e in elements)
        mapping, = set(m for e in elements for m in e.mapping())

        # set up entity_ids - for each geometric entity, just concatenate
        # the entities of the constituent elements
        entity_ids = concatenate_entity_dofs(ref_el, elements)

        # set up dual basis - just concatenation
        nodes = list(chain.from_iterable(e.dual_basis() for e in elements))
        dual = DualSet(nodes, ref_el, entity_ids)

        super(EnrichedElement, self).__init__(ref_el, dual, order, formdegree, mapping)

        # required degree (for quadrature) is definitely max
        self.polydegree = max(e.degree() for e in elements)

        # Store subelements
        self._elements = elements

    def elements(self):
        "Return reference to original subelements"
        return self._elements

    def degree(self):
        """Return the degree of the (embedding) polynomial space."""
        return self.polydegree

    def get_nodal_basis(self):
        """Return the nodal basis, encoded as a PolynomialSet object,
        for the finite element."""
        raise NotImplementedError("get_nodal_basis not implemented")

    def get_coeffs(self):
        """Return the expansion coefficients for the basis of the
        finite element."""
        raise NotImplementedError("get_coeffs not implemented")

    def tabulate(self, order, points, entity=None):
        """Return tabulated values of derivatives up to given order of
        basis functions at given points."""

        num_components = numpy.prod(self.value_shape())
        table_shape = (self.space_dimension(), num_components, len(points))

        table = {}
        irange = slice(0)
        for element in self._elements:

            etable = element.tabulate(order, points, entity)
            irange = slice(irange.stop, irange.stop + element.space_dimension())

            # Insert element table into table
            for dtuple in etable.keys():

                if dtuple not in table:
                    if num_components == 1:
                        table[dtuple] = numpy.zeros((self.space_dimension(), len(points)),
                                                    dtype=etable[dtuple].dtype)
                    else:
                        table[dtuple] = numpy.zeros(table_shape,
                                                    dtype=etable[dtuple].dtype)

                table[dtuple][irange][:] = etable[dtuple]

        return table

    def value_shape(self):
        """Return the value shape of the finite element functions."""
        result, = set(e.value_shape() for e in self._elements)
        return result

    def dmats(self):
        """Return dmats: expansion coefficients for basis function
        derivatives."""
        raise NotImplementedError("dmats not implemented")

    def get_num_members(self, arg):
        """Return number of members of the expansion set."""
        raise NotImplementedError("get_num_members not implemented")