Skip to content

Commit 16af0c4

Browse files
committed
EXODUS.PY: Add get_variable_values_multi_time to get values at a range of time steps
1 parent 1433745 commit 16af0c4

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

packages/seacas/scripts/exodus3.in.py

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
exodus.py v 1.21.3 (seacas-py3) is a python wrapper of some of the exodus library
2+
exodus.py v 1.21.4 (seacas-py3) is a python wrapper of some of the exodus library
33
(Python 3 Version)
44
55
Exodus is a common database for multiple application codes (mesh
@@ -78,10 +78,10 @@
7878

7979
EXODUS_PY_COPYRIGHT_AND_LICENSE = __doc__
8080

81-
EXODUS_PY_VERSION = "1.21.3 (seacas-py3)"
81+
EXODUS_PY_VERSION = "1.21.4 (seacas-py3)"
8282

8383
EXODUS_PY_COPYRIGHT = """
84-
You are using exodus.py v 1.21.3 (seacas-py3), a python wrapper of some of the exodus library.
84+
You are using exodus.py v 1.21.4 (seacas-py3), a python wrapper of some of the exodus library.
8585
8686
Copyright (c) 2013-2023 National Technology &
8787
Engineering Solutions of Sandia, LLC (NTESS). Under the terms of
@@ -2354,7 +2354,7 @@ def get_variable_values_time(self, objType, entityId, var_name, start_step, end_
23542354
objType : ex_entity_type
23552355
type of object being queried
23562356
entityid : ex_entity_id
2357-
id of the entity (block, set) *ID* (not *INDEX*)
2357+
index/id of the entity (element, node)
23582358
var_name : string
23592359
name of variable
23602360
start_step : int
@@ -2415,6 +2415,45 @@ def get_variable_values(self, objType, entityId, name, step):
24152415
values = ctype_to_numpy(self, values)
24162416
return values
24172417

2418+
def get_variable_values_multi_time(self, objType, entityId, name, begin_step, end_step):
2419+
"""
2420+
get list of `objType` variable values for a specified object id
2421+
block, variable name, and 1-based range of time steps
2422+
2423+
>>> evar_vals = exo.get_variable_values_multi_time('EX_ELEM_BLOCK', elem_blk_id,
2424+
... evar_name, 1, 10)
2425+
2426+
Parameters
2427+
----------
2428+
objType : ex_entity_type
2429+
type of object being queried
2430+
entityid : ex_entity_id
2431+
id of the entity (block, set) *ID* (not *INDEX*)
2432+
name : string
2433+
name of variable
2434+
begin_step : int
2435+
1-based index of time step at beginning of range
2436+
end_step : int
2437+
1-based index of time step at end of range
2438+
2439+
Returns
2440+
-------
2441+
2442+
if array_type == 'ctype':
2443+
<list<ctypes.c_double>> evar_vals
2444+
2445+
if array_type == 'numpy':
2446+
<np_array<double>> evar_vals
2447+
"""
2448+
names = self.get_variable_names(objType)
2449+
var_id = names.index(name) + 1
2450+
numVals = self.get_entity_count(objType, entityId)
2451+
2452+
values = self.__ex_get_var(begin_step, end_step, objType, var_id, entityId, numVals)
2453+
if self.use_numpy:
2454+
values = ctype_to_numpy(self, values)
2455+
return values
2456+
24182457
def put_variable_values(self, objType, entityId, name, step, values):
24192458
"""
24202459
store a list of element variable values for a specified element
@@ -5938,6 +5977,27 @@ def __ex_get_var(self, timeStep, varType, varId, blkId, numValues):
59385977
var_vals)
59395978
return var_vals
59405979

5980+
def __ex_get_var_multi_time(self, start_step, end_step, varType, varId, blkId, numValues):
5981+
s_step = ctypes.c_int(start_step)
5982+
e_step = ctypes.c_int(end_step)
5983+
var_type = ctypes.c_int(get_entity_type(varType))
5984+
var_id = ctypes.c_int(varId)
5985+
block_id = ctypes.c_longlong(blkId)
5986+
num_values = ctypes.c_longlong(numValues)
5987+
num_steps = end_step - start_step + 1
5988+
var_vals = (ctypes.c_double * num_values.value * num_steps)()
5989+
EXODUS_LIB.ex_get_var_multi_time(
5990+
self.fileId,
5991+
step,
5992+
var_type,
5993+
var_id,
5994+
block_id,
5995+
num_values,
5996+
s_step,
5997+
e_step,
5998+
var_vals)
5999+
return var_vals
6000+
59416001
def __ex_get_var_time(self, varType, varId, entityID, start_step, end_step):
59426002
s_step = ctypes.c_int(start_step)
59436003
e_step = ctypes.c_int(end_step)

0 commit comments

Comments
 (0)