-
Notifications
You must be signed in to change notification settings - Fork 11
Add Catalyst Plugin. #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Catalyst Plugin. #496
Changes from all commits
2b683ab
e80f299
68c6b4e
ba60b07
4732d2b
a662abc
f2ca845
43b7b7e
18445fb
86c681d
c5a5a67
34537f4
b93fd16
26e668d
1dd559a
09f94a1
5589a61
3cbb8bb
0472fd9
1cc0640
62b9aad
528662a
1ed529a
55da19c
9f55394
abb7862
188db01
f6eaebe
77545ba
51f29ee
89a55d1
dbe7731
efbb775
73e396c
542d8a6
b7c6633
09073ba
848e775
eed03ef
a859d18
122ecd2
f1f5a6e
74b4a03
e520247
b32c617
4233806
df247ba
a460c8f
8303bb6
7c39728
aa81851
c6af01a
511078a
340b3dd
ee8fffe
cf4fc95
7023c8c
5a53aa9
2f7b593
fb202b9
b2e0899
1081af5
54f1ee7
6a311f5
6405fe2
9299c28
8c09f06
5052912
13057e0
5135456
426d8e9
daa390b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add additional authors (Jacques/Yushan) |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||
| #============================================================================= | ||||||||
| # Copyright (C) 2015-2026 Commissariat a l'energie atomique et aux energies alternatives (CEA) | ||||||||
| # Copyright (C) 2024-2025 Kitware SAS | ||||||||
| # | ||||||||
| # All rights reserved. | ||||||||
| # | ||||||||
|
|
@@ -34,8 +35,6 @@ | |||||||
| cmake_minimum_required(VERSION 3.22...4.2) | ||||||||
| project(PDI_DIST LANGUAGES C CXX) | ||||||||
|
|
||||||||
|
|
||||||||
|
|
||||||||
| ### Build options | ||||||||
|
|
||||||||
| ## Global options | ||||||||
|
|
@@ -77,6 +76,7 @@ option(BUILD_TRACE_PLUGIN "Build Trace plugin" ON) | |||||||
| option(BUILD_USER_CODE_PLUGIN "Build User-code plugin" ON) | ||||||||
| option(BUILD_JSON_PLUGIN "Build JSON plugin" OFF) | ||||||||
| option(ENABLE_BENCHMARKING "Activate benchmarks in the test suite" OFF) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be an unwanted removal |
||||||||
| option(BUILD_CATALYST_PLUGIN "Build Catalyst plugin" "${BUILD_UNSTABLE}") | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (gone with a rebase)
Suggested change
|
||||||||
|
|
||||||||
|
|
||||||||
|
|
||||||||
|
|
@@ -554,3 +554,10 @@ sbuild_add_module(PDI_API_TESTS | |||||||
| INSTALL_COMMAND "" | ||||||||
| SUBSTEPS test | ||||||||
| ) | ||||||||
|
|
||||||||
| sbuild_add_module(CATALYST_PLUGIN | ||||||||
| ENABLE_BUILD_FLAG BUILD_CATALYST_PLUGIN | ||||||||
| SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/catalyst" | ||||||||
| DEPENDS PDI | ||||||||
| SUBSTEPS test | ||||||||
| ) | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # duration in seconds | ||
| duration: 1.75 | ||
| # global [height, width] (excluding boundary conditions or ghosts) | ||
| datasize: [60, 12] | ||
| # degree of parallelism | ||
| parallelism: { height: 3, width: 1 } | ||
|
|
||
| # only the following config is passed to PDI | ||
| pdi: | ||
| metadata: # type of small values for which PDI keeps a copy | ||
| iter: int # current iteration id | ||
| dsize: { size: 2, type: array, subtype: int } # local data size including ghosts/boundary | ||
| psize: { size: 2, type: array, subtype: int } # number of processes in each dimension | ||
| pcoord: { size: 2, type: array, subtype: int } # coordinate of the process | ||
| data: # type of values for which PDI does not keep a copy | ||
| main_field: { size: [ '$dsize[0]', '$dsize[1]' ], type: array, subtype: double } | ||
|
|
||
| plugins: | ||
| mpi: | ||
| catalyst: | ||
| scripts: | ||
| script1: "@CATALYST_SCRIPT_FOLDER@/catalyst_pipeline_with_rendering.py" | ||
| on_event: "newiter" | ||
| execute: | ||
| state: | ||
| timestep: '$iter' | ||
| time: '1.0*$iter' | ||
| multiblock: 0 | ||
| channels: | ||
| grid: | ||
| type: "mesh" | ||
| data: | ||
| coordsets: | ||
| my_coords: | ||
| type: "uniform" | ||
| dims: { i: '1+$dsize[1]', j: '1+$dsize[0]' } | ||
| origin: | ||
| x: '1.0*$pcoord[1]*($dsize[1]-2.0)-1.0' | ||
| y: '1.0*$pcoord[0]*($dsize[0]-2.0)-1.0' | ||
| spacing: { dx: 1.0, dy: 1.0 } | ||
| topologies: | ||
| my_mesh: | ||
| type: "uniform" | ||
| coordset: "my_coords" | ||
| # elements: | ||
| # dims: {offsets: [] strides: []} | ||
| fields: | ||
| temperature: | ||
| association: "element" | ||
| topology: "my_mesh" | ||
| volume_dependent: "false" | ||
| values: | ||
| PDI_data_array: "main_field" | ||
| size: '$dsize[0]*$dsize[1]' | ||
| ghost_layers: | ||
| my_mesh: { association: "element", start: ['1', '1'], size: ['$dsize[1]-2', '$dsize[0]-2'] } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # script-version: 2.0 | ||
| from paraview.simple import * | ||
| from paraview import catalyst | ||
| import time | ||
|
|
||
| # registrationName must match the channel name used in the | ||
| # 'CatalystAdaptor'. | ||
| producer = TrivialProducer(registrationName="grid") | ||
|
|
||
| # ---------------------------------------------------------------- | ||
| # setup views used in the visualization | ||
| # ---------------------------------------------------------------- | ||
|
|
||
| # ######## render view temperature | ||
|
|
||
| # Create a new 'Render View' | ||
| renderView1 = CreateView('RenderView') | ||
| # renderView1.Set( | ||
| # ViewSize=[800, 600], | ||
| # InteractionMode='2D', | ||
| # CenterOfRotation=[20.0, 3.0, 0.0], | ||
| # CameraPosition=[20.0, 30.0, 408.7], | ||
| # CameraFocalPoint=[20.0, 30.0, 0.0], | ||
| # CameraFocalDisk=1.0, | ||
| # CameraParallelScale=32.0, | ||
| # ) | ||
|
|
||
| renderView1.ViewSize=[800, 600] | ||
| renderView1.InteractionMode='2D' | ||
| renderView1.CenterOfRotation=[20.0, 3.0, 0.0] | ||
| renderView1.CameraPosition=[20.0, 30.0, 408.7] | ||
| renderView1.CameraFocalPoint=[20.0, 30.0, 0.0] | ||
| renderView1.CameraFocalDisk=1.0, | ||
| renderView1.CameraParallelScale=32.0 | ||
|
|
||
|
|
||
| # get color transfer function/color map for 'temperature' | ||
| temperatureLUT = GetColorTransferFunction('temperature') | ||
| ## RGB: first line: min value, last line: max value | ||
| # temperatureLUT.Set( | ||
| # RGBPoints=GenerateRGBPoints( | ||
| # range_min=0.0, | ||
| # range_max=200.0, | ||
| # ), | ||
| # ScalarRangeInitialized=1.0, | ||
| # ) | ||
|
|
||
|
|
||
| temperatureLUT.RGBPoints=[0.0, 0.231373, 0.298039, 0.752941, | ||
| 500000.0, 0.865003, 0.865003, 0.865003, | ||
| 1000000, 0.705882, 0.0156863, 0.14902] | ||
|
|
||
| temperatureLUT.ScalarRangeInitialized=1.0 | ||
|
|
||
|
|
||
|
|
||
| # show data from grid | ||
| ## wgridDisplay = Show(producer, renderView1, 'UnstructuredGridRepresentation') | ||
| gridDisplay = Show(producer, renderView1, 'StructuredGridRepresentation') | ||
|
|
||
| gridDisplay.Representation = 'Surface With Edges' | ||
| gridDisplay.ColorArrayName = ['CELLS', 'temperature'] | ||
| gridDisplay.LookupTable = temperatureLUT | ||
|
|
||
| # get color legend/bar for temperatureLUT in view renderView1 | ||
| temperatureLUTColorBar = GetScalarBar(temperatureLUT, renderView1) | ||
| temperatureLUTColorBar.Title = 'temperature' | ||
|
|
||
| # set color bar visibility | ||
| temperatureLUTColorBar.Visibility = 1 | ||
|
|
||
| # show color legend | ||
| gridDisplay.SetScalarBarVisibility(renderView1, True) | ||
|
|
||
| # # ---------------------------------------------------------------- | ||
| # # setup extractors | ||
| # # ---------------------------------------------------------------- | ||
|
|
||
| SetActiveView(renderView1) | ||
| # create extractor | ||
| pNG2= CreateExtractor('PNG', renderView1, registrationName='PNG2') | ||
| # trace defaults for the extractor. | ||
| pNG2.Trigger = 'TimeStep' | ||
|
|
||
| # init the 'PNG' selected for 'Writer' | ||
| pNG2.Writer.FileName = 'temperature_screenshot_{timestep:06d}.png' | ||
| pNG2.Writer.ImageResolution=[800, 600] | ||
| pNG2.Writer.Format = 'PNG' | ||
|
|
||
| # # ---------------------------------------------------------------- | ||
| # # setup extractor for saving the solution in VTK file | ||
| # # ---------------------------------------------------------------- | ||
|
|
||
| extractor_vtk_file = None | ||
|
|
||
| mesh_grid = producer.GetClientSideObject().GetOutputDataObject(0) | ||
| if mesh_grid.IsA('vtkUnstructuredGrid'): | ||
| extractor_vtk_file = CreateExtractor('VTU', producer, registrationName='VTU') | ||
| elif mesh_grid.IsA('vtkMultiBlockDataSet'): | ||
| extractor_vtk_file = CreateExtractor('VTM', producer, registrationName='VTM') | ||
| elif mesh_grid.IsA('vtkPartitionedDataSet'): | ||
| extractor_vtk_file = CreateExtractor('VTPD', producer, registrationName='VTPD') | ||
| else: | ||
| raise RuntimeError("Unsupported data type: %s. Check that the adaptor is providing channel named %s", | ||
| mesh_grid.GetClassName(), "grid") | ||
|
|
||
|
|
||
| # ------------------------------------------------------------------------------ | ||
| # Catalyst options | ||
| options = catalyst.Options() | ||
| ## 0: no client, generate the png images and vtk files. | ||
| ## 1: interactive | ||
| options.EnableCatalystLive = 0 | ||
|
|
||
|
|
||
| # Greeting to ensure that ctest knows this script is being imported | ||
| print("#############################################################") | ||
| print("executing catalyst_pipeline") | ||
| print("#############################################################") | ||
| def catalyst_execute(info): | ||
| global producer | ||
| producer.UpdatePipeline() | ||
| print("-----------------------------------") | ||
| print("executing (cycle={}, time={})".format(info.cycle, info.time)) | ||
| print("bounds:", producer.GetDataInformation().GetBounds()) | ||
| print("temperature-range:", producer.CellData["temperature"].GetRange(0)) | ||
| # In a real simulation sleep is not needed. We use it here to slow down the | ||
| # "simulation" and make sure ParaView client can catch up with the produced | ||
| # results instead of having all of them flashing at once. | ||
| if options.EnableCatalystLive: | ||
| time.sleep(0.1) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # duration in seconds | ||
| duration: 2.75 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2.75 instead of 1.75 like other tests, is this on purpose ? Is the delay not long enough ? |
||
| # global [height, width] (excluding boundary conditions or ghosts) | ||
| datasize: [60, 12] | ||
| # degree of parallelism | ||
| parallelism: { height: 1 , width: 1 } | ||
|
|
||
| # only the following config is passed to PDI | ||
| pdi: | ||
| metadata: # type of small values for which PDI keeps a copy | ||
| iter: int # current iteration id | ||
| dsize: { size: 2, type: array, subtype: int } # local data size including ghosts/boundary | ||
| psize: { size: 2, type: array, subtype: int } # number of processes in each dimension | ||
| pcoord: { size: 2, type: array, subtype: int } # coordinate of the process | ||
| data: # type of values for which PDI does not keep a copy | ||
| main_field: { size: [ '$dsize[0]', '$dsize[1]' ], type: array, subtype: double } | ||
|
|
||
| logging: debug | ||
| plugins: | ||
| mpi: | ||
| catalyst: | ||
| scripts: | ||
| script1: "@CATALYST_SCRIPT_FOLDER@/catalyst_pipeline_with_rendering.py" | ||
| on_event: "newiter" | ||
| execute: | ||
| state: | ||
| timestep: $iter | ||
| time: 1.0*$iter | ||
| multiblock: 0 | ||
| channels: | ||
| grid: | ||
| type: "mesh" | ||
| data: | ||
| coordsets: | ||
| my_coords: | ||
| type: "uniform" | ||
| dims: { i: '1+$dsize[1]', j: '1+$dsize[0]' } | ||
| origin: | ||
| x: 1.0*$pcoord[1]*($dsize[1]-2.0)-1.0 | ||
| y: 1.0*$pcoord[0]*($dsize[0]-2.0)-1.0 | ||
| spacing: { dx: 1.0, dy: 1.0 } | ||
| topologies: | ||
| my_mesh: | ||
| type: "uniform" | ||
| coordset: "my_coords" | ||
| fields: | ||
| temperature: | ||
| association: "element" | ||
| topology: "my_mesh" | ||
| volume_dependent: "false" | ||
| values: | ||
| PDI_data_array: "main_field" | ||
| size: $dsize[0]*$dsize[1] | ||
| ghost_layers: | ||
| my_mesh: | ||
| association: "element" | ||
| start: ['1', '1'] | ||
| size: ['$dsize[1]-2', '$dsize[0]-2'] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add additional authors (Jacques/Yushan)