SyFi
0.3
|
Public Member Functions | |
def | setUp |
def | tearDown |
def | testSetup |
def | testValueShapes |
def | testGeometryDimensions |
def | testTopologyDimensions |
def | testArguments |
def | testDofTopology |
def | testPointEvaluation |
def | testCoordinates |
def | testSubHierarchy |
Public Attributes | |
P1 | |
P2 | |
Q | |
VQ | |
V1 | |
V2 | |
T1 | |
T2 | |
TH | |
M | |
P1rep | |
P2rep | |
Qrep | |
VQrep | |
V1rep | |
V2rep | |
T1rep | |
T2rep | |
THrep | |
Mrep | |
reps |
Definition at line 36 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
00038 00039 def setUp(self): 00040 SyFi.initSyFi(2) 00041 cell = ufl.triangle 00042 polygon_name = cell.domain() 00043 geomrep = GeometryRepresentation(polygon_name) 00044 00045 # Create ufl elements 00046 self.P1 = FiniteElement("CG", cell, 1) 00047 self.P2 = FiniteElement("CG", cell, 2) 00048 self.Q = FiniteElement("Q", cell, 1) 00049 self.VQ = VectorElement("Q", cell, 1) 00050 self.V1 = VectorElement("CG", cell, 1) 00051 self.V2 = VectorElement("CG", cell, 2) 00052 self.T1 = TensorElement("CG", cell, 1, symmetry=True) 00053 self.T2 = TensorElement("CG", cell, 2, symmetry=True) 00054 self.TH = self.V2 * self.P1 00055 self.M = MixedElement(self.T1, self.V1, self.P1) 00056 00057 # Create sfc representations 00058 qr2 = find_quadrature_rule(polygon_name, 2) 00059 self.P1rep = ElementRepresentation(self.P1, geomrep) 00060 self.P2rep = ElementRepresentation(self.P2, geomrep) 00061 self.Qrep = ElementRepresentation(self.Q, geomrep, quad_rule=qr2) 00062 self.VQrep = ElementRepresentation(self.VQ, geomrep, quad_rule=qr2) 00063 self.V1rep = ElementRepresentation(self.V1, geomrep) 00064 self.V2rep = ElementRepresentation(self.V2, geomrep) 00065 self.T1rep = ElementRepresentation(self.T1, geomrep) 00066 self.T2rep = ElementRepresentation(self.T2, geomrep) 00067 self.THrep = ElementRepresentation(self.TH, geomrep) 00068 self.Mrep = ElementRepresentation(self.M, geomrep) 00069 00070 self.reps = [getattr(self, d) for d in dir(self) 00071 if isinstance(getattr(self, d), ElementRepresentation)]
Definition at line 72 of file test_element_representations.py.
Definition at line 114 of file test_element_representations.py.
References test_sfc::test_element_representations.info(), and test_sfc.test_element_representations.TestElementRepresentations.reps.
00114 00115 def testArguments(self): 00116 # Tests that for each basisfunction there is at least one nonzero value component 00117 #for rep in (self.P1rep, self.V1rep, self.T1rep): 00118 #for rep in (self.V1rep, ): 00119 for rep in self.reps: 00120 if rep.ufl_element.family() == "Quadrature"\ 00121 or rep.ufl_element.family() == "Boundary Quadrature": 00122 continue 00123 for i in range(rep.local_dimension): 00124 zeros = 0 00125 for c in ufl.permutation.compute_indices(rep.value_shape): 00126 info("Calling basis_function(", i, c, 00127 ") for element ", repr(rep.ufl_element)) 00128 N = rep.basis_function(i, c) 00129 if N == 0.0: 00130 zeros += 1 00131 self.assertTrue(zeros < rep.value_size) 00132 if rep.local_dimension > 1 and rep.value_size > 1: 00133 self.assertTrue(zeros > 0) # This should hold for compositions of scalar elements 00134 # FIXME: Test something more
Definition at line 166 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.reps.
00166 00167 def testCoordinates(self): 00168 for rep in self.reps: 00169 for i in range(rep.local_dimension): 00170 x = rep.dof_x[i] 00171 xi = rep.dof_xi[i] 00172 #print i, xi 00173 #x2 = rep.xi_to_x(xi) 00174 #xi2 = rep.x_to_xi(x) 00175 #self.assertTrue(x2 == x) 00176 #self.assertTrue(xi2 == xi) 00177 # FIXME: Test something more
Definition at line 135 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.reps.
00135 00136 def testDofTopology(self): 00137 def triangle_entities(): 00138 for d in range(2): 00139 for i in range((3,3,1)[d]): 00140 yield (d,i) 00141 for rep in self.reps: 00142 for (d,i) in triangle_entities(): 00143 dofs = rep.entity_dofs[d][i] 00144 self.assertTrue(len(dofs) == rep.num_entity_dofs[d]) 00145 # FIXME: Test something more
Definition at line 90 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.Mrep, test_sfc.test_element_representations.TestElementRepresentations.P1rep, test_sfc.test_element_representations.TestElementRepresentations.P2rep, test_sfc.test_element_representations.TestElementRepresentations.Qrep, test_sfc.test_element_representations.TestElementRepresentations.T1rep, test_sfc.test_element_representations.TestElementRepresentations.T2rep, test_sfc.test_element_representations.TestElementRepresentations.THrep, test_sfc.test_element_representations.TestElementRepresentations.V1rep, test_sfc.test_element_representations.TestElementRepresentations.V2rep, and test_sfc.test_element_representations.TestElementRepresentations.VQrep.
00090 00091 def testGeometryDimensions(self): 00092 self.assertTrue( self.P1rep.geometric_dimension == 2 ) 00093 self.assertTrue( self.P2rep.geometric_dimension == 2 ) 00094 self.assertTrue( self.Qrep.geometric_dimension == 2 ) 00095 self.assertTrue( self.VQrep.geometric_dimension == 2 ) 00096 self.assertTrue( self.V1rep.geometric_dimension == 2 ) 00097 self.assertTrue( self.V2rep.geometric_dimension == 2 ) 00098 self.assertTrue( self.T1rep.geometric_dimension == 2 ) 00099 self.assertTrue( self.T2rep.geometric_dimension == 2 ) 00100 self.assertTrue( self.THrep.geometric_dimension == 2 ) 00101 self.assertTrue( self.Mrep.geometric_dimension == 2 )
Definition at line 146 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.P1rep, and test_sfc.test_element_representations.TestElementRepresentations.P2rep.
00146 00147 def testPointEvaluation(self): 00148 # Tests that the property { N_k(\xi_j) == \delta_{kj} } holds for scalar elements. 00149 for rep in (self.P1rep, self.P2rep): 00150 for i in range(rep.local_dimension): 00151 x = rep.dof_x[i] 00152 xi = rep.dof_xi[i] 00153 00154 repmap = swiginac.exmap() 00155 for j in range(2): 00156 repmap[rep.p[j]] = xi[j] 00157 00158 for k in range(rep.local_dimension): 00159 c = () # Assuming scalar element here: 00160 N = rep.basis_function(k, c) 00161 Nxi = N.subs(repmap) 00162 if i == k: 00163 self.assertTrue(Nxi == 1.0) 00164 else: 00165 self.assertTrue(Nxi == 0.0)
Definition at line 75 of file test_element_representations.py.
Definition at line 178 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.Mrep, test_sfc.test_element_representations.TestElementRepresentations.P1rep, test_sfc.test_element_representations.TestElementRepresentations.P2rep, test_sfc.test_element_representations.TestElementRepresentations.Qrep, test_sfc.test_element_representations.TestElementRepresentations.T1rep, test_sfc.test_element_representations.TestElementRepresentations.T2rep, test_sfc.test_element_representations.TestElementRepresentations.THrep, test_sfc.test_element_representations.TestElementRepresentations.V1rep, test_sfc.test_element_representations.TestElementRepresentations.V2rep, and test_sfc.test_element_representations.TestElementRepresentations.VQrep.
00178 00179 def testSubHierarchy(self): 00180 self.assertTrue(len(self.P1rep.sub_elements) == 0 ) 00181 self.assertTrue(len(self.P2rep.sub_elements) == 0 ) 00182 self.assertTrue(len(self.Qrep.sub_elements) == 0 ) 00183 self.assertTrue(len(self.VQrep.sub_elements) == 2 ) 00184 self.assertTrue(len(self.V1rep.sub_elements) == 2 ) 00185 self.assertTrue(len(self.V2rep.sub_elements) == 2 ) 00186 self.assertTrue(len(self.T1rep.sub_elements) == 3 ) 00187 self.assertTrue(len(self.T2rep.sub_elements) == 3 ) 00188 self.assertTrue(len(self.THrep.sub_elements) == 2 ) 00189 self.assertTrue(len(self.Mrep.sub_elements) == 3 )
Definition at line 102 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.Mrep, test_sfc.test_element_representations.TestElementRepresentations.P1rep, test_sfc.test_element_representations.TestElementRepresentations.P2rep, test_sfc.test_element_representations.TestElementRepresentations.Qrep, test_sfc.test_element_representations.TestElementRepresentations.T1rep, test_sfc.test_element_representations.TestElementRepresentations.T2rep, test_sfc.test_element_representations.TestElementRepresentations.THrep, test_sfc.test_element_representations.TestElementRepresentations.V1rep, test_sfc.test_element_representations.TestElementRepresentations.V2rep, and test_sfc.test_element_representations.TestElementRepresentations.VQrep.
00102 00103 def testTopologyDimensions(self): 00104 self.assertTrue( self.P1rep.topological_dimension == 2 ) 00105 self.assertTrue( self.P2rep.topological_dimension == 2 ) 00106 self.assertTrue( self.Qrep.topological_dimension == 2 ) 00107 self.assertTrue( self.VQrep.topological_dimension == 2 ) 00108 self.assertTrue( self.V1rep.topological_dimension == 2 ) 00109 self.assertTrue( self.V2rep.topological_dimension == 2 ) 00110 self.assertTrue( self.T1rep.topological_dimension == 2 ) 00111 self.assertTrue( self.T2rep.topological_dimension == 2 ) 00112 self.assertTrue( self.THrep.topological_dimension == 2 ) 00113 self.assertTrue( self.Mrep.topological_dimension == 2 )
Definition at line 78 of file test_element_representations.py.
References test_sfc.test_element_representations.TestElementRepresentations.Mrep, test_sfc.test_element_representations.TestElementRepresentations.P1rep, test_sfc.test_element_representations.TestElementRepresentations.P2rep, test_sfc.test_element_representations.TestElementRepresentations.Qrep, test_sfc.test_element_representations.TestElementRepresentations.T1rep, test_sfc.test_element_representations.TestElementRepresentations.T2rep, test_sfc.test_element_representations.TestElementRepresentations.THrep, test_sfc.test_element_representations.TestElementRepresentations.V1rep, test_sfc.test_element_representations.TestElementRepresentations.V2rep, and test_sfc.test_element_representations.TestElementRepresentations.VQrep.
00078 00079 def testValueShapes(self): 00080 self.assertTrue( self.P1rep.value_shape == () ) 00081 self.assertTrue( self.P2rep.value_shape == () ) 00082 self.assertTrue( self.Qrep.value_shape == () ) 00083 self.assertTrue( self.VQrep.value_shape == (2,) ) 00084 self.assertTrue( self.V1rep.value_shape == (2,) ) 00085 self.assertTrue( self.V2rep.value_shape == (2,) ) 00086 self.assertTrue( self.T1rep.value_shape == (2,2) ) 00087 self.assertTrue( self.T2rep.value_shape == (2,2) ) 00088 self.assertTrue( self.THrep.value_shape == (2+1,) ) 00089 self.assertTrue( self.Mrep.value_shape == (4+2+1,) )
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testPointEvaluation(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testPointEvaluation(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testArguments(), test_sfc.test_element_representations.TestElementRepresentations.testCoordinates(), and test_sfc.test_element_representations.TestElementRepresentations.testDofTopology().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().
Definition at line 38 of file test_element_representations.py.
Definition at line 38 of file test_element_representations.py.
Referenced by test_sfc.test_element_representations.TestElementRepresentations.testGeometryDimensions(), test_sfc.test_element_representations.TestElementRepresentations.testSubHierarchy(), test_sfc.test_element_representations.TestElementRepresentations.testTopologyDimensions(), and test_sfc.test_element_representations.TestElementRepresentations.testValueShapes().