Debian Codegraph @

test/unit/symbolics/test_dg_elastodyn.py

raw
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2010 Kristian B. Oelgaard
3 #
4 # This file is part of FFC.
5 #
6 # FFC is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # FFC is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with FFC. If not, see <http://www.gnu.org/licenses/>.
18
19 import pytest
20 import time
21
22 # FFC modules
23 from ffc.quadrature.symbolics import *
24 from ffc.quadrature.cpp import format, set_float_formatting
25 from ffc.parameters import FFC_PARAMETERS
26 set_float_formatting(FFC_PARAMETERS['precision'])
27
28
29 def testDGElastoDyn():
30 expr = Product([
31 Sum([
32 Symbol("F0", IP),
33 Symbol("F1", IP)
34 ]),
35 Fraction(
36 Symbol("w4", GEO),
37 Symbol("w3", GEO)
38 ),
39 Fraction(
40 Product([
41 Symbol("w2", GEO),
42 Symbol("w5", GEO)
43 ]),
44 Symbol("w6", GEO)
45 )
46 ])
47
48 expr_exp = expr.expand()
49
50 expr_red = expr_exp.reduce_ops()
51
52 F0, F1, w2, w3, w4, w5, w6 = (3.12, -8.1, -45.3, 17.5, 2.2, 5.3, 9.145)
53 assert round(eval(str(expr)) - eval(str(expr_exp)), 10) == 0
54 assert round(eval(str(expr)) - eval(str(expr_red)), 10) == 0
55 assert expr.ops() == 6
56 assert expr_exp.ops() == 11
57 assert expr_red.ops() == 6