Volume

class pyspline.pyVolume.Volume(recompute=True, **kwargs)[source]

Create an instance of a b-spline surface. There are two ways to initialize the class

  • Creation: Create an instance of the Volume class directly by supplying the required information: kwargs MUST contain the following information: ku, kv, kw, tu, tv, tw, coef.

  • LMS/Interpolation: Create an instance of the Volume class by using an interpolating spline to given data points or a LMS spline. The following keyword argument information is required:

    1. ku and kv and kw Spline Orders

    2. X real array size (Nu, Nv, Nw, nDim) of data to fit. OR
      1. x (3D) and y (3D) z (3D) 3D volume interpolation/fitting

    3. u, v, w real array of size (Nu, Nv, Nw). Optional

    4. nCtlu, nCtlv, nCtlw. Specify number of control points. Only for LMS fitting.

Parameters
kuint

Spline order in u

kvint

Spline order in v

kwint

Spline order in w

nCtluint

Number of control points in u

nCtlvint

Number of control points in v

nCtlwint

Number of control points in w

coefarray, size (nCtlu, nCtl, nDim)

b-spline coefficient array.

tuarray, size(nCtlu + ku)

knot array in u

tvarray, size(nCtlv + kv)

knot array in v

twarray, size(nCtlw + kw)

knot array in w

Xarray, size (Nu, Nv, Nw, ndim)

Full data array to fit

xarray, size (Nu, Nv)

Just x data to fit/interpolate

yarray, size (Nu, Nv, Nw)

Just y data to fit/interpolate

zarray, size (Nu, Nv, Nw)

Just z data to fit/interpolate

uarray, size (Nu, Nv, Nw)

Explict u parameters to use. Optional.

varray, size (Nu, Nv, Nw)

Explict v parameters to use. Optional.

warray, size (Nu, Nv, Nw)

Explict w parameters to use. Optional.

nIterint

Number of Hoscheks parater corrections to run

recomputebool

Specifies whether the actual fitting is completed.

Notes

The orientation of the nodes, edges and faces for the volumes is given below:

          NODES      |           EDGES         |           FACES
      6           7|             5          |
      #-----------#|       #------------#  |          #-----------#
     /           / |      /|           /|  |         /|          /|
    /           /  |     / |          / |  |        / |         / |
   /           /   |   6/  |        7/  |  |       /  |   1    /  |
  /           /    |   /   |10      /   |11|      /   |    ---------- 5
 /           /     |  /    |    4  /    |  |     /    |      /    |(back)
#-----------#      | #------------#     |  |    #-----------#     |
4           5      | |     |      |     |  |    |     |     |     |
                   | |     |      |     |  |    |     |     |     | <-3
      2           3| |     |   1  |     |  |2-> |     |     |     |
      #-----------#| |     #------|-----#  |    |     #-----|-----#
     /           / | |8   /       |9   /   |4 ----------    |    /
    /           /  | |   /        |   /    |    |   /       |   /
   /           /   | |  /2        |  /3    |    |  /      0 |  /
  /           /    | | /          | /      |    | /         | /
 /           /     | |/           |/       |    |/          |/
#-----------#      | #------------#        |    #-----------#
0           1      |         0             |
calcKnots()[source]

Determine the knots depending on if it is inerpolated or an LMS fit

calcParameterization()[source]

Compute distance based parametrization. Use the fortran function for this

computeData(recompute=False)[source]

Compute discrete data that is used for the Tecplot Visualization as well as the data for doing the brute-force checks

Parameters
recomputebool

If True, recompute the data even if it has already been computed.

getBasisPt(u, v, w, vals, istart, colInd, lIndex)[source]

This function should only be called from pyBlock The purpose is to compute the basis function for a u, v, w point and add it to pyBlocks’s global dPt/dCoef matrix. vals, rowPtr, colInd is the CSR data and lIndex in the local -> global mapping for this volume

getBounds()[source]

Determine the extents of the volume

Returns
xMinarray of length 3

Lower corner of the bounding box

xMaxarray of length 3

Upper corner of the bounding box

getMidPointEdge(edge)[source]

Get the midpoint of the edge using the original data.

Parameters
edgeint

Edge index. Must be 0<edge<11.

Returns
midpointarray of length nDim

Mid point of edge

getMidPointFace(face)[source]

Get the midpoint of the face using the original data.

Parameters
faceint

Face index. Must be 0, 1, 2, 3, 4 or 5

Returns
midpointarray of length nDim

Mid point of face

getOrigValueCorner(corner)[source]

Get the value of the original spline data on the corner if it exists

Parameters
cornerint

Index of corner, 0<=corner<=7

Returns
valuefloat

Original data on corner.

getOrigValuesFace(face)[source]

For a given face index, face, return the 4 corners and the values of the midpoints of the 4 edges on that face.

Parameters
faceint

Index of face, 0<=face<=5

Returns
coordsarray of size (8, ndim)

The first 4 entries are the corner, and the last 4 are the midpoints.

getValue(u, v, w)[source]

Get the value at the volume points(s) u, v, w. This is the main evaluation routine for the volume object.

Parameters
uscalar, vector or matrix or tensor of values

u position

vscalar, vector or matrix or tensor of values

v position

wscalar, vector or matrix or tensor of values

w position

Returns
valuesscalar, vector, matrix or tensor of values

The spline evaluation at (u, v, w)

getValueCorner(corner)[source]

Get the value of the volume spline on the corner.

Parameters
cornerint

Index of corner, 0<=corner<=7

Returns
valuefloat

Volume spline evaluation at corner.

getValueEdge(edge, s)[source]

Get the value at the volume points(s) u, v, w

Parameters
edgeint

Index of edge. Must be between 0 and 11.

sfloat or array

Parameter position(s) along edge to evaluate.

Returns
valuesarray

Array of values evaluated along edge.

insertKnot(direction, s, r)[source]

Insert a knot into the volume along either u, v, w:

Parameters
directionstr

Parameteric direction to insert. Either ‘u’, ‘v’, or ‘w’

sfloat

Parametric position along ‘direction’ to insert

rint

Desired number of times to insert.

Returns
rint

The actual number of times the knot was inserted.

projectPoint(x0, nIter=25, eps=1e-10, **kwargs)[source]

Project a point x0 or points x0 onto the volume and return parametric positions

Parameters
x0array of length 3 or array of size (N, 3)

Points to embed in the volume. If the points do not actually lie in the volume, the closest point is returned

nIterint

Maximum number of Newton iterations to perform

epsfloat

Tolerance for the Newton iteration

ufloat or array of len(X0)

Optional initial guess for u position.

vfloat or array of len(X0)

Optional initial guess for v position.

wfloat or array of len(X0)

Optional initial guess for w position.

Returns
ufloat or array of length N

u parametric position of closest point

vfloat or array of length N

v parametric position of closest point

wfloat or array of length N

w parametric position of closest point

Dfloat or array of length N

Distance between projected point and closest point If the points are ‘inside’ the volume, D should be less than eps.

recompute()[source]

Recompute the volume if any driving data has been modified

setEdgeCurves()[source]

Create edge spline objects for each edge

setFaceSurfaces()[source]

Create face spline objects for each of the faces

writeTecplot(fileName, vols=True, coef=True, orig=False)[source]

Write the volume to a tecplot data file.

Parameters
fileNamestr

Tecplot filename. Should end in .dat

volsbool

Flag specifiying whether the interpolated volume should be used. This is usually True if you want to get an approximation of the entire volume.

coefbool

Flag specifiying if the control points are to be plotted

origbool

Flag specifiying if original data (used for fitting) is to be included. If on original data exists, this argument is ignored.