-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de424ca
commit 2d648b1
Showing
3 changed files
with
104 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# VTKHDF files | ||
https://www.kitware.com/how-to-write-time-dependent-data-in-vtkhdf-files/ | ||
> October 27, 2023; Lucas Givord and Julien Fausty | ||
> It can be read into VTK or ParaView master at the moment and will be available in the next release of both : VTK 9.3.0 and ParaView 5.12.0. | ||
## Application | ||
python vtkpython.py | ||
|
||
## issues | ||
* python=3.10 with vtk>=9.3.0 in bareVE.yaml; | ||
* python=3.11 with vtk>=9.3.0 in bareVE.yaml; | ||
* python=3.9 with vtk>=9.3.0 in bareVE.yaml; | ||
* python=3.9 with - vtk>=9.2.5 in bareVE.yaml; | ||
* python=3.9 with - vtk>=9.2.0 in bareVE.yaml; | ||
* python=3.8 with - vtk>=9.2.0 in bareVE.yaml; | ||
|
||
|
||
``` | ||
Traceback (most recent call last): | ||
File "/home/mxochicale/repositories/mxochicale/code/vtk/vtkhdf/vtkpython.py", line 3, in <module> | ||
from vtkmodules.vtkFiltersGeneral import (vtkGroupDataSetsFilter, | ||
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.10/site-packages/vtkmodules/vtkFiltersGeneral.cpython-310-x86_64-linux-gnu.so) | ||
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.9/site-packages/vtkmodules/vtkFiltersGeneral.cpython-39-x86_64-linux-gnu.so) | ||
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.9/site-packages/vtkmodules/vtkFiltersGeneral.cpython-39-x86_64-linux-gnu.so) | ||
ImportError: cannot import name 'vtkSpatioTemporalHarmonicsAttribute' from 'vtkmodules.vtkFiltersGeneral' (/home/mxochicale/mambaforge/envs/bareVE/lib/python3.11/site-packages/vtkmodules/vtkFiltersGeneral.cpython-311-x86_64-linux-gnu.so) | ||
``` | ||
|
||
|
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,68 @@ | ||
import numpy as np | ||
import h5py as h5 | ||
|
||
from vtkmodules.vtkCommonDataModel import (vtkDataObject, | ||
vtkPartitionedDataSet, | ||
vtkPolyData) | ||
from vtkmodules.vtkFiltersGeneral import vtkGroupDataSetsFilter | ||
from vtkmodules.vtkFiltersGeneral import vtkWarpScalar | ||
|
||
from vtkmodules.vtkFiltersGeneral import vtkSpatioTemporalHarmonicsAttribute | ||
#https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/General/vtkSpatioTemporalHarmonicsAttribute.h | ||
|
||
from vtkmodules.vtkFiltersHybrid import vtkGenerateTimeSteps | ||
from vtkmodules.vtkFiltersSources import vtkSphereSource | ||
from vtkmodules.util.numpy_support import vtk_to_numpy | ||
|
||
|
||
|
||
sphere0 = vtkSphereSource() | ||
sphere0.SetPhiResolution(30) | ||
sphere0.SetThetaResolution(30) | ||
sphere0.SetRadius(10) | ||
|
||
sphere1 = vtkSphereSource() | ||
sphere1.SetPhiResolution(30) | ||
sphere1.SetThetaResolution(30) | ||
sphere1.SetRadius(10) | ||
sphere1.SetCenter(15, 15, 15) | ||
|
||
# store the spheres in a single partitioned data set | ||
groupDataSets = vtkGroupDataSetsFilter() | ||
groupDataSets.AddInputConnection(sphere0.GetOutputPort()) | ||
groupDataSets.AddInputConnection(sphere1.GetOutputPort()) | ||
groupDataSets.SetOutputTypeToPartitionedDataSet() | ||
|
||
# generate time steps | ||
timeSteps = vtkGenerateTimeSteps() | ||
timeSteps.SetInputConnection(groupDataSets.GetOutputPort()) | ||
timeValues = np.linspace(0.0, 2*np.pi, 100, endpoint=False) | ||
timeSteps.SetTimeStepValues(100, timeValues) | ||
|
||
# generate fields | ||
addFields = vtkSpatioTemporalHarmonicsAttribute() | ||
harmonics = np.array([ | ||
[1.0, 1.0, 0.6283, 0.6283, 0.6283, 0.0], | ||
[3.0, 1.0, 0.6283, 0.0, 0.0, 1.5708], | ||
[2.0, 2.0, 0.0, 0.6283, 0.0, 3.1416], | ||
[1.0, 3.0, 0.0, 0.0, 0.6283, 4.7124] | ||
]) | ||
for iH in range(harmonics.shape[0]): | ||
addFields.AddHarmonic(harmonics[iH, 0], | ||
harmonics[iH, 1], | ||
harmonics[iH, 2], | ||
harmonics[iH, 3], | ||
harmonics[iH, 4], | ||
harmonics[iH, 5]) | ||
|
||
addFields.SetInputConnection(timeSteps.GetOutputPort()) | ||
|
||
# warp spheres | ||
warp = vtkWarpScalar() | ||
warp.SetInputConnection(addFields.GetOutputPort()) | ||
warp.SetInputArrayToProcess(0, 0, 0, | ||
vtkDataObject.FIELD_ASSOCIATION_POINTS, | ||
'SpatioTemporalHarmonics') | ||
|
||
# update the entire thing | ||
warp.Update() |