pymech.core#

This module contains the classes for the data structures used by pymech.neksuite and pymech.simsonsuite. The Contents of core.py are reported at the bottom of this page.

HexaData#

The main data class is pymech.core.HexaData which is a structure for general and element by element information on data stored on hexahedral element(s). The general information is constituted by:

ndim

integer

number of spatial dimensions of the data

nel

integer

number of elements included in pymech.core.HexaData

ncurv

integer

number of curved sides (used only by Nek5000)

var

string

variables included in pymech.core.HexaData (e.g. ‘XUPT’)

lr1

ndim-array of integers

number of datapoints per element

time

float

simulation time of the file

istep

integer

simulation time step of the file

wdsz

integer

word size, i.e. double or single precision file

endian

string

endianness of the file (little/big)

lims

DataLims

extrema of all quantities stored

The element by element data is stored in:

elem

nel-array of Elem

array containing element data

Elem#

This class contains the data for one hexahedral element organised as follows:

pos

array of floats

x,y,z coordinates of each grid point

curv

array of floats

radius of curvature of the element edges (Nek5000)

ccurv

array of strings

defines the type of curvature

vel

array of floats

u,v,w velocity at each grid point

pres

array of floats

pressure at each grid point

temp

array of floats

temperature at each grid point

scal

array of floats

passive scalars at each grid point

bcs

array of floats

list of boundary condition parameters (Nek5000)

DataLims#

This class contains the extrema of all quantities stored in the mesh.

pos

array of floats

max and min of x,y,z coordinates

vel

array of floats

max and min of u,v,w velocity

pres

array of floats

max and min of pressure

temp

array of floats

max and min of temperature

scal

array of floats

max and min of passive scalars


Contents of core.py#

Core data structures for pymech

class pymech.core.DataLims(elements)[source]#

A class containing the extrema of all quantities stored in the mesh

- pos
Type:

x,y,z min,max

- vel
Type:

u,v,w min,max

- pres
Type:

p min,max

- temp
Type:

T min,max

- scal
Type:

s_i min,max

class pymech.core.Elem(var, lr1, nbc, dtype='float64')[source]#

A class containing one hexahedral element of Nek5000/SIMSON flow field.

Parameters:
  • var (iterable) – Iterable of integers of size 5, indicating how many variables are to be initialized

  • lr1 (iterable) – Iterable of integers of size 3, defining the shape of an element as (lx, ly, lz)

  • nbc (int) – Number of boundary conditions

  • dtype (str) – Floating point data type. Typical values are ‘f4’ or ‘float32’ for single precision, ‘f8’ or ‘float64’ for double precision

face_center(i)[source]#

Return the coordinates (x, y, z) of the center of the face number i

smallest_edge()[source]#

returns the length of the smallest edge, neglecting curvature

class pymech.core.HexaData(ndim, nel, lr1, var, nbc=0, dtype='float64')[source]#

A class containing data related to a hexahedral mesh

check_bcs_present()[source]#

Returns True if and only if all faces of all elements have boundary conditions applied.

Note that this function returning False does not mean the mesh is invalid: it is not mandatory to define internal boundary conditions for Nek5000.

check_connectivity(tol=0.001)[source]#

Check element connectivity, specifically for matching boundary conditions and geometry. Errors are reported as logging messages.

Parameters:

tol (float) – relative tolerance (compared to the smallest edge of adjacent elements) for detecting whether faces are at the same location

get_points()[source]#

Returns an array containing the coordinates of all the points in the mesh as a (nel, lx1*ly1*lz1, 3) array

merge(other, tol=0.01, ignore_empty=True, ignore_all_bcs=False)[source]#

Merges another pymech.core.HexaData into the current one and connects it

Parameters:
  • other (pymech.core.HexaData) – mesh to merge into self

  • tol (float) – maximum distance, relative to the smallest edge of neighbouring elements, at which faces are considered touching

  • ignore_empty (bool) – if True, the faces with an empty boundary condition (‘’) will be treated as internal faces and will not be merged. This is useful if internal boundary conditions are not defined and will make the operation much faster, but requires boundary conditions to be defined on the faces to be merged.

  • ignore_all_bcs (bool) – if True, the boundary conditions will not be changed. This is likely to result in invalid boundary conditions at the interface between the merged meshes. This option is intended for fast merging in a situation in which the boundary conditions are either irrelevant or will be defined or corrected later.

offset_connectivity(offset: int, iel_min=0)[source]#

Adds a value to the index of the elements connected via internal or periodic boundary conditions to elements of the mesh. This is used to keep the connectivity valid when deleting or inserting elements in the mesh.

Parameters:
  • offset (int) – The value by which to offset the indices

  • iel_min (int) – The first element (in zero-based indexing) to offset

update_ncurv()[source]#

Updates the metadata ncurv integer to match the actual number of curved faces present in the mesh