The surface and curve Classes

The main classes used for handling complex geometries are the surface and curve classes. surface is used in 3D problems, while curve is used in 2D problems. The only differences in the classes are the number of dimensions; otherwise they are identical.

class fdfault.surface(n1, n2, direction, x, y, z)

The surface class represents a surface for defining interfaces and block boundaries

Each surface contains the following attributes:

Variables:
  • n1 – Number of grid points in the first spatial direction (x unless the interface is an 'x' interface)
  • n2 – Number of grid points in the second spatial direction (z unless the interface is a 'z' interface)
  • direction – Normal direction in computational space
  • x – Numpy array holding x coordinates, must have shape (n1,n2)
  • y – Numpy array holding y coordinates, must have shape (n1,n2)
  • z – Numpy array holding z coordinates, must have shape (n1,n2)
__init__(n1, n2, direction, x, y, z)

Initialize a surface instance

Required arguments are n1 and n2, which are number of grid points in each direction, a direction which indicates the surface orientation in computational space ('x', 'y', or 'z'), plus three arrays x, y, and z (must have shape (n1, n2) that hold the coordinates for the new surface. Initializing with a negative number of grid points, with arrays that do not have the correct shape, or with a bad string for the surface orientation will result in an error.

Parameters:
  • n1 (int) – Number of grid points along first dimension
  • n2 (int) – Number of grid points along second dimension
  • direction (str) – String indicating surface normal direction in computational space (must be 'x', 'y', or 'z')
  • x (ndarray) – Array holding surface x coordinates (must have shape (n1, n2))
  • y (ndarray) – Array holding surface y coordinates (must have shape (n1, n2))
  • z (ndarray) – Array holding surface z coordinates (must have shape (n1, n2))
Returns:

New surface with specified properties

Return type:

surface

get_direction()

Returns approximate normal direction

Returns:Normal direction in computational space
Return type:str
get_n1()

Returns number of grid points along first dimension

Returns:Number of grid points along first dimension (x unless interface direction is 'x')
Return type:int
get_n2()

Returns number of grid points along second dimension

Returns:Number of grid points along second dimension (z unless interface direction is 'z')
Return type:int
get_x(i=None)

Returns x coordinate array

if no argument is provided, the method returns the entire array. Otherwise, i must be a valid index tuple for the array.

Parameters:i (tuple or None) – Index tuple (must be a valid index into the array). Optional, if not provided or if None is given, this returns the entire array.
Returns:Value of x coordinate
Return type:ndarray or float
get_y(i=None)

Returns y coordinate array

if no argument is provided, the method returns the entire array. Otherwise, i must be a valid index tuple for the array.

Parameters:i (tuple or None) – Index tuple (must be a valid index into the array). Optional, if not provided or if None is given, this returns the entire array.
Returns:Value of y coordinate
Return type:ndarray or float
get_z(i=None)

Returns z coordinate array

if no argument is provided, the method returns the entire array. Otherwise, i must be a valid index tuple for the array.

Parameters:i (tuple or None) – Index tuple (must be a valid index into the array). Optional, if not provided or if None is given, this returns the entire array.
Returns:Value of z coordinate
Return type:ndarray or float
has_same_edge(edge1, edge2, othersurf)

Compares the edges of two surfaces

The method compares the edges of two surfaces, using the indices 0-3 to indicate the edges (one argument must be provided for each surface)

  • 0 means edge where second index is zero
  • 1 means edge where first index is zero
  • 2 means edge where second index is n2-1
  • 3 means edge where first index is n1-1

Returns a boolean.

Parameters:
  • edge1 (int) – Edge of first surface to be used. Must be integer 0-3
  • edge2 (int) – Edge of second surface to be used. Must be integer 0-3
  • othersurf (surface) – The second surface, must be a surface
Returns:

Whether or not the selected edges match

Return type:

bool

write(filename, endian='=')

Write surface to binary file

Method writes the surface to a binary file. Input arguments include the desired filename (required) and the byte ordering of the file ('=' native, '>' big endian, '<' little endian; default is native)

Parameters:
  • filename (str) – Filename for output
  • endian (str) – Byte ordering of output (optional, default is native)
Returns:

None

class fdfault.curve(n, direction, x, y)

The curve class represents a curve for defining interfaces and block boundaries in 2D problems

A curve is simply a surface class with the z spatial dimension removed. However, you cannot use curves and surfaces interchangeably as the C++ code reads the files for 2D and 3D problems differently, thus appropriate typing is enforced.

Each curve contains the following attributes:

Variables:
  • n1 – Number of grid points (x for 'y' interfaces, y for 'x' interfaces)
  • direction – Normal direction in computational space
  • x – Numpy array holding x coordinates, must have shape (n1,)
  • y – Numpy array holding y coordinates, must have shape (n1,)
__init__(n, direction, x, y)

Initialize a curve instance

Required arguments are n, which are number of grid points in each direction, a direction which indicates the surface orientation in computational space ('x' or 'y'), plus three arrays x and y (must have shape (n,) that hold the coordinates for the new surface. Initializing with a negative number of grid points, with arrays that do not have the correct shape, or with a bad string for the surface orientation will result in an error.

Parameters:
  • n (int) – Number of grid points
  • direction (str) – String indicating curve normal direction in computational space (must be 'x' or 'y')
  • x (ndarray) – Array holding surface x coordinates (must have shape (n1,))
  • y (ndarray) – Array holding surface y coordinates (must have shape (n1,))
Returns:

New curve with specified properties

Return type:

curve

get_direction()

Returns approximate normal direction

Returns:Normal direction in computational space
Return type:str
get_n1()

Returns number of grid points along first dimension

Returns:Number of grid points along first dimension (x unless interface direction is 'x')
Return type:int
get_n2()

Returns number of grid points along second dimension

Returns:Number of grid points along second dimension (z unless interface direction is 'z')
Return type:int
get_x(i=None)

Returns x coordinate array

if no argument is provided, the method returns the entire array. Otherwise, i must be a valid index tuple for the array.

Parameters:i (tuple or None) – Index tuple (must be a valid index into the array). Optional, if not provided or if None is given, this returns the entire array.
Returns:Value of x coordinate
Return type:ndarray or float
get_y(i=None)

Returns y coordinate array

if no argument is provided, the method returns the entire array. Otherwise, i must be a valid index tuple for the array.

Parameters:i (tuple or None) – Index tuple (must be a valid index into the array). Optional, if not provided or if None is given, this returns the entire array.
Returns:Value of y coordinate
Return type:ndarray or float
get_z(i=None)

Returns z coordinate array

if no argument is provided, the method returns the entire array. Otherwise, i must be a valid index tuple for the array.

Parameters:i (tuple or None) – Index tuple (must be a valid index into the array). Optional, if not provided or if None is given, this returns the entire array.
Returns:Value of z coordinate
Return type:ndarray or float
has_same_edge(edge1, edge2, othersurf)

Compares the edges of two curves

The method compares the edges of two curves, using the indices 1 or 3 to indicate the edges (one argument must be provided for each curve). Note that this definition is made to be consistent with the surface class.

  • 1 means edge where first index is zero
  • 3 means edge where first index is n1-1

Returns a boolean.

Parameters:
  • edge1 (int) – Edge of first surface to be used. Must be integer 1 or 3
  • edge2 (int) – Edge of second surface to be used. Must be integer 1 or 3
  • othersurf (curve) – The second curve, must be a curve
Returns:

Whether or not the selected edges match

Return type:

bool

write(filename, endian='=')

Write curve to binary file

Method writes the curve to a binary file. Input arguments include the desired filename (required) and the byte ordering of the file ('=' native, '>' big endian, '<' little endian; default is native)

Parameters:
  • filename (str) – Filename for output
  • endian (str) – Byte ordering of output (optional, default is native)
Returns:

None