Changeset 611


Ignore:
Timestamp:
Nov 22, 2004, 4:50:04 PM (20 years ago)
Author:
duncan
Message:

Optimised the least_squares algorithm for building A matrix

Location:
inundation/ga/storm_surge/pyvolution
Files:
3 edited

Legend:

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

    r608 r611  
    185185        self.build_coefficient_matrix_B(point_coordinates)   
    186186
    187 
     187    def set_point_coordinates(self, point_coordinates):
     188        """
     189        A public interface to setting the point co-ordinates.
     190        """
     191        self.build_coefficient_matrix_B(point_coordinates)
    188192       
    189193    def build_coefficient_matrix_B(self, point_coordinates=None):
     
    239243            #Find vertices near x
    240244            candidate_vertices = root.search(x[0], x[1])
    241                
    242             element_found, sigma0, sigma1, sigma2, k = \
    243                 self.search_triangles_of_vertices(candidate_vertices, x)
    244245
    245246            is_more_elements = True
     247            if candidate_vertices == []:
     248                # The point isn't even within the root cell!
     249                is_more_elements = False
     250                element_found = False
     251            else:
     252                element_found, sigma0, sigma1, sigma2, k = \
     253                    self.search_triangles_of_vertices(candidate_vertices, x)
     254
    246255            while not element_found and is_more_elements:
    247256                candidate_vertices = root.expand_search()
  • inundation/ga/storm_surge/pyvolution/quad.py

    r608 r611  
    8181            for child in self:
    8282                if child.contains(x,y):
    83                     branch.append(self)
     83                    brothers = list(self.children)
     84                    brothers.remove(child)
     85                    branch.append(brothers)
    8486                    points, branch = child.search_branch(x,y, branch)
    8587        else:
     
    98100            for child in self:
    99101                if child.contains(x,y):
    100                     branch.append(self)
     102                    brothers = list(self.children)
     103                    brothers.remove(child)
     104                    branch.append(brothers)
    101105                    points, branch = child.search_branch(x,y, branch)
    102106                   
     
    114118            points = []
    115119        else:
    116             larger_cell = self.branch.pop()
    117             #print "larger_cell ", larger_cell.show() # Get_tree()
    118             for child in larger_cell:
    119                 #This means it will also go down the branch known to be bad.
    120                 #So, if things are too slow, this could be speed up
    121                 points += child.retrieve()
     120            three_cells = self.branch.pop()
     121            for cell in three_cells:
     122                #print "cell ", cell.show()
     123                points += cell.retrieve()
    122124        return points
    123125
  • inundation/ga/storm_surge/pyvolution/test_least_squares.py

    r608 r611  
    6969        answer =  [ [ 0.06666667,  0.46666667,  0.46666667,  0.,
    7070                      0., 0. , 0., 0., 0., 0.]]
    71         assert allclose(interp.get_A(), answer)
     71        assert allclose(interp.get_A(), answer)
     72        interp.set_point_coordinates([[-30, -30]]) #point outside of mesh
     73        #print "PDSG - interp.get_A()", interp.get_A()
     74        answer =  [ [ 0.0,  0.0,  0.0,  0.,
     75                      0., 0. , 0., 0., 0., 0.]]
     76        assert allclose(interp.get_A(), answer)
     77
     78       
     79        #point outside of quad tree root cell
     80        interp.set_point_coordinates([[-70, -70]])
     81        #print "PDSG - interp.get_A()", interp.get_A()
     82        answer =  [ [ 0.0,  0.0,  0.0,  0.,
     83                      0., 0. , 0., 0., 0., 0.]]
     84        assert allclose(interp.get_A(), answer)
    7285       
    7386
Note: See TracChangeset for help on using the changeset viewer.