This file is indexed.

/usr/lib/python2.7/dist-packages/ffc/uflacs/backends/ufc/form.py is in python-ffc 2016.2.0-1.

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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -*- coding: utf-8 -*-
# Copyright (C) 2009-2016 Anders Logg and Martin Sandve Alnæs
#
# This file is part of UFLACS.
#
# UFLACS 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.
#
# UFLACS 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 UFLACS. If not, see <http://www.gnu.org/licenses/>.

# Note: Most of the code in this file is a direct translation from the old implementation in FFC

from ffc.cpp import make_integral_classname
from ffc.uflacs.backends.ufc.generator import ufc_generator, integral_name_templates, ufc_integral_types
from ffc.uflacs.backends.ufc.utils import generate_return_new, generate_return_new_switch


def add_ufc_form_integral_methods(cls):
    """This function generates methods on the class it decorates,
    for each integral name template and for each integral type.

    This allows implementing e.g. create_###_integrals once in the
    decorated class as '_create_foo_integrals', and this function will
    expand that implementation into 'create_cell_integrals',
    'create_exterior_facet_integrals', etc.

    Name templates are taken from 'integral_name_templates' and 'ufc_integral_types'.
    """
    # The dummy name "foo" is chosen for familiarity for ffc developers
    dummy_integral_type = "foo"

    for template in integral_name_templates:
        implname = "_" + (template % (dummy_integral_type,))
        impl = getattr(cls, implname)
        for integral_type in ufc_integral_types:
            declname = template % (integral_type,)

            # Binding variables explicitly because Python closures don't
            # capture the value of integral_type for each iteration here
            def _delegate(self, L, ir, integral_type=integral_type, declname=declname, impl=impl):
                return impl(self, L, ir, integral_type, declname)
            _delegate.__doc__ = impl.__doc__ % {"declname": declname, "integral_type": integral_type}

            setattr(cls, declname, _delegate)
    return cls


@add_ufc_form_integral_methods
class ufc_form(ufc_generator):
    def __init__(self):
        ufc_generator.__init__(self, "form")

    def topological_dimension(self, L, ir):
        "Default implementation of returning topological dimension fetched from ir."
        tdim = ir["topological_dimension"]
        return L.Return(L.LiteralInt(tdim))

    def geometric_dimension(self, L, ir):
        "Default implementation of returning geometric dimension fetched from ir."
        gdim = ir["geometric_dimension"]
        return L.Return(L.LiteralInt(gdim))

    def num_coefficients(self, L, ir):
        value = ir["num_coefficients"]
        return L.Return(L.LiteralInt(value))

    def rank(self, L, ir):
        value = ir["rank"]
        return L.Return(L.LiteralInt(value))

    def original_coefficient_position(self, L, ir):
        i = L.Symbol("i")

        positions = ir["original_coefficient_position"]

        position = L.Symbol("position")

        # Throwing a lot into the 'typename' string here but
        # no plans for building a full C++ type system
        typename = "static const std::vector<std::size_t>"
        initializer_list = L.VerbatimExpr("{" + ", ".join(str(i) for i in positions) + "}")
        code = L.StatementList([
            L.VariableDecl(typename, position, value=initializer_list),
            L.Return(position[i]),
            ])
        return code


    def create_coordinate_finite_element(self, L, ir):
        classnames = ir["create_coordinate_finite_element"]
        assert len(classnames) == 1
        return generate_return_new(L, classnames[0], factory=ir["jit"])

    def create_coordinate_dofmap(self, L, ir):
        classnames = ir["create_coordinate_dofmap"]
        assert len(classnames) == 1
        return generate_return_new(L, classnames[0], factory=ir["jit"])

    def create_coordinate_mapping(self, L, ir):
        classnames = ir["create_coordinate_mapping"]
        assert len(classnames) == 1
        return generate_return_new(L, classnames[0], factory=ir["jit"])

    def create_finite_element(self, L, ir):
        i = L.Symbol("i")
        classnames = ir["create_finite_element"]
        return generate_return_new_switch(L, i, classnames, factory=ir["jit"])

    def create_dofmap(self, L, ir):
        i = L.Symbol("i")
        classnames = ir["create_dofmap"]
        return generate_return_new_switch(L, i, classnames, factory=ir["jit"])


    # This group of functions are repeated for each
    # foo_integral by add_ufc_form_integral_methods:
    
    def _max_foo_subdomain_id(self, L, ir, integral_type, declname):
        "Return implementation of ufc::form::%(declname)s()."
        # e.g. max_subdomain_id = ir["max_cell_subdomain_id"]
        max_subdomain_id = ir[declname]
        return L.Return(L.LiteralInt(max_subdomain_id))

    def _has_foo_integrals(self, L, ir, integral_type, declname):
        "Return implementation of ufc::form::%(declname)s()."
        # e.g. has_integrals = ir["has_cell_integrals"]
        has_integrals = ir[declname]
        return L.Return(L.LiteralBool(has_integrals))

    def _create_foo_integral(self, L, ir, integral_type, declname):
        "Return implementation of ufc::form::%(declname)s()."
        #print("CREATE_FOO_INTEGRAL", id(ir), ir)
        form_id = ir["id"]
        prefix = ir["prefix"]
        subdomain_id = L.Symbol("subdomain_id")
        subdomain_ids = ir[declname] # e.g. ir["create_cell_integral"]
        classnames = [make_integral_classname(prefix, integral_type, form_id, i)
                      for i in subdomain_ids]
        return generate_return_new_switch(L, subdomain_id, classnames,
                                          subdomain_ids, factory=ir["jit"])

    def _create_default_foo_integral(self, L, ir, integral_type, declname):
        "Return implementation of ufc::form::%(declname)s()."
        subdomain_id = ir[declname] # e.g. ir["create_default_cell_integral"]
        if subdomain_id is None:
            return L.Return(L.Null())
        else:
            form_id = ir["id"]
            prefix = ir["prefix"]
            classname = make_integral_classname(prefix, integral_type, form_id, subdomain_id)
            return generate_return_new(L, classname, factory=ir["jit"])