/usr/lib/python2.7/dist-packages/ffc/timeelements.py is in python-ffc 1.6.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 | # Copyright (C) 2012 Benjamin Kehlet
#
# This file is part of FFC.
#
# FFC 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.
#
# FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>.
#
# Modified by Marie E. Rognes, 2012
#
# First added: 2012-08-15
# Last changed: 2012-09-07
from FIAT import finite_element, polynomial_set, dual_set, functional, reference_element
import ffc_time_ext.time_elements_ext as ext
import numpy
class TimeElementDualSet(dual_set.DualSet):
""". """
def __init__(self, family, degree):
assert(family == "Lobatto" or family == "Radau"), \
"Unknown time element '%s'" % family
if family == "Lobatto" :
assert (degree > 0), "Lobatto not defined for degree < 1!"
else :
assert(degree >= 0), "Degree must be >= 0"
# ids is a map from mesh entity (numbers) to dof numbers
ids = {}
# dofs is a list of functionals
dofs = []
# Only defined in 1D (on an inteval)
cell = reference_element.UFCInterval()
self.coords = (ext.compute_lobatto_points(degree) if family == "Lobatto"
else ext.compute_radau_points(degree))
points = [(c,) for c in self.coords]
# Create dofs from points
dofs = [functional.PointEvaluation(cell, point)
for point in points]
# Create ids
if family == "Lobatto":
ids[0] = {0: [0], 1: [len(points)-1]}
ids[1] = {0: list(range(1, len(points)-1))}
elif family == "Radau":
ids[0] = {0: [], 1: []}
ids[1] = {0: list(range(len(points)))} # Treat all Radau points as internal
else:
error("Undefined family: %s" % family)
# Initialize dual set
dual_set.DualSet.__init__(self, dofs, cell, ids)
class TimeElement(finite_element.FiniteElement):
"""."""
def __init__(self, family, degree):
"Create time element with given (polynomial degree)."
# Only defined in 1D (on an inteval)
cell = reference_element.UFCInterval()
# Initialize polynomial space of degree 'degree'
polynomial_space = polynomial_set.ONPolynomialSet(cell, degree)
# Create dual (degrees of freedom)
dual = TimeElementDualSet(family, degree)
# Initialize super class
finite_element.FiniteElement.__init__(self,
polynomial_space,
dual,
degree
)
def compute_quadrature_weights(self) :
"""Compute the quadrature weights by solving a linear system of equations
for exact integration of polynomials. We compute the integrals over
[-1,1] of the Legendre polynomials of degree <= n - 1; These integrals
are all zero, except for the integral of P0 which is 2.
This requires that the n-point quadrature rule is exact at least for
polynomials of degree n-1."""
n = len(self.dual.coords)
# Special case n = 0
if n == 0 :
weights[0] = 2.0;
return weights
# Initialize linear system
A = ext.compute_legendre_coeffs(self.dual.coords)
b = numpy.zeros(n)
b[0] = 2.0
weights = numpy.linalg.solve(A, b)
# Weights are computed on interval [-1, 1]. Scale to reference interval
return weights/2.0
class LobattoElement(TimeElement):
"""."""
def __init__(self, degree):
"Create Lobatto element with given (polynomial degree)."
TimeElement.__init__(self, "Lobatto", degree)
class RadauElement(TimeElement):
"""."""
def __init__(self, degree):
"Create Radau element with given (polynomial degree)."
TimeElement.__init__(self, "Radau", degree)
|