This file is indexed.

/usr/lib/python2.7/dist-packages/ufl/domains.py is in python-ufl 1.3.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
160
161
162
"Types for specification of domains and subdomain relations."

# Copyright (C) 2013 Martin Sandve Alnes
#
# This file is part of UFL.
#
# UFL 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.
#
# UFL 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 UFL. If not, see <http://www.gnu.org/licenses/>.
#
# First added:  2013-01-10
# Last changed: 2013-01-10

from ufl.log import warning, error
from ufl.assertions import ufl_assert
from ufl.common import istr
from ufl.terminal import Terminal

from ufl.geometry import as_cell, Cell

class DomainDescription(object):
    __slots__ = ('_cell',
                 '_name',
                 '_gdim',
                 '_tdim',
                 )
    def __init__(self, cell, name, gdim, tdim):
        ufl_assert(isinstance(cell, Cell), "Expecting a Cell.")

        self._cell = cell
        self._name = name or "%s_%s" % (cell.cellname(), "multiverse")
        self._gdim = gdim or cell.geometric_dimension()
        self._tdim = tdim or cell.topological_dimension()

        ufl_assert(isinstance(self._name, str), "Expecting a string.")
        ufl_assert(isinstance(self._gdim, int), "Expecting an integer.")
        ufl_assert(isinstance(self._tdim, int), "Expecting an integer.")

    def geometric_dimension(self):
        return self._gdim

    def topological_dimension(self):
        return self._tdim

    def cell(self):
        return self._cell

    def name(self):
        return self._name

    def top_domain(self):
        raise NotImplementedException("Missing implementation of top_domain.")

    def __eq__(self, other):
        return (isinstance(other, DomainDescription)
                and self._cell == other._cell
                and self._name == other._name
                and self._gdim == other._gdim
                and self._tdim == other._tdim)

    def __hash__(self):
        return hash(repr(self))

    def __lt__(self, other):
        return repr(self) < repr(other) # FIXME: Sort in a more predictable way

class Domain(DomainDescription):
    __slots__ = ()
    def __init__(self, cell, name=None, gdim=None, tdim=None):
        DomainDescription.__init__(self, cell, name, gdim, tdim)

    def __repr__(self):
        return "Domain(%r, %r, %r, %r)" % (self._cell, self._name,
                                           self._gdim, self._tdim)

    def __eq__(self, other):
        return (isinstance(other, Domain)
                and DomainDescription.__eq__(self, other))

    def top_domain(self):
        return self

    def subdomain_ids(self):
        return None

    def __getitem__(self, subdomain_id):
        if isinstance(subdomain_id, int):
            return Region(self, (subdomain_id,), "%s_%d" % (self._name, subdomain_id))
        else:
            error("Invalid subdomain label %r, expecting integer." % (subdomain_id,))

class Region(DomainDescription):
    __slots__ = ('_parent', '_subdomain_ids')
    def __init__(self, parent, subdomain_ids, name):
        DomainDescription.__init__(self, parent.cell(), name,
                                   parent._gdim, parent._tdim)
        self._parent = parent
        self._subdomain_ids = tuple(sorted(set(subdomain_ids)))
        ufl_assert(name != parent.name(), "Cannot assign same name to top level domain and region.")

    def top_domain(self):
        return self._parent

    def subdomain_ids(self):
        return self._subdomain_ids

    def __repr__(self):
        return "Region(%r, %r, %r)" % (self._parent, self._subdomain_ids, self._name)

    def __eq__(self, other):
        return (isinstance(other, Region)
                and self._parent == other._parent
                and self._subdomain_ids == other._subdomain_ids
                and DomainDescription.__eq__(self, other))

# Map cells to a default domain for compatibility and cache this:
_default_domains = {}
def as_domain(domain):
    if isinstance(domain, DomainDescription):
        return domain
    else:
        cell = as_cell(domain)
        if isinstance(cell, Cell):
            if cell not in _default_domains:
                _default_domains[cell] = Domain(cell)
            return _default_domains[cell]
        else:
            error("Invalid domain %s." % str(domain))

# TODO: Move somewhere else
def extract_top_domains(integrand):
    from ufl.terminal import FormArgument
    from ufl.algorithms.traversal import traverse_terminals
    top_domains = set()
    for t in traverse_terminals(integrand):
        if isinstance(t, FormArgument):
            domain = t.element().domain()
            if domain is not None:
                top_domains.add(domain.top_domain())
        # FIXME: Check geometry here too when that becomes necessary
    return sorted(top_domains)

def extract_domains(integrand):
    from ufl.terminal import FormArgument
    from ufl.algorithms.traversal import traverse_terminals
    regions = set()
    for t in traverse_terminals(integrand): # FIXME: Need to analyse which components of functions are actually referenced
        if isinstance(t, FormArgument):
            reg = t.element().regions() # FIXME: Implement
            regions.update(reg)
            regions.update(r.top_domain() for r in reg)
        # FIXME: Check geometry here too when that becomes necessary
    return sorted(regions)