CADWRDeltaModeling / BayDeltaSCHISM

Tools, scripts, templates and data for running SCHISM on the Bay-Delta
https://cadwrdeltamodeling.github.io/BayDeltaSCHISM
Apache License 2.0
5 stars 7 forks source link

Geometry calculation enhancements to SchismMesh #3

Open water-e opened 6 years ago

water-e commented 6 years ago

These are proposed use cases for geometry calculations and quadrature. The ones that involve mass/moment calculations like centroid() are self-expoanatory. The quadrature takes several flavors. In one, motivated by mesh smoothing, it is desirable to deliver quadrature pionts and weights to an outside process that will populate the quadrature points on its own. In another set of cases, the points are assumed to live on the mesh and be linear/bilinear and can be integrated exactly. An example of that would be integrating the water surface. Finally, a quantity could be defined on the nodes but be non-linear in a quantity assumed bilinear (e.g., elev*elev). In this case quadrature is used but there are differences (and simplifications) that happen because the quadrature and values are both defined in triangular/bilinear coordinates.

### Enhancements to mesh (geometry mixin?)

k = some edge
j = some element
c = mesh or some other class built from mesh

len0 = c.edge_len(k)
edgelens = c.edge_lens  # or ()

a0 = c.area(j)
a0 = c.areas   # or ()

x,y = c.centroid(j)
nx2 = c.centroids

# For a quantity not defined on grid (ie offline bathymetry)
nodes, weights = c.quadrature(j,n=model_n)     # maybe n doesn't have to be offered 
Nodes, Weights = c.quadrature_pts(n=model_n)   # n is the # of points

# Note that the quadrature method here allows great simplification relative to the one above
# because values are presumably at nodes
el_vals = c.integrate_nodes(node_vals,method="exact|quadrature")
el_vals = c.ave_nodes(node_vals,method = ...)  # note lots of shared code

quadsparse = c.quadrature_matrix  # returns sparse matrix specialized for multiplication
kjnam commented 6 years ago

Calculation of the areas and edge lengths are added.

kjnam commented 6 years ago

A centroid calculation routine is added.