Changeset 8188


Ignore:
Timestamp:
Jun 19, 2011, 3:54:42 PM (14 years ago)
Author:
paul
Message:

Added state evolved quantity to pipe domain

Location:
trunk/anuga_work/development/2010-projects/anuga_1d/pipe
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain.py

    r8177 r8188  
    3232b         width            width of pipe [m]
    3333t         top              height of pipe above z [m]
     34st        state            state of the cell (pressurised or free surface
    3435eta                        mannings friction coefficient [to appear]
    3536
     
    5859
    5960        conserved_quantities = ['area', 'discharge']
    60         evolved_quantities = ['area', 'discharge', 'elevation', 'height', 'velocity','width','top','stage']
     61        evolved_quantities = ['area', 'discharge', 'elevation', 'height', 'velocity','width','top','stage','state']
    6162        other_quantities = ['friction']
    6263        Generic_domain.__init__(self,
     
    126127        msg = 'Eighth evolved quantity must be "stage"'
    127128        assert self.evolved_quantities[7] == 'stage', msg
     129        msg = 'Ninth evolved quantity must be "state"'
     130        assert self.evolved_quantities[8] == 'state', msg
    128131
    129132        Generic_domain.check_integrity(self)
     
    156159    width      = domain.quantities['width']
    157160    top        = domain.quantities['top']
     161    state      = domain.quantities['state']
    158162
    159163
    160164    from anuga_1d.pipe.pipe_domain_ext import compute_fluxes_pipe_ext
    161     domain.flux_timestep = compute_fluxes_pipe_ext(timestep,domain,area,discharge,bed,height,velocity,width,top)
     165    domain.flux_timestep = compute_fluxes_pipe_ext(timestep,domain,area,discharge,bed,height,velocity,width,top,state)
    162166
    163167#-----------------------------------------------------------------------
     
    186190    top       = domain.quantities['top']
    187191    stage     = domain.quantities['stage']
     192    state     = domain.quantities['state']
    188193
    189194    #Arrays   
     
    196201    t_C   = top.centroid_values
    197202    w_C   = stage.centroid_values
     203    s_C   = state.centroid_values
    198204
    199205    if domain.setstageflag:
     
    241247    b_V  = width.vertex_values
    242248    t_V  = top.vertex_values
     249    s_V  = state.vertex_values
    243250
    244251
     
    283290        self.top    = domain.quantities['top'].vertex_values
    284291        self.stage    = domain.quantities['stage'].vertex_values
    285 
    286         self.evolved_quantities = numpy.zeros(8, numpy.float)
     292        self.state    = domain.quantities['state'].vertex_values
     293
     294        self.evolved_quantities = numpy.zeros(9, numpy.float)
    287295
    288296    def __repr__(self):
     
    304312        q[6] =  self.top[vol_id,edge_id]
    305313        q[7] =  self.stage[vol_id,edge_id]
    306 
     314        q[8] =  self.state[vol_id,edge_id]
    307315        return q
    308316
     
    322330            raise msg
    323331
    324         assert len(evolved_quantities) == 8
     332        assert len(evolved_quantities) == 9
    325333
    326334        self.evolved_quantities=numpy.array(evolved_quantities,numpy.float)
  • trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain_ext.c

    r8187 r8188  
    230230                                double* width_edge_values,
    231231                                double* top_edge_values,
     232                                double* state_edge_values,
    232233                                double* area_boundary_values,
    233234                                double* discharge_boundary_values,
     
    237238                                double* width_boundary_values,
    238239                                double* top_boundary_values,
     240                                double* state_boundary_values,
    239241                                double* area_explicit_update,
    240242                                double* discharge_explicit_update,
     
    242244                                double* max_speed_array) {
    243245
    244   double flux[2], qlm[7], qlp[7], qrm[7], qrp[7], edgeflux[2];
     246  double flux[2], qlm[8], qlp[8], qrm[8], qrp[8], edgeflux[2];
    245247  double max_speed;
    246248  int k, ki, n, m, nm=0;
     
    264266      qlm[5] = width_boundary_values[m];
    265267      qlm[6] = top_boundary_values[m];
     268      qlm[7] = state_boundary_values[m];
    266269
    267270    } else {
     
    277280      qlm[5] = width_edge_values[nm];
    278281      qlm[6] = top_edge_values[nm];
     282      qlm[7] = state_edge_values[nm];
    279283    }
    280284
     
    286290    qlp[5] = width_edge_values[ki];
    287291    qlp[6] = top_edge_values[ki];
     292    qlp[7] = state_edge_values[ki];
    288293
    289294    ki = k*2+1;
     
    299304      qrp[5] = width_boundary_values[m];
    300305      qrp[6] = top_boundary_values[m];
     306      qrp[7] = state_boundary_values[m];
    301307    } else {
    302308      m = neighbour_vertices[ki];
     
    311317      qrp[5] = width_edge_values[nm];
    312318      qrp[6] = top_edge_values[nm];
     319      qrp[7] = state_edge_values[nm];
    313320    }
    314321
     
    320327    qrm[5] = width_edge_values[ki];
    321328    qrm[6] = top_edge_values[ki];
     329    qrm[7] = state_edge_values[ki];
    322330
    323331    _flux_function_pipe(qlm,qlp,qrm,qrp,g,epsilon,h0,edgeflux,&max_speed);
     
    367375    *velocity,
    368376    *width,
    369     *top;
     377    *top,
     378    *state;
    370379
    371380  PyArrayObject
     
    381390    *width_vertex_values,
    382391    *top_vertex_values,
     392    *state_vertex_values,
    383393    *area_boundary_values,
    384394    *discharge_boundary_values,
     
    388398    *width_boundary_values,
    389399    *top_boundary_values,
     400    *state_boundary_values,
    390401    *area_explicit_update,
    391402    *discharge_explicit_update,
     
    397408
    398409  // Convert Python arguments to C
    399   if (!PyArg_ParseTuple(args, "dOOOOOOOO",
     410  if (!PyArg_ParseTuple(args, "dOOOOOOOOO",
    400411                        &timestep,
    401412                        &domain,
     
    406417                        &velocity,
    407418                        &width,
    408                         &top)) {
     419                        &top,
     420                        &state)) {
    409421    PyErr_SetString(PyExc_RuntimeError, "comp_flux_pipe_ext.c: compute_fluxes_pipe_ext could not parse input");
    410422    return NULL;
     
    431443  width_vertex_values      = get_consecutive_array(width, "vertex_values");
    432444  top_vertex_values      = get_consecutive_array(top, "vertex_values");
     445  state_vertex_values      = get_consecutive_array(state, "vertex_values");
    433446
    434447  area_boundary_values     = get_consecutive_array(area,     "boundary_values");
     
    439452  width_boundary_values       = get_consecutive_array(width,     "boundary_values");
    440453  top_boundary_values       = get_consecutive_array(top,     "boundary_values");
     454  state_boundary_values       = get_consecutive_array(state,     "boundary_values");
    441455
    442456
     
    464478                                      (double*) width_vertex_values -> data,
    465479                                      (double*) top_vertex_values -> data,
     480                                      (double*) state_vertex_values -> data,
    466481                                      (double*) area_boundary_values -> data,
    467482                                      (double*) discharge_boundary_values -> data,
     
    471486                                      (double*) width_boundary_values -> data,
    472487                                      (double*) top_boundary_values -> data,
     488                                      (double*) state_boundary_values -> data,
    473489                                      (double*) area_explicit_update -> data,
    474490                                      (double*) discharge_explicit_update -> data,
     
    488504  Py_DECREF(width_vertex_values);
    489505  Py_DECREF(top_vertex_values);
     506  Py_DECREF(state_vertex_values);
    490507  Py_DECREF(area_boundary_values);
    491508  Py_DECREF(discharge_boundary_values);
     
    495512  Py_DECREF(width_boundary_values);
    496513  Py_DECREF(top_boundary_values);
     514  Py_DECREF(state_boundary_values);
    497515  Py_DECREF(area_explicit_update);
    498516  Py_DECREF(discharge_explicit_update);
  • trunk/anuga_work/development/2010-projects/anuga_1d/pipe/test_pipe.py

    r8183 r8188  
    4949    return 4
    5050 
     51def initial_state(x):
     52    return 1
     53 
    5154import time
    5255
     
    8184domain.set_quantity('width',width)
    8285domain.set_quantity('top',top)
     86domain.set_quantity('state',initial_state)
    8387
    8488# Set boundry type, order, timestepping method and limiter
Note: See TracChangeset for help on using the changeset viewer.