Changeset 1916 for inundation/pyvolution/test_domain.py
- Timestamp:
- Oct 14, 2005, 9:46:38 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/test_domain.py
r1753 r1916 134 134 q = domain.get_conserved_quantities(3, edge=2) 135 135 assert allclose(q, [-1.5, -1.5, 0.]) 136 137 138 139 def test_create_quantity_from_expression(self): 140 """Quantity created from other quantities using arbitrary expression 141 142 """ 143 144 145 a = [0.0, 0.0] 146 b = [0.0, 2.0] 147 c = [2.0,0.0] 148 d = [0.0, 4.0] 149 e = [2.0, 2.0] 150 f = [4.0,0.0] 151 152 points = [a, b, c, d, e, f] 153 #bac, bce, ecf, dbe, daf, dae 154 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]] 155 156 domain = Domain(points, vertices, boundary=None, 157 conserved_quantities =\ 158 ['stage', 'xmomentum', 'ymomentum'], 159 other_quantities = ['elevation', 'friction']) 160 161 162 domain.set_quantity('elevation', -1) 163 164 165 domain.set_quantity('stage', [[1,2,3], [5,5,5], 166 [0,0,9], [-6, 3, 3]]) 167 168 domain.set_quantity('xmomentum', [[1,2,3], [5,5,5], 169 [0,0,9], [-6, 3, 3]]) 170 171 domain.set_quantity('ymomentum', [[3,3,3], [4,2,1], 172 [2,4,-1], [1, 0, 1]]) 173 174 domain.check_integrity() 175 176 177 178 expression = 'stage - elevation' 179 Q = create_quantity_from_expression(domain, expression) 180 181 assert allclose(Q.vertex_values, [[2,3,4], [6,6,6], 182 [1,1,10], [-5, 4, 4]]) 183 184 expression = '(xmomentum*xmomentum + ymomentum*ymomentum)**0.5' 185 Q = create_quantity_from_expression(domain, expression) 186 187 X = domain.quantities['xmomentum'].vertex_values 188 Y = domain.quantities['ymomentum'].vertex_values 189 190 assert allclose(Q.vertex_values, (X**2 + Y**2)**0.5) 191 192 193 194 136 195 137 196
Note: See TracChangeset
for help on using the changeset viewer.