~chaffra/ffc/main-old

« back to all changes in this revision

Viewing changes to ffc/quadrature/quadratureutils.py

  • Committer: Chaffra Affouda
  • Date: 2013-03-17 13:09:45 UTC
  • mfrom: (1675.1.153 work)
  • Revision ID: chaffra@gmail.com-20130317130945-6znd0m92hslnarkb
commit to trunk r1828

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# First added:  2007-03-16
21
21
# Last changed: 2010-05-18
22
22
 
 
23
# Hacked by Marie E. Rognes, 2013.
 
24
 
23
25
# Python modules.
24
26
import numpy
25
27
 
27
29
from ffc.log import debug, error, ffc_assert
28
30
from ffc.cpp import format
29
31
 
30
 
def create_psi_tables(tables, parameters):
 
32
def create_psi_tables(tables, parameters, vertex=None):
31
33
    "Create names and maps for tables and non-zero entries if appropriate."
32
34
 
33
35
    debug("\nQG-utils, psi_tables:\n" + str(tables))
34
36
    # Create element map {points:{element:number,},}
35
37
    # and a plain dictionary {name:values,}.
36
 
    element_map, flat_tables = flatten_psi_tables(tables)
 
38
    element_map, flat_tables = flatten_psi_tables(tables, vertex)
37
39
    debug("\nQG-utils, psi_tables, flat_tables:\n" + str(flat_tables))
38
40
 
39
41
    # Reduce tables such that we only have those tables left with unique values
45
47
 
46
48
    return (element_map, name_map, unique_tables)
47
49
 
48
 
def flatten_psi_tables(tables):
 
50
def flatten_psi_tables(tables, vertex=None):
49
51
    """Create a 'flat' dictionary of tables with unique names and a name
50
52
    map that maps number of quadrature points and element name to a unique
51
53
    element number. returns:
80
82
                            ffc_assert(len(numpy.shape(psi_table)) == 2 and numpy.shape(psi_table)[1] == point, \
81
83
                                        "Something is wrong with this table: " + str(psi_table))
82
84
                            # Generate the table name.
83
 
                            name = generate_psi_name(counter, facet, num_comp, derivs)
 
85
                            if vertex is not None:
 
86
                                name = generate_psi_name(counter, None, num_comp, derivs, facet)
 
87
                            else:
 
88
                                name = generate_psi_name(counter, facet, num_comp, derivs)
84
89
                            ffc_assert(name not in flat_tables, \
85
90
                                        "Table name is not unique, something is wrong: " + name + str(flat_tables))
86
91
                            # Take transpose such that we get (ip_number, basis_number)
95
100
                        ffc_assert(len(numpy.shape(psi_table)) == 2 and numpy.shape(psi_table)[1] == point, \
96
101
                                    "Something is wrong with this table: " + str(psi_table))
97
102
                        # Generate the table name.
98
 
                        name = generate_psi_name(counter, facet, (), derivs)
 
103
                        if vertex is not None:
 
104
                            name = generate_psi_name(counter, None, (), derivs, facet)
 
105
                        else:
 
106
                            name = generate_psi_name(counter, facet, (), derivs)
99
107
                        ffc_assert(name not in flat_tables, \
100
108
                                    "Table name is not unique, something is wrong: " + name + str(flat_tables))
101
109
                        flat_tables[name] = numpy.transpose(psi_table)