Do you know how to change the normal directions in FIAT? If so, maybe you can just push the change and we keep our fingers crossed Rob won't notice/object. ;-)
-- Anders On Fri, Jan 15, 2010 at 12:54:12PM -0000, [email protected] wrote: > ------------------------------------------------------------ > revno: 1470 > committer: Marie E. Rognes <[email protected]> > branch nick: ffc-unstable > timestamp: Fri 2010-01-15 13:51:33 +0100 > message: > Updated function-value unit tests. Pass (except for RT1/BDM1/RT2 > cf. FIAT normal directions.) Need to add for NED and RT/BDM in 3D. > modified: > test/unit/test.py > > > === modified file 'test/unit/test.py' > --- test/unit/test.py 2009-12-11 18:47:52 +0000 > +++ test/unit/test.py 2010-01-15 12:51:33 +0000 > @@ -5,6 +5,7 @@ > __copyright__ = "Copyright (C) 2007-2009 Anders Logg" > __license__ = "GNU GPL version 3 or any later version" > > +# Modified by Marie E. Rognes <[email protected]> 2010 > import unittest > import sys > import numpy > @@ -15,7 +16,7 @@ > sys.path.append(os.path.join(os.pardir, os.pardir)) > > from ufl import * > -from ffc.finiteelement import FiniteElement as FFCElement > +from ffc.fiatinterface import create_element as create > from ffc import jit > > interval = [(0,), (1,)] > @@ -32,128 +33,122 @@ > def testContinuousLagrange(self): > "Test space dimensions of continuous Lagrange elements." > > - P1 = FFCElement(FiniteElement("Lagrange", "triangle", 1)) > + P1 = create(FiniteElement("Lagrange", "triangle", 1)) > self.assertEqual(P1.space_dimension(), 3) > > - P2 = FFCElement(FiniteElement("Lagrange", "triangle", 2)) > + P2 = create(FiniteElement("Lagrange", "triangle", 2)) > self.assertEqual(P2.space_dimension(), 6) > > - P3 = FFCElement(FiniteElement("Lagrange", "triangle", 3)) > + P3 = create(FiniteElement("Lagrange", "triangle", 3)) > self.assertEqual(P3.space_dimension(), 10) > > def testDiscontinuousLagrange(self): > "Test space dimensions of discontinuous Lagrange elements." > > - P0 = FFCElement(FiniteElement("Discontinuous Lagrange", "triangle", > 0)) > + P0 = create(FiniteElement("DG", "triangle", 0)) > self.assertEqual(P0.space_dimension(), 1) > > - P1 = FFCElement(FiniteElement("Discontinuous Lagrange", "triangle", > 1)) > + P1 = create(FiniteElement("DG", "triangle", 1)) > self.assertEqual(P1.space_dimension(), 3) > > - P2 = FFCElement(FiniteElement("Discontinuous Lagrange", "triangle", > 2)) > + P2 = create(FiniteElement("DG", "triangle", 2)) > self.assertEqual(P2.space_dimension(), 6) > > - P3 = FFCElement(FiniteElement("Discontinuous Lagrange", "triangle", > 3)) > + P3 = create(FiniteElement("DG", "triangle", 3)) > self.assertEqual(P3.space_dimension(), 10) > > class FunctionValueTests(unittest.TestCase): > + """ > + These tests examine tabulate gives the correct answers for a the > + supported (non-mixed) elements of polynomial degree less than or > + equal to 3 > + """ > + > + # FIXME: Add tests for NED and BDM/RT in 3D. > + > + def _check_function_values(self, points, element, reference): > + for x in points: > + table = element.tabulate(0, (x,)) > + basis = table[table.keys()[0]] > + for i in range(len(basis)): > + if element.value_shape() == (): > + self.assertAlmostEqual(basis[i], reference[i](x)) > + else: > + for k in range(element.value_shape()[0]): > + self.assertAlmostEqual(basis[i][k][0], > + reference[i](x)[k]) > > def testContinuousLagrange1D(self): > "Test values of continuous Lagrange functions in 1D." > > - element = FFCElement(FiniteElement("Lagrange", "interval", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("Lagrange", "interval", 1)) > reference = [lambda x: 1 - x[0], > lambda x: x[0]] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(interval) > - self.assertAlmostEqual(basis[i](x), reference[i](x)) > + points = [random_point(interval) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > def testContinuousLagrange2D(self): > "Test values of continuous Lagrange functions in 2D." > > - element = FFCElement(FiniteElement("Lagrange", "triangle", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("Lagrange", "triangle", 1)) > reference = [lambda x: 1 - x[0] - x[1], > lambda x: x[0], > lambda x: x[1]] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(triangle) > - self.assertAlmostEqual(basis[i](x), reference[i](x)) > + points = [random_point(triangle) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > def testContinuousLagrange3D(self): > "Test values of continuous Lagrange functions in 3D." > > - element = FFCElement(FiniteElement("Lagrange", "tetrahedron", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("Lagrange", "tetrahedron", 1)) > reference = [lambda x: 1 - x[0] - x[1] - x[2], > lambda x: x[0], > lambda x: x[1], > lambda x: x[2]] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(tetrahedron) > - self.assertAlmostEqual(basis[i](x), reference[i](x)) > + points = [random_point(tetrahedron) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > def testDiscontinuousLagrange1D(self): > "Test values of discontinuous Lagrange functions in 1D." > > - element = FFCElement(FiniteElement("Discontinuous Lagrange", > "interval", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("DG", "interval", 1)) > reference = [lambda x: 1 - x[0], > lambda x: x[0]] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(interval) > - self.assertAlmostEqual(basis[i](x), reference[i](x)) > + points = [random_point(interval) for i in range(num_points)] > + self._check_function_values(points, element, reference) > + > > def testDiscontinuousLagrange2D(self): > "Test values of discontinuous Lagrange functions in 2D." > > - element = FFCElement(FiniteElement("Discontinuous Lagrange", > "triangle", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("DG", "triangle", 1)) > reference = [lambda x: 1 - x[0] - x[1], > lambda x: x[0], > lambda x: x[1]] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(triangle) > - self.assertAlmostEqual(basis[i](x), reference[i](x)) > + points = [random_point(triangle) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > def testDiscontinuousLagrange3D(self): > "Test values of discontinuous Lagrange functions in 3D." > > - element = FFCElement(FiniteElement("Discontinuous Lagrange", > "tetrahedron", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("DG", "tetrahedron", 1)) > reference = [lambda x: 1 - x[0] - x[1] - x[2], > lambda x: x[0], > lambda x: x[1], > lambda x: x[2]] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(tetrahedron) > - self.assertAlmostEqual(basis[i](x), reference[i](x)) > + points = [random_point(tetrahedron) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > def testBDM1(self): > "Test values of BDM1." > > - element = FFCElement(FiniteElement("Brezzi-Douglas-Marini", > "triangle", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("Brezzi-Douglas-Marini", "triangle", > 1)) > reference = [lambda x: (2*x[0], -x[1]), > lambda x: (-x[0], 2*x[1]), > lambda x: (2 - 2*x[0] - 3*x[1], x[1]), > @@ -161,34 +156,25 @@ > lambda x: (-x[0], -2 + 3*x[0] + 2*x[1]), > lambda x: (2*x[0], 1 - 3*x[0] - x[1])] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(triangle) > - self.assertAlmostEqual(basis[i](x)[0], reference[i](x)[0]) > - self.assertAlmostEqual(basis[i](x)[1], reference[i](x)[1]) > + points = [random_point(triangle) for i in range(num_points)] > + self._check_function_values(points, element, reference) > + > > def testRT1(self): > "Test values of RT1." > > - element = FFCElement(FiniteElement("Raviart-Thomas", "triangle", 1)) > - basis = element.basis() > - > + element = create(FiniteElement("Raviart-Thomas", "triangle", 1)) > reference = [lambda x: (x[0], x[1]), > lambda x: (1 - x[0], -x[1]), > lambda x: (x[0], x[1] - 1)] > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(triangle) > - self.assertAlmostEqual(basis[i](x)[0], reference[i](x)[0]) > - self.assertAlmostEqual(basis[i](x)[1], reference[i](x)[1]) > + points = [random_point(triangle) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > def testRT2(self): > "Test values of RT2." > > - element = FFCElement(FiniteElement("Raviart-Thomas", "triangle", 2)) > - basis = element.basis() > - > + element = create(FiniteElement("Raviart-Thomas", "triangle", 2)) > reference = [lambda x: (-2*x[0] + 4*x[0]**2, -x[1] + 4*x[0]*x[1]), > lambda x: (-x[0] + 4*x[0]*x[1], -2*x[1] + 4*x[1]**2), > lambda x: (2 - 6*x[0] - 3*x[1] + 4*x[0]*x[1] + > 4*x[0]**2, > @@ -208,12 +194,9 @@ > 16/math.sqrt(2)*x[1] - > 8/math.sqrt(2)*x[0]*x[1] > - 16/math.sqrt(2)*x[1]**2) > ] > + points = [random_point(triangle) for i in range(num_points)] > + self._check_function_values(points, element, reference) > > - for i in range(len(basis)): > - for j in range(num_points): > - x = random_point(triangle) > - self.assertAlmostEqual(basis[i](x)[0], reference[i](x)[0]) > - self.assertAlmostEqual(basis[i](x)[1], reference[i](x)[1]) > > class JITTests(unittest.TestCase): > > @@ -221,7 +204,8 @@ > "Test that JIT compiler is fast enough." > > # FIXME: Use local cache: cache_dir argument to instant.build_module > - options = {"log_level": INFO + 5} > + #options = {"log_level": INFO + 5} > + options = {"log_level": 5} > > # Define two forms with the same signatures > element = FiniteElement("Lagrange", "triangle", 1) > @@ -264,6 +248,6 @@ > self.assertTrue(dt1 < 10*dt1_good) > > if __name__ == "__main__": > - os.system("python testcreateelement.py") > + #os.system("python testcreateelement.py") > #os.system("python test_symbolics.py") > unittest.main() >
signature.asc
Description: Digital signature
_______________________________________________ Mailing list: https://launchpad.net/~ffc Post to : [email protected] Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp

