~ubuntu-branches/ubuntu/natty/ffc/natty

« back to all changes in this revision

Viewing changes to test/unit/symbolics/testrealexamples.py

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2010-02-03 20:22:35 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100203202235-fe8d0kajuvgy2sqn
Tags: 0.9.0-1
* New upstream release.
* debian/control: Bump Standards-Version (no changes needed).
* Update debian/copyright and debian/copyright_hints.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
__author__ = "Kristian B. Oelgaard (k.b.oelgaard@gmail.com)"
 
4
__date__ = "2010-01-06"
 
5
__copyright__ = "Copyright (C) 2010 Kristian B. Oelgaard"
 
6
__license__  = "GNU GPL version 3 or any later version"
 
7
 
 
8
# Last changed: 2010-02-01
 
9
 
 
10
# Pyhton modules
 
11
import unittest
 
12
import time
 
13
 
 
14
# FFC modules
 
15
from ffc.quadrature.symbolics import *
 
16
from ffc.cpp import format, set_float_formatting
 
17
from ffc.parameters import FFC_PARAMETERS
 
18
set_float_formatting(FFC_PARAMETERS['precision'])
 
19
 
 
20
class TestRealExamples(unittest.TestCase):
 
21
 
 
22
    def testRealExamples(self):
 
23
 
 
24
#        p = Product([
 
25
#                    Sum([
 
26
#                        Product([
 
27
#                                  Symbol('w[5][0]', GEO),
 
28
#                                  Fraction(
 
29
#                                            Product([
 
30
#                                                    Symbol('FE0_C1_D01[ip][k]', BASIS), Symbol('Jinv_10', GEO)
 
31
#                                                    ]),
 
32
#                                            Product([
 
33
#                                                    Symbol('w[5][0]', GEO), Symbol('w[5][0]', GEO)
 
34
#                                                    ])
 
35
#                                            )
 
36
#                                                    
 
37
#                                ]),
 
38
#                        Product([
 
39
#                                  Symbol('w[5][0]', GEO),
 
40
#                                  Fraction(
 
41
#                                          Product([
 
42
#                                                    Symbol('FE0_C1_D01[ip][k]', BASIS), Symbol('Jinv_11', GEO)
 
43
#                                                  ]),
 
44
#                                          Product([
 
45
#                                                    Symbol('w[5][0]', GEO), Symbol('w[5][0]', GEO)
 
46
#                                                  ])
 
47
#                                          )
 
48
#                                ])
 
49
#                        ])
 
50
#                   ])
 
51
 
 
52
#        p = Product([
 
53
#                      Sum([
 
54
#                            Product([
 
55
#                                      Symbol('x', BASIS),
 
56
#                                      Sum([
 
57
#                                            Symbol('y', BASIS),
 
58
#                                            Product([
 
59
#                                                      Sum([
 
60
#                                                           Symbol('y', BASIS),
 
61
#                                                           Product([
 
62
#                                                                    Symbol('y', BASIS),
 
63
#                                                                    Symbol('z', GEO)
 
64
#                                                                   ]),
 
65
#                                                           Symbol('y', BASIS)
 
66
#                                                         ])
 
67
#                                                    ]),
 
68
#                                           Symbol('y', BASIS)
 
69
#                                          ])
 
70
#                                    ]),
 
71
#                          Product([
 
72
#                                  Symbol('x', BASIS),
 
73
#                                  Sum([
 
74
#                                        Product([
 
75
#                                                Symbol('y', BASIS),
 
76
#                                                              Symbol('z', GEO)
 
77
#                                              ]),
 
78
#                                        Symbol('y', BASIS)
 
79
#                                      ])
 
80
#                                ])
 
81
 
 
82
#                          ])
 
83
#                      ])
 
84
 
 
85
#        p = Product([
 
86
#                     Sum([
 
87
#                          Product([
 
88
#                                    Symbol('FE0_C1_D01[ip][j]', BASIS),
 
89
#                                    Product([
 
90
#                                            Symbol('FE0_C1_D01[ip][k]', BASIS),
 
91
#                                            Sum([
 
92
#                                                 Symbol('w[4][0]', GEO)
 
93
#                                                ]),
 
94
#                                            Sum([
 
95
#                                                  Symbol('w[4][0]', GEO)
 
96
#                                                ])
 
97
#                                          ])
 
98
#                                    ]),
 
99
#                        Product([
 
100
#                                  Symbol('FE0_C1_D01[ip][j]', BASIS),
 
101
#                                  Symbol('FE0_C1_D01[ip][k]', BASIS)
 
102
#                                ])
 
103
#                         ])
 
104
#                      ])
 
105
 
 
106
        p = Product([ Symbol('FE0_C1_D01[ip][k]', BASIS),
 
107
                      Sum([
 
108
                            Symbol('Jinv_10', GEO),
 
109
                            Symbol('w[4][0]', GEO)
 
110
                          ]),
 
111
                      Sum([
 
112
                            Symbol('Jinv_10', GEO),
 
113
                            Symbol('w[4][0]', GEO)
 
114
                          ])
 
115
                    ])
 
116
 
 
117
#        print "p: ", p
 
118
#        print p.expand()
 
119
 
 
120
        br = p.reduce_vartype(BASIS)
 
121
#        print
 
122
#        print br[0]
 
123
#        print br[1]
 
124
 
 
125
        be = p.expand().reduce_vartype(BASIS)
 
126
#        print
 
127
#        print be[0][0]
 
128
#        print be[0][1]
 
129
        if len(be) == 1:
 
130
            if be[0][0] == br[0]:
 
131
                if be[0][1] != br[1].expand():
 
132
#                        print "\np: ", repr(p)
 
133
                        print "\nbe: ", repr(be[0][1])
 
134
                        print "\nbr: ", repr(br[1].expand())
 
135
                        print "\nbe: ", be[0][1]
 
136
                        print "\nbr: ", br[1].expand()
 
137
                        error("here1")
 
138
 
 
139
if __name__ == "__main__":
 
140
 
 
141
    # Run all returned tests
 
142
    runner = unittest.TextTestRunner()
 
143
    runner.run(TestRealExamples('testRealExamples'))
 
144