Closed GuillemBarroso closed 1 year ago
This PR includes an example on how to retrieve data from a field by ID.
In Post this feature can be exposed as a method of DataObject, so the users could:
DataObject
Retrieve all the data with its associated IDs
simulation = post.load_simulation("my_example") my_named_selection = "test" my_selection = select(named_selection=my_named_selection) nodal_ids, nodal_disp = simulation.displacement(select=my_selection).get_data_by_id() assert len(nodal_ids) == len(nodal_disp) == n_nodes assert type(nodal_ids) == np.ndarray or ints assert type(nodal_disp) == np.ndarray of floats
Retrieve data for one ID
simulation = post.load_simulation("my_example") my_named_selection = "test" my_selection = select(named_selection=my_named_selection) nodal_id, nodal_disp = simulation.displacement(select=my_selection).get_data_by_id(5) assert len(nodal_id) == len(nodal_disp) == 1 assert type(nodal_id) == np.array of ints assert type(nodal_disp) == np.array of floats # (containing the three components of the displacement for that node)
Retrieve data for a list of IDs
simulation = post.load_simulation("my_example") my_named_selection = "test" my_selection = select(named_selection=my_named_selection) nodal_ids, nodal_disp = simulation.displacement(select=my_selection).get_data_by_id([1, 5, 25]) assert len(nodal_ids) == len(nodal_disp) == 3 assert type(nodal_ids) == np.array of ints assert type(nodal_disp) == np.array of floats
Implement the get_data_by_id() method in the data object.
get_data_by_id()
Make only one server call to increase performance.
N/A
Closing as stale for now. To reopen later.
Description of the feature
This PR includes an example on how to retrieve data from a field by ID.
In Post this feature can be exposed as a method of
DataObject
, so the users could:Retrieve all the data with its associated IDs
Retrieve data for one ID
Retrieve data for a list of IDs
Steps for implementing the feature
Implement the
get_data_by_id()
method in the data object.Make only one server call to increase performance.
Useful links and references
N/A