~chaffra/fiat/main

« back to all changes in this revision

Viewing changes to FIAT/dualbasis.py

  • Committer: kirby
  • Date: 2005-05-31 15:03:57 UTC
  • Revision ID: devnull@localhost-20050531150357-n7ka5987yo6ylpaz
[project @ 2005-05-31 15:03:57 by kirby]
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
6
#
 
7
# Last modified 10 May 2005 by RCK
 
8
 
 
9
import functional, Numeric
 
10
 
 
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
 
21
    should look like:
 
22
    { 0: {0: [0], 1: [1], 2: [2]}, \
 
23
      1: {0: [] , 2: [], 2: []}, \
 
24
      2: {0: []} }
 
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]}, \
 
30
      2: {0: [9]} }
 
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.
 
34
    '''
 
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
 
43
        return
 
44
    def get_functional_set( self ): return self.node_set
 
45
    def getNodeIDs(self, dim):
 
46
        try:
 
47
            return self.entity_ids[ dim ].values()
 
48
        except:
 
49
            raise RuntimeError, "Illegal dimension for this dual basis"