SyFi  0.3
sfc_jit.test.SFCJitTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def testSetup
def testJitVolumeInterval
def testJitVolumeTriangle
def testJitVolumeTetrahedron
def testJitConstantInterval
def testJitConstantTriangle
def testJitConstantTetrahedron
def testJitSource
def testJitMass
def testJitSplitTerms

Private Member Functions

def _testJitVolume
def _testJitVolumeQuadrilateral
def _testJitVolumeHexahedron
def _testJitConstant
def _testJitConstantQuadrilateral
def _testJitConstantHexahedron

Detailed Description

Definition at line 93 of file tests/sfc_jit/test.py.


Member Function Documentation

def sfc_jit.test.SFCJitTest._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 138 of file tests/sfc_jit/test.py.

References sfc_jit::test.assemble_on_cell(), and sfc_jit::test.num_integrals().

Referenced by sfc_jit.test.SFCJitTest._testJitConstantHexahedron(), sfc_jit.test.SFCJitTest._testJitConstantQuadrilateral(), sfc_jit.test.SFCJitTest.testJitConstantInterval(), sfc_jit.test.SFCJitTest.testJitConstantTetrahedron(), and sfc_jit.test.SFCJitTest.testJitConstantTriangle().

00138 
00139     def _testJitConstant(self, polygon, degree):
00140         """Test that the integral of a constant coefficient over a unit 
00141         cell mesh equals the constant times the volume of the unit cell."""
00142         element = FiniteElement("CG", polygon, degree)
00143         f = Coefficient(element)
00144         a = f*dx
00145         form = sfc.jit(a)
00146         self.assertTrue(form.rank() == 0)
00147         self.assertTrue(form.num_coefficients() == 1)
00148         self.assertTrue(num_integrals(form) == (1,0,0))
00149         const = 1.23
00150         A = assemble_on_cell(form, polygon, coeffs=[const])
00151         self.assertAlmostEqual(A, const*cell2volume[polygon])
    

Definition at line 172 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitConstant(), and sfc_jit.test.SFCJitTest._testJitConstant().

00172 
00173     def _testJitConstantHexahedron(self): # Not supported by dolfin yet
00174         polygon = "hexahedron"
00175         self._testJitConstant(polygon, 1)
00176         self._testJitConstant(polygon, 2)
    

Definition at line 167 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitConstant(), and sfc_jit.test.SFCJitTest._testJitConstant().

00167 
00168     def _testJitConstantQuadrilateral(self): # Not supported by dolfin yet
00169         polygon = "quadrilateral"
00170         self._testJitConstant(polygon, 1)
00171         self._testJitConstant(polygon, 2)

def sfc_jit.test.SFCJitTest._testJitVolume (   self,
  polygon 
) [private]

Definition at line 112 of file tests/sfc_jit/test.py.

Referenced by sfc_jit.test.SFCJitTest._testJitVolumeHexahedron(), sfc_jit.test.SFCJitTest._testJitVolumeQuadrilateral(), sfc_jit.test.SFCJitTest.testJitVolumeInterval(), sfc_jit.test.SFCJitTest.testJitVolumeTetrahedron(), and sfc_jit.test.SFCJitTest.testJitVolumeTriangle().

00112 
00113     def _testJitVolume(self, polygon):
00114         "Test that the integral of 1.0 over a unit cell equals the length/area/volume of the unit cell."
00115         c = Constant(polygon)
00116         a = c*dx
00117         form = sfc.jit(a)
00118         self.assertTrue(form.rank() == 0)
00119         self.assertTrue(form.num_coefficients() == 1)
00120         self.assertTrue(num_integrals(form) == (1,0,0))
00121         A = assemble_on_cell(form, polygon, coeffs=[1.0])
00122         self.assertAlmostEqual(A, cell2volume[polygon])
    

Definition at line 135 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitVolume(), and sfc_jit.test.SFCJitTest._testJitVolume().

00135 
00136     def _testJitVolumeHexahedron(self): # Not supported by dolfin yet
00137         self._testJitVolume("hexahedron")

Definition at line 132 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitVolume(), and sfc_jit.test.SFCJitTest._testJitVolume().

00132 
00133     def _testJitVolumeQuadrilateral(self): # Not supported by dolfin yet
00134         self._testJitVolume("quadrilateral")
    

Definition at line 94 of file tests/sfc_jit/test.py.

00094 
00095     def setUp(self):
00096         #print "Running sfc jit test in testdir"
00097         #print "Imported SyFi from location", SyFi.__file__
00098         #print "Imported sfc  from location", sfc.__file__
00099         # Generate code in a clean directory:
00100         shutil.rmtree(_test_temp_dir, ignore_errors=True)
00101         os.mkdir(_test_temp_dir)
00102         os.chdir(_test_temp_dir)
    

Definition at line 103 of file tests/sfc_jit/test.py.

00103 
00104     def tearDown(self):
00105         dirs = glob.glob("*")
00106         os.chdir("..")
00107         for d in dirs:
00108             os.rename(os.path.join(_test_temp_dir, d), os.path.join(_done_test_temp_dir, d))
    

Definition at line 152 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitConstant(), and sfc_jit.test.SFCJitTest._testJitConstant().

00152 
00153     def testJitConstantInterval(self):
00154         polygon = "interval"
00155         self._testJitConstant(polygon, 1)
00156         self._testJitConstant(polygon, 2)

Definition at line 162 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitConstant(), and sfc_jit.test.SFCJitTest._testJitConstant().

00162 
00163     def testJitConstantTetrahedron(self):
00164         polygon = "tetrahedron"
00165         self._testJitConstant(polygon, 1)
00166         self._testJitConstant(polygon, 2)
    

Definition at line 157 of file tests/sfc_jit/test.py.

References volumes.VolumeTest._testJitConstant(), and sfc_jit.test.SFCJitTest._testJitConstant().

00157 
00158     def testJitConstantTriangle(self):
00159         polygon = "triangle"
00160         self._testJitConstant(polygon, 1)
00161         self._testJitConstant(polygon, 2)
    

Definition at line 190 of file tests/sfc_jit/test.py.

References sfc_jit::test.assemble_on_cell(), and sfc_jit::test.num_integrals().

00190 
00191     def testJitMass(self):
00192         "Test the mass matrix."
00193         element = FiniteElement("CG", "triangle", 1)
00194         v = TestFunction(element)
00195         u = TrialFunction(element)
00196         f = Coefficient(element)
00197         a = f*u*v*dx
00198         form = sfc.jit(a)
00199         self.assertTrue(form.rank() == 2)
00200         self.assertTrue(form.num_coefficients() == 1)
00201         self.assertTrue(num_integrals(form) == (1,0,0))
00202         A = assemble_on_cell(form, "triangle", coeffs=[5.43])
00203         # TODO: Assert correct result

Definition at line 177 of file tests/sfc_jit/test.py.

References sfc_jit::test.assemble_on_cell(), and sfc_jit::test.num_integrals().

00177 
00178     def testJitSource(self):
00179         "Test the source vector."
00180         element = FiniteElement("CG", "triangle", 1)
00181         v = TestFunction(element)
00182         f = Coefficient(element)
00183         a = f*v*dx
00184         form = sfc.jit(a)
00185         self.assertTrue(form.rank() == 1)
00186         self.assertTrue(form.num_coefficients() == 1)
00187         self.assertTrue(num_integrals(form) == (1,0,0))
00188         A = assemble_on_cell(form, "triangle", coeffs=[3.14])
00189         # TODO: Assert correct result
    

Definition at line 204 of file tests/sfc_jit/test.py.

References sfc_jit::test.assemble_on_cell(), and sfc_jit::test.num_integrals().

00204 
00205     def testJitSplitTerms(self):
00206         "Test a form split over two foo*dx terms, using the mass matrix."
00207         element = FiniteElement("CG", "triangle", 1)
00208         v = TestFunction(element)
00209         u = TrialFunction(element)
00210         f = Coefficient(element)
00211         a = u*v*dx + f*u*v*dx
00212         form = sfc.jit(a)
00213         self.assertTrue(form.rank() == 2)
00214         self.assertTrue(form.num_coefficients() == 1)
00215         self.assertTrue(num_integrals(form) == (1,0,0))
00216         A = assemble_on_cell(form, "triangle", coeffs=[4.43])
00217         # TODO: Assert correct result
00218 

Definition at line 109 of file tests/sfc_jit/test.py.

00109 
00110     def testSetup(self):
00111         pass
    

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines