Public Member Functions | |
def | __init__ |
def | setUp |
def | tearDown |
def | testSetup |
def | testJitVolumeInterval |
def | testJitVolumeTriangle |
def | testJitVolumeTetrahedron |
def | testJitConstantInterval |
def | testJitConstantTriangle |
def | testJitConstantTetrahedron |
Public Attributes | |
options | |
Private Member Functions | |
def | _testJitVolume |
def | _testJitVolumeQuadrilateral |
def | _testJitVolumeHexahedron |
def | _testJitConstant |
def | _testJitConstantQuadrilateral |
def | _testJitConstantHexahedron |
Definition at line 37 of file volumes.py.
def volumes::VolumeTest::__init__ | ( | self, | ||
args, | ||||
kwargs | ||||
) |
Definition at line 38 of file volumes.py.
00038 : 00039 unittest.TestCase.__init__(self, *args, **kwargs) 00040 shutil.rmtree(_done_test_temp_dir, ignore_errors=True) 00041 os.mkdir(_done_test_temp_dir) 00042 def setUp(self):
def volumes::VolumeTest::_testJitConstant | ( | self, | ||
polygon, | ||||
degree | ||||
) | [private] |
Test that the integral of a constant coefficient over a unit cell mesh equals the constant times the volume of the unit cell.
Definition at line 89 of file volumes.py.
00089 : 00090 """Test that the integral of a constant coefficient over a unit 00091 cell mesh equals the constant times the volume of the unit cell.""" 00092 element = FiniteElement("CG", polygon, degree) 00093 f = Function(element) 00094 a = f*dx 00095 form = sfc.jit(a, options = self.options) 00096 self.assertTrue(form.rank() == 0) 00097 self.assertTrue(form.num_coefficients() == 1) 00098 self.assertTrue(num_integrals(form) == (1,0,0)) 00099 const = 1.23 00100 A = assemble_on_cell(form, polygon, coeffs=[const]) 00101 self.assertAlmostEqual(A, const*cell2volume[polygon]) 00102 def testJitConstantInterval(self):
def volumes::VolumeTest::_testJitConstantHexahedron | ( | self | ) | [private] |
Definition at line 123 of file volumes.py.
00123 : # Not supported by dolfin yet 00124 polygon = "hexahedron" 00125 self._testJitConstant(polygon, 1) 00126 self._testJitConstant(polygon, 2) 00127 00128
def volumes::VolumeTest::_testJitConstantQuadrilateral | ( | self | ) | [private] |
Definition at line 118 of file volumes.py.
00118 : # Not supported by dolfin yet 00119 polygon = "quadrilateral" 00120 self._testJitConstant(polygon, 1) 00121 self._testJitConstant(polygon, 2) 00122
def volumes::VolumeTest::_testJitVolume | ( | self, | ||
polygon | ||||
) | [private] |
Definition at line 63 of file volumes.py.
00063 : 00064 "Test that the integral of 1.0 over a unit cell equals the length/area/volume of the unit cell." 00065 c = Constant(polygon) 00066 a = c*dx 00067 form = sfc.jit(a, options = self.options) 00068 self.assertTrue(form.rank() == 0) 00069 self.assertTrue(form.num_coefficients() == 1) 00070 self.assertTrue(num_integrals(form) == (1,0,0)) 00071 A = assemble_on_cell(form, polygon, coeffs=[1.0]) 00072 self.assertAlmostEqual(A, cell2volume[polygon]) 00073 def testJitVolumeInterval(self):
def volumes::VolumeTest::_testJitVolumeHexahedron | ( | self | ) | [private] |
Definition at line 86 of file volumes.py.
00086 : # Not supported by dolfin yet 00087 self._testJitVolume("hexahedron") 00088
def volumes::VolumeTest::_testJitVolumeQuadrilateral | ( | self | ) | [private] |
Definition at line 83 of file volumes.py.
00083 : # Not supported by dolfin yet 00084 self._testJitVolume("quadrilateral") 00085
def volumes::VolumeTest::setUp | ( | self | ) |
Definition at line 43 of file volumes.py.
00043 : 00044 #print "Running sfc jit test in testdir" 00045 #print "Imported SyFi from location", SyFi.__file__ 00046 #print "Imported sfc from location", sfc.__file__ 00047 self.options = sfc.default_options() 00048 self.options.compilation.cache_dir = os.path.abspath("test_cache") 00049 # Generate code in a clean directory: 00050 shutil.rmtree(_test_temp_dir, ignore_errors=True) 00051 os.mkdir(_test_temp_dir) 00052 os.chdir(_test_temp_dir) 00053 def tearDown(self):
def volumes::VolumeTest::tearDown | ( | self | ) |
Definition at line 54 of file volumes.py.
00054 : 00055 dirs = glob.glob("*") 00056 os.chdir("..") 00057 for d in dirs: 00058 os.rename(os.path.join(_test_temp_dir, d), os.path.join(_done_test_temp_dir, d)) 00059 def testSetup(self):
def volumes::VolumeTest::testJitConstantInterval | ( | self | ) |
Definition at line 103 of file volumes.py.
00103 : 00104 polygon = "interval" 00105 self._testJitConstant(polygon, 1) 00106 self._testJitConstant(polygon, 2) 00107 def testJitConstantTriangle(self):
def volumes::VolumeTest::testJitConstantTetrahedron | ( | self | ) |
Definition at line 113 of file volumes.py.
00113 : 00114 polygon = "tetrahedron" 00115 self._testJitConstant(polygon, 1) 00116 self._testJitConstant(polygon, 2) 00117 def _testJitConstantQuadrilateral(self): # Not supported by dolfin yet
def volumes::VolumeTest::testJitConstantTriangle | ( | self | ) |
Definition at line 108 of file volumes.py.
00108 : 00109 polygon = "triangle" 00110 self._testJitConstant(polygon, 1) 00111 self._testJitConstant(polygon, 2) 00112 def testJitConstantTetrahedron(self):
def volumes::VolumeTest::testJitVolumeInterval | ( | self | ) |
Definition at line 74 of file volumes.py.
00074 : 00075 self._testJitVolume("interval") 00076 def testJitVolumeTriangle(self):
def volumes::VolumeTest::testJitVolumeTetrahedron | ( | self | ) |
Definition at line 80 of file volumes.py.
00080 : 00081 self._testJitVolume("tetrahedron") 00082 def _testJitVolumeQuadrilateral(self): # Not supported by dolfin yet
def volumes::VolumeTest::testJitVolumeTriangle | ( | self | ) |
Definition at line 77 of file volumes.py.
00077 : 00078 self._testJitVolume("triangle") 00079 def testJitVolumeTetrahedron(self):
def volumes::VolumeTest::testSetup | ( | self | ) |
Definition at line 60 of file volumes.py.
00060 : 00061 pass 00062 def _testJitVolume(self, polygon):
Definition at line 47 of file volumes.py.