Вычисление распределенных характеристик

Help create a filter or script to calculate distributed aerodynamic forces along a streamlined body. I dug up something. This is where my knowledge ends. Here’s what I wrote:

trace generated using paraview version 5.11.2

#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()

select the data

openFOAMReader1 = FindSource(‘OpenFOAMReader1’)

Create an ‘Extract Block’ filter and select the required block

extractBlock1 = ExtractBlock(registrationName=‘ExtractBlock1’, Input=openFOAMReader1)
extractBlock1.Selectors = [‘/Root/boundary’]

calculate the normals from the surface ‘Generate Surface Normals’

generateSurfaceNormals1 = GenerateSurfaceNormals(registrationName=‘GenerateSurfaceNormals1’, Input=extractBlock1)
generateSurfaceNormals1.ComputeCellNormals = 1

calculate the Forces using the calculator ‘Calculator1’

calculator1 = Calculator(registrationName=‘Calculator1’, Input=generateSurfaceNormals1)
calculator1.ResultArrayName = ‘Force1’
calculator1.Function = ‘p*Normals’

calculate Moments using the calculator ‘Calculator2’

calculator2 = Calculator(registrationName=‘Calculator2’, Input=calculator1)
calculator2.ResultArrayName = ‘Moment1’
calculator2.Function = ‘cross(Force1,0iHat+0jHat+0*kHat-coords)’

calculate the total integrals of Forces and Moments ‘Integrate Variables’

integrateVariables1 = IntegrateVariables(registrationName=‘IntegrateVariables1’, Input=calculator2)

#################################################################################

Creating a visualization window

renderView1 = GetActiveViewOrCreate(‘RenderView’)
#create a new table ‘SpreadSheet View’
spreadSheetView1 = CreateView(‘SpreadSheetView’)
spreadSheetView1.ColumnToSort = ‘’
spreadSheetView1.BlockSize = 1024

display the results in the table spreadSheetView1

integrateVariables1Display = Show(integrateVariables1, spreadSheetView1, ‘SpreadSheetRepresentation’)
spreadSheetView1.HiddenColumnLabels = [‘Block Number’, ‘Point ID’, ‘Ma’, ‘Normals’, ‘Normals_Magnitude’, ‘p’, ‘Points’, ‘Points_Magnitude’, ‘rho’, ‘T’, ‘U’, ‘U_Magnitude’]
layout1 = GetLayoutByName(“Layout #1”)
AssignViewToLayout(view=spreadSheetView1, layout=layout1, hint=0)
spreadSheetView1.Update()

create a new table ‘SpreadSheet View’ under the previous one

layout1.SplitVertical(2, 0.5)
spreadSheetView2 = CreateView(‘SpreadSheetView’)
spreadSheetView2.ColumnToSort = ‘’
spreadSheetView2.BlockSize = 1024
#################################################################################

create a new filter ‘Clip’ with source Input=calculator1

clip1 = Clip(registrationName=‘Clip1’, Input=calculator1)
clip1.HyperTreeGridClipper = ‘Plane’
clip1.HyperTreeGridClipper.Origin = [0.0, 0.0, 0.0]
clip1.ClipType = ‘Plane’
clip1.ClipType.Origin = [0.0, 0.0, 0.0]
clip1.ClipType.Normal = [1.0, 0.0, 0.0]
clip1.ClipType.Offset = 0.1
clip1.Invert = 1
clip1.Crinkleclip = 1

display clip1’s data in renderView1

clip1Display = Show(clip1, renderView1, ‘UnstructuredGridRepresentation’)
clip1Display.Representation = ‘Surface’
renderView1.ResetActiveCameraToPositiveZ()
renderView1.ResetCamera(False)
renderView1.Update()

#################################################################################

calculate the integral on part of the surface Force(L) ‘Integrate Variables’

integrateVariables2 = IntegrateVariables(registrationName=‘IntegrateVariables2’, Input=clip1)

display the results in the spreadSheetView2 table

integrateVariables2Display = Show(integrateVariables2, spreadSheetView2, ‘SpreadSheetRepresentation’)
spreadSheetView2.HiddenColumnLabels = [‘Block Number’, ‘Point ID’, ‘Ma’, ‘Normals’, ‘Normals_Magnitude’, ‘p’, ‘rho’, ‘T’, ‘U’, ‘U_Magnitude’]
AssignViewToLayout(view=spreadSheetView2, layout=layout1, hint=0)
spreadSheetView2.Update()
#################################################################################

Next, you need to cycle the shift clip1.ClipType.Offset from 1 to N - the number of sections and write the data to an array for each shift

Properties modified on clip1.ClipType

clip1.ClipType.Offset = 0.12

update the view to ensure updated data information

renderView1.ResetActiveCameraToPositiveZ()
renderView1.ResetCamera(False)
renderView1.Update()

#################################################################################

export view

ExportView(‘D:/OPENFOAM/Projectile_/case/F_M.csv’, view=spreadSheetView1)

export view

ExportView(‘D:/OPENFOAM/Projectile_/case/F(L).csv’, view=spreadSheetView2)

This is an english speaking forum. Please use english.