Last active
March 8, 2022 14:46
-
-
Save appleparan/0aabdb169ae1ecca79235387de92b593 to your computer and use it in GitHub Desktop.
Xdmf Time Series for HDF5 dataset for fluid & particle (3D Cartesian Grid (with blanking) + Unstructured Grid)
This file contains hidden or 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
#### import the simple module from the paraview | |
from paraview.simple import * | |
#### disable automatic camera reset on 'Show' | |
paraview.simple._DisableFirstRenderCameraReset() | |
# get active source. | |
xdmfSrc = GetActiveSource() | |
# set active source | |
SetActiveSource(xdmfSrc) | |
# get active view | |
renderView1 = GetActiveViewOrCreate('RenderView') | |
# uncomment following to set a specific view size | |
# renderView1.ViewSize = [1989, 783] | |
# show data in view | |
xdmfSrcDisplay = Show(xdmfSrc, renderView1) | |
# trace defaults for the display properties. | |
xdmfSrcDisplay.Representation = 'Surface' | |
# reset view to fit data | |
renderView1.ResetCamera() | |
# show data in view | |
xdmfSrcDisplay = Show(xdmfSrc, renderView1) | |
# reset view to fit data | |
renderView1.ResetCamera() | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# set scalar coloring | |
ColorBy(xdmfSrcDisplay, ('FIELD', 'vtkBlockColors')) | |
# show color bar/color legend | |
xdmfSrcDisplay.SetScalarBarVisibility(renderView1, True) | |
# get color transfer function/color map for 'vtkBlockColors' | |
vtkBlockColorsLUT = GetColorTransferFunction('vtkBlockColors') | |
# create a new 'Extract Block' | |
extractBlock1 = ExtractBlock(Input=xdmfSrc) | |
# Properties modified on extractBlock1 | |
extractBlock1.BlockIndices = [1] | |
# show data in view | |
extractBlock1Display = Show(extractBlock1, renderView1) | |
# trace defaults for the display properties. | |
extractBlock1Display.Representation = 'Outline' | |
# hide data in view | |
Hide(xdmfSrc, renderView1) | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# set active source | |
SetActiveSource(xdmfSrc) | |
# create a new 'Extract Block' | |
extractBlock2 = ExtractBlock(Input=xdmfSrc) | |
# Properties modified on extractBlock2 | |
extractBlock2.BlockIndices = [2] | |
# show data in view | |
extractBlock2Display = Show(extractBlock2, renderView1) | |
# trace defaults for the display properties. | |
extractBlock2Display.Representation = 'Surface' | |
# hide data in view | |
Hide(xdmfSrc, renderView1) | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# rename source object | |
RenameSource('particle', extractBlock2) | |
# set active source | |
SetActiveSource(extractBlock1) | |
# rename source object | |
RenameSource('fluid', extractBlock1) | |
# create a new 'Calculator' | |
calculator1 = Calculator(Input=extractBlock1) | |
# Properties modified on calculator1 | |
calculator1.Function = 'mag(Fluid Velocity)' | |
# show data in view | |
calculator1Display = Show(calculator1, renderView1) | |
# trace defaults for the display properties. | |
calculator1Display.Representation = 'Outline' | |
# hide data in view | |
Hide(extractBlock1, renderView1) | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# Properties modified on calculator1 | |
calculator1.ResultArrayName = 'vel' | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# Properties modified on calculator1Display | |
calculator1Display.SelectScaleArray = 'Fluid Velocity' | |
# Properties modified on calculator1Display | |
calculator1Display.GlyphTableIndexArray = 'Fluid Velocity' | |
# Properties modified on calculator1Display | |
calculator1Display.SetScaleArray = ['POINTS', 'vel'] | |
# Properties modified on calculator1Display | |
calculator1Display.OpacityArray = ['POINTS', 'vel'] | |
# Properties modified on calculator1Display | |
calculator1Display.OSPRayScaleArray = 'Fluid Velocity' | |
# rename source object | |
RenameSource('fluid_vel_mag', calculator1) | |
# create a new 'Contour' | |
contour1 = Contour(Input=calculator1) | |
# show data in view | |
contour1Display = Show(contour1, renderView1) | |
# trace defaults for the display properties. | |
contour1Display.Representation = 'Surface' | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# rename source object | |
RenameSource('fluid_vel_isosurface', contour1) | |
# set active source | |
SetActiveSource(extractBlock2) | |
# change representation type | |
extractBlock2Display.SetRepresentationType('Point Gaussian') | |
# Properties modified on extractBlock2Display | |
extractBlock2Display.GaussianRadius = 0.25 | |
# change solid color | |
extractBlock2Display.DiffuseColor = [0.6666666666666666, 1.0, 0.4980392156862745] | |
# create a new 'Glyph' | |
glyph1 = Glyph(Input=extractBlock2, | |
GlyphType='Arrow') | |
# Properties modified on glyph1 | |
glyph1.Vectors = ['POINTS', 'Particle Velocity'] | |
# show data in view | |
glyph1Display = Show(glyph1, renderView1) | |
# trace defaults for the display properties. | |
glyph1Display.Representation = 'Surface' | |
# update the view to ensure updated data information | |
renderView1.Update() | |
# change solid color | |
glyph1Display.DiffuseColor = [0.6666666666666666, 1.0, 0.0] | |
# find source | |
glyph1 = FindSource('Glyph1') | |
# set active source | |
SetActiveSource(glyph1) | |
# rename source object | |
RenameSource('par_vel', glyph1) | |
# set active source | |
SetActiveSource(calculator1) | |
#### saving camera placements for all active views | |
# current camera placement for renderView1 | |
renderView1.CameraPosition = [-3.614122428975542, 3.570376548967818, 22.91909562514047] | |
renderView1.CameraFocalPoint = [3.125230191385, 3.125230191385, 3.125230191385] | |
renderView1.CameraViewUp = [0.04192160103128363, 0.9990872921285796, -0.008195247046683101] | |
renderView1.CameraParallelScale = 5.413057476827026 | |
#### uncomment the following to render all views | |
# RenderAllViews() | |
# alternatively, if you want to write images, you can use SaveScreenshot(...). |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8" ?> | |
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []> | |
<Xdmf Version="3.0" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
<Domain> | |
<Grid Name="Fluid" GridType="Collection" CollectionType="Temporal"> | |
<Grid Name="Fluid0000" GridType="Uniform"> | |
<Time Value="0.0" /> | |
<Topology Name="FluidTopo" TopologyType="3DCoRectMesh" Dimensions="192 192 192" /> | |
<Geometry Name="FluidGeo" GeometryType="ORIGIN_DXDYDZ"> | |
<DataItem Name="FluidOrigin" Format="XML" Dimensions="3" NumberType="Float" Precision="8"> | |
0.0 0.0 0.0 | |
</DataItem> | |
<DataItem Name="FluidSpacing" Format="XML" Dimensions="3" NumberType="Float" Precision="8"> | |
0.03272492347 0.03272492347 0.03272492347 | |
</DataItem> | |
</Geometry> | |
<Attribute Name="Fluid Velocity" AttributeType="Vector" Center="Node"> | |
<DataItem Format="HDF" NumberType="Float" Precision="8" Dimensions="192 192 192 3"> | |
iso_N192_R70_1x_0000.h5:/vel | |
</DataItem> | |
</Attribute> | |
</Grid> | |
<Grid Name="Fluid0001" GridType="Uniform"> | |
<Time Value="0.1" /> | |
<Topology Name="FluidTopo" TopologyType="3DCoRectMesh" Dimensions="192 192 192" /> | |
<Geometry Name="FluidGeo" GeometryType="ORIGIN_DXDYDZ"> | |
<DataItem Name="FluidOrigin" Format="XML" Dimensions="3" NumberType="Float" Precision="8"> | |
0.0 0.0 0.0 | |
</DataItem> | |
<DataItem Name="FluidSpacing" Format="XML" Dimensions="3" NumberType="Float" Precision="8"> | |
0.03272492347 0.03272492347 0.03272492347 | |
</DataItem> | |
</Geometry> | |
<Attribute Name="Fluid Velocity" AttributeType="Vector" Center="Node"> | |
<DataItem Format="HDF" NumberType="Float" Precision="8" Dimensions="192 192 192 3"> | |
iso_N192_R70_1x_0001.h5:/vel | |
</DataItem> | |
</Attribute> | |
</Grid> | |
</Grid> | |
<Grid Name="Particle" GridType="Collection" CollectionType="Temporal"> | |
<Grid Name="Particle0000" GridType="Uniform"> | |
<Time Value="0.0" /> | |
<Topology Name="ParticleTopo" TopologyType="PolyVertex" NumberOfElements="10"/> | |
<Geometry GeometryType="XYZ"> | |
<DataItem Format="HDF" NumberType="Float" Precision="8" Dimensions="10 3"> | |
iso_N192_R70_1x_0000.h5:/p_loc | |
</DataItem> | |
</Geometry> | |
<Attribute Name="Particle Velocity" AttributeType="Vector" Center="Node"> | |
<DataItem Format="HDF" NumberType="Float" Precision="8" Dimensions="10 3"> | |
iso_N192_R70_1x_0000.h5:/p_vel | |
</DataItem> | |
</Attribute> | |
</Grid> | |
<Grid Name="Particle0001" GridType="Uniform"> | |
<Time Value="0.1" /> | |
<Topology Name="ParticleTopo" TopologyType="PolyVertex" NumberOfElements="10"/> | |
<Geometry GeometryType="XYZ"> | |
<DataItem Format="HDF" NumberType="Float" Precision="8" Dimensions="10 3"> | |
iso_N192_R70_1x_0001.h5:/p_loc | |
</DataItem> | |
</Geometry> | |
<Attribute Name="Particle Velocity" AttributeType="Vector" Center="Node"> | |
<DataItem Format="HDF" NumberType="Float" Precision="8" Dimensions="10 3"> | |
iso_N192_R70_1x_0001.h5:/p_vel | |
</DataItem> | |
</Attribute> | |
</Grid> | |
</Grid> | |
</Domain> | |
</Xdmf> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the hdmf file (iso_N192_R70_1x_0001.h5) is still available, it would be very helpful to make it available as a complete example of how to use xdml!
Stephen