hpcflow.sdk.core.loop_cache.LoopCache#
- class hpcflow.sdk.core.loop_cache.LoopCache(element_dependents, elements, zeroth_iters, data_idx, iterations, task_iterations)#
Bases:
object
Class to store a cache for use in
Workflow.add_empty_loop()
andWorkflowLoop.add_iterations()
. Usebuild()
to get a new instance.- Parameters:
element_dependents (Dict[int, Dict]) – Keys are element IDs, values are dicts whose keys are element IDs that depend on the key element ID (via Element.get_dependent_elements_recursively), and whose values are dicts with keys: group_names, which is a tuple of the string group names associated with the dependent element’s element set.
elements (Dict[int, Dict]) – Keys are element IDs, values are dicts with keys: input_statuses, input_sources, and task_insert_ID.
zeroth_iters (Dict[int, Tuple]) – Keys are element IDs, values are data associated with the zeroth iteration of that element, namely a tuple of iteration ID and ElementIteration.data_idx.
data_idx (Dict[int, Dict]) – Keys are element IDs, values are data associated with all iterations of that element, namely a dict whose keys are the iteration loop index as a tuple, and whose values are data indices via ElementIteration.get_data_idx().
iterations (Dict[int, Tuple]) – Keys are iteration IDs, values are tuples of element ID and iteration index within that element.
task_iterations (Dict[int, List[int]]) – Keys are task insert IDs, values are list of all iteration IDs associated with that task.
Methods
Update the cache to include a newly added iteration.
Build a cache of data for use in adding loops and iterations.
Retrieve a list of iteration IDs belonging to a given loop.
Retrieve the mapping from element to loop index for each given iteration.
Set the loop indices for a named loop to the given list of iteration IDs.
Attributes
Keys are element IDs, values are dicts whose keys are element IDs that depend on the key element ID (via Element.get_dependent_elements_recursively), and whose values are dicts with keys: group_names, which is a tuple of the string group names associated with the dependent element's element set.
input_statuses, input_sources, and task_insert_ID.
Keys are element IDs, values are data associated with the zeroth iteration of that element, namely a tuple of iteration ID and ElementIteration.data_idx.
Keys are element IDs, values are data associated with all iterations of that element, namely a dict whose keys are the iteration loop index as a tuple, and whose values are data indices via ElementIteration.get_data_idx().
Keys are iteration IDs, values are tuples of element ID and iteration index within that element.
Keys are task insert IDs, values are list of all iteration IDs associated with that task.
- add_iteration(iter_ID, task_insert_ID, element_ID, loop_idx, data_idx)#
Update the cache to include a newly added iteration.
- classmethod build(workflow, loops=None)#
Build a cache of data for use in adding loops and iterations.
- data_idx: Dict[int, Dict]#
Keys are element IDs, values are data associated with all iterations of that element, namely a dict whose keys are the iteration loop index as a tuple, and whose values are data indices via ElementIteration.get_data_idx().
- element_dependents: Dict[int, Dict]#
Keys are element IDs, values are dicts whose keys are element IDs that depend on the key element ID (via Element.get_dependent_elements_recursively), and whose values are dicts with keys: group_names, which is a tuple of the string group names associated with the dependent element’s element set.
- elements: Dict[int, Dict]#
input_statuses, input_sources, and task_insert_ID.
- Type:
Keys are element IDs, values are dicts with keys
- get_iter_IDs(loop)#
Retrieve a list of iteration IDs belonging to a given loop.
- get_iter_loop_indices(iter_IDs)#
Retrieve the mapping from element to loop index for each given iteration.
- iterations: Dict[int, Tuple]#
Keys are iteration IDs, values are tuples of element ID and iteration index within that element.
- task_iterations: Dict[int, List[int]]#
Keys are task insert IDs, values are list of all iteration IDs associated with that task.
- update_loop_indices(new_loop_name, iter_IDs)#
Set the loop indices for a named loop to the given list of iteration IDs.