Results¶
pynumgeo.results
¶
Readers for numgeo's result files (numpy and the standard library only).
- :func:
open_results-> :class:Resultsof one job: VTK frames (:meth:Results.frames), print output (:meth:Results.print_files, :meth:Results.print_series), the status file (:meth:Results.sta). - Single files: :func:
read_vtu, :func:read_vtm, :func:read_pvd(:mod:~pynumgeo.results.vtk), :func:read_print_file, :func:read_print_blocks(:mod:~pynumgeo.results.printfiles), :func:read_sta, :func:read_msg_steps(:mod:~pynumgeo.results.sta). - :func:
voigt_to_tensor: stresses/strains as tensors with explicit component order and shear.
Values are returned as numgeo writes them: total time, Voigt components in the file's order, strains with engineering shear, reaction forces with numgeo's sign. The format details and the source lines they come from are in the module docstrings.
Examples:
>>> import pathlib, tempfile
>>> d = pathlib.Path(tempfile.mkdtemp())
>>> (d / "sim-print-out").mkdir()
>>> _ = (d / "sim-print-out" / "SOIL.TOP_node_3.dat").write_text(
... " Time U1 U2 U3\n"
... ".500000000E+00 0.100000E-02 0.211464-100 0.000000E+00\n")
>>> s = open_results(d, "sim").print_series("soil.top", kind="node", index=3)
>>> s.columns, s.values.tolist()
(['U1', 'U2', 'U3'], [[0.001, 2.11464e-101, 0.0]])
PrintFileInfo(set_name, kind, index, path)
dataclass
¶
A print file found in <job>-print-out/.
Attributes:
| Name | Type | Description |
|---|---|---|
set_name |
str
|
set name as in the file name (upper case; |
kind |
PrintKind
|
|
index |
int
|
number in the file name: node label, or element position (= label for meshes numbered 1..n). |
path |
Path
|
the file. |
PrintFormatError
¶
Bases: ValueError
The rows of a print file cannot be matched to its header (see the module docstring).
PrintSeries(columns, time, values, path, kind, ip=None, header=(), issues=())
dataclass
¶
Contents of one print file.
Attributes:
| Name | Type | Description |
|---|---|---|
columns |
list[str]
|
names of the value columns in data order (time excluded). |
time |
FloatArray
|
total time of each row. |
values |
FloatArray
|
|
path |
Path
|
the file. |
kind |
PrintKind
|
|
ip |
tuple[int, ...] | None
|
integration point of each column ( |
header |
tuple[str, ...]
|
names as written in the header (time excluded), for reference. |
issues |
tuple[Issue, ...]
|
what the reader had to interpret (dropped columns, header deviations). |
column(name, ip=None)
¶
Values of one column; the name is matched exactly, else case-insensitively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
column name (e.g. |
required |
ip
|
int | None
|
integration point (required for |
None
|
Raises:
| Type | Description |
|---|---|
KeyError
|
no such column. |
ValueError
|
the name (and |
Frame(path, time, step, counter, step_name=None, increment=None)
¶
One written VTK frame (one <DataSet> of the .pvd); datasets are read on first use.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
the |
|
time |
total time from the |
|
step |
step number from the file name |
|
counter |
number of the frame within its step (starts at 1 in every step; it is not the increment). |
|
step_name |
step name (upper case) from the |
|
increment |
increment of the frame, |
The frame-level properties (:attr:points, :attr:cells, :meth:point_data, ...) concatenate the
datasets of the block Model elements (1D elements, 2D elements, 3D elements) in this
order. Each dataset has its own points, so a node shared by beam and solid elements appears in both
(with the nodal averages of its own dataset, VTK_write_results_.f90:291-339). With EMBEDDED
output, embedded regions and their guest beams are separate datasets; use
:attr:datasets for them.
datasets
property
¶
All datasets of the .vtm in file order (with :attr:VtuData.name, :attr:VtuData.block).
model_datasets
property
¶
The datasets of the block Model elements.
points
property
¶
(n, 3) point coordinates of the model datasets.
cells
property
¶
Cells of the model datasets as (vtk_type, connectivity[k, nodes_per_cell]) blocks.
Connectivity indexes :attr:points (0-based); the blocks in order give the cells in the order of
:meth:cell_data. VTK cell types are numgeo's (e.g. 3 line, 9 quad, 23 quad8, 12 hexahedron) and
node order is numgeo's element node order (VTK_write_cells_.f90:87-104).
node_labels
property
¶
Node label of each point (NodeLabel).
element_labels
property
¶
Element label of each cell (ElementLabel).
point_names
property
¶
PointData names present in every model dataset (order of the first).
cell_names
property
¶
CellData names present in every model dataset (order of the first).
dataset(name)
¶
The dataset with this name (e.g. "2D elements").
Raises:
| Type | Description |
|---|---|
KeyError
|
no or more than one dataset with this name. |
point_data(name)
¶
PointData array over all model datasets (names as numgeo writes them, blanks stripped).
cell_data(name)
¶
CellData array over all model datasets (names as numgeo writes them, blanks stripped).
Results(workdir, job='job')
¶
Result files of one job in one folder (see :func:open_results).
pvd_path
property
¶
<job>-all-results.pvd (VTK_type.f90:1204).
print_dir
property
¶
<job>-print-out (print_type.f90:93).
sta_path
property
¶
<job>.sta (report_construct_.f90:51).
msg_path
property
¶
<job>.msg (report_construct_.f90:53).
step_names()
¶
Step number -> name (upper case) of the executed steps, from the .msg file ({} without it).
sta()
¶
Increment rows of <job>.sta (see :func:pynumgeo.results.read_sta), with step numbers
from the .msg file when it exists.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
no |
frames()
¶
All VTK frames in the order of the .pvd.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
no |
print_files()
¶
The print files of the run ([] if there is no <job>-print-out folder).
print_series(set_name, kind='node', index=None, *, columns=None)
¶
Read the print file of one set member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
set_name
|
str
|
set name, compared case-insensitively (numgeo upper-cases it); sets of an instance
are named |
required |
kind
|
PrintKind
|
|
'node'
|
index
|
int | None
|
node label or element number in the file name; may be omitted if the set has one file. |
None
|
columns
|
Sequence[str] | None
|
column names to use instead of the header (see
:func: |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
no such file (the message lists what exists). |
ValueError
|
|
StaRow(step, step_type, step_number, increment, iterations, total_time, step_time, dt, rejection, accepted, fos=None, dfos=None, max_disp=None, cpu_time=None, dt_crit=None, critical_element=None)
dataclass
¶
One increment attempt of the .sta file.
Attributes:
| Name | Type | Description |
|---|---|---|
step |
str
|
step name as written (upper case). |
step_type |
str
|
|
step_number |
int | None
|
number of the step in the input, if known (from the |
increment |
int | None
|
increment number ( |
iterations |
int | None
|
equilibrium iterations ( |
total_time |
float | None
|
total time ( |
step_time |
float | None
|
step time ( |
dt |
float | None
|
time increment ( |
rejection |
str
|
rejection text as written, |
accepted |
bool | None
|
|
fos, |
(dfos, max_disp)
|
factor of safety, its increment and max. |
cpu_time |
float | None
|
CPU time of the step (EXPLICIT DYNAMIC only). |
dt_crit, |
critical_element
|
critical time increment and element (TRANSIENT CRITICAL only). |
DataArray(name, vtk_type, values, component_names=())
dataclass
¶
One DataArray of a PointData or CellData section.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
array name with leading/trailing blanks removed. |
vtk_type |
str
|
VTK scalar type as declared ( |
values |
NDArray[Any]
|
shape |
component_names |
tuple[str, ...]
|
|
components
property
¶
Number of components.
PvdEntry(time, file, part)
dataclass
¶
One <DataSet> of a .pvd collection.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
|
file |
Path
|
referenced file, resolved against the folder of the |
part |
int
|
|
VtmEntry(name, block, file)
dataclass
¶
One <DataSet> with a file in a .vtm multiblock file.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
dataset name ( |
block |
tuple[str, ...]
|
names of the enclosing blocks, outermost first. |
file |
Path
|
referenced |
VtuData(path, points, connectivity, offsets, types, point_arrays, cell_arrays, name=None, block=())
dataclass
¶
Contents of one .vtu file (one Piece).
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
the file. |
points |
FloatArray
|
|
connectivity |
IntArray
|
0-based point indices of all cells, concatenated (numgeo node order). |
offsets |
IntArray
|
end position of each cell in |
types |
NDArray[uint8]
|
VTK cell type per cell (e.g. 23 for an 8-node quadrilateral). |
point_arrays |
tuple[DataArray, ...]
|
|
cell_arrays |
tuple[DataArray, ...]
|
|
name |
str | None
|
dataset name in the |
block |
tuple[str, ...]
|
names of the enclosing |
number_of_points
property
¶
Number of points.
number_of_cells
property
¶
Number of cells.
cells
property
¶
Cells as blocks (vtk_type, connectivity[k, nodes_per_cell]).
Consecutive cells with the same VTK type and node count form one block, so concatenating the
blocks in order gives the cells in file order (the order of :meth:cell_data).
point_names
property
¶
Names of the PointData arrays in file order.
cell_names
property
¶
Names of the CellData arrays in file order.
node_labels
property
¶
Node labels of the points (PointData NodeLabel, VTK_write_results_.f90:1009-1029).
element_labels
property
¶
Element labels of the cells (CellData ElementLabel, VTK_write_results_.f90:1034-1053).
point_data(name)
¶
Values of a PointData array (see :func:find_array for the name lookup).
cell_data(name)
¶
Values of a CellData array (see :func:find_array for the name lookup).
list_print_files(directory)
¶
All files of a <job>-print-out folder named <SET>_<kind>_<n>.dat, sorted by set, kind, n.
read_print_blocks(path, *, kind=None)
¶
Read a print file whose row width changes, as one series per run of equal-width rows.
numgeo writes the header once, for the variables of the first step that defines the file
(:126-134), and the rows of each step with that step's variables (:384). Blocks that match the
header are named from it; other blocks get the names col1, col2, ... and a warning issue.
read_print_file(path, *, kind=None, columns=None)
¶
Read one print file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
the |
required |
kind
|
PrintKind | None
|
|
None
|
columns
|
Sequence[str] | None
|
names of the value columns (time excluded) to use instead of the header; their number must equal the row width. |
None
|
Raises:
| Type | Description |
|---|---|
PrintFormatError
|
rows of different widths (variables changed between steps; use
:func: |
read_print_rows(path)
¶
Raw access: header lines and every data row (time first) as written.
Node and element files have one header line, integration-point files two (decided from the file
name; a file not named *_ip_<n>.dat is treated as a node/element file).
open_results(workdir, job='job')
¶
Open the results of job job in workdir.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
|
read_msg_steps(path)
¶
Step numbers and names of the executed steps from a .msg file, in order.
Reads the Step <n>: <NAME> line that follows a rule of 100 = (report_convergence_.f90:66-68).
read_sta(path, *, step_numbers=None)
¶
Read all increment rows of a .sta file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
the |
required |
step_numbers
|
Sequence[int] | None
|
step number of the 1st, 2nd, ... step block of the file (e.g. from
:func: |
None
|
Acceptance, :attr:StaRow.accepted:
- a row followed by another row of its step: rejected if that row repeats the increment number (a
cut-back keeps the number,
src/main.f90:574-579), else accepted, whatever the rejection text (under NOCUTBACK a non-converged attempt is accepted,src/main.f90:950-970); - the last row of a step: accepted without rejection text, or with
rejected (niter > maxiter)when the step ended withStep sucessfully terminated(the text is also printed for attempts that converged in the last iteration); elseNone. Not visible in the.sta: a step that ran out of increments ends after a rejected attempt numbermaxinc + 1(src/main.f90:555), and is still reported as terminated; such a last row is then wrongly taken as accepted. :func:pynumgeo.runknowsmaxincfrom the deck and decides this case correctly; - strength reduction rows:
None; the factor-of-safety logic decides (src/database/step_ty_.f90:330-440).
voigt_to_tensor(values, *, order, engineering_shear)
¶
Symmetric 3x3 tensors from Voigt vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ArrayLike
|
shape |
required |
order
|
VoigtOrder
|
|
required |
engineering_shear
|
bool
|
|
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Array of shape |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the last axis does not have 6 components or |
read_pvd(path)
¶
Read a ParaView collection file (<job>-all-results.pvd), entries in file order.
Raises:
| Type | Description |
|---|---|
ValueError
|
if the file is not a |
read_vtm(path)
¶
Read a vtkMultiBlockDataSet file: all datasets with a file, in document order.
Raises:
| Type | Description |
|---|---|
ValueError
|
if the file is not a |
read_vtu(path, *, name=None, block=())
¶
Read an UnstructuredGrid .vtu file as numgeo writes it (ASCII or raw appended binary).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
the file. |
required |
name
|
str | None
|
dataset name to record (from the |
None
|
block
|
tuple[str, ...]
|
enclosing block names to record (from the |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
for anything numgeo does not write (several pieces, compression, base64, unknown types) or inconsistent sizes. |