Ignore:
Timestamp:
Aug 24, 2004, 12:10:48 PM (21 years ago)
Author:
ole
Message:

testing of set_value and a bit of name changing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/test_quantity.py

    r205 r209  
    145145
    146146
     147    def test_set_values_const(self):
     148        quantity = Quantity(self.mesh4)
     149
     150        quantity.set_values(1.0, location = 'vertices')
     151        assert allclose(quantity.vertex_values,
     152                        [[1,1,1], [1,1,1], [1,1,1], [1, 1, 1]])
     153        assert allclose(quantity.centroid_values, [1, 1, 1, 1]) #Centroid
     154        assert allclose(quantity.edge_values, [[1, 1, 1],
     155                                               [1, 1, 1],
     156                                               [1, 1, 1],
     157                                               [1, 1, 1]])
     158
     159
     160        quantity.set_values(2.0, location = 'centroids')
     161        assert allclose(quantity.centroid_values, [2, 2, 2, 2])
     162
     163        quantity.set_values(3.0, location = 'edges')
     164        assert allclose(quantity.edge_values, [[3, 3, 3],
     165                                               [3, 3, 3],
     166                                               [3, 3, 3],
     167                                               [3, 3, 3]])       
     168
     169
     170    def test_set_values_func(self):
     171        quantity = Quantity(self.mesh4)
     172
     173        def f(x, y):
     174            return x+y
     175
     176        quantity.set_values(f, location = 'vertices')
     177        assert allclose(quantity.vertex_values,
     178                        [[2,0,2], [2,2,4], [4,2,4], [4,2,4]])       
     179        assert allclose(quantity.centroid_values,
     180                        [4.0/3, 8.0/3, 10.0/3, 10.0/3])
     181        assert allclose(quantity.edge_values,
     182                        [[1,2,1], [3,3,2], [3,4,3], [3,4,3]])               
     183
     184       
     185        quantity.set_values(f, location = 'centroids')
     186        assert allclose(quantity.centroid_values,
     187                        [4.0/3, 8.0/3, 10.0/3, 10.0/3])       
     188
     189
    147190    def test_gradient(self):
    148191        quantity = Quantity(self.mesh4)
     
    165208
    166209
    167         quantity.second_order_extrapolator()
     210        quantity.extrapolate_second_order()
    168211       
    169212        assert allclose(quantity.vertex_values, [[2., 2.,  2.],
     
    359402
    360403        #Extrapolate
    361         quantity.first_order_extrapolator()
     404        quantity.extrapolate_first_order()
    362405
    363406        #Check vertices but not edge values
     
    375418
    376419
    377         quantity.second_order_extrapolator()
    378         quantity.limiter()
     420        quantity.extrapolate_second_order()
     421        quantity.limit()
    379422
    380423
     
    408451
    409452        #Limit
    410         quantity.limiter()
     453        quantity.limit()
    411454
    412455        #Assert that central triangle is limited by neighbours
     
    439482
    440483        #Extrapolate
    441         quantity.first_order_extrapolator()
     484        quantity.extrapolate_first_order()
    442485
    443486        #Interpolate
Note: See TracChangeset for help on using the changeset viewer.