|
[Sponsors] |
September 2, 2014, 03:54 |
Plotting (Forces) in log file - 2nd match
|
#1 |
Senior Member
Join Date: Jul 2011
Posts: 120
Rep Power: 14 |
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])) 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. |
|
September 2, 2014, 04:46 |
|
#2 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 |
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. |
|
September 2, 2014, 04:48 |
|
#3 |
Senior Member
Join Date: Jul 2011
Posts: 120
Rep Power: 14 |
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') |
|
|
|
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 |