pymech.neksuite#
This module contains the functions used to interact with Nek5000 files. The Contents of neksuite are reported at the bottom of this page.
readnek#
This function reads the binary .f%05d
files that Nek5000 uses to store
output flow fields.
The only input needed by this function is:
fname
: a string containing the name of the file;
readnek() is clever enough to figure out the rest.
The output is a single pymech.core.HexaData
data structure containing all
the information that was stored in the file.
Note
If you are only interested in the metadata (for example, the simulation
time) of a solution file a quicker solution would be to execute
pymech.neksuite.field.read_header()
writenek#
This function writes a binary .f%05d
file in the same format that Nek5000
uses to store output flow fields. It is therefore possible to open this file with
VisIt or Paraview.
The inputs needed by this function are:
fname
: a string containing the name of the file;data
: a singlepymech.core.HexaData
data structure containing the data to be written to file.
writenek() produces no output.
readrea#
This function reads an ASCII .rea
file that Nek5000 uses to store
simulation parameters and mesh (when a .re2
file is absent).
ONLY the mesh is actually read, all parameters are disregarded.
The only input needed by this function is:
fname
: a string containing the name of the file;
readrea() is clever enough to figure out the rest.
The output is a single pymech.core.HexaData
data structure containing the
mesh that was stored in the file.
writerea#
This function writes an ASCII .rea
file in the same format that Nek5000
uses to store simulation parameters and mesh.
ONLY the mesh is actually written, all simulation parameters are initialised
to sensible defaults.
The inputs needed by this function are:
fname
: a string containing the name of the file;data
: a singlepymech.core.HexaData
data structure containing the mesh to be written to file.
writerea() produces no output.
readre2 and writere2#
These functions are analagous to readrea
and writerea
but works with
the newer, binary .re2
mesh files. New in pymech 1.4.0.
Contents of neksuite#
- class pymech.neksuite.field.Header(wdsz, orders, nb_elems, nb_elems_file, time, istep, fid, nb_files, variables: str | bytes = _Nothing.NOTHING, realtype: str = _Nothing.NOTHING, nb_pts_elem: int = _Nothing.NOTHING, nb_dims: int = _Nothing.NOTHING, nb_vars: Tuple[int, ...] = _Nothing.NOTHING)[source]#
Dataclass for Nek5000 field file header. This relies on the package attrs and its ability to do type-validation and type-conversion of the header metadata.
- pymech.neksuite.field.read_header(path_or_file_obj: str | PathLike | BinaryIO) Header [source]#
Make a
pymech.neksuite.Header
instance from a file buffer opened in binary mode.
- pymech.neksuite.field.readnek(fname, dtype='float64', skip_vars=())[source]#
A function for reading binary data from the nek5000 binary format
- Parameters:
fname (str) – File name
dtype (str or type) – Floating point data type. See also
pymech.core.Elem
.skip_vars (tuple[str]) – Variables to skip. Valid values to skip are
("x", "y", "z", "ux", "uy", "uz", "pressure", "temperature", "s01", "s02", ...)
. It also accept some extra values("vx", "vy", "vz", "p", "t")
. If empty (default), it reads all variables available in the file.
- pymech.neksuite.field.writenek(fname, data)[source]#
A function for writing binary data in the nek5000 binary format
- Parameters:
fname (str) – file name
data (
pymech.core.HexaData
) – data structure
- pymech.neksuite.mesh.readre2(fname)[source]#
A function for reading .re2 files for nek5000
- Parameters:
fname (str) – file name
- pymech.neksuite.mesh.readrea(fname)[source]#
A function for reading .rea files for nek5000
- Parameters:
fname (str) – file name
- pymech.neksuite.mesh.writere2(fname, data)[source]#
A function for writing binary .re2 files for nek5000
- Parameters:
fname (str) – file name
data (
pymech.core.HexaData
) – data structure
- pymech.neksuite.mesh.writerea(fname, data)[source]#
A function for writing ascii .rea files for nek5000
- Parameters:
fname (str) – file name
data (
pymech.core.HexaData
) – data structure
- pymech.neksuite.map.readma2(fname)[source]#
A function for reading binary map files (
*.ma2
) for nek5000.The map file comtains, for each element in the mesh, the id of the MPI rank that owns it followed by the ids of the vertices of the element in the global address space.
The partitioning is determined by generating the undirected graph formed by the mesh, then repeatedly computing and deviding the graph using the Fiedler vector of the graph Laplacian.
- Parameters:
fname (str) – file name
- Returns:
cell (2d int ndarray) – list of the vertices for each element of the mesh (in global address space)
procmap (1d int ndarray) – processor map (0-based) indicating ownership for each element of the mesh
Note
See usage for more details.