CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Plotting (Forces) in log file - 2nd match

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 2, 2014, 03:54
Default Plotting (Forces) in log file - 2nd match
  #1
Senior Member
 
Join Date: Jul 2011
Posts: 120
Rep Power: 14
haze_1986 is on a distinguished road
I need to plot the Force vector over time using a sixDoFRigidBodyMotion solver.

Using the below script I managed to extract the "attachmentPt - anchor" and plot it with time without problems, but unsure how to extract the force vector using the getstatusoutput with grep command. Can someone enlighten me on this?

Code:
 
pathname = os.path.abspath('.')
fileName = os.path.join(pathname,'log')

status, data = commands.getstatusoutput('cat ' + fileName + '| grep translationDamper1')
data = data.split('\n')

x = []
y = []
z = []

for i in range(len(data)-1):
    line = data[i]
    line = line.split('(')[1].split(')')[0].split(' ')
    x.append(float(line[0]))
    y.append(float(line[1]))
    z.append(float(line[2]))
Here is the log file with the information I need
Code:
 
Restraint translationDamper1:  attachmentPt - anchor (0.4 0 0.4) spring length 0.565685424949 force (3.58941192118e-07 0 3.58941192118e-07)
Restraint translationDamper2:  attachmentPt - anchor (-0.4 0 0.4) spring length 0.565685424949 force (-3.58939622026e-07 0 3.58939622026e-07)

Last edited by haze_1986; September 3, 2014 at 21:05.
haze_1986 is offline   Reply With Quote

Old   September 2, 2014, 04:46
Default
  #2
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
Why not just get the index of the where the strings start?

something like int start = searchString(line,"attachment")

Playing with the indices, other way would be playing with the format of the string given, but I don't how does it work in python.
ssss is offline   Reply With Quote

Old   September 2, 2014, 04:48
Default
  #3
Senior Member
 
Join Date: Jul 2011
Posts: 120
Rep Power: 14
haze_1986 is on a distinguished road
Thanks for the reply, I'm new to python as well and it has been a hit and miss by trial and error for me. Would be good if anyone can help me modifying this line for it to work.
Code:
status, data = commands.getstatusoutput('cat ' + fileName + '| grep translationDamper1')
haze_1986 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
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 08:46
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 13:14
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 05:18
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 15:16


All times are GMT -4. The time now is 01:24.