Changeset 4200


Ignore:
Timestamp:
Jan 31, 2007, 12:07:32 PM (17 years ago)
Author:
ole
Message:

Added diagnosticts about which triangle is responsible for the largest computed speed.

Location:
anuga_core/source/anuga
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r4020 r4200  
    44
    55   Copyright 2004
    6    Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
     6   Ole Nielsen, Stephen Roberts, Duncan Gray
    77   Geoscience Australia
    88"""
    99
    10 from Numeric import allclose
     10from Numeric import allclose, argmax
    1111from anuga.config import epsilon
    1212
     
    216216        self.already_computed_flux = zeros((N, 3), Int)
    217217
     218        # Storage for maximal speeds computed for each triangle by compute_fluxes
     219        # This is used for diagnostics only
     220        self.max_speed = zeros(N, Float)
     221
    218222        if mesh_filename is not None:
    219223            # If the mesh file passed any quantity values
     
    546550        ##assert hasattr(self, 'boundary_objects')
    547551
    548     def write_time(self):
    549         print self.timestepping_statistics()
    550 
    551 
    552     def timestepping_statistics(self):
     552    def write_time(self, track_location=False):
     553        print self.timestepping_statistics(track_location)
     554
     555
     556    def timestepping_statistics(self, track_location=False):
    553557        """Return string with time stepping statistics for printing or logging
     558
     559        Optional boolean keyword track_location decides whether to report location of smallest timestep.
    554560        """
    555561
     
    568574                     self.max_timestep, self.number_of_steps,
    569575                     self.number_of_first_order_steps)
     576
     577        if track_location is True:
     578            msg += '\n'
     579            # Find index of largest computed flux speed
     580            i = argmax(self.max_speed)
     581
     582            x, y = self.get_centroid_coordinates()[i]
     583
     584            s = 'Triangle #%d with centroid (%.4f, %.4f) ' %(i, x, y)
     585            s += 'had the largest computed speed: %.4f m/s' %(self.max_speed[i])
     586
     587            # FIXME (Ole): Maybe add all quantity values at vertices
     588
     589            msg += s
    570590
    571591        return msg
  • anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r3945 r4200  
    616616            v1 = [x2-x1, y2-y1]
    617617            v2 = [x0-x2, y0-y2]
    618 
    619618            a0 = anglediff(v1, v0)
    620619            a1 = anglediff(v2, v1)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py

    r4026 r4200  
    8282#Evolve
    8383for t in domain.evolve(yieldstep = 0.1, finaltime = 30):
    84     domain.write_time()
     84    domain.write_time(track_location=True)
    8585    domain.write_boundary_statistics(['stage'],'left')
    8686
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r4085 r4200  
    780780        Xmom.explicit_update[k] = flux[1]
    781781        Ymom.explicit_update[k] = flux[2]
     782        domain.max_speed[k] = max_speed
    782783
    783784
     
    832833   
    833834    domain.timestep = compute_fluxes_ext(timestep, domain.epsilon, domain.g,
    834                                      domain.neighbours,
    835                                      domain.neighbour_edges,
    836                                      domain.normals,
    837                                      domain.edgelengths,
    838                                      domain.radii,
    839                                      domain.areas,
    840                                      domain.tri_full_flag,
    841                                      Stage.edge_values,
    842                                      Xmom.edge_values,
    843                                      Ymom.edge_values,
    844                                      Bed.edge_values,
    845                                      Stage.boundary_values,
    846                                      Xmom.boundary_values,
    847                                      Ymom.boundary_values,
    848                                      Stage.explicit_update,
    849                                      Xmom.explicit_update,
    850                                      Ymom.explicit_update,
    851                                      domain.already_computed_flux)
     835                                         domain.neighbours,
     836                                         domain.neighbour_edges,
     837                                         domain.normals,
     838                                         domain.edgelengths,
     839                                         domain.radii,
     840                                         domain.areas,
     841                                         domain.tri_full_flag,
     842                                         Stage.edge_values,
     843                                         Xmom.edge_values,
     844                                         Ymom.edge_values,
     845                                         Bed.edge_values,
     846                                         Stage.boundary_values,
     847                                         Xmom.boundary_values,
     848                                         Ymom.boundary_values,
     849                                         Stage.explicit_update,
     850                                         Xmom.explicit_update,
     851                                         Ymom.explicit_update,
     852                                         domain.already_computed_flux,
     853                                         domain.max_speed)
    852854
    853855
  • anuga_core/source/anuga/shallow_water/shallow_water_ext.c

    r4191 r4200  
    12171217    *xmom_explicit_update,
    12181218    *ymom_explicit_update,
    1219     *already_computed_flux;//tracks whether the flux across an edge has already been computed
    1220 
     1219    *already_computed_flux,//tracks whether the flux across an edge has already been computed
     1220    *max_speed_array; //Keeps track of max speeds for each triangle
    12211221
    12221222  //Local variables
     
    12311231
    12321232  // Convert Python arguments to C
    1233   if (!PyArg_ParseTuple(args, "dddOOOOOOOOOOOOOOOOOO",
     1233  if (!PyArg_ParseTuple(args, "dddOOOOOOOOOOOOOOOOOOO",
    12341234                        &timestep,
    12351235                        &epsilon,
     
    12501250                        &xmom_explicit_update,
    12511251                        &ymom_explicit_update,
    1252                         &already_computed_flux)) {
     1252                        &already_computed_flux,
     1253                        &max_speed_array)) {
    12531254    PyErr_SetString(PyExc_RuntimeError, "Input arguments failed");
    12541255    return NULL;
     
    12611262    ((double *) stage_explicit_update -> data)[k]=0.0;
    12621263    ((double *) xmom_explicit_update -> data)[k]=0.0;
    1263     ((double *) ymom_explicit_update -> data)[k]=0.0;
    1264   }
     1264    ((double *) ymom_explicit_update -> data)[k]=0.0; 
     1265  }
     1266 
    12651267  //Loop through neighbours and compute edge flux for each
    12661268  for (k=0; k<number_of_elements; k++) {
     
    13271329    }
    13281330    } // end for i
     1331   
    13291332    //Normalise by area and store for when all conserved
    13301333    //quantities get updated
     
    13321335    ((double *) xmom_explicit_update -> data)[k] /= ((double *) areas -> data)[k];
    13331336    ((double *) ymom_explicit_update -> data)[k] /= ((double *) areas -> data)[k];
     1337   
     1338   
     1339    //Keep track of maximal speeds
     1340    ((double *) max_speed_array -> data)[k] = max_speed;   
     1341   
    13341342  } //end for k
    13351343  return Py_BuildValue("d", timestep);
Note: See TracChangeset for help on using the changeset viewer.