Changeset 8209


Ignore:
Timestamp:
Sep 8, 2011, 5:30:37 PM (13 years ago)
Author:
steve
Message:

Commiting quite a few changes to operators and parallel stuff

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/file/sww.py

    r8144 r8209  
    4545        self.domain = domain
    4646
    47         # Exclude ghosts in case this is a parallel domain
    48         self.number_of_nodes = domain.number_of_full_nodes
    49         self.number_of_volumes = domain.number_of_full_triangles
     47        # Probably should exclude ghosts in case this is a parallel domain
     48       
     49        self.number_of_nodes   = domain.number_of_nodes
     50        self.number_of_volumes = domain.number_of_triangles
    5051        #self.number_of_volumes = len(domain)
    5152
     
    109110                                     domain.starttime,
    110111                                     self.number_of_volumes,
    111                                      self.domain.number_of_full_nodes,
     112                                     self.domain.number_of_nodes,
    112113                                     description=description,
    113114                                     smoothing=domain.smooth,
  • trunk/anuga_core/source/anuga/operators/kinematic_viscosity_operator.py

    r8166 r8209  
    99import anuga.utilities.log as log
    1010
    11 from anuga.operators.base_operator import Operator
     11from anuga.operators.elliptic_operator import Operator
    1212
    1313
     
    1818    operator using centroid values.
    1919
    20     div ( diffusivity grad )
    21 
    22     where diffusvity is scalar quantity (defaults to quantity with values = 1)
    23     boundary values of f are used to setup entries associated with cells with boundaries
    24 
    25     There are procedures to apply this operator, ie
    26 
    27     (1) Calculate div( diffusivity grad u )
    28     using boundary values stored in u
    29 
    30     (2) Calculate ( u + dt div( diffusivity grad u )
    31     using boundary values stored in u
    32 
    33     (3) Solve div( diffusivity grad u ) = f
    34     for quantity f and using boundary values stored in u
    35 
    36     (4) Solve ( u + dt div( diffusivity grad u ) = f
    37     for quantity f using boundary values stored in u
     20
     21    As an anuga operator, when the __call__ method is called one step of the parabolic
     22    step is applied. In particular the x and y velocities are updated using
     23
     24    du/dt = div( h grad u )
     25    dv/dt = div( h grad v )
    3826
    3927    """
     
    4129    def __init__(self, domain, use_triangle_areas=True, verbose=False):
    4230        if verbose: log.critical('Kinematic Viscosity: Beginning Initialisation')
     31       
     32
     33        Operator.__init__(self,domain)
     34
    4335        #Expose the domain attributes
    44 
    45         Operator.__init__(self,domain)
    46 
    4736        self.mesh = self.domain.mesh
    4837        self.boundary = domain.boundary
    4938        self.boundary_enumeration = domain.boundary_enumeration
    5039       
    51         # Pick up height as diffusivity
     40        # Setup a quantity as diffusivity
     41        # FIXME SR: Could/Should pass a quantity which already exists
    5242        self.diffusivity = Quantity(self.domain)
    5343        self.diffusivity.set_values(1.0)
     
    159149    def statistics(self):
    160150
    161         message = 'You need to implement operator statistics for your operator'
     151        message = 'Kinematic_viscosity_operator '
    162152        return message
    163153
  • trunk/anuga_core/source/anuga_parallel/parallel_generic_communications.py

    r8107 r8209  
    1818    """Buffers for synchronisation of timesteps
    1919    """
    20        
     20
    2121    domain.local_timestep = num.zeros(1, num.float)
    2222    domain.global_timestep = num.zeros(1, num.float)
     
    2424    domain.local_timesteps = num.zeros(domain.numproc, num.float)
    2525
    26 
    2726    domain.communication_time = 0.0
    2827    domain.communication_reduce_time = 0.0
    2928    domain.communication_broadcast_time = 0.0
    3029
    31        
    3230
    3331def communicate_flux_timestep(domain, yieldstep, finaltime):
  • trunk/anuga_core/source/anuga_parallel/parallel_meshes.py

    r8026 r8209  
    4242
    4343
    44 
     44    import pypar
    4545    m_low, m_high = pypar.balance(m_g, numprocs, myid)
    4646   
  • trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r8200 r8209  
    2626                 full_send_dict=None,
    2727                 ghost_recv_dict=None,
    28 #                 number_of_full_nodes=None,
    29 #                 number_of_full_triangles=None,
     28                 number_of_full_nodes=None,
     29                 number_of_full_triangles=None,
    3030                 geo_reference=None): #jj added this
    3131
     
    3838                        processor=pypar.rank(),
    3939                        numproc=pypar.size(),
    40 #                        number_of_full_nodes=number_of_full_nodes,
    41 #                        number_of_full_triangles=number_of_full_triangles,
     40                        number_of_full_nodes=number_of_full_nodes,
     41                        number_of_full_triangles=number_of_full_triangles,
    4242                        geo_reference=geo_reference) #jj added this
    4343
  • trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangle.py

    r8011 r8209  
    2929# Parallel interface
    3030#---------------------------
    31 from anuga_parallel.interface import Parallel_shallow_water_domain
    32 from anuga_parallel.interface import parallel_rectangle
    33 from anuga_parallel.interface import myid, numprocs, finalize, get_processor_name
     31from anuga_parallel import Parallel_shallow_water_domain
     32from anuga_parallel import parallel_rectangle
     33from anuga_parallel import myid, numprocs, finalize, get_processor_name
    3434
    35 ###############################
    36 # Read in processor information
    37 ###############################
    38 #numprocs = numprocs()
    39 #myid     = myid()
     35
    4036processor_name = get_processor_name()
    4137
     
    6258
    6359
    64 
     60print 'after parallel domain'
    6561
    6662
     
    7571domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R, 'ghost': None} )
    7672
     73
     74print 'after set_boundary'
    7775
    7876
     
    9593        return self.h0 + self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
    9694
     95print 'after check_integrity'
     96
    9797domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
    9898
     99
     100print 'after set quantity'
    99101
    100102# Set Evolve parameters
     
    110112
    111113
     114print 'after evolve parameters'
    112115
    113116
     117import pdb; pdb.set_trace()
    114118
    115119if myid == 0:
  • trunk/anuga_validation/validation_tests/periodic_wave.py

    r8155 r8209  
    5151# Setup Algorithm
    5252#------------------------------------------------------------------------------
    53 domain.set_timestepping_method('rk2')
     53domain.set_timestepping_method(2)
    5454domain.set_default_order(2)
    5555
     
    5959domain.tight_slope_limiters = False
    6060domain.use_centroid_velocities = False
     61domain.set_beta(1.5)
    6162
    6263domain.CFL = 1.0
     
    7374# Setup initial conditions
    7475#------------------------------------------------------------------------------
    75 domain.set_quantity('elevation',-10.0)
     76domain.set_quantity('elevation',-100.0)
    7677domain.set_quantity('friction', 0.00)
    7778domain.set_quantity('stage', 0.0)           
     
    8788Bw = anuga.Time_boundary(domain=domain,     # Time dependent boundary 
    8889## Sine wave
    89                   f=lambda t: [(-amplitude*sin((1./600.)*t*2*pi)), 0.0, 0.0])
     90                  f=lambda t: [(-amplitude*sin((1./900.)*t*2*pi)), 0.0, 0.0])
    9091## Sawtooth?
    9192#                   f=lambda t: [(-8.0*(sin((1./180.)*t*2*pi))+(1./2.)*sin((2./180.)*t*2*pi)+(1./3.)*sin((3./180.)*t*2*pi)), 0.0, 0.0])
  • trunk/anuga_work/development/2010-projects/anuga_1d/channel/channel_domain.py

    r8195 r8209  
    140140        #Call correct module function
    141141        #(either from this module or C-extension)
    142         distribute_to_vertices_and_edges_limit_s_v_h(self)
    143         #distribute_to_vertices_and_edges_limit_s_v(self)
     142        #distribute_to_vertices_and_edges_limit_s_v_h(self)
     143        distribute_to_vertices_and_edges_limit_s_v(self)
    144144       
    145145
  • trunk/anuga_work/development/2010-projects/anuga_1d/channel/test_padarn.py

    r8194 r8209  
    4747
    4848# Set final time and yield time for simulation
    49 finaltime = 200.0
     49finaltime = 1000.0
    5050yieldstep = 10.0
    5151
  • trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain.py

    r8196 r8209  
    140140        #Call correct module function
    141141        #(either from this module or C-extension)
    142         distribute_to_vertices_and_edges_limit_s_v_h(self)
    143         #distribute_to_vertices_and_edges_limit_s_v(self)
     142        #distribute_to_vertices_and_edges_limit_s_v_h(self)
     143        distribute_to_vertices_and_edges_limit_s_v(self)
    144144       
    145145
  • trunk/anuga_work/development/2010-projects/anuga_1d/pipe/test_pipe.py

    r8197 r8209  
    3636
    3737def top(x):
    38     return 4.0
     38    return 20.0
    3939
    4040def initial_area(x):
     
    5252
    5353# Set final time and yield time for simulation
    54 finaltime = 130.0
     54finaltime = 100.0
    5555yieldstep = 1.0
    5656
  • trunk/anuga_work/development/2010-projects/anuga_1d/sww/run_tsunami_model.py

    r8206 r8209  
    2727    return y
    2828
    29 tsunami_centre = -200000
     29tsunami_centre = -400000
    3030tsunami_radius = 100000
    3131tsunami_height = 2.0
     
    4040import time
    4141
    42 # Set final time and yield time for simulation
    43 finaltime = 60*10
    44 yieldstep = finaltime
     42
    4543
    4644# Length of channel (m)
     
    6765#domain.set_boundary({'exterior': Dirichlet_boundary([14,20,0,1.4,20/14,9])})
    6866Br = Reflective_boundary(domain)
    69 domain.set_boundary({'left': Br, 'right' : Br })
     67Bt = Transmissive_boundary(domain)
     68domain.set_boundary({'left': Bt, 'right' : Br })
    7069#domain.set_boundary({'exterior': Br})
    7170
     
    8079t0 = time.time()
    8180
    82 finaltime= 60*60*8
     81# Set final time and yield time for simulation
     82finaltime= 60*60*6
     83yieldstep = finaltime
     84
    8385
    8486#===================================================================
  • trunk/anuga_work/development/2010-projects/anuga_1d/sww/sww_boundary_conditions.py

    r7884 r8209  
    3636    This class is specific to the shallow water equation as it
    3737    works with the momentum quantities assumed to be the second
    38     and third conserved quantities.
     38    conserved quantities.
    3939    """
    4040
     
    7878
    7979
     80class Transmissive_boundary(Boundary):
     81    """Transmissive boundary returns same conserved quantities as
     82    those present in its neighbour volume but reflected.
     83
     84    This class is specific to the shallow water equation as it
     85    works with the momentum quantities assumed to be the second
     86    quantities.
     87    """
     88
     89    def __init__(self, domain = None):
     90        Boundary.__init__(self)
     91
     92        if domain is None:
     93            msg = 'Domain must be specified for transmissive boundary'
     94            raise msg
     95
     96        #Handy shorthands
     97        self.normals  = domain.normals
     98        self.stage    = domain.quantities['stage'].vertex_values
     99        self.xmom     = domain.quantities['xmomentum'].vertex_values
     100        self.bed      = domain.quantities['elevation'].vertex_values
     101        self.height   = domain.quantities['height'].vertex_values
     102        self.velocity = domain.quantities['velocity'].vertex_values
     103
     104
     105        self.quantities = numpy.zeros(5, numpy.float)
     106
     107    def __repr__(self):
     108        return 'Transmissive_boundary'
     109
     110
     111    def evaluate(self, vol_id, edge_id):
     112        """Transmissive boundaries mimics the outward momentum
     113        of the volume they serve.
     114        """
     115
     116        q = self.quantities
     117        q[0] =  self.stage[vol_id, edge_id]
     118        q[1] =  self.xmom[vol_id, edge_id]
     119        q[2] =  self.bed[vol_id, edge_id]
     120        q[3] =  self.height[vol_id, edge_id]
     121        q[4] =  self.velocity[vol_id, edge_id]
     122
     123        #normal = self.normals[vol_id,edge_id]
     124
     125        return q
     126
    80127
    81128
  • trunk/anuga_work/development/2010-projects/anuga_1d/sww/sww_domain.py

    r8206 r8209  
    244244    h_C[:] = w_C - z_C
    245245
    246 
    247     u_C[:]  = uh_C/(h_C + h0/(h_C + h0))
     246    #h0 = 1.0e-12
     247    u_C[:]  = uh_C/(h_C + h0/(h_C + 1.0e-16))
    248248
    249249    #print 'domain.order', domain.order
Note: See TracChangeset for help on using the changeset viewer.