hertzforge.io.exodus¶
exodus
¶
Read and write Exodus finite element files (.exo, .e, .exo2, .g, .gen).
Exodus is netCDF, and both directions go through netCDF4. Reading
gives the nodes, the element blocks, the file's coordinate frames (as
coordinate systems), the node sets that record which node is placed or
measured in which frame, and the results. Writing (save) gives a
geometry as named blocks, its coordinate systems as frames and its
assignments as node sets, and mode shapes or data records on that
geometry as nodal and global variables. Damping and modal mass are
written as the global variables Damping and ModalMass, and the
imaginary part of a complex value as <name>_IM beside the real part,
so a modal model reads back with all of them. A drawn line is a block
of two-node line elements and is written as beam elements. The format
has no units: length_unit declares the unit of the positions on
import, and without it the geometry is unit-less.
Beyond the mesh, an Exodus file holds results: time_whole is a step
axis, nodal variables are (steps x nodes) records, and global variables
are one value per step. The file cannot say what the step axis means.
A modal run stores one mode per step with the frequency as the time, a
transient stores time, and spectral results store frequency, so
load(steps=...) declares it, in the same way units are declared.
Functions:
| Name | Description |
|---|---|
sniff |
True for a path ending in one of |
load |
Read an Exodus file: the mesh, and the results it holds. |
handles |
True for a Geometry, ShapeSet, TimeHistory or Spectrum. Shapes and |
save |
Write a geometry, mode shapes, or a time history or spectrum, as |
result_summary |
The names and counts of the file's results, read without the |
node_set_nodes |
The node ids in one node set, in the form |
Classes¶
Functions:¶
sniff
¶
True for a path ending in one of EXTENSIONS, in any case.
Only the suffix is checked; the file is not opened, so one that is not
Exodus is found out by load.
load
¶
load(path: str | PathLike, length_unit: str | None = None, blocks: dict[int, str] | None = None, steps: str | None = None, nodes: Any | None = None) -> Any
Read an Exodus file: the mesh, and the results it holds.
length_unit declares the unit of the positions; without it the
geometry is unit-less. blocks keeps only the element blocks whose
ids are among its keys (and then numbers the elements from 1).
steps declares what the file's step axis means, because the file
cannot say. 'modes' (the default) reads the displacement and
rotation variables as one mode per step with the step's time as the
frequency, and returns the geometry alone, or a dict keyed
'geometry' and 'shapes' when there are modes. 'time' reads every
nodal and global variable as a TimeHistory, returned in a dict
keyed 'geometry', 'time' and 'global'. 'frequency' reads them as a
Spectrum, with _RE/_IM variable pairs merged into complex
records, keyed 'geometry', 'spectra' and 'global spectra'. A key is
left out when there is nothing for it.
nodes limits the result records to those node ids, since a large
transient is a record for every node and direction, which for a
200,000-node mesh is far more channels than anyone wants.
node_set_nodes gives the ids of a node set.
Raises ValueError for an unknown steps, an element type with no
match, a node in nodes the file does not have, or, with 'time'
or 'frequency', a file with no step axis or no variables.
handles
¶
True for a Geometry, ShapeSet, TimeHistory or Spectrum. Shapes and
data also need the geometry they are written on, which save asks for
and this cannot check.
save
¶
save(obj: Any, path: str | PathLike, title: str = 'hertzforge geometry', geometry: Geometry | None = None, unit_system: UnitSystem | None = None) -> None
Write a geometry, mode shapes, or a time history or spectrum, as Exodus.
Shapes and data need geometry, the mesh they are written on, and
are refused without it. Each mode is written as one time step with
its frequency as the time, and each data record as a nodal variable
over time_whole (or a global variable when it has no DOF). Values
at a node with a local displacement system are rotated into the
global frame, because an Exodus nodal variable is always global.
Positions and values are written in unit_system, g included,
where their units are defined, and as stored otherwise. title is
the file's title.
result_summary
¶
The names and counts of the file's results, read without the values, for the import dialog.
Returns {'nodal': [names], 'global': [names], 'steps': n, 'nodes': n, 'node_sets': [(id, name, count)]}. For a mesh with no results the lists are empty and the step count is zero. The node sets that record coordinate system assignments are not listed.
node_set_nodes
¶
The node ids in one node set, in the form load(nodes=...)
takes.
Exodus stores set members as 1-based local indices; they are mapped
through node_num_map to node ids. Raises ValueError when the file
has no node set set_id.