Changeset 4780


Ignore:
Timestamp:
Nov 5, 2007, 1:11:52 PM (16 years ago)
Author:
duncan
Message:

Bug fix

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  
    179179        self.build_tagged_elements_dictionary(tagged_elements)
    180180
     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               
    181190        #Update boundary indices FIXME: OBSOLETE
    182191        #self.build_boundary_structure()
     
    667676                assert x < epsilon, msg
    668677
    669         self.lone_vertices = []
    670         #Check that all vertices have been registered
    671         for node, count in enumerate(self.number_of_triangles_per_node):
    672        
    673             #msg = 'Node %d does not belong to an element.' %node
    674             #assert count > 0, msg
    675             if count == 0:
    676                 self.lone_vertices.append(node)
    677678
    678679
     
    762763        """Return a list of vertices that are not connected to any triangles.
    763764
    764         Precondition
    765         FIXME(DSG - DSG) Pull the code out of check integrity that builds this
    766                          structure.
    767         check_integrity has to have been called.
    768765        """
    769766        return self.lone_vertices
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r4779 r4780  
    693693                                        verbose = False,
    694694                                        use_cache = False):
    695 
    696695        #FIXME: Use this function for the time being. Later move code in here
    697696
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4776 r4780  
    47744774    # this could be a problem. I would prefer taking them from
    47754775    # 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   
    47764781    sww_quantities = Domain.conserved_quantities
    47774782
     
    48764881        outfile.createVariable('volumes', Int, ('number_of_volumes',
    48774882                                                'number_of_vertices'))
    4878        
     4883
    48794884        outfile.createVariable('time', precision,
    48804885                               ('number_of_timesteps',))
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r4769 r4780  
    33import unittest, os
    44from math import sqrt, pi
     5import tempfile
    56
    67from anuga.config import g, epsilon
     
    89from anuga.utilities.numerical_tools import mean
    910from anuga.utilities.polygon import is_inside_polygon
     11from anuga.coordinate_transforms.geo_reference import Geo_reference
     12from anuga.abstract_2d_finite_volumes.quantity import Quantity
     13from anuga.geospatial_data.geospatial_data import Geospatial_data
    1014
    1115from shallow_water_domain import *
     
    1317# Get gateway to C implementation of flux function for direct testing
    1418from shallow_water_ext import flux_function_central as flux_function
     19
     20# For test_fitting_using_shallow_water_domain example
     21def linear_function(point):
     22    point = array(point)
     23    return point[:,0]+point[:,1]
    1524
    1625class Weir:
     
    51855194
    51865195        #-------------------------------------------------------------
     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
    51875301       
    51885302if __name__ == "__main__":
    51895303
    51905304    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')   
    51925306    #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
    51935307    #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_maximum_inundation_from_sww')
Note: See TracChangeset for help on using the changeset viewer.