diff --git a/tutorials/incompressible/icoFoam/cavity/Allrun-serial b/tutorials/incompressible/icoFoam/cavity/Allrun-serial index 07de5ab78882039b1c7c18649df3e7873781ea4b..988f2497ee22e5dfc272e727e552201480800842 100755 --- a/tutorials/incompressible/icoFoam/cavity/Allrun-serial +++ b/tutorials/incompressible/icoFoam/cavity/Allrun-serial @@ -2,6 +2,10 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions +# Force FPE handling on - worst case. +export FOAM_SIGFPE=true +export FOAM_SETNAN=true + runApplication blockMesh runApplication icoFoam diff --git a/tutorials/incompressible/icoFoam/cavity/system/controlDict b/tutorials/incompressible/icoFoam/cavity/system/controlDict index 2c89a6a6679cede125ce797f1ee2d1de25e798ef..221f4092fcb6822fe66565e68b5d3c8392c83d39 100644 --- a/tutorials/incompressible/icoFoam/cavity/system/controlDict +++ b/tutorials/incompressible/icoFoam/cavity/system/controlDict @@ -48,6 +48,7 @@ runTimeModifiable true; functions { #include "catalyst" + // #include "test/badCatalyst" } // ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst b/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst new file mode 100644 index 0000000000000000000000000000000000000000..0cbe4eb948bfbba512887d8ecdf2467e3c3cf37a --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst @@ -0,0 +1,26 @@ +// ParaView Catalyst function object for OpenFOAM (-*- C++ -*-) + +catalyst +{ + #includeEtc "caseDicts/insitu/catalyst/catalyst.cfg" + + scripts + ( +// "<system>/test/badCatalyst0.py" +// "<system>/test/badCatalyst1.py" +// "<system>/test/badCatalyst2.py" +// "<system>/test/contourGood.py" +// "<system>/test/contourBad1.py" + "<system>/test/contourBad2.py" + ); + + inputs + { + region + { + fields (".*"); + } + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst0.py b/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst0.py new file mode 100644 index 0000000000000000000000000000000000000000..cf9d821f4b91692ccbc9c97f2fb028cab3c1b182 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst0.py @@ -0,0 +1,77 @@ +from paraview.simple import * +from paraview import coprocessing + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + input1 = coprocessor.CreateProducer(datadescription, 'region') + + # create a new 'Parallel UnstructuredGrid Writer' + meshWriter = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) + + # register the writer with coprocessor + # and provide it with information such as the filename to use, + # how frequently to write the data, etc. + coprocessor.RegisterWriter(syntaxErrormeshWriterBad, filename='region_%t.vtm', freq=10) + + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + freqs = {'region': [10, 100]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + +#-------------------------------------------------------------- +# Global variables that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView +coprocessor.EnableLiveVisualization(False) + + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + "Callback to populate the request for current timestep" + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + "Callback to do co-processing for current timestep" + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=False) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, "localhost", 22222) + diff --git a/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst1.py b/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst1.py new file mode 100644 index 0000000000000000000000000000000000000000..e6dd141c0808f8219dbcde18a8820c23f59fd4d4 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavity/system/test/badCatalyst1.py @@ -0,0 +1,220 @@ + +from paraview.simple import * +from paraview import coprocessing + + +#-------------------------------------------------------------- +# Code generated from cpstate.py to create the CoProcessor. +# paraview version 5.5.2 + +#-------------------------------------------------------------- +# Global screenshot output options +imageFileNamePadding=0 +rescale_lookuptable=False + + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + # state file generated using paraview version 5.5.2 + + # ---------------------------------------------------------------- + # setup views used in the visualization + # ---------------------------------------------------------------- + + # trace generated using paraview version 5.5.2 + + #### disable automatic camera reset on 'Show' + paraview.simple._DisableFirstRenderCameraReset() + + # Create a new 'Render View' + renderView1 = CreateView('RenderView') + renderView1.ViewSize = [1310, 756] + renderView1.AxesGrid = 'GridAxes3DActor' + renderView1.CenterOfRotation = [0.5, 0.5, 0.5] + renderView1.StereoType = 0 + renderView1.CameraPosition = [1.8716405831674128, 1.847832336175357, 3.241910834080083] + renderView1.CameraFocalPoint = [0.6252880309830952, 0.5161911805422628, 0.4366497818793457] + renderView1.CameraViewUp = [0.04375835431915484, 0.8948481435873961, -0.44422067302802376] + renderView1.CameraParallelScale = 0.8660254037844386 + renderView1.CameraParallelProjection = 1 + renderView1.Background = [0.32, 0.34, 0.43] + + # init the 'GridAxes3DActor' selected for 'AxesGrid' + renderView1.AxesGrid.XTitleFontFile = '' + renderView1.AxesGrid.YTitleFontFile = '' + renderView1.AxesGrid.ZTitleFontFile = '' + renderView1.AxesGrid.XLabelFontFile = '' + renderView1.AxesGrid.YLabelFontFile = '' + renderView1.AxesGrid.ZLabelFontFile = '' + + # register the view with coprocessor + # and provide it with information such as the filename to use, + # how frequently to write the images, etc. + coprocessor.RegisterView(renderView1, + filename='image_%t.png', freq=1, fittoscreen=0, magnification=1, width=1310, height=756, cinema={}) + renderView1.ViewTime = datadescription.GetTime() + + # ---------------------------------------------------------------- + # restore active view + SetActiveView(renderView1) + # ---------------------------------------------------------------- + + # ---------------------------------------------------------------- + # setup the data processing pipelines + # ---------------------------------------------------------------- + + # create a new 'OpenFOAMReader' + # create a producer from a simulation input + cavityfoam = coprocessor.CreateProducer(datadescription, 'region') + + # create a new 'Contour' + contour1 = Contour(Input=cavityfoam) + contour1.ContourBy = ['POINTS', 'p_NOFIELD'] + contour1.Isosurfaces = [0.05] + contour1.PointMergeMethod = 'Uniform Binning' + + # ---------------------------------------------------------------- + # setup the visualization in view 'renderView1' + # ---------------------------------------------------------------- + + # show data from contour1 + contour1Display = Show(contour1, renderView1) + + # get color transfer function/color map for 'U' + uLUT = GetColorTransferFunction('U') + uLUT.RGBPoints = [0.0012199414294188375, 0.231373, 0.298039, 0.752941, 0.5006099707147095, 0.865003, 0.865003, 0.865003, 1.0, 0.705882, 0.0156863, 0.14902] + uLUT.ScalarRangeInitialized = 1.0 + + # trace defaults for the display properties. + contour1Display.Representation = 'Surface' + contour1Display.ColorArrayName = ['POINTS', 'U'] + contour1Display.LookupTable = uLUT + contour1Display.OSPRayScaleArray = 'Normals' + contour1Display.OSPRayScaleFunction = 'PiecewiseFunction' + contour1Display.SelectOrientationVectors = 'U' + contour1Display.ScaleFactor = 0.1 + contour1Display.SelectScaleArray = 'p' + contour1Display.GlyphType = 'Arrow' + contour1Display.GlyphTableIndexArray = 'p' + contour1Display.GaussianRadius = 0.005 + contour1Display.SetScaleArray = ['POINTS', 'Normals'] + contour1Display.ScaleTransferFunction = 'PiecewiseFunction' + contour1Display.OpacityArray = ['POINTS', 'Normals'] + contour1Display.OpacityTransferFunction = 'PiecewiseFunction' + contour1Display.DataAxesGrid = 'GridAxesRepresentation' + contour1Display.SelectionCellLabelFontFile = '' + contour1Display.SelectionPointLabelFontFile = '' + contour1Display.PolarAxes = 'PolarAxesRepresentation' + + # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' + contour1Display.ScaleTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' + contour1Display.OpacityTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'GridAxesRepresentation' selected for 'DataAxesGrid' + contour1Display.DataAxesGrid.XTitleFontFile = '' + contour1Display.DataAxesGrid.YTitleFontFile = '' + contour1Display.DataAxesGrid.ZTitleFontFile = '' + contour1Display.DataAxesGrid.XLabelFontFile = '' + contour1Display.DataAxesGrid.YLabelFontFile = '' + contour1Display.DataAxesGrid.ZLabelFontFile = '' + + # init the 'PolarAxesRepresentation' selected for 'PolarAxes' + contour1Display.PolarAxes.PolarAxisTitleFontFile = '' + contour1Display.PolarAxes.PolarAxisLabelFontFile = '' + contour1Display.PolarAxes.LastRadialAxisTextFontFile = '' + contour1Display.PolarAxes.SecondaryRadialAxesTextFontFile = '' + + # setup the color legend parameters for each legend in this view + + # get color legend/bar for uLUT in view renderView1 + uLUTColorBar = GetScalarBar(uLUT, renderView1) + uLUTColorBar.Title = 'U' + uLUTColorBar.ComponentTitle = 'Magnitude' + uLUTColorBar.TitleFontFile = '' + uLUTColorBar.LabelFontFile = '' + + # set color bar visibility + uLUTColorBar.Visibility = 1 + + # show color legend + contour1Display.SetScalarBarVisibility(renderView1, True) + + # ---------------------------------------------------------------- + # setup color maps and opacity mapes used in the visualization + # note: the Get..() functions create a new object, if needed + # ---------------------------------------------------------------- + + # get opacity transfer function/opacity map for 'U' + uPWF = GetOpacityTransferFunction('U') + uPWF.Points = [0.0012199414294188375, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] + uPWF.ScalarRangeInitialized = 1 + + # ---------------------------------------------------------------- + # finally, restore active source + SetActiveSource(contour1) + # ---------------------------------------------------------------- + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + # these are the frequencies at which the coprocessor updates. + freqs = {'region': [1, 1]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + + +#-------------------------------------------------------------- +# Global variable that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView and the update frequency +coprocessor.EnableLiveVisualization(True, 1) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + "Callback to populate the request for current timestep" + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + "Callback to do co-processing for current timestep" + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=rescale_lookuptable, + image_quality=0, padding_amount=imageFileNamePadding) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, "localhost", 22222) diff --git a/tutorials/incompressible/icoFoam/cavity/system/test/contourBad1.py b/tutorials/incompressible/icoFoam/cavity/system/test/contourBad1.py new file mode 100644 index 0000000000000000000000000000000000000000..bb6e02f7eb9990206af16ca8f7d404d3e61efc06 --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavity/system/test/contourBad1.py @@ -0,0 +1,220 @@ + +from paraview.simple import * +from paraview import coprocessing + + +#-------------------------------------------------------------- +# Code generated from cpstate.py to create the CoProcessor. +# paraview version 5.5.2 + +#-------------------------------------------------------------- +# Global screenshot output options +imageFileNamePadding=0 +rescale_lookuptable=False + + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + # state file generated using paraview version 5.5.2 + + # ---------------------------------------------------------------- + # setup views used in the visualization + # ---------------------------------------------------------------- + + # trace generated using paraview version 5.5.2 + + #### disable automatic camera reset on 'Show' + paraview.simple._DisableFirstRenderCameraReset() + + # Create a new 'Render View' + renderView1 = CreateView('RenderView') + renderView1.ViewSize = [1310, 756] + renderView1.AxesGrid = 'GridAxes3DActor' + renderView1.CenterOfRotation = [0.5, 0.5, 0.5] + renderView1.StereoType = 0 + renderView1.CameraPosition = [1.6164034525143194, 1.95607761769238, 3.315929590372999] + renderView1.CameraFocalPoint = [0.7588666642735185, 0.6245162535577884, 0.3684344821388413] + renderView1.CameraViewUp = [-0.0014112507857125675, 0.9114732717260123, -0.411356880701294] + renderView1.CameraParallelScale = 0.8660254037844386 + renderView1.CameraParallelProjection = 1 + renderView1.Background = [0.32, 0.34, 0.43] + + # init the 'GridAxes3DActor' selected for 'AxesGrid' + renderView1.AxesGrid.XTitleFontFile = '' + renderView1.AxesGrid.YTitleFontFile = '' + renderView1.AxesGrid.ZTitleFontFile = '' + renderView1.AxesGrid.XLabelFontFile = '' + renderView1.AxesGrid.YLabelFontFile = '' + renderView1.AxesGrid.ZLabelFontFile = '' + + # register the view with coprocessor + # and provide it with information such as the filename to use, + # how frequently to write the images, etc. + coprocessor.RegisterView(renderView1, + filename='image_%t.png', freq=1, fittoscreen=0, magnification=1, width=1310, height=756, cinema={}) + renderView1.ViewTime = datadescription.GetTime() + + # ---------------------------------------------------------------- + # restore active view + SetActiveView(renderView1) + # ---------------------------------------------------------------- + + # ---------------------------------------------------------------- + # setup the data processing pipelines + # ---------------------------------------------------------------- + + # create a new 'OpenFOAMReader' + # create a producer from a simulation input + region = coprocessor.CreateProducer(datadescription, 'region') + + # create a new 'Contour' + contour1 = Contour(Input=region) + contour1.ContourBy = ['POINTS', 'p'] + contour1.Isosurfaces = [0.05] + contour1.PointMergeMethod = 'Uniform Binning' + + # ---------------------------------------------------------------- + # setup the visualization in view 'renderView1' + # ---------------------------------------------------------------- + + # show data from contour1 + contour1Display = Show(contour1, renderView1) + + # get color transfer function/color map for 'p' + pLUT = GetColorTransferFunction('p') + pLUT.RGBPoints = [-0.2828664779663086, 0.231373, 0.298039, 0.752941, 0.023635268211364746, 0.865003, 0.865003, 0.865003, 0.3301370143890381, 0.705882, 0.0156863, 0.14902] + pLUT.ScalarRangeInitialized = 1.0 + + # trace defaults for the display properties. + contour1Display.Representation = 'Surface' + contour1Display.ColorArrayName = ['CELLS', 'p_NOFIELD'] + contour1Display.LookupTable = pLUT + contour1Display.OSPRayScaleArray = 'Normals' + contour1Display.OSPRayScaleFunction = 'PiecewiseFunction' + contour1Display.SelectOrientationVectors = 'U' + contour1Display.ScaleFactor = 0.1 + contour1Display.SelectScaleArray = 'p' + contour1Display.GlyphType = 'Arrow' + contour1Display.GlyphTableIndexArray = 'p' + contour1Display.GaussianRadius = 0.005 + contour1Display.SetScaleArray = ['POINTS', 'Normals'] + contour1Display.ScaleTransferFunction = 'PiecewiseFunction' + contour1Display.OpacityArray = ['POINTS', 'Normals'] + contour1Display.OpacityTransferFunction = 'PiecewiseFunction' + contour1Display.DataAxesGrid = 'GridAxesRepresentation' + contour1Display.SelectionCellLabelFontFile = '' + contour1Display.SelectionPointLabelFontFile = '' + contour1Display.PolarAxes = 'PolarAxesRepresentation' + + # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' + contour1Display.ScaleTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' + contour1Display.OpacityTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'GridAxesRepresentation' selected for 'DataAxesGrid' + contour1Display.DataAxesGrid.XTitleFontFile = '' + contour1Display.DataAxesGrid.YTitleFontFile = '' + contour1Display.DataAxesGrid.ZTitleFontFile = '' + contour1Display.DataAxesGrid.XLabelFontFile = '' + contour1Display.DataAxesGrid.YLabelFontFile = '' + contour1Display.DataAxesGrid.ZLabelFontFile = '' + + # init the 'PolarAxesRepresentation' selected for 'PolarAxes' + contour1Display.PolarAxes.PolarAxisTitleFontFile = '' + contour1Display.PolarAxes.PolarAxisLabelFontFile = '' + contour1Display.PolarAxes.LastRadialAxisTextFontFile = '' + contour1Display.PolarAxes.SecondaryRadialAxesTextFontFile = '' + + # setup the color legend parameters for each legend in this view + + # get color legend/bar for pLUT in view renderView1 + pLUTColorBar = GetScalarBar(pLUT, renderView1) + pLUTColorBar.Title = 'p' + pLUTColorBar.ComponentTitle = '' + pLUTColorBar.TitleFontFile = '' + pLUTColorBar.LabelFontFile = '' + + # set color bar visibility + pLUTColorBar.Visibility = 1 + + # show color legend + contour1Display.SetScalarBarVisibility(renderView1, True) + + # ---------------------------------------------------------------- + # setup color maps and opacity mapes used in the visualization + # note: the Get..() functions create a new object, if needed + # ---------------------------------------------------------------- + + # get opacity transfer function/opacity map for 'p' + pPWF = GetOpacityTransferFunction('p') + pPWF.Points = [-0.2828664779663086, 0.0, 0.5, 0.0, 0.3301370143890381, 1.0, 0.5, 0.0] + pPWF.ScalarRangeInitialized = 1 + + # ---------------------------------------------------------------- + # finally, restore active source + SetActiveSource(contour1) + # ---------------------------------------------------------------- + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + # these are the frequencies at which the coprocessor updates. + freqs = {'region': [1, 1]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + + +#-------------------------------------------------------------- +# Global variable that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView and the update frequency +coprocessor.EnableLiveVisualization(False, 1) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + "Callback to populate the request for current timestep" + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + "Callback to do co-processing for current timestep" + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=rescale_lookuptable, + image_quality=0, padding_amount=imageFileNamePadding) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, "localhost", 22222) diff --git a/tutorials/incompressible/icoFoam/cavity/system/test/contourBad2.py b/tutorials/incompressible/icoFoam/cavity/system/test/contourBad2.py new file mode 100644 index 0000000000000000000000000000000000000000..7d9eac3c0430a3f4a80948591b0afe05450a16ae --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavity/system/test/contourBad2.py @@ -0,0 +1,220 @@ + +from paraview.simple import * +from paraview import coprocessing + + +#-------------------------------------------------------------- +# Code generated from cpstate.py to create the CoProcessor. +# paraview version 5.5.2 + +#-------------------------------------------------------------- +# Global screenshot output options +imageFileNamePadding=0 +rescale_lookuptable=False + + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + # state file generated using paraview version 5.5.2 + + # ---------------------------------------------------------------- + # setup views used in the visualization + # ---------------------------------------------------------------- + + # trace generated using paraview version 5.5.2 + + #### disable automatic camera reset on 'Show' + paraview.simple._DisableFirstRenderCameraReset() + + # Create a new 'Render View' + renderView1 = CreateView('RenderView') + renderView1.ViewSize = [1310, 756] + renderView1.AxesGrid = 'GridAxes3DActor' + renderView1.CenterOfRotation = [0.5, 0.5, 0.5] + renderView1.StereoType = 0 + renderView1.CameraPosition = [1.6164034525143194, 1.95607761769238, 3.315929590372999] + renderView1.CameraFocalPoint = [0.7588666642735185, 0.6245162535577884, 0.3684344821388413] + renderView1.CameraViewUp = [-0.0014112507857125675, 0.9114732717260123, -0.411356880701294] + renderView1.CameraParallelScale = 0.8660254037844386 + renderView1.CameraParallelProjection = 1 + renderView1.Background = [0.32, 0.34, 0.43] + + # init the 'GridAxes3DActor' selected for 'AxesGrid' + renderView1.AxesGrid.XTitleFontFile = '' + renderView1.AxesGrid.YTitleFontFile = '' + renderView1.AxesGrid.ZTitleFontFile = '' + renderView1.AxesGrid.XLabelFontFile = '' + renderView1.AxesGrid.YLabelFontFile = '' + renderView1.AxesGrid.ZLabelFontFile = '' + + # register the view with coprocessor + # and provide it with information such as the filename to use, + # how frequently to write the images, etc. + coprocessor.RegisterView(renderView1, + filename='image_%t.png', freq=1, fittoscreen=0, magnification=1, width=1310, height=756, cinema={}) + renderView1.ViewTime = datadescription.GetTime() + + # ---------------------------------------------------------------- + # restore active view + SetActiveView(renderView1) + # ---------------------------------------------------------------- + + # ---------------------------------------------------------------- + # setup the data processing pipelines + # ---------------------------------------------------------------- + + # create a new 'OpenFOAMReader' + # create a producer from a simulation input + region = coprocessor.CreateProducer(datadescription, 'region') + + # create a new 'Contour' + contour1 = Contour(Input=region) + contour1.ContourBy = ['POINTS', 'p_NOFIELD'] + contour1.Isosurfaces = [0.05] + contour1.PointMergeMethod = 'Uniform Binning' + + # ---------------------------------------------------------------- + # setup the visualization in view 'renderView1' + # ---------------------------------------------------------------- + + # show data from contour1 + contour1Display = Show(contour1, renderView1) + + # get color transfer function/color map for 'p' + pLUT = GetColorTransferFunction('p') + pLUT.RGBPoints = [-0.2828664779663086, 0.231373, 0.298039, 0.752941, 0.023635268211364746, 0.865003, 0.865003, 0.865003, 0.3301370143890381, 0.705882, 0.0156863, 0.14902] + pLUT.ScalarRangeInitialized = 1.0 + + # trace defaults for the display properties. + contour1Display.Representation = 'Surface' + contour1Display.ColorArrayName = ['CELLS', 'p'] + contour1Display.LookupTable = pLUT + contour1Display.OSPRayScaleArray = 'Normals' + contour1Display.OSPRayScaleFunction = 'PiecewiseFunction' + contour1Display.SelectOrientationVectors = 'U' + contour1Display.ScaleFactor = 0.1 + contour1Display.SelectScaleArray = 'p' + contour1Display.GlyphType = 'Arrow' + contour1Display.GlyphTableIndexArray = 'p' + contour1Display.GaussianRadius = 0.005 + contour1Display.SetScaleArray = ['POINTS', 'Normals'] + contour1Display.ScaleTransferFunction = 'PiecewiseFunction' + contour1Display.OpacityArray = ['POINTS', 'Normals'] + contour1Display.OpacityTransferFunction = 'PiecewiseFunction' + contour1Display.DataAxesGrid = 'GridAxesRepresentation' + contour1Display.SelectionCellLabelFontFile = '' + contour1Display.SelectionPointLabelFontFile = '' + contour1Display.PolarAxes = 'PolarAxesRepresentation' + + # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' + contour1Display.ScaleTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' + contour1Display.OpacityTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'GridAxesRepresentation' selected for 'DataAxesGrid' + contour1Display.DataAxesGrid.XTitleFontFile = '' + contour1Display.DataAxesGrid.YTitleFontFile = '' + contour1Display.DataAxesGrid.ZTitleFontFile = '' + contour1Display.DataAxesGrid.XLabelFontFile = '' + contour1Display.DataAxesGrid.YLabelFontFile = '' + contour1Display.DataAxesGrid.ZLabelFontFile = '' + + # init the 'PolarAxesRepresentation' selected for 'PolarAxes' + contour1Display.PolarAxes.PolarAxisTitleFontFile = '' + contour1Display.PolarAxes.PolarAxisLabelFontFile = '' + contour1Display.PolarAxes.LastRadialAxisTextFontFile = '' + contour1Display.PolarAxes.SecondaryRadialAxesTextFontFile = '' + + # setup the color legend parameters for each legend in this view + + # get color legend/bar for pLUT in view renderView1 + pLUTColorBar = GetScalarBar(pLUT, renderView1) + pLUTColorBar.Title = 'p' + pLUTColorBar.ComponentTitle = '' + pLUTColorBar.TitleFontFile = '' + pLUTColorBar.LabelFontFile = '' + + # set color bar visibility + pLUTColorBar.Visibility = 1 + + # show color legend + contour1Display.SetScalarBarVisibility(renderView1, True) + + # ---------------------------------------------------------------- + # setup color maps and opacity mapes used in the visualization + # note: the Get..() functions create a new object, if needed + # ---------------------------------------------------------------- + + # get opacity transfer function/opacity map for 'p' + pPWF = GetOpacityTransferFunction('p') + pPWF.Points = [-0.2828664779663086, 0.0, 0.5, 0.0, 0.3301370143890381, 1.0, 0.5, 0.0] + pPWF.ScalarRangeInitialized = 1 + + # ---------------------------------------------------------------- + # finally, restore active source + SetActiveSource(contour1) + # ---------------------------------------------------------------- + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + # these are the frequencies at which the coprocessor updates. + freqs = {'region': [1, 1]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + + +#-------------------------------------------------------------- +# Global variable that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView and the update frequency +coprocessor.EnableLiveVisualization(False, 1) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + "Callback to populate the request for current timestep" + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + "Callback to do co-processing for current timestep" + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=rescale_lookuptable, + image_quality=0, padding_amount=imageFileNamePadding) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, "localhost", 22222) diff --git a/tutorials/incompressible/icoFoam/cavity/system/test/contourGood.py b/tutorials/incompressible/icoFoam/cavity/system/test/contourGood.py new file mode 100644 index 0000000000000000000000000000000000000000..7bde131e9382e609f8c087b1d7ed6d998fcea02e --- /dev/null +++ b/tutorials/incompressible/icoFoam/cavity/system/test/contourGood.py @@ -0,0 +1,220 @@ + +from paraview.simple import * +from paraview import coprocessing + + +#-------------------------------------------------------------- +# Code generated from cpstate.py to create the CoProcessor. +# paraview version 5.5.2 + +#-------------------------------------------------------------- +# Global screenshot output options +imageFileNamePadding=0 +rescale_lookuptable=False + + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + # state file generated using paraview version 5.5.2 + + # ---------------------------------------------------------------- + # setup views used in the visualization + # ---------------------------------------------------------------- + + # trace generated using paraview version 5.5.2 + + #### disable automatic camera reset on 'Show' + paraview.simple._DisableFirstRenderCameraReset() + + # Create a new 'Render View' + renderView1 = CreateView('RenderView') + renderView1.ViewSize = [1310, 756] + renderView1.AxesGrid = 'GridAxes3DActor' + renderView1.CenterOfRotation = [0.5, 0.5, 0.5] + renderView1.StereoType = 0 + renderView1.CameraPosition = [1.6164034525143194, 1.95607761769238, 3.315929590372999] + renderView1.CameraFocalPoint = [0.7588666642735185, 0.6245162535577884, 0.3684344821388413] + renderView1.CameraViewUp = [-0.0014112507857125675, 0.9114732717260123, -0.411356880701294] + renderView1.CameraParallelScale = 0.8660254037844386 + renderView1.CameraParallelProjection = 1 + renderView1.Background = [0.32, 0.34, 0.43] + + # init the 'GridAxes3DActor' selected for 'AxesGrid' + renderView1.AxesGrid.XTitleFontFile = '' + renderView1.AxesGrid.YTitleFontFile = '' + renderView1.AxesGrid.ZTitleFontFile = '' + renderView1.AxesGrid.XLabelFontFile = '' + renderView1.AxesGrid.YLabelFontFile = '' + renderView1.AxesGrid.ZLabelFontFile = '' + + # register the view with coprocessor + # and provide it with information such as the filename to use, + # how frequently to write the images, etc. + coprocessor.RegisterView(renderView1, + filename='image_%t.png', freq=1, fittoscreen=0, magnification=1, width=1310, height=756, cinema={}) + renderView1.ViewTime = datadescription.GetTime() + + # ---------------------------------------------------------------- + # restore active view + SetActiveView(renderView1) + # ---------------------------------------------------------------- + + # ---------------------------------------------------------------- + # setup the data processing pipelines + # ---------------------------------------------------------------- + + # create a new 'OpenFOAMReader' + # create a producer from a simulation input + region = coprocessor.CreateProducer(datadescription, 'region') + + # create a new 'Contour' + contour1 = Contour(Input=region) + contour1.ContourBy = ['POINTS', 'p'] + contour1.Isosurfaces = [0.05] + contour1.PointMergeMethod = 'Uniform Binning' + + # ---------------------------------------------------------------- + # setup the visualization in view 'renderView1' + # ---------------------------------------------------------------- + + # show data from contour1 + contour1Display = Show(contour1, renderView1) + + # get color transfer function/color map for 'p' + pLUT = GetColorTransferFunction('p') + pLUT.RGBPoints = [-0.2828664779663086, 0.231373, 0.298039, 0.752941, 0.023635268211364746, 0.865003, 0.865003, 0.865003, 0.3301370143890381, 0.705882, 0.0156863, 0.14902] + pLUT.ScalarRangeInitialized = 1.0 + + # trace defaults for the display properties. + contour1Display.Representation = 'Surface' + contour1Display.ColorArrayName = ['CELLS', 'p'] + contour1Display.LookupTable = pLUT + contour1Display.OSPRayScaleArray = 'Normals' + contour1Display.OSPRayScaleFunction = 'PiecewiseFunction' + contour1Display.SelectOrientationVectors = 'U' + contour1Display.ScaleFactor = 0.1 + contour1Display.SelectScaleArray = 'p' + contour1Display.GlyphType = 'Arrow' + contour1Display.GlyphTableIndexArray = 'p' + contour1Display.GaussianRadius = 0.005 + contour1Display.SetScaleArray = ['POINTS', 'Normals'] + contour1Display.ScaleTransferFunction = 'PiecewiseFunction' + contour1Display.OpacityArray = ['POINTS', 'Normals'] + contour1Display.OpacityTransferFunction = 'PiecewiseFunction' + contour1Display.DataAxesGrid = 'GridAxesRepresentation' + contour1Display.SelectionCellLabelFontFile = '' + contour1Display.SelectionPointLabelFontFile = '' + contour1Display.PolarAxes = 'PolarAxesRepresentation' + + # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' + contour1Display.ScaleTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' + contour1Display.OpacityTransferFunction.Points = [-0.9980009198188782, 0.0, 0.5, 0.0, -0.18620361387729645, 1.0, 0.5, 0.0] + + # init the 'GridAxesRepresentation' selected for 'DataAxesGrid' + contour1Display.DataAxesGrid.XTitleFontFile = '' + contour1Display.DataAxesGrid.YTitleFontFile = '' + contour1Display.DataAxesGrid.ZTitleFontFile = '' + contour1Display.DataAxesGrid.XLabelFontFile = '' + contour1Display.DataAxesGrid.YLabelFontFile = '' + contour1Display.DataAxesGrid.ZLabelFontFile = '' + + # init the 'PolarAxesRepresentation' selected for 'PolarAxes' + contour1Display.PolarAxes.PolarAxisTitleFontFile = '' + contour1Display.PolarAxes.PolarAxisLabelFontFile = '' + contour1Display.PolarAxes.LastRadialAxisTextFontFile = '' + contour1Display.PolarAxes.SecondaryRadialAxesTextFontFile = '' + + # setup the color legend parameters for each legend in this view + + # get color legend/bar for pLUT in view renderView1 + pLUTColorBar = GetScalarBar(pLUT, renderView1) + pLUTColorBar.Title = 'p' + pLUTColorBar.ComponentTitle = '' + pLUTColorBar.TitleFontFile = '' + pLUTColorBar.LabelFontFile = '' + + # set color bar visibility + pLUTColorBar.Visibility = 1 + + # show color legend + contour1Display.SetScalarBarVisibility(renderView1, True) + + # ---------------------------------------------------------------- + # setup color maps and opacity mapes used in the visualization + # note: the Get..() functions create a new object, if needed + # ---------------------------------------------------------------- + + # get opacity transfer function/opacity map for 'p' + pPWF = GetOpacityTransferFunction('p') + pPWF.Points = [-0.2828664779663086, 0.0, 0.5, 0.0, 0.3301370143890381, 1.0, 0.5, 0.0] + pPWF.ScalarRangeInitialized = 1 + + # ---------------------------------------------------------------- + # finally, restore active source + SetActiveSource(contour1) + # ---------------------------------------------------------------- + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + # these are the frequencies at which the coprocessor updates. + freqs = {'region': [1, 1]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + + +#-------------------------------------------------------------- +# Global variable that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView and the update frequency +coprocessor.EnableLiveVisualization(False, 1) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + "Callback to populate the request for current timestep" + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + "Callback to do co-processing for current timestep" + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=rescale_lookuptable, + image_quality=0, padding_amount=imageFileNamePadding) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, "localhost", 22222)