ocmw.core.meshTools module

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

getBarycentricWeights

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

getTriangleArea

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

getTriangleCentroid

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

isInsideTriangle

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

interpTriangle

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

getElemAroundLoc

Identify themesh element that contians the location [LocX,LocY]

getElemNodes

Get the mesh nodes of the element that contains the location [LocX,LocY]

getNearestNode

Get the nearest mesh node to the location [LocX,LocY]

getNodesAroundNode

Get all mesh nodes that a connected to a specific mesh node.

weightsMatrix

Convert a set of node barycentric weights to matrix for layered models.

getCentroidWeights

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

getNodesWeights

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

gradientAtNode

Calculate spatial gradient of a variable at a model node.

meshDensity

Calculate mesh local mesh density based on element area

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

ocmw.core.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] (list) – barycentric weights for triangle (p1, p2, p3).

ocmw.core.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 (float) – the area of the triangle (p1, p2, p3).

ocmw.core.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 (list[ float ]) – centroid location for the triangle (p1, p2, p3).

ocmw.core.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 (bool) – True/False flag defining whether p is inside (p1, p2, p3).

ocmw.core.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 (float) – interpolated variable value at point p.

ocmw.core.meshTools.getElemAroundLoc(meshx, meshy, meshElems, LocX, LocY, nLys=1)[source]

Identify themesh element that contians the location [LocX,LocY]

ocmw.core.meshTools.getElemNodes(meshx, meshy, elems, LocX, LocY)[source]

Get the mesh nodes of the element that contains the location [LocX,LocY]

ocmw.core.meshTools.getNearestNode(meshX, meshY, locX, locY, nLys=1, exclude=[])[source]

Get the nearest mesh node to the location [LocX,LocY]

ocmw.core.meshTools.getNodesAroundNode(node, edges)[source]

Get all mesh nodes that a connected to a specific mesh node.

ocmw.core.meshTools.weightsMatrix(nodeWghts, nLays)[source]

Convert a set of node barycentric weights to matrix for layered models.

ocmw.core.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 (list[ float ]) – centroid Barycentric weights for triangle (p1, p2, p3).

ocmw.core.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]).

ocmw.core.meshTools.gradientAtNode(node, nodes, nodesX, nodesY, var)[source]

Calculate spatial gradient of a variable at a model node.

ocmw.core.meshTools.meshDensity(areas)[source]

Calculate mesh local mesh density based on element area

Parameters:

areas (numpy.array, float) – Mesh element areas.

Returns:

mshDen (numpy.array) – Mesh density at element centroid.