Changeset 1150


Ignore:
Timestamp:
Mar 28, 2005, 11:20:14 PM (20 years ago)
Author:
steve
Message:

Added logging to cg_solve.py

Location:
inundation/ga/storm_surge/pyvolution
Files:
1 added
4 edited

Legend:

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

    r599 r1150  
    11import exceptions
    22class VectorShapeError(exceptions.Exception): pass
     3
     4import logging, logging.config
     5logger = logging.getLogger('cg_solve')
     6
     7logging.config.fileConfig('log.ini')
     8
     9#logger.setLevel(logging.DEBUG)
     10
     11
     12
    313
    414
     
    717   Try to solve linear equation Ax = b using
    818   conjugate gradient method
    9    
     19
    1020   Input
    1121   A: matrix or function which applies a matrix, assumed symmetric
     
    1525   imax: max number of iterations
    1626   tol: tolerance used for residual
    17    
     27
    1828   Output
    1929   x: approximate solution
     
    2131
    2232   from Numeric import dot, array, Float, zeros
    23    
     33
    2434   b  = array(b, typecode=Float)
    2535   if len(b.shape) != 1 :
     
    2838   if x0 is None:
    2939      x0 = zeros(b.shape, typecode=Float)
    30    else:   
     40   else:
    3141      x0 = array(x0, typecode=Float)
    32      
     42
    3343
    3444   #FIXME: Should test using None
    3545   if iprint == 0:
    3646      iprint = imax
    37      
     47
    3848   i=1
    3949   x = x0
     
    5868       i = i+1
    5969       if i%iprint == 0 :
    60           pass
    61           #FIXME: Should depend on verbosity
    62           #print 'i = %g rTr = %20.15e'% (i,rTr)
     70          logger.info('i = %g rTr = %20.15e'% (i,rTr))
    6371
    64    #FIXME: Should this raise an exception?       
     72   #FIXME: Should this raise an exception?
    6573   if i==imax:
    6674     print 'max number of iterations attained'
    6775
    6876   return x
    69 
    70 
  • inundation/ga/storm_surge/pyvolution/pyvolution.ini

    r1065 r1150  
    11[Files MRU]
    2 0=c:\home\projects\python-fvm\pyvolution\cg_solve.py.html
    3 1=c:\home\projects\python-fvm\pyvolution\pyvolution.zpi
    4 2=c:\program files\zfw\readme.txt
     20=c:\home\projects\python-fvm\pyvolution\least_squares.py
     31=c:\home\projects\python-fvm\pyvolution\cg_solve.py.html
     42=c:\home\projects\python-fvm\pyvolution\pyvolution.zpi
     53=c:\program files\zfw\readme.txt
  • inundation/ga/storm_surge/pyvolution/test_advection.py

    r1018 r1150  
    133133
    134134        #Populate boundary array with dirichlet conditions.
    135         domain.neighbours = array([[1,-1,-2], [0,-3,-4]])
     135        domain.neighbours = array([[1,-1,-2], [0,-3,-4]])
    136136        domain.set_quantity('stage', [1.0, 0.0], 'centroids')
    137         domain.distribute_to_vertices_and_edges()
     137        domain.distribute_to_vertices_and_edges()
    138138
    139         domain.compute_fluxes()
     139        domain.compute_fluxes()
    140140
    141141        X = domain.quantities['stage'].explicit_update
Note: See TracChangeset for help on using the changeset viewer.