showMesh3d.py
# trace generated using paraview version 5.10.0
#import paraview
#paraview.compatibility.major = 5
#paraview.compatibility.minor = 10
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'OpenFOAMReader'
casefoam = OpenFOAMReader(registrationName='case.foam', FileName='C:\\myPC\\myFile\\SJTU_U42\\BS212_UPT\\postpro\\case\\case.foam')
casefoam.MeshRegions = ['internalMesh']
casefoam.CellArrays = ['U', 'alpha0', 'alpha1', 'div']
# find source
casefoam_1 = FindSource('case.foam')
# Properties modified on casefoam_1
casefoam_1.MeshRegions = ['internalMesh']
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# show data in view
casefoamDisplay = Show(casefoam, renderView1, 'UnstructuredGridRepresentation')
# trace defaults for the display properties.
casefoamDisplay.Representation = 'Surface'
# reset view to fit data
renderView1.ResetCamera(False)
# get the material library
materialLibrary1 = GetMaterialLibrary()
# update the view to ensure updated data information
renderView1.Update()
# change representation type
casefoamDisplay.SetRepresentationType('Surface With Edges')
casefoam.Decomposepolyhedra = 0
# addendum: following script captures some of the application
# state to faithfully reproduce the visualization during playback
# get layout
layout1 = GetLayout()
# saving layout sizes for layouts
# layout/tab size in pixels
layout1.SetSize(500, 490)
#-----------------------------------
# saving camera placements for views
# current camera placement for renderView1
# camera modification
renderView1.CameraPosition = [3.0, 3.0, 3.0]
renderView1.CameraFocalPoint = [0.5, 0.5, 0.5]
renderView1.CameraViewUp = [-0.3, 2.0, -0.3]
renderView1.CameraParallelScale = 1.0
# create a new 'Clip'
clip1 = Clip(registrationName='Clip1', Input=casefoam)
clip1.ClipType = 'Plane'
clip1.HyperTreeGridClipper = 'Plane'
clip1.Scalars = ['POINTS', 'alpha0']
clip1.Value = 0.5
# Properties modified on clip1.ClipType
clip1.ClipType.Origin = [0.75, 0.75, 0.75]
clip1.ClipType.Normal = [0.5, 0.5, 0.5]
# show data in view
renderView1 = GetActiveViewOrCreate('RenderView')
clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')
clip1Display.Representation = 'Surface'
clip1Display.SetRepresentationType('Surface With Edges')
clip1.Crinkleclip = 1
Hide(casefoam, renderView1)
Hide3DWidgets(proxy=clip1.ClipType)
clip1Display.EdgeColor = [0.0, 0.0, 0.0]
renderView1.OrientationAxesVisibility = 0
renderView1.CameraParallelProjection = 1
renderView1.UseColorPaletteForBackground = 0
renderView1.Background = [1.0, 1.0, 1.0]
SaveScreenshot('C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\showMesh.png', renderView1, ImageResolution=[500, 490])
ExportView('C:/myPC/myFile/SJTU_U42/BS212_UPT/postpro/showMesh.eps', view=renderView1)
# uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
bubbleR30.mcr
#!MC 1410
$!ReadDataSet '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
DataSetReader = 'OpenFOAM (FEA)'
$!PlotType = Cartesian2D
$!TwoDAxis XDetail{RangeMin = 0.0}
$!TwoDAxis XDetail{RangeMax = 1.0}
$!TwoDAxis YDetail{RangeMin = 0.0}
$!TwoDAxis YDetail{RangeMax = 2.0}
$!FieldLayers ShowMesh = No
$!FieldMap [2] Shade{Show = No}
$!TwoDAxis GridArea{DrawBorder = No}
$!TwoDAxis YDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{AxisLine{Show = No}}
$!TwoDAxis XDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{AxisLine{Show = No}}
$!FieldLayers ShowContour = Yes
$!FieldMap [2] Contour{ContourType = Lines}
$!GlobalTime SolutionTime = 3.0
$!SetContourVar
Var = 'alpha.water'
ContourGroup = 1
$!ContourLevels New
ContourGroup = 1
RawData
1
0.5
$!View MakeCurrentViewNice
$!GlobalContour 1 Legend{Show = No}
$!CreateNewFrame
XYPos
{
X = 2.51
Y = 2.45
}
Width = 2.40
Height = 4.88
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!RedrawAll
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\BR2d30.jpeg'
$!Export
ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\BR2d30.eps'
$!Export
ExportRegion = CurrentFrame
$!QUIT
plotZalesak2d.mcr
#!MC 1410
$!ReadDataSet '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
DataSetReader = 'OpenFOAM (FEA)'
$!PlotType = Cartesian2D
$!TwoDAxis XDetail{RangeMin = 0.3}
$!TwoDAxis XDetail{RangeMax = 0.7}
$!TwoDAxis AxisMode = Independent
$!TwoDAxis YDetail{RangeMin = 0.572}
$!TwoDAxis YDetail{RangeMax = 0.928}
$!FieldLayers ShowMesh = No
$!FieldMap [2] Shade{Show = No}
$!FrameLayout ShowBorder = No
$!TwoDAxis GridArea{DrawBorder = No}
$!TwoDAxis YDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{AxisLine{Show = No}}
$!TwoDAxis XDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{AxisLine{Show = No}}
$!FieldLayers ShowContour = Yes
$!FieldMap [2] Contour{ContourType = Lines}
$!FieldMap [2] Contour{Color = Red}
$!FieldMap [2] Contour{LineThickness = 0.4}
$!GlobalContour 1 Legend{Show = No}
$!GlobalTime SolutionTime = 6.28318023682
$!SetContourVar
Var = 'alpha1'
ContourGroup = 1
# create contour with alpha1
$!ContourLevels New
ContourGroup = 1
RawData
3
0.05
0.5
0.95
$!View MakeCurrentViewNice
$!CreateNewFrame
XYPos
{
X = 2.4
Y = 1.55
}
Width = 6.3
Height = 5.5
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!RedrawAll
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\zalesak2d.jpeg'
$!Export
ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\zalesak2d.eps'
$!Export
ExportRegion = CurrentFrame
# $!QUIT
RT2d090.mcr
#!MC 1410
$!ReadDataSet '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
DataSetReader = 'OpenFOAM (FEA)'
$!PlotType = Cartesian2D
$!TwoDAxis XDetail{RangeMin = 0.0}
$!TwoDAxis XDetail{RangeMax = 1.0}
$!TwoDAxis YDetail{RangeMin = 0.0}
$!TwoDAxis YDetail{RangeMax = 4.0}
$!FieldLayers ShowMesh = No
$!FieldMap [2] Shade{Show = No}
$!TwoDAxis GridArea{DrawBorder = No}
$!TwoDAxis YDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{AxisLine{Show = No}}
$!TwoDAxis XDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{AxisLine{Show = No}}
$!FieldLayers ShowContour = Yes
$!FieldMap [2] Contour{ContourType = Lines}
$!GlobalTime SolutionTime = 0.90
$!SetContourVar
Var = 'alpha.water'
ContourGroup = 1
$!ContourLevels New
ContourGroup = 1
RawData
1
0.5
$!View MakeCurrentViewNice
$!GlobalContour 1 Legend{Show = No}
$!CreateNewFrame
XYPos
{
X = 2.09
Y = 3.00
}
Width = 1.65
Height = 3.32
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!RedrawAll
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\RT2d090.jpeg'
$!Export
ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\RT2d090.eps'
$!Export
ExportRegion = CurrentFrame
#$!QUIT
showAsteroid2d.mcr
#!MC 1410
$!ReadDataSet '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_U42\BS212_UPT\postpro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
DataSetReader = 'OpenFOAM (FEA)'
$!PlotType = Cartesian2D
$!TwoDAxis XDetail{RangeMin = 0.0}
$!TwoDAxis XDetail{RangeMax = 1.0}
$!TwoDAxis AxisMode = Independent
$!TwoDAxis YDetail{RangeMin = 0.0}
$!TwoDAxis YDetail{RangeMax = 1.0}
$!TwoDAxis YDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{AxisLine{Show = No}}
$!TwoDAxis XDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{AxisLine{Show = No}}
$!View MakeCurrentViewNice
$!FrameLayout ShowBorder = No
$!TwoDAxis GridArea{DrawBorder = No}
$!FieldLayers ShowMesh = No
$!FieldMap [2] Shade{Show = No}
$!FieldLayers ShowContour = Yes
$!FieldMap [2] Contour{ContourType = Lines}
$!GlobalTime SolutionTime = 20.0
$!SetContourVar
Var = 'alpha0'
ContourGroup = 1
$!ContourLevel

文章提供了一系列ParaView脚本,用于读取OpenFOAM数据,进行3D视图操作,如剪切、着色、轮廓显示等,并导出JPEG和EPS图像。这些脚本涉及不同场景的流体模拟结果展示,如水坝破裂、圆柱体和二维结构的变形等。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



