# Utils

exception pyspline.utils.Error(message)[source]

Format the error message in a box to make it clear this was a explicitly raised exception.

pyspline.utils.bilinearSurface(*args)[source]

This is short-cut function to create a bilinear surface.

Args can contain:

1. x array of size(4, 3). The four corners of the array arranged in the coordinate direction orientation:

2          3
+----------+
|          |
|          |
|          |
+----------+
0          1

2. p1, p2, p3, p4. Individual corner points in CCW Ordering:

3          2
+----------+
|          |
|          |
|          |
+----------+
0          1

pyspline.utils.checkInput(inputVal, inputName, dataType, dataRank, dataShape=None)[source]

This is a generic function to check the data type and sizes of inputs in functions where the user must supply proper values. Since Python does not do type checking on Inputs, this is required

Parameters
inputint, float, or complex

The input argument to check

inputNamestr

The name of the variable, so it can be identified in an Error message

dataTypestr

Numpy string dtype code

dataRankint

Desired rank. 0 for scalar, 1 for vector 2 for matrix etc

dataShapetuple

The required shape of the data. Scalar is denoted by () Vector is denoted by (n, ) where n is the shape Matrix is denoted by (n, m) where n and m are rows/columns

Returns
outputvarious

The input transformed to the correct type and guaranteed to the desired size and shape.

pyspline.utils.closeTecplot(f)[source]

Close Tecplot file opened with openTecplot()

pyspline.utils.line(*args, **kwargs)[source]

This is a short cut function to create a line as a pySpline Curve object.

Args can contain: (pick one)

1. X array of size(2, ndim). The two end points

2. x1, x2 The two end points (each of size ndim)

3. x, dir=direction. A point and a displacement vector

4. x1, dir=direction, length=length. As 3. but with a specific length

pyspline.utils.line_plane(ia, vc, p0, v1, v2)[source]

Check a line against multiple planes. Solve for the scalars $$\alpha, \beta, \gamma$$ such that

$\begin{split}i_a + \alpha \times v_c &= p_0 + \beta \times v_1 + \gamma \times v_2 \\ i_a - p_0 &= \begin{bmatrix}-v_c & v_1 & v_2\end{bmatrix}\begin{bmatrix}\alpha\\\beta\\\gamma\end{bmatrix}\\ \alpha &\ge 0: \text{The point lies above the initial point}\\ \alpha &< 0: \text{The point lies below the initial point}\end{split}$

The domain of the triangle is defined by

$\beta + \gamma = 1$

and

$0 < \beta, \gamma < 1$
Parameters
iandarray[3]

initial point

vcndarray[3]

search vector from initial point

p0ndarray[3, n]

vector to triangle origins

v1ndarray[3, n]

vector along first triangle direction

v2ndarray[3, n]

vector along second triangle direction

Returns
solreal ndarray[6, n]

Solution vector—parametric positions + physical coordinates

nSolint

Number of solutions

pidint ndarray[n]
pyspline.utils.openTecplot(fileName, ndim)[source]

A Generic function to open a Tecplot file to write spatial data.

Parameters
fileNamestr

Tecplot filename. Should have a .dat extension.

ndimint

Number of spatial dimensions. Must be 1, 2 or 3.

Returns
ffile handle

Open file handle

pyspline.utils.plane_line(ia, vc, p0, v1, v2)[source]

Check a plane against multiple lines

Parameters
iandarray[3, n]

initial point

vcndarray[3, n]

search vector from initial point

p0ndarray[3]

vector to triangle origins

v1ndarray[3]

vector along first triangle direction

v2ndarray[3]

vector along second triangle direction

Returns
solndarray[6, n]

Solution vector - parametric positions + physical coordiantes

nSolint

Number of solutions

This routine searches for the closest point on a set of quads for each searchPt. An ADT tree is built and used for the search and subsequently destroyed.

Parameters
ptsndarray[3, nPts]

connndarray[4, nConn]

local connectivity of the quad elements

searchPtsndarray[3, nSearchPts]

set of points to search for

Returns
faceIDndarray[nSearchPts]

index of the quad elements, one for each search point

uvndarray[2, nSearchPts]

parametric u and v weights of the projected point on the closest quad

pyspline.utils.tfi2d(e0, e1, e2, e3)[source]

Perform a simple 2D transfinite interpolation in 3D.

Parameters
e0ndarray[3, Nu]

coordinates along 0th edge

e1ndarray[3, Nu]

coordinates along 1st edge

e2ndarray[3, Nv]

coordinates along 2nd edge

e3ndarray[3, Nv]

coordinates along 3rd edge

Returns
Xndarray[3 x Nu x Nv]

evaluated points

pyspline.utils.trilinearVolume(*args)[source]

This is a short-cut function to create a trilinear b-spline volume. It can be created with x OR with xmin and xmax`.

Parameters
xarray of size (2, 2, 2, 3)

Coordinates of the corners of the box.

xminarray of size (3)

The extreme lower corner of the box

xmaxarray of size (3)

The extreme upper corner of the box. In this case, by construction, the box will be coordinate axis aligned.

pyspline.utils.writeTecplot1D(handle, name, data, solutionTime=None)[source]

A Generic function to write a 1D data zone to a tecplot file. Parameters ———- handle : file handle

Open file handle

namestr

Name of the zone to use

dataarray of size (N, ndim)

1D array of data to write to file

SolutionTimefloat

Solution time to write to the file. This could be a fictitious time to make visualization easier in tecplot.

pyspline.utils.writeTecplot2D(handle, name, data, solutionTime=None)[source]

A Generic function to write a 2D data zone to a tecplot file. Parameters ———- handle : file handle

Open file handle

namestr

Name of the zone to use

data2D np array of size (nx, ny, ndim)

2D array of data to write to file

SolutionTimefloat

Solution time to write to the file. This could be a fictitious time to make visualization easier in tecplot.

pyspline.utils.writeTecplot3D(handle, name, data, solutionTime=None)[source]

A Generic function to write a 3D data zone to a tecplot file. Parameters ———- handle : file handle

Open file handle

namestr

Name of the zone to use

data3D np array of size (nx, ny, nz, ndim)

3D array of data to write to file

SolutionTimefloat

Solution time to write to the file. This could be a fictitious time to make visualization easier in tecplot.