Changeset 4780
- Timestamp:
- Nov 5, 2007, 1:11:52 PM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r4705 r4780 179 179 self.build_tagged_elements_dictionary(tagged_elements) 180 180 181 # Build a list of vertices that are not connected to any triangles 182 self.lone_vertices = [] 183 #Check that all vertices have been registered 184 for node, count in enumerate(self.number_of_triangles_per_node): 185 #msg = 'Node %d does not belong to an element.' %node 186 #assert count > 0, msg 187 if count == 0: 188 self.lone_vertices.append(node) 189 181 190 #Update boundary indices FIXME: OBSOLETE 182 191 #self.build_boundary_structure() … … 667 676 assert x < epsilon, msg 668 677 669 self.lone_vertices = []670 #Check that all vertices have been registered671 for node, count in enumerate(self.number_of_triangles_per_node):672 673 #msg = 'Node %d does not belong to an element.' %node674 #assert count > 0, msg675 if count == 0:676 self.lone_vertices.append(node)677 678 678 679 … … 762 763 """Return a list of vertices that are not connected to any triangles. 763 764 764 Precondition765 FIXME(DSG - DSG) Pull the code out of check integrity that builds this766 structure.767 check_integrity has to have been called.768 765 """ 769 766 return self.lone_vertices -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r4779 r4780 693 693 verbose = False, 694 694 use_cache = False): 695 696 695 #FIXME: Use this function for the time being. Later move code in here 697 696 -
anuga_core/source/anuga/shallow_water/data_manager.py
r4776 r4780 4774 4774 # this could be a problem. I would prefer taking them from 4775 4775 # the instantiation of Domain. 4776 # 4777 # (DSG) There is not always a Domain instance when Write_sww is used. 4778 # Check to see if this is the same level of hardwiring as is in 4779 # shallow water doamain. 4780 4776 4781 sww_quantities = Domain.conserved_quantities 4777 4782 … … 4876 4881 outfile.createVariable('volumes', Int, ('number_of_volumes', 4877 4882 'number_of_vertices')) 4878 4883 4879 4884 outfile.createVariable('time', precision, 4880 4885 ('number_of_timesteps',)) -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r4769 r4780 3 3 import unittest, os 4 4 from math import sqrt, pi 5 import tempfile 5 6 6 7 from anuga.config import g, epsilon … … 8 9 from anuga.utilities.numerical_tools import mean 9 10 from anuga.utilities.polygon import is_inside_polygon 11 from anuga.coordinate_transforms.geo_reference import Geo_reference 12 from anuga.abstract_2d_finite_volumes.quantity import Quantity 13 from anuga.geospatial_data.geospatial_data import Geospatial_data 10 14 11 15 from shallow_water_domain import * … … 13 17 # Get gateway to C implementation of flux function for direct testing 14 18 from shallow_water_ext import flux_function_central as flux_function 19 20 # For test_fitting_using_shallow_water_domain example 21 def linear_function(point): 22 point = array(point) 23 return point[:,0]+point[:,1] 15 24 16 25 class Weir: … … 5185 5194 5186 5195 #------------------------------------------------------------- 5196 5197 def test_get_lone_vertices(self): 5198 5199 a = [0.0, 0.0] 5200 b = [0.0, 2.0] 5201 c = [2.0,0.0] 5202 d = [0.0, 4.0] 5203 e = [2.0, 2.0] 5204 f = [4.0,0.0] 5205 5206 points = [a, b, c, d, e, f] 5207 #bac, bce, ecf, dbe 5208 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ] 5209 boundary = { (0, 0): 'Third', 5210 (0, 2): 'First', 5211 (2, 0): 'Second', 5212 (2, 1): 'Second', 5213 (3, 1): 'Second', 5214 (3, 2): 'Third'} 5215 5216 5217 domain = Domain(points, vertices, boundary) 5218 #domain.check_integrity() 5219 domain.get_lone_vertices() 5220 5221 5222 def test_fitting_using_shallow_water_domain(self): 5223 5224 #Mesh in zone 56 (absolute coords) 5225 5226 x0 = 314036.58727982 5227 y0 = 6224951.2960092 5228 5229 a = [x0+0.0, y0+0.0] 5230 b = [x0+0.0, y0+2.0] 5231 c = [x0+2.0, y0+0.0] 5232 d = [x0+0.0, y0+4.0] 5233 e = [x0+2.0, y0+2.0] 5234 f = [x0+4.0, y0+0.0] 5235 5236 points = [a, b, c, d, e, f] 5237 5238 #bac, bce, ecf, dbe 5239 elements = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ] 5240 5241 #absolute going in .. 5242 mesh4 = Domain(points, elements, 5243 geo_reference = Geo_reference(56, 0, 0)) 5244 mesh4.check_integrity() 5245 quantity = Quantity(mesh4) 5246 5247 #Get (enough) datapoints (relative to georef) 5248 data_points_rel = [[ 0.66666667, 0.66666667], 5249 [ 1.33333333, 1.33333333], 5250 [ 2.66666667, 0.66666667], 5251 [ 0.66666667, 2.66666667], 5252 [ 0.0, 1.0], 5253 [ 0.0, 3.0], 5254 [ 1.0, 0.0], 5255 [ 1.0, 1.0], 5256 [ 1.0, 2.0], 5257 [ 1.0, 3.0], 5258 [ 2.0, 1.0], 5259 [ 3.0, 0.0], 5260 [ 3.0, 1.0]] 5261 5262 data_geo_spatial = Geospatial_data(data_points_rel, 5263 geo_reference = Geo_reference(56, x0, y0)) 5264 data_points_absolute = data_geo_spatial.get_data_points(absolute=True) 5265 attributes = linear_function(data_points_absolute) 5266 att = 'spam_and_eggs' 5267 5268 #Create .txt file 5269 ptsfile = tempfile.mktemp(".txt") 5270 file = open(ptsfile,"w") 5271 file.write(" x,y," + att + " \n") 5272 for data_point, attribute in map(None, data_points_absolute 5273 ,attributes): 5274 row = str(data_point[0]) + ',' + str(data_point[1]) \ 5275 + ',' + str(attribute) 5276 file.write(row + "\n") 5277 file.close() 5278 5279 #file = open(ptsfile, 'r') 5280 #lines = file.readlines() 5281 #file.close() 5282 5283 5284 #Check that values can be set from file 5285 quantity.set_values(filename = ptsfile, 5286 attribute_name = att, alpha = 0) 5287 answer = linear_function(quantity.domain.get_vertex_coordinates()) 5288 5289 assert allclose(quantity.vertex_values.flat, answer) 5290 5291 5292 #Check that values can be set from file using default attribute 5293 quantity.set_values(filename = ptsfile, alpha = 0) 5294 assert allclose(quantity.vertex_values.flat, answer) 5295 5296 #Cleanup 5297 import os 5298 os.remove(ptsfile) 5299 5300 5187 5301 5188 5302 if __name__ == "__main__": 5189 5303 5190 5304 suite = unittest.makeSuite(Test_Shallow_Water,'test') 5191 #suite = unittest.makeSuite(Test_Shallow_Water,'test_ extrema')5305 #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain') 5192 5306 #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters') 5193 5307 #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_maximum_inundation_from_sww')
Note: See TracChangeset
for help on using the changeset viewer.