SyFi  0.3
test_uflacsmode.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 __authors__ = "Martin Sandve Alnes"
00004 __date__ = "2012-05-25"
00005 
00006 from test_tempdir_base import TempDirTestBase
00007 import swiginac
00008 import SyFi
00009 import sfc
00010 from ufl import *
00011 from time import time
00012 
00013 from test_tempdir_base import TempDirTestBase
00014 from cell_assembly import assemble_on_cell, num_integrals
00015 
00016 def info(*args):
00017     if 0: print " ".join(map(str,args))
00018 
00019 class TestUflacsMode(TempDirTestBase):
00020     def __init__(self, *args, **kwargs):
00021         TempDirTestBase.__init__(self, *args, **kwargs)
00022 
00023     def setUp(self):
00024         TempDirTestBase.setUp(self)
00025         self.options.code.integral.integration_method = "quadrature"
00026         self.set_uflacs_options()
00027 
00028     def set_uflacs_options(self):
00029         try:
00030             import uflacs
00031             self.options.code.integral.use_uflacs = True
00032         except:
00033             print "UFLACS NOT AVAILABLE"
00034 
00035     def tearDown(self):
00036         TempDirTestBase.tearDown(self)
00037 
00038     def test_uflacs_options(self):
00039         self.assertTrue(hasattr(self.options.code.integral, "use_uflacs"))
00040         self.assertTrue(hasattr(self.options.code.integral, "uflacs"))
00041         self.assertTrue(hasattr(self.options.code.integral.uflacs, "register_threshold"))
00042         self.assertTrue(hasattr(self.options.code.integral.uflacs, "max_registers"))
00043 
00044     def test_uflacs_jit(self):
00045         cell = triangle
00046         v = cell.volume
00047         a = v*dx
00048 
00049         form, module, formdata, prefix = sfc.jit(a, parameters = self.options)
00050         self.assertTrue(form.rank() == 0)
00051         self.assertTrue(form.num_coefficients() == 0)
00052         self.assertTrue(num_integrals(form) == (1,0,0))
00053 
00054         if 0: # Testing call of generated throw code
00055             e = None
00056             try:
00057                 A = assemble_on_cell(form, cell.domain(), coeffs=[], elements=[])
00058             except e:
00059                 pass
00060 
00061         # TODO: Assert correct result instead
00062 
00063     def xtest_backlog(self):
00064         """
00065         TODO: Make backlog
00066         """
00067         pass
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines