Surface
- class pyspline.pySurface.Surface(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 Surface class directly by supplying the required information: kwargs MUST contain the following information:
ku, kv, tu, tv, coef
.LMS/Interpolation: Create an instance of the Surface class by using an interpolating spline to given data points or a LMS spline. The following keyword argument information is required:
ku
andkv
Spline OrdersX
real array size (Nu, Nv, nDim) of data to fit. ORx
(2D) andy
(2D) for 2D surface interpolationx
(3D) andy
(3D) andz
(3) for 3D surface
u
,v
real array of size (Nu, Nv). OptionalnCtlu
,nCtlv
Specify number of control points. Only for LMS fitting.
- Parameters:
- kuint
Spline order in u
- kvint
Spline order in v
- nCtluint
Number of control points in u
- nCtlvint
Number of control points in v
- 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
- Xarray, size (Nu, Nv, ndim)
Full data array to fit
- xarray, size (Nu, Nv)
Just x data to fit/interpolate
- yarray, size (Nu, Nv)
Just y data to fit/interpolate
- uarray, size (Nu, Nv)
Explicit u parameters to use. Optional.
- varray, size (Nu, Nv)
Explicit v parameters to use. Optional.
- scaledParamsbool
default is to use u,v for parameterization. If true use u,v as well. If false, use U,V.
- nIterint
Number of Hoscheks parameter corrections to run
Notes
The orientation of the nodes, edges and faces is the same as the bottom surface as described in
Volume
documentation.- 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, vals, istart, colInd, lIndex)[source]
This function should only be called from pyGeo The purpose is to compute the basis function for a u, v point and add it to pyGeo’s global dPt/dCoef matrix. vals, row_ptr, col_ind is the CSR data and lIndex in the local -> global mapping for this surface
- getBounds()[source]
Determine the extents of the surface
- Returns:
- xMinarray of length 3
Lower corner of the bounding box
- xMaxarray of length 3
Upper corner of the bounding box
- getDerivative(u, v)[source]
Evaluate the first derivatives of the spline surface
- Parameters:
- ufloat
Parametric u value
- vfloat
Parametric v value
- Returns:
- derivarray size (2,3)
Spline derivative evaluation at u,vall points u,v. Shape depend on the input.
- getOrigValueCorner(corner)[source]
Return the original data for he spline at the corner if it exists
- Parameters:
- cornerint
Corner index 0<=corner<=3
- Returns:
- valuefloat
Original value at corner
- getOrigValuesEdge(edge)[source]
Return the endpoints and the mid-point value for a given edge.
- Parameters:
- edgeint
Edge index 0<=edge<=3
- Returns:
- startValuearray size nDim
Original value at start of edge
- midValuearray size nDim
Original value at mid point of edge
- endValuearray size nDim
Original value at end of edge.
- getSecondDerivative(u, v)[source]
Evaluate the second derivatives of the spline surface
- deriv = [ (d^2)/(du^2) (d^2)/(dudv) ]
[ (d^2)/(dudv) (d^2)/(dv^2) ]
- Parameters:
- ufloat
Parametric u value
- vfloat
Parametric v value
- Returns:
- derivarray size (2,2,3)
Spline derivative evaluation at u,vall points u,v. Shape depend on the input.
- getValue(u, v)[source]
Evaluate the spline surface at parametric positions u,v. This is the main function for spline evaluation.
- Parameters:
- ufloat, array or matrix (rank 0, 1, or 2)
Parametric u values
- vfloat, array or matrix (rank 0, 1, or 2)
Parametric v values
- Returns:
- valuesvaries
Spline evaluation at all points u,v. Shape depend on the input. If u,v are scalars, values is array of size nDim. If u,v are a 1D list, return is (N,nDim) etc.
- getValueCorner(corner)[source]
Evaluate the spline spline at one of the four corners
- Parameters:
- cornerint
Corner index 0<=corner<=3
- Returns:
- valuefloat
Spline evaluated at corner
- getValueEdge(edge, s)[source]
Evaluate the spline at parametric distance s along edge ‘edge’
- Parameters:
- edgeint
Edge index 0<=edge<=3
- sfloat or array
Parameter values to evaluate
- Returns:
- valuesarray size (nDim) or array of size (N,nDim)
Requested spline evaluated values
- insertKnot(direction, s, r)[source]
Insert a knot into the surface along either u or v.
- Parameters:
- directionstr
Parameteric direction to insert. Either ‘u’ or ‘v’.
- 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.
- projectCurve(inCurve, nIter=25, eps=1e-10, **kwargs)[source]
Find the minimum distance between this surface (self) and a curve (inCurve).
- Parameters:
- inCurvepySpline.curve object
Curve to use
- nIterint
Maximum number of Newton iterations to perform.
- epsfloat
Desired parameter tolerance.
- sfloat
Initial solution guess for curve
- ufloat
Initial solution guess for parametric u position
- vfloat
Initial solution guess for parametric v position
- Returns:
- ufloat
Surface parameter u yielding min distance to point x0
- ufloat
Surface parameter v yielding min distance to point x0
- sfloat
Parametric position on curve yielding min distance to point x0
- Dfloat
Minimum distance between this surface and curve. is equivalent to ||surface(u,v) - curve(s)||_2.
- projectPoint(x0, nIter=25, eps=1e-10, **kwargs)[source]
Perform a point inversion algorithm. Attempt to find the closest parameter values (u,v) to the given points x0.
- Parameters:
- x0array
A point or list of points in nDim space for which the minimum distance to the curve is sought.
- nIterint
Maximum number of Newton iterations to perform.
- epsfloat
Desired parameter tolerance.
- ufloat or array of length x0
Optional initial guess for u parameter
- vfloat or array of length x0
Optional initial guess for v parameter
- Returns:
- ufloat or array
Solution to the point inversion. u are the u-parametric locations yielding the minimum distance to points x0
- vfloat or array
Solution to the point inversion. v are the v-parametric locations yielding the minimum distance to points x0
- Dfloat or array
Physical distances between the points and the curve. This is simply ||surface(u,v) - X0||_2.
- splitSurface(direction, s)[source]
Split surface into two surfaces at parametric location s
- Parameters:
- directionstr
Parameteric direction along which to split. Either ‘u’ or ‘v’.
- sfloat
Parametric position along ‘direction’ to split
- Returns:
- surf1pySpline.surface
Lower part of the surface
- surf2pySpline.surface
Upper part of the surface
- windowSurface(uvLow, uvHigh)[source]
Create a surface that is windowed by the rectangular parametric range defined by uvLow and uvHigh.
- Parameters:
- uvLowlist or array of length 2
(u,v) coordinates at the bottom left corner of the parameteric box
- uvHighlist or array of length 2
(u,v) coordinates at the top left corner of the parameteric box
- Returns:
- surfpySpline.surface
A new surface defined only on the interior of uvLow -> uvHigh
- writeIGES_directory(handle, Dcount, Pcount)[source]
Write the IGES file header information (Directory Entry Section) for this surface
- writeIGES_parameters(handle, Pcount, counter)[source]
Write the IGES parameter information for this surface
- writeTecplot(fileName, surf=True, coef=True, orig=True, directions=False)[source]
Write the surface to a tecplot .dat file
- Parameters:
- fileNamestr
File name for tecplot file. Should have .dat extension
- surfbool
Flag to write discrete approximation of the actual surface
- coef: bool
Flag to write b-spline coefficients
- origbool
Flag to write original data (used for fitting) if it exists
- directionsbool
Flag to write surface direction visualization