fastwater.general.meshTools module

Functions for the manipulation and interpolation of data on unstructured triangular meshes.

fastwater.general.meshTools.getBarycentricWeights(p1, p2, p3, p)[source]

Calculate Barycentric weights for point p within triangle (p1,p2,p3)

Parameters
  • p1 (list[ float ]) – [x, y] coordinates for triangle corner point p1.

  • p2 (list[ float ]) – [x, y] coordinates for triangle corner point p2.

  • p3 (list[ float ]) – [x, y] coordinates for triangle corner point p3.

  • p (list[ float ]) – [x, y] coordinates for point p within triangle (p1, p2, p3).

Returns

[w1, w2 ,w3] – barycentric weights for triangle (p1, p2, p3).

Return type

list

fastwater.general.meshTools.getCentroidWeights(p1, p2, p3)[source]

Calculate Barycentric weights for interpolating data on the centroid of the triange defined by the points (p1, p2, p3)

Parameters
  • p1 (list[ float ]) – [x, y] coordinates for triangle corner point p1.

  • p2 (list[ float ]) – [x, y] coordinates for triangle corner point p2.

  • p3 (list[ float ]) – [x, y] coordinates for triangle corner point p3.

Returns

centroidWghts – centroid Barycentric weights for triangle (p1, p2, p3).

Return type

list[ float ]

fastwater.general.meshTools.getElemAroundLoc(meshx, meshy, meshElems, LocX, LocY, nLys=1)[source]
fastwater.general.meshTools.getElemNodes(meshx, meshy, elems, LocX, LocY)[source]
fastwater.general.meshTools.getNearestNode(meshX, meshY, locX, locY, nLys=1)[source]
fastwater.general.meshTools.getNodesAroundNode(node, edges)[source]
fastwater.general.meshTools.getNodesWeights(meshx, meshy, elems, LocX, LocY)[source]

Extract the information required to interpolate mesh data onto a specific location defined by the point (LocX, LocY)

Parameters
  • meshx (numpy.array, float) – mesh nodes x coordinate values.

  • meshy (numpy.array, float) – mesh nodes y coordinate values.

  • elems (numpy.ndarray, int) – mesh elements defninition matrix (nElems, 3).

  • LocX (float) – x coordinate of location of interest.

  • LocY (flaat) – y coordinate of location of interest.

Returns

  • NNodes (list[ int ]) – node indices of triangular element corner points.

  • NWghts (list[ float ]) – Barycentric weighting values for triangular element corner points.

  • NLocs (list[ list ]) – list of the triangular element corner point locations (p1[x,y], p2[x,y] ,p3[x,y]).

fastwater.general.meshTools.getTriangleArea(p1, p2, p3)[source]

Calculate area of the triangle defined by the points (p1, p2, p3)

Parameters
  • p1 (list[ float ]) – [x, y] coordinates for triangle corner point p1.

  • p2 (list[ float ]) – [x, y] coordinates for triangle corner point p2.

  • p3 (list[ float ]) – [x, y] coordinates for triangle corner point p3.

Returns

area – the area of the triangle (p1, p2, p3).

Return type

float

fastwater.general.meshTools.getTriangleCentroid(p1, p2, p3)[source]

Calculate the centroid location for the triangle defined by the points (p1, p2, p3)

Parameters
  • p1 (list[ float ]) – [x, y] coordinates for triangle corner point p1.

  • p2 (list[ float ]) – [x, y] coordinates for triangle corner point p2.

  • p3 (list[ float ]) – [x, y] coordinates for triangle corner point p3.

Returns

centroid – centroid location for the triangle (p1, p2, p3).

Return type

list[ float ]

fastwater.general.meshTools.gradation2meshDensity(gradRaster)[source]
fastwater.general.meshTools.gradation2numElems(gradRaster, dx, dy)[source]
fastwater.general.meshTools.gradientAtNode(node, nodes, nodesX, nodesY, var)[source]
fastwater.general.meshTools.interpTriangle(p1, p2, p3, p, v1, v2, v3)[source]

Use Barycentic weighting to interpolate variable data (v1, v2, v3) on triangle corner points (p1, p2, p3) onto the location p.

Parameters
  • p1 (list[ float ]) – [x, y] coordinates for triangle corner point p1.

  • p2 (list[ float ]) – [x, y] coordinates for triangle corner point p2.

  • p3 (list[ float ]) – [x, y] coordinates for triangle corner point p3.

  • p (list[ float ]) – [x, y] coordinates for point p.

  • v1 (float) – variable value at point p1.

  • v2 (floate) – variable value at point p2.

  • v3 (float) – variable value at point p3.

Returns

vp – interpolated variable value at point p.

Return type

float

fastwater.general.meshTools.isInsideTriangle(p1, p2, p3, p)[source]

Determine if the point p lies with in the triangle defeind by (p1, p2, p3)

Parameters
  • p1 (list[ float ]) – [x, y] coordinates for triangle corner point p1.

  • p2 (list[ float ]) – [x, y] coordinates for triangle corner point p2.

  • p3 (list[ float ]) – [x, y] coordinates for triangle corner point p3.

  • p (list[ float ]) – [x, y] coordinates for point p.

Returns

isInside – True/False flag defining whether p is inside (p1, p2, p3).

Return type

bool

fastwater.general.meshTools.meshDensity(areas)[source]
fastwater.general.meshTools.weightsMatrix(nodeWghts, nStps)[source]