CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] Load forces in ParaView

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 16, 2017, 05:19
Default Load forces in ParaView
  #1
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
kandelabr is on a distinguished road
Hello,

I have results from a simulation and I run pimpleFoam -postProcess on them, which creates a postProcessing folder with calculated forces and torques.

How do I load those data in paraview for further calculations (efficiency) and display?

Thanks.
kandelabr is offline   Reply With Quote

Old   December 16, 2017, 10:00
Default
  #2
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
kandelabr is on a distinguished road
Well, if anyone from the future wants to know how I did it, here's the python script for ParaView 'programmable filter'. I needed to know efficiency of a pump so I calculated total torque. You might need something else.

It's not very efficient but for a small number of timesteps it should do its job.

Code:
# current time
timestep = inputs[0].GetInformation().Get(vtk.vtkDataObject.DATA_TIME_STEP())
timestep = float(timestep)

# forces: load from forces.dat file
input_file = open('postProcessing/forces_impeller/0/forces.dat', 'r')

for i in range(3):
    # first few lines do not contain data
    input_file.readline()

# read lines until the right timestep has been reached
for line in input_file:
    # values in a single line:
    # 0           1 2 3    4 5 6   7 8 9          10 11 12 13 14 15 16 17 18
    # Time forces(pressure viscous porous) moment(pressure viscous porous)
    values = line.split()
    values = [float(v.strip('()')) for v in values]

    if values[0] == timestep:
        # add pressure and viscous forces;
        # axial
        F_a = values[1] + values[4]

        # maximum radial force
        F_r1 = values[2] + values[5]
        F_r2 = values[3] + values[6]

        F_r = (F_r1**2 + F_r2**2)**0.5


        # torque = pressure + viscous
        T = values[10] + values[13]

        break

# do something with the data
kandelabr is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Drag Force from Forces Function different from Paraview edomalley1 ParaView 4 December 14, 2018 00:44
[OpenFOAM.org] Paraview 5.4 in shell environment of5x - Segmentation fault (core dumped) dslbkxd OpenFOAM Installation 1 February 3, 2018 01:56
[OpenFOAM.org] Two different versions of ParaView with same OpenFOAM release FJSJ OpenFOAM Installation 2 July 23, 2017 06:48
[OpenFOAM] Viewing forces output in Paraview Boloar ParaView 1 August 12, 2013 04:11
FORCES don't run! C12Carbon OpenFOAM 0 September 10, 2011 08:34


All times are GMT -4. The time now is 00:07.