-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/development' into doc_updates
- Loading branch information
Showing
162 changed files
with
4,309 additions
and
3,527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
Docs/source/dataanalysis/catalyst/catalyst_simple_pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
from paraview import catalyst | ||
from paraview.simple import * # noqa: F403 | ||
|
||
|
||
# Helper function | ||
def create_data_extractor(data_node, filename="Dataset"): | ||
"""Creates a data extractor that saves `data_node` to a datafile named `filename`. | ||
The filetype is chosen based on the type of `data_note`. | ||
Note: no rendering is performed by such an extractor. The data are | ||
written directly to a file via VTK. | ||
""" | ||
VTK_TYPES = [ | ||
"vtkImageData", | ||
"vtkRectilinearGrid", | ||
"vtkStructuredGrid", | ||
"vtkPolyData", | ||
"vtkUnstructuredGrid", | ||
"vtkUniformGridAMR", | ||
"vtkMultiBlockDataSet", | ||
"vtkPartitionedDataSet", | ||
"vtkPartitionedDataSetCollection", | ||
"vtkHyperTreeGrid", | ||
] | ||
FILE_ASSOCIATIONS = [ | ||
"VTI", | ||
"VTR", | ||
"VTS", | ||
"VTP", | ||
"VTU", | ||
"VTH", | ||
"VTM", | ||
"VTPD", | ||
"VTPC", | ||
"HTG", | ||
] | ||
clientside_data = data_node.GetClientSideObject().GetOutputDataObject( | ||
0 | ||
) # Gets the dataobject from the default output port | ||
|
||
# Loop is required because .IsA() detects valid classes that inherit from the VTK_TYPES | ||
for i, vtk_type in enumerate(VTK_TYPES): | ||
if clientside_data.IsA(vtk_type): | ||
filetype = FILE_ASSOCIATIONS[i] | ||
extractor = CreateExtractor( | ||
filetype, data_node, registrationName=f"_{filetype}" | ||
) | ||
extractor.Writer.FileName = filename + "_{timestep:}" + f".{filetype}" | ||
return extractor | ||
|
||
raise RuntimeError(f"Unsupported data type: {clientside_data.GetClassName()}") | ||
|
||
|
||
# Camera settings | ||
paraview.simple._DisableFirstRenderCameraReset() # Prevents the camera from being shown | ||
|
||
# Options | ||
options = catalyst.Options() | ||
|
||
options.CatalystLiveTrigger = "TimeStep" # "Python", "TimeStep", "TimeValue" | ||
options.EnableCatalystLive = 0 # 0 (disabled), 1 (enabled) | ||
if options.EnableCatalystLive == 1: | ||
options.CatalystLiveURL = "localhost:22222" # localhost:22222 is default | ||
|
||
options.ExtractsOutputDirectory = "datasets" # Base for where all files are saved | ||
options.GenerateCinemaSpecification = 0 # 0 (disabled), 1 (enabled), generates additional descriptor files for cinema exports | ||
options.GlobalTrigger = "TimeStep" # "Python", "TimeStep", "TimeValue" | ||
|
||
meshSource = PVTrivialProducer( | ||
registrationName="mesh" | ||
) # "mesh" is the node where the mesh data is stored | ||
create_extractor(meshSource, filename="meshdata") | ||
particleSource = PVTrivialProducer( | ||
registrationName="particles" | ||
) # "particles" is the node where particle data is stored | ||
create_extractor(particleSource, filename="particledata") | ||
|
||
|
||
# Called on catalyst initialize (after Cxx side initialize) | ||
def catalyst_initialize(): | ||
return | ||
|
||
|
||
# Called on catalyst execute (after Cxx side update) | ||
def catalyst_execute(info): | ||
print(f"Time: {info.time}, Timestep: {info.timestep}, Cycle: {info.cycle}") | ||
return | ||
|
||
|
||
# Callback if global trigger is set to "Python" | ||
def is_activated(controller): | ||
return True | ||
|
||
|
||
# Called on catalyst finalize (after Cxx side finalize) | ||
def catalyst_finalize(): | ||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
paraview.simple.SaveExtractsUsingCatalystOptions(options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.