1
# Written by Robert C. Kirby
2
# Copyright 2005 by The University of Chicago
3
# Distributed under the LGPL license
4
# This work is partially supported by the US Department of Energy
5
# under award number DE-FG02-04ER25650
7
# Last modified 10 May 2005 by RCK
9
import functional, Numeric
11
#class DualBasis( functional.FunctionalList ):
12
class DualBasis( object ):
13
'''Creates the basis P\' which is dual to some space P.
14
ls is a list of functionals or a FunctionalList.
15
entity_ids is a dictionary mapping each mesh component to
16
the associated vertex numbers. The keys are integers for
17
the topological dimension, and each value is itself a
18
dictionary mapping the id of each entity of that topological
19
dimension to a list of ids for functionals associated with that
20
entity. E.g. for linear Lagrange elements on triangles, entity_ids
22
{ 0: {0: [0], 1: [1], 2: [2]}, \
23
1: {0: [] , 2: [], 2: []}, \
25
since there are three vertices (dimension 0),
26
each with one node each, and there are no nodes on the edges or
27
interior. Similarly, cubics would look like:
28
{ 0: {0: [0], 1:[1], 2:[2]}, \
29
1: {0: [3,4], 1:[5,6], 2:[7,8]}, \
31
num_reps is used to indicate a vector-valued space where
32
entity_ids is used for the first component and then
33
replicated num_reps-1 times additional times.
35
def __init__( self, node_set , entity_ids , num_reps = 1 ):
36
self.node_set = node_set
37
self.entity_ids = entity_ids
38
self.num_reps = num_reps
39
# self.mat is the matrix whose rows are the vectors
40
# associated with each functional
41
# Now, all the dual basis can be applied to a single
42
# item by a matrix-vector multiply
44
def get_functional_set( self ): return self.node_set
45
def getNodeIDs(self, dim):
47
return self.entity_ids[ dim ].values()
49
raise RuntimeError, "Illegal dimension for this dual basis"