diff --git a/applications/leofea/resources/mainDialog.ui b/applications/leofea/resources/mainDialog.ui index 3e306843..67496f74 100644 --- a/applications/leofea/resources/mainDialog.ui +++ b/applications/leofea/resources/mainDialog.ui @@ -164,21 +164,63 @@ - - - + 40 670 - 271 - 71 + 90 + 25 + + + + Postprocess + + + + + + + 70 + 710 + 241 + 31 + + + + View PNG + + + + + + + 70 + 750 + 241 + 31 + + + + Open Paraview + + + + + + + 70 + 790 + 241 + 31 Check Limits + + @@ -192,6 +234,7 @@ Open LeoCAD + @@ -205,6 +248,7 @@ Jobname + @@ -377,22 +421,8 @@ true - - - - 80 - 510 - 211 - 23 - - - - Open Paraview - - - true - - + + diff --git a/applications/leofea/resources/templatePostProcessParaviewLinux.py b/applications/leofea/resources/templatePostProcessParaviewLinux.py new file mode 100644 index 00000000..6c0702b2 --- /dev/null +++ b/applications/leofea/resources/templatePostProcessParaviewLinux.py @@ -0,0 +1,265 @@ + +#jobname = '....' +#timeVisualization = 1.0 # Time to be displayed in paraview + +import os +username = os.getlogin() + +# trace generated using paraview version 5.11.1-1862-g99cf1048e5 +#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() + +# load plugin +LoadPlugin(f'/home/{username}/apps/paraview/bin/../lib/paraview-5.11/plugins/MEDReader/MEDReader.so', remote=False, ns=globals()) + +# create a new 'MED Reader' +result_rmed = MEDReader(registrationName=f'{jobname}.rmed', FileNames=[f'{filename}.rmed']) + +# get animation scene +animationScene1 = GetAnimationScene() + +# update animation scene based on data timesteps +animationScene1.UpdateAnimationUsingDataTimeSteps() + +# Properties modified on result_rmed +result_rmed.FieldsStatus = ['TS0/00000001/ComSup0/resnonl_DEPL@@][@@P1', 'TS0/00000001/ComSup0/resnonl_FORC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_REAC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_SIEF_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_NOEU@@][@@P1', 'TS0/00000001/ComSup0/resnonl_VARI_ELGA@@][@@GAUSS'] + +# get active view +renderView1 = GetActiveViewOrCreate('RenderView') + +# show data in view +result_rmedDisplay = Show(result_rmed, renderView1, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +result_rmedDisplay.Representation = 'Surface' + +# reset view to fit data +renderView1.ResetCamera(False, 0.9) + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# update the view to ensure updated data information +renderView1.Update() + +renderView1.ResetActiveCameraToPositiveY() + +# reset view to fit data +renderView1.ResetCamera(False, 0.9) + +# set scalar coloring +ColorBy(result_rmedDisplay, ('POINTS', 'resnonl_DEPL', 'Magnitude')) + +# rescale color and/or opacity maps used to include current data range +result_rmedDisplay.RescaleTransferFunctionToDataRange(True, False) + +# show color bar/color legend +result_rmedDisplay.SetScalarBarVisibility(renderView1, True) + +# get color transfer function/color map for 'resnonl_DEPL' +resnonl_DEPLLUT = GetColorTransferFunction('resnonl_DEPL') + +# Apply a preset using its name. Note this may not work as expected when presets have duplicate names. +resnonl_DEPLLUT.ApplyPreset('Rainbow Uniform', True) + +# get opacity transfer function/opacity map for 'resnonl_DEPL' +resnonl_DEPLPWF = GetOpacityTransferFunction('resnonl_DEPL') + +# get 2D transfer function for 'resnonl_DEPL' +resnonl_DEPLTF2D = GetTransferFunction2D('resnonl_DEPL') + +# change representation type +result_rmedDisplay.SetRepresentationType('Surface With Edges') + +# Properties modified on renderView1 +renderView1.CameraParallelProjection = 1 + +# Properties modified on animationScene1 +animationScene1.AnimationTime = timeVisualization + +# get the time-keeper +timeKeeper1 = GetTimeKeeper() + +# rescale color and/or opacity maps used to exactly fit the current data range +result_rmedDisplay.RescaleTransferFunctionToDataRange(False, True) + +# get layout +layout1 = GetLayout() + +# layout/tab size in pixels +layout1.SetSize(1612, 713) + +# current camera placement for renderView1 +renderView1.CameraPosition = [112.0, -422.8299576397467, 11.2] +renderView1.CameraFocalPoint = [112.0, 16.0, 11.2] +renderView1.CameraViewUp = [0.0, 0.0, 1.0] +renderView1.CameraParallelScale = 113.57755059869886 +renderView1.CameraParallelProjection = 1 + +########################################################################### +### Set Color + +# find settings proxy +generalSettings = GetSettingsProxy('GeneralSettings') + +# find settings proxy +iOSettings = GetSettingsProxy('IOSettings') + +# find settings proxy +renderViewInteractionSettings = GetSettingsProxy('RenderViewInteractionSettings') + +# find settings proxy +renderViewSettings = GetSettingsProxy('RenderViewSettings') + +# find settings proxy +representedArrayListSettings = GetSettingsProxy('RepresentedArrayListSettings') + +# find settings proxy +colorPalette = GetSettingsProxy('ColorPalette') + +# Properties modified on colorPalette +colorPalette.Background = [1.0, 1.0, 1.0] + +# Properties modified on colorPalette +colorPalette.Foreground = [0.0, 0.0, 0.0] + +# Properties modified on colorPalette +colorPalette.Text = [0.0, 0.0, 0.0] +########################################################################### + +# save screenshot +SaveScreenshot(f'/home/{username}/work/13_leoFEM/simulation_files/s{jobname}_DEPL_F000.png', renderView1, 16, ImageResolution=[1612, 713]) + +# layout/tab size in pixels +layout1.SetSize(1612, 713) + +## current camera placement for renderView1 +#renderView1.CameraPosition = [112.0, -422.8299576397467, 11.2] +#renderView1.CameraFocalPoint = [112.0, 16.0, 11.2] +#renderView1.CameraViewUp = [0.0, 0.0, 1.0] +#renderView1.CameraParallelScale = 113.57755059869886# +renderView1.CameraParallelProjection = 1 + +# save screenshot +#SaveScreenshot('/home/{username}/work/13_leoFEM/simulation_files/s4_barCantilever_DEPL1.png', renderView1, 16, ImageResolution=[1612, 713],# +# TransparentBackground=1) + +# create a new 'Warp By Vector' +warpByVector1 = WarpByVector(registrationName='WarpByVector1', Input=result_rmed) + +# show data in view +warpByVector1Display = Show(warpByVector1, renderView1, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +warpByVector1Display.Representation = 'Surface' + +# hide data in view +Hide(result_rmed, renderView1) + +# show color bar/color legend +warpByVector1Display.SetScalarBarVisibility(renderView1, True) + +# update the view to ensure updated data information +renderView1.Update() + +# Properties modified on warpByVector1Display +warpByVector1Display.Opacity = 10.0 + +# change representation type +warpByVector1Display.SetRepresentationType('Surface With Edges') + +# Properties modified on warpByVector1Display +warpByVector1Display.Opacity = 1.0 + +# Properties modified on warpByVector1 +warpByVector1.ScaleFactor = 10.0 + +# update the view to ensure updated data information +renderView1.Update() + +# layout/tab size in pixels +layout1.SetSize(1500, 713) + +# current camera placement for renderView1 +renderView1.CameraPosition = [112.0, -422.8299576397467, 11.2] +renderView1.CameraFocalPoint = [112.0, 16.0, 11.2] +renderView1.CameraViewUp = [0.0, 0.0, 1.0] +renderView1.CameraParallelScale = 113.57755059869886 +renderView1.CameraParallelProjection = 1 + +# save screenshot +SaveScreenshot(f'/home/{username}/work/13_leoFEM/simulation_files/{jobname}_DEPL_F010.png', renderView1, 16, ImageResolution=[1500, 713], + TransparentBackground=0) + +# Properties modified on warpByVector1 +warpByVector1.ScaleFactor = 1.0 + +# update the view to ensure updated data information +renderView1.Update() + +# layout/tab size in pixels +layout1.SetSize(1500, 713) + +# current camera placement for renderView1 +renderView1.CameraPosition = [112.0, -422.8299576397467, 11.2] +renderView1.CameraFocalPoint = [112.0, 16.0, 11.2] +renderView1.CameraViewUp = [0.0, 0.0, 1.0] +renderView1.CameraParallelScale = 113.57755059869886 +renderView1.CameraParallelProjection = 1 + +# save screenshot +SaveScreenshot(f'/home/{username}/work/13_leoFEM/simulation_files/{jobname}_DEPL_F100.png', renderView1, 16, ImageResolution=[1500, 713], + TransparentBackground=0) + +#================================================================ +# addendum: following script captures some of the application +# state to faithfully reproduce the visualization during playback +#================================================================ + +#-------------------------------- +# saving layout sizes for layouts + +# layout/tab size in pixels +layout1.SetSize(1500, 713) + +#----------------------------------- +# saving camera placements for views + +# current camera placement for renderView1 +renderView1.CameraPosition = [112.0, -422.8299576397467, 11.2] +renderView1.CameraFocalPoint = [112.0, 16.0, 11.2] +renderView1.CameraViewUp = [0.0, 0.0, 1.0] +renderView1.CameraParallelScale = 113.57755059869886 +renderView1.CameraParallelProjection = 1 + + +##-------------------------------------------- +## You may need to add some code at the end of this python script depending on your usage, eg: +# +## Render all views to see them appears +# RenderAllViews() +# +## Interact with the view, usefull when running from pvpython +# Interact() +# +## Save a screenshot of the active view +# SaveScreenshot("path/to/screenshot.png") +# +## Save a screenshot of a layout (multiple splitted view) +# SaveScreenshot("path/to/screenshot.png", GetLayout()) +# +## Save all "Extractors" from the pipeline browser +# SaveExtracts() +# +## Save a animation of the current active view +# SaveAnimation() +# +## Please refer to the documentation of paraview.simple +## https://kitware.github.io/paraview-docs/latest/python/paraview.simple.html +##-------------------------------------------- diff --git a/applications/leofea/resources/templatePostProcessParaviewWin.py b/applications/leofea/resources/templatePostProcessParaviewWin.py new file mode 100644 index 00000000..e44c95b4 --- /dev/null +++ b/applications/leofea/resources/templatePostProcessParaviewWin.py @@ -0,0 +1,204 @@ + +#jobname = '....' +#timeVisualization = 1.0 # Time to be displayed in paraview + +# trace generated using paraview version 5.9.0 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# create a new 'MED Reader' +s8_tableLeoCADprmed = MEDReader(registrationName=f'{jobname}.rmed', FileNames=f'{filename}.rmed') +#s8_tableLeoCADprmed.AllArrays = ['TS0/00000001/ComSup0/resnonl_SIEF_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_VARI_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_DEPL@@][@@P1', 'TS0/00000001/ComSup0/resnonl_FORC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_REAC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_SIEQ_NOEU@@][@@P1'] +#s8_tableLeoCADprmed.AllTimeSteps = ['0000', '0001'] + +# get animation scene +animationScene1 = GetAnimationScene() + +# update animation scene based on data timesteps +animationScene1.UpdateAnimationUsingDataTimeSteps() + +# Properties modified on s8_tableLeoCADprmed +#s8_tableLeoCADprmed.AllArrays = ['TS0/00000001/ComSup0/resnonl_DEPL@@][@@P1', 'TS0/00000001/ComSup0/resnonl_FORC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_REAC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_SIEF_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_NOEU@@][@@P1', 'TS0/00000001/ComSup0/resnonl_VARI_ELGA@@][@@GAUSS'] + +# get active view +renderView1 = GetActiveViewOrCreate('RenderView') + +# show data in view +s8_tableLeoCADprmedDisplay = Show(s8_tableLeoCADprmed, renderView1, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +s8_tableLeoCADprmedDisplay.Representation = 'Surface' +s8_tableLeoCADprmedDisplay.ColorArrayName = [None, ''] +s8_tableLeoCADprmedDisplay.SelectTCoordArray = 'None' +s8_tableLeoCADprmedDisplay.SelectNormalArray = 'None' +s8_tableLeoCADprmedDisplay.SelectTangentArray = 'None' +s8_tableLeoCADprmedDisplay.OSPRayScaleArray = 'FamilyIdNode' +s8_tableLeoCADprmedDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +s8_tableLeoCADprmedDisplay.SelectOrientationVectors = 'None' +s8_tableLeoCADprmedDisplay.ScaleFactor = 19.18 +s8_tableLeoCADprmedDisplay.SelectScaleArray = 'FamilyIdNode' +s8_tableLeoCADprmedDisplay.GlyphType = 'Arrow' +s8_tableLeoCADprmedDisplay.GlyphTableIndexArray = 'FamilyIdNode' +s8_tableLeoCADprmedDisplay.GaussianRadius = 0.959 +s8_tableLeoCADprmedDisplay.SetScaleArray = ['POINTS', 'FamilyIdNode'] +s8_tableLeoCADprmedDisplay.ScaleTransferFunction = 'PiecewiseFunction' +s8_tableLeoCADprmedDisplay.OpacityArray = ['POINTS', 'FamilyIdNode'] +s8_tableLeoCADprmedDisplay.OpacityTransferFunction = 'PiecewiseFunction' +s8_tableLeoCADprmedDisplay.DataAxesGrid = 'GridAxesRepresentation' +s8_tableLeoCADprmedDisplay.PolarAxes = 'PolarAxesRepresentation' +s8_tableLeoCADprmedDisplay.ScalarOpacityUnitDistance = 13.531230554418737 +s8_tableLeoCADprmedDisplay.OpacityArrayName = ['POINTS', 'FamilyIdNode'] +#s8_tableLeoCADprmedDisplay.ExtractedBlockIndex = 1 + + + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +s8_tableLeoCADprmedDisplay.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +s8_tableLeoCADprmedDisplay.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# reset view to fit data +renderView1.ResetCamera() + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# update the view to ensure updated data information +renderView1.Update() + +# set scalar coloring +ColorBy(s8_tableLeoCADprmedDisplay, ('POINTS', 'resnonl_DEPL', 'Magnitude')) + +# rescale color and/or opacity maps used to include current data range +s8_tableLeoCADprmedDisplay.RescaleTransferFunctionToDataRange(True, False) + +# show color bar/color legend +s8_tableLeoCADprmedDisplay.SetScalarBarVisibility(renderView1, True) + +# get color transfer function/color map for 'resnonl_DEPL' +resnonl_DEPLLUT = GetColorTransferFunction('resnonl_DEPL') + +# Apply a preset using its name. Note this may not work as expected when presets have duplicate names. +resnonl_DEPLLUT.ApplyPreset('Rainbow Uniform', True) + +# get opacity transfer function/opacity map for 'resnonl_DEPL' +resnonl_DEPLPWF = GetOpacityTransferFunction('resnonl_DEPL') + +# Properties modified on animationScene1 +animationScene1.AnimationTime = timeVisualization + +# get the time-keeper +timeKeeper1 = GetTimeKeeper() + +# rescale color and/or opacity maps used to exactly fit the current data range +s8_tableLeoCADprmedDisplay.RescaleTransferFunctionToDataRange(False, True) + +# change representation type +s8_tableLeoCADprmedDisplay.SetRepresentationType('Surface With Edges') + +# create a new 'Warp By Vector' +warpByVector1 = WarpByVector(registrationName='WarpByVector1', Input=s8_tableLeoCADprmed) +warpByVector1.Vectors = ['POINTS', 'resnonl_DEPL'] + + +# Properties modified on warpByVector1 +warpByVector1.ScaleFactor = 10.0 + + +# show data in view +warpByVector1Display = Show(warpByVector1, renderView1, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +warpByVector1Display.Representation = 'Surface' +warpByVector1Display.ColorArrayName = ['POINTS', 'resnonl_DEPL'] +warpByVector1Display.LookupTable = resnonl_DEPLLUT +warpByVector1Display.SelectTCoordArray = 'None' +warpByVector1Display.SelectNormalArray = 'None' +warpByVector1Display.SelectTangentArray = 'None' +warpByVector1Display.OSPRayScaleArray = 'FamilyIdNode' +warpByVector1Display.OSPRayScaleFunction = 'PiecewiseFunction' +warpByVector1Display.SelectOrientationVectors = 'None' +warpByVector1Display.ScaleFactor = 19.250944942564622 +warpByVector1Display.SelectScaleArray = 'FamilyIdNode' +warpByVector1Display.GlyphType = 'Arrow' +warpByVector1Display.GlyphTableIndexArray = 'FamilyIdNode' +warpByVector1Display.GaussianRadius = 0.962547247128231 +warpByVector1Display.SetScaleArray = ['POINTS', 'FamilyIdNode'] +warpByVector1Display.ScaleTransferFunction = 'PiecewiseFunction' +warpByVector1Display.OpacityArray = ['POINTS', 'FamilyIdNode'] +warpByVector1Display.OpacityTransferFunction = 'PiecewiseFunction' +warpByVector1Display.DataAxesGrid = 'GridAxesRepresentation' +warpByVector1Display.PolarAxes = 'PolarAxesRepresentation' +warpByVector1Display.ScalarOpacityFunction = resnonl_DEPLPWF +warpByVector1Display.ScalarOpacityUnitDistance = 13.576284100807992 +warpByVector1Display.OpacityArrayName = ['POINTS', 'FamilyIdNode'] +#warpByVector1Display.ExtractedBlockIndex = 1 + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +warpByVector1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +warpByVector1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# hide data in view +Hide(s8_tableLeoCADprmed, renderView1) + +# show color bar/color legend +warpByVector1Display.SetScalarBarVisibility(renderView1, True) + +# update the view to ensure updated data information +renderView1.Update() + +# change representation type +warpByVector1Display.SetRepresentationType('Surface With Edges') + +# get layout +layout1 = GetLayout() + +# layout/tab size in pixels +layout1.SetSize(887, 579) + +# current camera placement for renderView1 +renderView1.CameraPosition = [459.0665256627675, -36.87014103922412, 233.35626992493675] +renderView1.CameraFocalPoint = [231.99999999999983, 263.99999999999994, 28.799999999999997] +renderView1.CameraViewUp = [-0.3488896990961528, 0.33242318455634107, 0.8762253159056846] +renderView1.CameraParallelScale = 110.9984684579026 + +# save screenshot +SaveScreenshot('C:/work/salomeMeca/13_LeoFEM/table.png', renderView1, ImageResolution=[887, 579]) + +#================================================================ +# addendum: following script captures some of the application +# state to faithfully reproduce the visualization during playback +#================================================================ + +#-------------------------------- +# saving layout sizes for layouts + +# layout/tab size in pixels +layout1.SetSize(887, 579) + +#----------------------------------- +# saving camera placements for views + +# current camera placement for renderView1 +#renderView1.CameraPosition = [459.0665256627675, -36.87014103922412, 233.35626992493675] +#renderView1.CameraFocalPoint = [231.99999999999983, 263.99999999999994, 28.799999999999997] +#renderView1.CameraViewUp = [-0.3488896990961528, 0.33242318455634107, 0.8762253159056846] +#renderView1.CameraParallelScale = 110.9984684579026 + +# current camera placement for renderView1 +renderView1.CameraPosition = [504.18069104868545, -421.0512495561344, 366.8949071453546] +renderView1.CameraFocalPoint = [120.0000002637771, 88.0, 20.799995732208668] +renderView1.CameraViewUp = [-0.3488896990961528, 0.33242318455634107, 0.8762253159056846] +renderView1.CameraParallelScale = 187.80165047998622 +renderView1.CameraParallelProjection = 1 + +#-------------------------------------------- +# uncomment the following to render all views +# RenderAllViews() +# alternatively, if you want to write images, you can use SaveScreenshot(...). diff --git a/applications/leofea/resources/templatePostProcessParaviewWin.py.bak b/applications/leofea/resources/templatePostProcessParaviewWin.py.bak new file mode 100644 index 00000000..f0fbb93e --- /dev/null +++ b/applications/leofea/resources/templatePostProcessParaviewWin.py.bak @@ -0,0 +1,204 @@ + +#jobname = '....' +#timeVisualization = 1.0 # Time to be displayed in paraview + +# trace generated using paraview version 5.9.0 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# create a new 'MED Reader' +s8_tableLeoCADprmed = MEDReader(registrationName=f'{jobname}.rmed', FileNames=f'{filename}.rmed') +#s8_tableLeoCADprmed.AllArrays = ['TS0/00000001/ComSup0/resnonl_SIEF_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_VARI_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_DEPL@@][@@P1', 'TS0/00000001/ComSup0/resnonl_FORC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_REAC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_SIEQ_NOEU@@][@@P1'] +#s8_tableLeoCADprmed.AllTimeSteps = ['0000', '0001'] + +# get animation scene +animationScene1 = GetAnimationScene() + +# update animation scene based on data timesteps +animationScene1.UpdateAnimationUsingDataTimeSteps() + +# Properties modified on s8_tableLeoCADprmed +#s8_tableLeoCADprmed.AllArrays = ['TS0/00000001/ComSup0/resnonl_DEPL@@][@@P1', 'TS0/00000001/ComSup0/resnonl_FORC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_REAC_NODA@@][@@P1', 'TS0/00000001/ComSup0/resnonl_SIEF_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_ELGA@@][@@GAUSS', 'TS0/00000001/ComSup0/resnonl_SIEQ_NOEU@@][@@P1', 'TS0/00000001/ComSup0/resnonl_VARI_ELGA@@][@@GAUSS'] + +# get active view +renderView1 = GetActiveViewOrCreate('RenderView') + +# show data in view +s8_tableLeoCADprmedDisplay = Show(s8_tableLeoCADprmed, renderView1, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +s8_tableLeoCADprmedDisplay.Representation = 'Surface' +s8_tableLeoCADprmedDisplay.ColorArrayName = [None, ''] +s8_tableLeoCADprmedDisplay.SelectTCoordArray = 'None' +s8_tableLeoCADprmedDisplay.SelectNormalArray = 'None' +s8_tableLeoCADprmedDisplay.SelectTangentArray = 'None' +s8_tableLeoCADprmedDisplay.OSPRayScaleArray = 'FamilyIdNode' +s8_tableLeoCADprmedDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +s8_tableLeoCADprmedDisplay.SelectOrientationVectors = 'None' +s8_tableLeoCADprmedDisplay.ScaleFactor = 19.18 +s8_tableLeoCADprmedDisplay.SelectScaleArray = 'FamilyIdNode' +s8_tableLeoCADprmedDisplay.GlyphType = 'Arrow' +s8_tableLeoCADprmedDisplay.GlyphTableIndexArray = 'FamilyIdNode' +s8_tableLeoCADprmedDisplay.GaussianRadius = 0.959 +s8_tableLeoCADprmedDisplay.SetScaleArray = ['POINTS', 'FamilyIdNode'] +s8_tableLeoCADprmedDisplay.ScaleTransferFunction = 'PiecewiseFunction' +s8_tableLeoCADprmedDisplay.OpacityArray = ['POINTS', 'FamilyIdNode'] +s8_tableLeoCADprmedDisplay.OpacityTransferFunction = 'PiecewiseFunction' +s8_tableLeoCADprmedDisplay.DataAxesGrid = 'GridAxesRepresentation' +s8_tableLeoCADprmedDisplay.PolarAxes = 'PolarAxesRepresentation' +s8_tableLeoCADprmedDisplay.ScalarOpacityUnitDistance = 13.531230554418737 +s8_tableLeoCADprmedDisplay.OpacityArrayName = ['POINTS', 'FamilyIdNode'] +#s8_tableLeoCADprmedDisplay.ExtractedBlockIndex = 1 + +exit() + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +s8_tableLeoCADprmedDisplay.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +s8_tableLeoCADprmedDisplay.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# reset view to fit data +renderView1.ResetCamera() + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# update the view to ensure updated data information +renderView1.Update() + +# set scalar coloring +ColorBy(s8_tableLeoCADprmedDisplay, ('POINTS', 'resnonl_DEPL', 'Magnitude')) + +# rescale color and/or opacity maps used to include current data range +s8_tableLeoCADprmedDisplay.RescaleTransferFunctionToDataRange(True, False) + +# show color bar/color legend +s8_tableLeoCADprmedDisplay.SetScalarBarVisibility(renderView1, True) + +# get color transfer function/color map for 'resnonl_DEPL' +resnonl_DEPLLUT = GetColorTransferFunction('resnonl_DEPL') + +# Apply a preset using its name. Note this may not work as expected when presets have duplicate names. +resnonl_DEPLLUT.ApplyPreset('Rainbow Uniform', True) + +# get opacity transfer function/opacity map for 'resnonl_DEPL' +resnonl_DEPLPWF = GetOpacityTransferFunction('resnonl_DEPL') + +# Properties modified on animationScene1 +animationScene1.AnimationTime = timeVisualization + +# get the time-keeper +timeKeeper1 = GetTimeKeeper() + +# rescale color and/or opacity maps used to exactly fit the current data range +s8_tableLeoCADprmedDisplay.RescaleTransferFunctionToDataRange(False, True) + +# change representation type +s8_tableLeoCADprmedDisplay.SetRepresentationType('Surface With Edges') + +# create a new 'Warp By Vector' +warpByVector1 = WarpByVector(registrationName='WarpByVector1', Input=s8_tableLeoCADprmed) +warpByVector1.Vectors = ['POINTS', 'resnonl_DEPL'] + + +# Properties modified on warpByVector1 +warpByVector1.ScaleFactor = 10.0 + + +# show data in view +warpByVector1Display = Show(warpByVector1, renderView1, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +warpByVector1Display.Representation = 'Surface' +warpByVector1Display.ColorArrayName = ['POINTS', 'resnonl_DEPL'] +warpByVector1Display.LookupTable = resnonl_DEPLLUT +warpByVector1Display.SelectTCoordArray = 'None' +warpByVector1Display.SelectNormalArray = 'None' +warpByVector1Display.SelectTangentArray = 'None' +warpByVector1Display.OSPRayScaleArray = 'FamilyIdNode' +warpByVector1Display.OSPRayScaleFunction = 'PiecewiseFunction' +warpByVector1Display.SelectOrientationVectors = 'None' +warpByVector1Display.ScaleFactor = 19.250944942564622 +warpByVector1Display.SelectScaleArray = 'FamilyIdNode' +warpByVector1Display.GlyphType = 'Arrow' +warpByVector1Display.GlyphTableIndexArray = 'FamilyIdNode' +warpByVector1Display.GaussianRadius = 0.962547247128231 +warpByVector1Display.SetScaleArray = ['POINTS', 'FamilyIdNode'] +warpByVector1Display.ScaleTransferFunction = 'PiecewiseFunction' +warpByVector1Display.OpacityArray = ['POINTS', 'FamilyIdNode'] +warpByVector1Display.OpacityTransferFunction = 'PiecewiseFunction' +warpByVector1Display.DataAxesGrid = 'GridAxesRepresentation' +warpByVector1Display.PolarAxes = 'PolarAxesRepresentation' +warpByVector1Display.ScalarOpacityFunction = resnonl_DEPLPWF +warpByVector1Display.ScalarOpacityUnitDistance = 13.576284100807992 +warpByVector1Display.OpacityArrayName = ['POINTS', 'FamilyIdNode'] +warpByVector1Display.ExtractedBlockIndex = 1 + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +warpByVector1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +warpByVector1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 778.0, 1.0, 0.5, 0.0] + +# hide data in view +Hide(s8_tableLeoCADprmed, renderView1) + +# show color bar/color legend +warpByVector1Display.SetScalarBarVisibility(renderView1, True) + +# update the view to ensure updated data information +renderView1.Update() + +# change representation type +warpByVector1Display.SetRepresentationType('Surface With Edges') + +# get layout +layout1 = GetLayout() + +# layout/tab size in pixels +layout1.SetSize(887, 579) + +# current camera placement for renderView1 +renderView1.CameraPosition = [459.0665256627675, -36.87014103922412, 233.35626992493675] +renderView1.CameraFocalPoint = [231.99999999999983, 263.99999999999994, 28.799999999999997] +renderView1.CameraViewUp = [-0.3488896990961528, 0.33242318455634107, 0.8762253159056846] +renderView1.CameraParallelScale = 110.9984684579026 + +# save screenshot +SaveScreenshot('C:/work/salomeMeca/13_LeoFEM/table.png', renderView1, ImageResolution=[887, 579]) + +#================================================================ +# addendum: following script captures some of the application +# state to faithfully reproduce the visualization during playback +#================================================================ + +#-------------------------------- +# saving layout sizes for layouts + +# layout/tab size in pixels +layout1.SetSize(887, 579) + +#----------------------------------- +# saving camera placements for views + +# current camera placement for renderView1 +#renderView1.CameraPosition = [459.0665256627675, -36.87014103922412, 233.35626992493675] +#renderView1.CameraFocalPoint = [231.99999999999983, 263.99999999999994, 28.799999999999997] +#renderView1.CameraViewUp = [-0.3488896990961528, 0.33242318455634107, 0.8762253159056846] +#renderView1.CameraParallelScale = 110.9984684579026 + +# current camera placement for renderView1 +renderView1.CameraPosition = [504.18069104868545, -421.0512495561344, 366.8949071453546] +renderView1.CameraFocalPoint = [120.0000002637771, 88.0, 20.799995732208668] +renderView1.CameraViewUp = [-0.3488896990961528, 0.33242318455634107, 0.8762253159056846] +renderView1.CameraParallelScale = 187.80165047998622 +renderView1.CameraParallelProjection = 1 + +#-------------------------------------------- +# uncomment the following to render all views +# RenderAllViews() +# alternatively, if you want to write images, you can use SaveScreenshot(...). diff --git a/applications/leofea/sources/LeoFEAgui.py b/applications/leofea/sources/LeoFEAgui.py index 4be8c492..9f344289 100644 --- a/applications/leofea/sources/LeoFEAgui.py +++ b/applications/leofea/sources/LeoFEAgui.py @@ -12,8 +12,9 @@ from requests_toolbelt import MultipartEncoder, MultipartDecoder from PyQt5 import QtWidgets, uic +from PyQt5 import QtGui from PyQt5.QtCore import QAbstractTableModel, Qt, QModelIndex -from PyQt5.QtGui import QIcon +from PyQt5.QtGui import * #from PyQt5.QtWidgets import QMessageBox, QTableWidget from PyQt5.QtWidgets import * @@ -67,6 +68,8 @@ def initUI(self): self.ui.button_SelectWorkdir.clicked.connect(self.onButton_SelectWorkdir) self.ui.button_LoadLDR.clicked.connect(self.onButton_LoadLDR) self.ui.button_startFEA.clicked.connect(self.onButton_startFEA) + self.ui.button_viewPNG.clicked.connect(self.onButton_viewPNG) + self.ui.button_openParaview.clicked.connect(self.onButton_openParaview) self.ui.button_checkLimitValues.clicked.connect(self.onButton_checkLimitValues) # Initialize Combobox @@ -109,8 +112,53 @@ def onButton_SelectWorkdir(self): self.workdir = ret self.textbox_workdir.setText(ret) + def onButton_viewPNG(self): + # View Bitmap result + dialog = QtWidgets.QDialog() + lay = QtWidgets.QVBoxLayout(dialog) + label = QtWidgets.QLabel() + lay.addWidget(label) + pixmap = QtGui.QPixmap(f"{OUTPUTS_DIR}/{JOB_NAME}.png") + label.setPixmap(pixmap) + dialog.exec_() + + + def onButton_openParaview(self): + + # Write postProcessParaviewFile + ftemp = open(PARAVIEW_RES_WIN, 'r') # Open template file + + fnamePost = f'{OUTPUTS_DIR}/pv_{JOB_NAME}.py' # Postprocessing file + fpost = open(fnamePost, 'w') + + timeVisualization = 1 # TODO: adapt either end of simulation or user input + + #Write information to postprocessing file + fpost.write(f"jobname = '{JOB_NAME}'\n") + fpost.write(f"filename = r'{OUTPUTS_DIR}/{JOB_NAME}'\n") + fpost.write(f"timeVisualization = {timeVisualization}\n") + fpost.write('\n') + + # Append template file + for line in ftemp: + fpost.write(line) + + ftemp.close() + fpost.close() + + # Start Paraview + + command = f"{PARAVIEW_CMD_WIN}{fnamePost} &" + + print(command) + ret = os.system(command) + print(ret) + + def onButton_checkLimitValues(self): + # TODO read results and check + QMessageBox.about(self, "ChecklimitValues", "Function not yet implemented") self.checkLimitValues() def loadLDR(self): @@ -200,7 +248,7 @@ def onButton_startFEA(self): "ldr": (f'{JOB_NAME}.ldr', open(self.textbox_FilenameLDR.text(), 'rb'), 'text/plain') } ) - resA = post("http://leofea:5000/", data = reqDataA, + resA = post("http://localhost:5000/", data = reqDataA, headers = { "Content-Type": reqDataA.content_type } @@ -208,14 +256,31 @@ def onButton_startFEA(self): # Check for errors if resA.status_code != 200: + QMessageBox.about(self, f"LeoFEA Error", "LeoFEA Error: {resA.status_code}") return "CodeAster error", 400 - + # Part multipart response resDataA = MultipartDecoder.from_response(resA) # Check for errors if len(resDataA.parts) != 3: + QMessageBox.about(self, f"LeoFEA Error", "LeoFEA Error: Less than 3 results returned") return "CodeAster error", 400 + + # TODO Make robust against changes in order! + with open(f"{OUTPUTS_DIR}/{JOB_NAME}.resMinMax", "wb") as file: + file.write(resDataA.parts[0].content) + with open(f"{OUTPUTS_DIR}/{JOB_NAME}.png", "wb") as file: + file.write(resDataA.parts[1].content) + with open(f"{OUTPUTS_DIR}/{JOB_NAME}.rmed", "wb") as file: + file.write(resDataA.parts[2].content) + + + + + + + if 0: # TODO: Model adpations, postprocessing .... # Scale Gravity @@ -275,11 +340,7 @@ def onButton_startFEA(self): - - # Postprocess Paraview - if self.ui.checkBox_OpenParaview.isChecked(): - lego.visualizeParaviewStatic() - + # Postprocess tEnd = timer() print(f"Total time of analysis: {tEnd-tStart:.2f}s\n") diff --git a/applications/leofea/sources/config.py b/applications/leofea/sources/config.py index d01a7cd5..f13148ac 100644 --- a/applications/leofea/sources/config.py +++ b/applications/leofea/sources/config.py @@ -6,13 +6,20 @@ RESOURCES_DIR = "../resources" LEOCADMODELS_DIR = "../leoCADmodels" -RESOURCES_LEOFEA_DIR = "../../../services/leofea/resources" +OUTPUTS_DIR = "../outputs" + +RESOURCES_LEOFEA_DIR = "../../../services/leofea/resources" # TODO Is it possible without Leofea directories? FILENAME_LIB_LDR = f"{RESOURCES_LEOFEA_DIR}/leoFeaPartLibrary.lib" SOURCES_LEOFEA_DIR = "../../../services/leofea/sources" -OUTPUTS_DIR = "../outputs" -COMMAND_START_LEOCAD_WIN = r"START C:\programs64\LeoCAD\leoCAD.exe" # TBD genearalize -COMMAND_START_LEOCAD_LINUX = "/home/christian/appImages/LeoCAD-Linux-23.03-x86_64.AppImage &" # TBD generalize +COMMAND_START_LEOCAD_WIN = r"START C:\programs64\LeoCAD\leoCAD.exe" # TODO genearalize +COMMAND_START_LEOCAD_LINUX = "/home/christian/appImages/LeoCAD-Linux-23.03-x86_64.AppImage &" # TODO generalize + +PARAVIEW_CMD_LINUX = "~/apps/paraview/bin/paraview " # TODO generalize +PARAVIEW_RES_LINUX = f"{RESOURCES_DIR}/templatePostProcessParaviewLinux.py" # TODO generalize +#PARAVIEW_CMD_WIN = "C:/programs64/SalomeMeca2021/run_paraview.bat --script=" # TODO generalize +PARAVIEW_CMD_WIN = "C:/programs64/Paraview5_12_RC/bin/paraview " +PARAVIEW_RES_WIN = f"{RESOURCES_DIR}/templatePostProcessParaviewWin.py" # TODO generalize JOB_NAME = "job" \ No newline at end of file diff --git a/services/leofea/sources/main.py b/services/leofea/sources/main.py index def6d6f8..5fcc54fa 100644 --- a/services/leofea/sources/main.py +++ b/services/leofea/sources/main.py @@ -32,6 +32,7 @@ def index(): request.files["ldr"].save(f"{OUTPUTS_DIR}/{JOB_NAME}.ldr") request.files["lib"].save(f"{OUTPUTS_DIR}/{JOB_NAME}.lib") + ######## PREPROCESSING # Read LDR file and get table of lego parts as return lM = leoFeaModelDescription.leoFeaModelDescription() tableLeoFeaModel = lM.readFileLDR(f"{OUTPUTS_DIR}/{JOB_NAME}.lib", f"{OUTPUTS_DIR}/{JOB_NAME}.ldr") @@ -41,6 +42,7 @@ def index(): lGM.buildLeoFeaModel(tableLeoFeaModel) lGM.writeInputFiles() + ######## SOLVER # Send mail and comm files to CodeAster and receive simulation results reqDataA = MultipartEncoder( fields = { @@ -71,6 +73,8 @@ def index(): with open(f"{OUTPUTS_DIR}/{JOB_NAME}.rmed", "wb") as file: file.write(resDataA.parts[2].content) + + ######### POSTPROCESSING PARAVIEW # Send rmed file to ParaView and receive rendered image reqDataB = MultipartEncoder( fields = { @@ -89,8 +93,29 @@ def index(): with open(f"{OUTPUTS_DIR}/{JOB_NAME}.png", "wb") as file: file.write(resB.content) + + ######### POSTPROCESSING text files + lP = leoFeaPostProcess.leoFeaPostProcess(JOB_NAME) + lP.postProcessStatic() + + + # Return results files + m = MultipartEncoder( + fields = { + 'resMinMax': (f'{JOB_NAME}.resMinMax.feather', open(f'{OUTPUTS_DIR}/{JOB_NAME}.resMinMax.feather', 'rb'), 'application/octet-stream'), + 'png': (f'{JOB_NAME}.png', open(f'{OUTPUTS_DIR}/{JOB_NAME}.png', 'rb'), 'text/plain'), + 'rmed': (f'{JOB_NAME}.rmed', open(f'{OUTPUTS_DIR}/{JOB_NAME}.rmed', 'rb'), 'text/plain') + #'comm': (f'{jobname}.comm', open(f'{OUTPUTS_DIR}/{JOB_NAME}.comm', 'rb'), 'text/plain') + # TODO simulation time + # TODO pd_DeplNoda if requested + # TODO pd_ForcNoda if requested + } + ) + + return Response(m.to_string(), mimetype = m.content_type) + # Return rendered image - return send_file(f"{OUTPUTS_DIR}/{JOB_NAME}.png") + #return send_file(f"{OUTPUTS_DIR}/{JOB_NAME}.png") # Register app route @APP.post("/preprocess")