|
[Sponsors] |
November 11, 2010, 08:19 |
Writing scalar to file
|
#1 |
New Member
Join Date: Aug 2010
Posts: 6
Rep Power: 16 |
Hello everybody!
I think I got a comparatively easy problem, but I can't find a solution. I have a program that calculates the power inserted by an impeller for every time step. But at the moment the value is just displayed bei "Info <<...... " on the screen. I'd like to write it into a file as kind of a list, with the time and the corresponding power value, so that I can easily plot it with gnuplot. I tried something with a IOdictionary but did'nt get very far. And I don't really know how to handle the list class. I would be glad if someone could tell me some details oder just show me where I can find an introduction of that topic. Thank you! Tobb |
|
November 11, 2010, 08:51 |
|
#2 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
To be honest, if you just want a file with 2 columns (Time and power), just use the standard library. Change Info to a file, so something like:
Code:
std::ofstream file("results.txt"); file << Time[i] << " " << Power[i] << std::endl; file.close();
__________________
Laurence R. McGlashan :: Website |
|
November 11, 2010, 09:39 |
|
#3 |
New Member
Join Date: Aug 2010
Posts: 6
Rep Power: 16 |
First of all thank you for your answer. But if I got you right, you basically told me how to merge two existing lists into one file.
So I think I have to be more precise. My routine is built as a loop. It reads in the velocity field, calculates the power (using rho, nu and the gradient of U) and than moves on to the next time directory. So I actually don't have any time or power list. My aim is to add the current time and the corresponding power value to a file after each loop. So the list or the file where the data should be stored doesn't exist right from the start. I have to create it either before starting my program or implement the construction once right at the beginning of the code and than add every entry step by step. But the construction of a such a list as well as writing data to a file are things I haven't really done before. I hope I managed to make things clearer now. Thank you in advance! Tobb |
|
November 11, 2010, 09:58 |
|
#4 |
Senior Member
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25 |
u can use Info, but save the result in a log file
solver > log then use foamlog ofcourse you should add new written variable in foamLog data base so i suggest : search for foamlog |
|
November 19, 2010, 08:38 |
|
#5 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Hi Tobb!
If you want a file with only two columns, you could use the makeGraph function! You can specify: Code:
makeGraph(Time, Power, "Your_Name", path, graphFormat); The format can be obtained from your runTime object with the command: Code:
const word& graphFormat = runTime.graphFormat(); Code:
U.path(); Kind regards, Francois. |
|
November 19, 2010, 12:55 |
|
#6 |
New Member
Join Date: Aug 2010
Posts: 6
Rep Power: 16 |
Thank you very much for your hint!
It sounds like this could be what I was looking for. I will try it out after the weekend and let you know whether I was successful or not. |
|
December 1, 2010, 17:19 |
|
#7 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
You can also replace the graphFormat option directly by (keep the quotes):
Kind regards, François. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh | gschaider | OpenFOAM Community Contributions | 300 | October 29, 2014 19:00 |
OpenFOAM Install Script | ljsh | OpenFOAM Installation | 82 | October 12, 2009 12:47 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
Problems With Journal When Writing Forces To File | Andrew | FLUENT | 2 | September 23, 2005 03:12 |