Skip to content

Instantly share code, notes, and snippets.

@robinknowles
Created August 4, 2023 14:21
Show Gist options
  • Save robinknowles/7299f6f33dfa7b0ebed4d6b4186ee2d3 to your computer and use it in GitHub Desktop.
Save robinknowles/7299f6f33dfa7b0ebed4d6b4186ee2d3 to your computer and use it in GitHub Desktop.
A scriptable method for producing run summary receipts for sharing in Slack/Teams/Whatsapp

Run Receipts in ParaView

Accompanies OnCFD Newsletter #158

Attached is an example ParaView script to create a "run receipt" summary of your results like this 👇

Straight from the command-line & ready to post into Slack/Teams/WhatsApp

Just save the Python script locally & run it using:

pvbatch runReceipt.py

For more info (& an example of the output) see the original article 👋

# state file generated using paraview version 5.11.1
import paraview
paraview.compatibility.major = 5
paraview.compatibility.minor = 11
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------
# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [300, 450]
renderView1.OrientationAxesVisibility = 0
renderView1.UseColorPaletteForBackground = 0
renderView1.Background = [1.0, 0.98824, 0.94902]
SetActiveView(renderView1)
# ----------------------------------------------------------------
# Setup all the text sources
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# Title Block
# ----------------------------------------------------------------
# create Date
Title_Date = Text(registrationName='Title_Date')
Title_Date.Text = "05 AUG 2023"
# add Date to view
Title_DateDisplay = Show(Title_Date, renderView1, 'TextSourceRepresentation')
# set text settings for Date
Title_DateDisplay.WindowLocation = 'Any Location'
Title_DateDisplay.Position = [0.633, 0.923]
Title_DateDisplay.Color = [0.0, 0.0, 0.16]
Title_DateDisplay.FontFamily = 'Courier'
Title_DateDisplay.FontSize = 14
Title_DateDisplay.Justification = 'Left'
# create Title
Title_Main = Text(registrationName='Title_Main')
Title_Main.Text = "R052"
# add Title to view
Title_MainDisplay = Show(Title_Main, renderView1, 'TextSourceRepresentation')
# set text settings for Title
Title_MainDisplay.WindowLocation = 'Any Location'
Title_MainDisplay.Position = [0.06, 0.8478]
Title_MainDisplay.Color = [0.0, 0.0, 0.16]
Title_MainDisplay.FontFamily = 'Courier'
Title_MainDisplay.FontSize = 26
Title_MainDisplay.Justification = 'Left'
# create subtitle
Title_SubTitle = Text(registrationName='Title_SubTitle')
Title_SubTitle.Text = "As R050 with finalised\nrear arches\n"
# add subtitle to view
Title_SubTitleDisplay = Show(Title_SubTitle, renderView1, 'TextSourceRepresentation')
# set text settings for subtitle
Title_SubTitleDisplay.WindowLocation = 'Any Location'
Title_SubTitleDisplay.Position = [0.06, 0.71]
Title_SubTitleDisplay.Color = [0.0, 0.0, 0.16]
Title_SubTitleDisplay.FontFamily = 'Courier'
Title_SubTitleDisplay.FontSize = 16
Title_SubTitleDisplay.Justification = 'Left'
Title_SubTitleDisplay.LineSpacing = 1.3
# ----------------------------------------------------------------
# Setup Average Force Block
# ----------------------------------------------------------------
# create block title
avg_Force_Title = Text(registrationName='Avg_Force_Title')
avg_Force_Title.Text = "Averaged Forces"
# add block title to view
avg_Force_TitleDisplay = Show(avg_Force_Title, renderView1, 'TextSourceRepresentation')
# set text settings for block title
avg_Force_TitleDisplay.WindowLocation = 'Any Location'
avg_Force_TitleDisplay.Position = [0.06, 0.655]
avg_Force_TitleDisplay.Color = [0.0, 0.0, 0.16]
avg_Force_TitleDisplay.FontFamily = 'Courier'
avg_Force_TitleDisplay.FontSize = 16
avg_Force_TitleDisplay.Justification = 'Left'
# create average force names
avg_Force_Names = Text(registrationName='Avg_Force_Names')
avg_Force_Names.Text = "Drag\nDownforce\nBalance"
# add average force names to view
avg_Force_NamesDisplay = Show(avg_Force_Names, renderView1, 'TextSourceRepresentation')
# set text settings for average force names
avg_Force_NamesDisplay.WindowLocation = 'Any Location'
avg_Force_NamesDisplay.Position = [0.06, 0.4348888888888889]
avg_Force_NamesDisplay.Color = [0.0, 0.0, 0.16]
avg_Force_NamesDisplay.FontFamily = 'Courier'
avg_Force_NamesDisplay.FontSize = 16
avg_Force_NamesDisplay.Justification = 'Left'
avg_Force_NamesDisplay.LineSpacing = 2.3
# create average force values
avg_Force_Values = Text(registrationName='Avg_Force_Values')
avg_Force_Values.Text = "1700\n955\n65.5"
# add average force values to view
avg_Force_ValuesDisplay = Show(avg_Force_Values, renderView1, 'TextSourceRepresentation')
# set text settings for average force values
avg_Force_ValuesDisplay.WindowLocation = 'Any Location'
avg_Force_ValuesDisplay.Position = [0.61, 0.4348888888888889]
avg_Force_ValuesDisplay.Color = [0.0, 0.0, 0.16]
avg_Force_ValuesDisplay.FontFamily = 'Courier'
avg_Force_ValuesDisplay.FontSize = 16
avg_Force_ValuesDisplay.Justification = 'Right'
avg_Force_ValuesDisplay.LineSpacing = 2.3
# create average force units
avg_Force_Units = Text(registrationName='Avg_Force_Units')
avg_Force_Units.Text = "N\nN\n%(fr)"
# add average force units to view
avg_Force_UnitsDisplay = Show(avg_Force_Units, renderView1, 'TextSourceRepresentation')
# set text settings for average force units
avg_Force_UnitsDisplay.WindowLocation = 'Any Location'
avg_Force_UnitsDisplay.Position = [0.77, 0.4348888888888889]
avg_Force_UnitsDisplay.Color = [0.0, 0.0, 0.16]
avg_Force_UnitsDisplay.FontFamily = 'Courier'
avg_Force_UnitsDisplay.FontSize = 16
avg_Force_UnitsDisplay.Justification = 'Left'
avg_Force_UnitsDisplay.LineSpacing = 2.3
# create dotted dividing lines
avg_divider = Text(registrationName='Avg_Force_Divider')
avg_divider.Text = '--------------------------------\n\n\n--------------------------------'
# add dotted dividing lines to view
avg_dividerDisplay = Show(avg_divider, renderView1, 'TextSourceRepresentation')
# set text settings for dotted dividing lines
avg_dividerDisplay.WindowLocation = 'Any Location'
avg_dividerDisplay.Position = [0.055, 0.4]
avg_dividerDisplay.Color = [0.0, 0.0, 0.16]
avg_dividerDisplay.FontFamily = 'Courier'
avg_dividerDisplay.FontSize = 14
avg_dividerDisplay.LineSpacing = 2.45
# ----------------------------------------------------------------
# Setup Delta Force Block
# ----------------------------------------------------------------
# create delta title
delta_Force_Title = Text(registrationName='Delta_Force_Title')
delta_Force_Title.Text = "Compared to R050"
# add delta title to view
delta_Force_TitleDisplay = Show(delta_Force_Title, renderView1, 'TextSourceRepresentation')
# set text settings for delta title
delta_Force_TitleDisplay.WindowLocation = 'Any Location'
delta_Force_TitleDisplay.Position = [0.06, 0.32]
delta_Force_TitleDisplay.Color = [0.0, 0.0, 0.16]
delta_Force_TitleDisplay.FontFamily = 'Courier'
delta_Force_TitleDisplay.FontSize = 16
delta_Force_TitleDisplay.Justification = 'Left'
# create delta names
delta_Force_Names = Text(registrationName='Delta_Force_Names')
delta_Force_Names.Text = "Drag\nDownforce\nBalance"
# add delta names to view
delta_Force_NamesDisplay = Show(delta_Force_Names, renderView1, 'TextSourceRepresentation')
# set text settings for delta names
delta_Force_NamesDisplay.WindowLocation = 'Any Location'
delta_Force_NamesDisplay.Position = [0.06, 0.097]
delta_Force_NamesDisplay.Color = [0.0, 0.0, 0.16]
delta_Force_NamesDisplay.FontFamily = 'Courier'
delta_Force_NamesDisplay.FontSize = 16
delta_Force_NamesDisplay.Justification = 'Left'
delta_Force_NamesDisplay.LineSpacing = 2.3
# create delta values
delta_Force_Values = Text(registrationName='Delta_Force_Values')
delta_Force_Values.Text = " +52\n-74\n+2"
# add delta values to view
delta_Force_ValuesDisplay = Show(delta_Force_Values, renderView1, 'TextSourceRepresentation')
# set text settings for delta values
delta_Force_ValuesDisplay.WindowLocation = 'Any Location'
delta_Force_ValuesDisplay.Position = [0.61, 0.097]
delta_Force_ValuesDisplay.Color = [0.0, 0.0, 0.16]
delta_Force_ValuesDisplay.FontFamily = 'Courier'
delta_Force_ValuesDisplay.FontSize = 16
delta_Force_ValuesDisplay.Justification = 'Right'
delta_Force_ValuesDisplay.LineSpacing = 2.3
# create delta units
delta_Force_Units = Text(registrationName='Delta_Force_Units')
delta_Force_Units.Text = "N\nN\n%(fr)"
# add delta units to view
delta_Force_UnitsDisplay = Show(delta_Force_Units, renderView1, 'TextSourceRepresentation')
# set text settings for delta units
delta_Force_UnitsDisplay.WindowLocation = 'Any Location'
delta_Force_UnitsDisplay.Position = [0.77, 0.097]
delta_Force_UnitsDisplay.Color = [0.0, 0.0, 0.16]
delta_Force_UnitsDisplay.FontFamily = 'Courier'
delta_Force_UnitsDisplay.FontSize = 16
delta_Force_UnitsDisplay.Justification = 'Left'
delta_Force_UnitsDisplay.LineSpacing = 2.3
# create dotted dividing lines
delta_Divider = Text(registrationName='Delta_Force_Divider')
delta_Divider.Text = '--------------------------------\n\n\n--------------------------------'
# add dotted dividing lines to view
delta_DividerDisplay = Show(delta_Divider, renderView1, 'TextSourceRepresentation')
# set text settings for dividing lines
delta_DividerDisplay.WindowLocation = 'Any Location'
delta_DividerDisplay.Position = [0.055, 0.065]
delta_DividerDisplay.Color = [0.0, 0.0, 0.16]
delta_DividerDisplay.FontFamily = 'Courier'
delta_DividerDisplay.FontSize = 14
delta_DividerDisplay.LineSpacing = 2.45
# ----------------------------------------------------------------
# Footer Bar
# ----------------------------------------------------------------
# create Title
Wordmark = Text(registrationName='Wordmark')
Wordmark.Text = "CFD ENGINE"
# add data from Wordmark to view
WordmarkDisplay = Show(Wordmark, renderView1, 'TextSourceRepresentation')
# trace defaults for the display properties.
WordmarkDisplay.WindowLocation = 'Any Location'
WordmarkDisplay.Position = [0.633, 0.02]
WordmarkDisplay.Position = [0.06, 0.02]
WordmarkDisplay.Color = [0.0, 0.0, 0.16]
WordmarkDisplay.FontFamily = 'Courier'
WordmarkDisplay.FontSize = 14
WordmarkDisplay.Opacity = 0.2
WordmarkDisplay.Justification = 'Left'
# ----------------------------------------------------------------
# Save output image
# ----------------------------------------------------------------
SaveScreenshot('./runReceipt.png', renderView1, ImageResolution=[600, 900])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment