# geo_utils

## File IO

pygeo.geo_utils.file_io.getCoordinatesFromFile(fileName)[source]

Get a list of coordinates from a file - useful for testing

Parameters
fileNamestr’

filename for file

Returns
coordinateslist

list of coordinates

pygeo.geo_utils.file_io.readAirfoilFile(fileName, bluntTe=False, bluntTaperRange=0.1, bluntThickness=0.002)[source]

Load the airfoil file

pygeo.geo_utils.file_io.readNValues(handle, N, dtype, binary=False, sep=' ')[source]

Read N values of dtype ‘float’ or ‘int’ from file handle

Read a plot3d file and return the points and connectivity in an unstructured mesh format

pygeo.geo_utils.file_io.writeAirfoilFile(fileName, name, x, y)[source]

write an airfoil file

pygeo.geo_utils.file_io.writeValues(handle, values, dtype, binary=False)[source]

Read N values of type ‘float’ or ‘int’ from file handle

## FFD Generation

pygeo.geo_utils.ffd_generation.createFittedWingFFD(surf, surfFormat, outFile, leList, teList, nSpan, nChord, absMargins, relMargins, liftIndex)[source]

Generates a wing FFD with chordwise points that follow the airfoil geometry.

Parameters
surfpyGeo object or list or str

The surface around which the FFD will be created. See the documentation for pygeo.constraints.DVCon.DVConstraints.setSurface() for details.

surfFormatstr

The surface format. See the documentation for pygeo.constraints.DVCon.DVConstraints.setSurface() for details.

outFilestr

Name of output file written in PLOT3D format.

leListlist or array

List or array of points (of size Nx3 where N is at least 2) defining the ‘leading edge’.

teListlist or array

Same as leList but for the trailing edge.

nSpanint or list of int

Number of spanwise sections in the FFD. Use a list of length N-1 to specify the number for each segment defined by leList and teList and to precisely match intermediate locations.

nChordint

Number of chordwise points in the FFD.

absMarginslist of float

List with 3 items specifying the absolute margins in the [chordwise, spanwise, thickness] directions. This is useful for areas where the relative margin is too small, such as the trailing edge or wing tip. The total margin is the sum of the absolute and relative margins.

relMarginslist of float

List with 3 items specifying the relative margins in the [chordwise, spanwise, thickness] directions. Relative margins are applied as a fraction of local chord, wing span, and local thickness. The total margin is the sum of the absolute and relative margins.

liftIndexint

Index specifying which direction lift is in (same as the ADflow option). Either 2 for the y-axis or 3 for the z-axis. This is used to determine the wing’s spanwise direction.

Examples

>>> CFDSolver = ADFLOW(options=aeroOptions)
>>> surf = CFDSolver.getTriangulatedMeshSurface()
>>> surfFormat = "point-vector"
>>> outFile = "wing_ffd.xyz"
>>> nSpan = [4, 4]
>>> nChord = 8
>>> relMargins = [0.01, 0.001, 0.01]
>>> absMargins = [0.05, 0.001, 0.05]
>>> liftIndex = 3
>>> createFittedWingFFD(surf, surfFormat, outFile, leList, teList, nSpan, nChord, absMargins, relMargins, liftIndex)

pygeo.geo_utils.ffd_generation.write_wing_FFD_file(fileName, slices, N0, N1, N2, axes=None, dist=None)[source]

This function can be used to generate a simple FFD. The FFD can be made up of more than one volume, but the volumes will be connected. It is meant for doing simple wing FFDs.

Parameters
fileNamestr

Name of output file. File is written in plot3d format.

slicesnumpy array of (Nvol+1, 2, 2, 3)

Array of slices. Each slice should contain four points in 3D that will be the corners of the FFD on that slice. If the zeroth dimension size is greater than 2, then multiple volumes will be created, connected by the intermediate slice.

N0integer or list

Number of points to distribute along the zeroth dimension (along the slice direction).

N1integer or list

Number of points to distribute along the first dimension.

N2integer or list

Number of points to distribute along the second dimension.

axeslist of [‘i’, ‘j’, ‘k’] in arbitrary order

The user can interchange which index of the FFD corresponds with each dimension of slices. By default ‘k’ -> 0, ‘j’ -> 1, ‘i’ -> 2.

distlist

For each volume, the user can specify the distribution of points along each dimension. Options include:

• linear

• cosine

• left (tighter spacing on the left side)

• right (tighter spacing on the other left side)

Examples

This is an example of two volumes:

axes = ['k', 'j', 'i']
slices = np.array([
# Slice 1
[[[0, 0, 0], [1, 0, 0]],
[[0, 0.2, 0], [1, 0.2, 0]]],
# Slice 2
[[[0, 0, 2], [1, 0, 2]],
[[0, 0.2, 2], [1, 0.2, 2]]],
# Slice 3
[[[0.5, 0, 6], [1, 0, 6]],
[[0.5, 0.2, 6], [1, 0.2, 6]]],
])

N0 = 5
N1 = 2
N2 = 8

dist = [
['left', 'linear', 'linear'],
['cosine', 'linear', 'right']
]


## Point Reduce

pygeo.geo_utils.remove_duplicates.pointReduce(points, nodeTol=0.0001)[source]

Given a list of N points in ndim space, with possible duplicates, return a list of the unique points AND a pointer list for the original points to the reduced set

pygeo.geo_utils.remove_duplicates.pointReduceBruteForce(points, nodeTol=0.0001)[source]

Given a list of N points in ndim space, with possible duplicates, return a list of the unique points AND a pointer list for the original points to the reduced set

Warning

This is the brute force version of pointReduce().

pygeo.geo_utils.remove_duplicates.unique(s)[source]

Return a list of the elements in s, but without duplicates.

For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3], unique("abcabc") some permutation of ["a", "b", "c"], and unique(([1, 2], [2, 3], [1, 2])) some permutation of [[2, 3], [1, 2]].

For best speed, all sequence elements should be hashable. Then unique() will usually work in linear time.

If not possible, the sequence elements should enjoy a total ordering, and if list(s).sort() doesn’t raise TypeError it’s assumed that they do enjoy a total ordering. Then unique() will usually work in $$\mathcal{O}(N\log_2(N))$$ time.

If that’s not possible either, the sequence elements must support equality-testing. Then unique() will usually work in quadratic time.

pygeo.geo_utils.remove_duplicates.uniqueIndex(s, sHash=None)[source]

This function is based on unique(). The idea is to take a list s, and reduce it as per unique.

However, it additionally calculates a linking index array that is the same size as the original s, and points to where it ends up in the the reduced list

if sHash is not specified for sorting, s is used