|
[Sponsors] |
March 31, 2011, 12:21 |
OFstream backspace
|
#1 |
Member
Dan
Join Date: Oct 2010
Location: UK
Posts: 41
Rep Power: 16 |
Hi all,
I'm writing a function to be called in the controlDict, the output is a .dat file that I then want to use on each iteration as a timeDataFile. On each iteration I want to either erase the last character in the file, and the write the desired data, or rewind the pointer by one place. I have tried to use a backspace character "\b" however it did not backspace the file. instead input an unrecognizable character. I also tried Code:
outfile.seekp (pos-1); Code:
error: ‘class Foam::OFstream’ has no member named ‘seekp’ |
|
March 31, 2011, 18:45 |
|
#2 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
OFStream is a derived class that simplifies a lot of the IO for FOAM usage, but it also limits that you can only get around by using the actual fstream classes provided by the c++ libraries, or possibly casting the OFStream as something else.
Out of curiosity, why is only the last character being replaced? |
|
April 1, 2011, 05:43 |
|
#3 |
Member
Dan
Join Date: Oct 2010
Location: UK
Posts: 41
Rep Power: 16 |
Thanks murcios777
I'm wrighting a timeDataFile on the fly, basically a list of parameters, each iteration it calculates the parameters for the next time iteration. However the entire list needs to be surrounded by parenthesis, so each time I add a line I need to remove the close brackets, write the line, then add another close brackets. There is probably a much easier way of doing this, any suggestions would be appreciated. |
|
April 5, 2011, 13:24 |
|
#4 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
Do you need to keep all the iterations of the parameters, or do you just need the one from the last iteration. If its the latter, then it seems you could look at the code that allows the controlDict to be modified at runTime.
In fact, making this list of parameters a dictionary might be the best option, and make it run time modifiable. Then you can just have it living in your system folder, and the existing foam utilities handle all the writing/rewriting. The class structure for a dictionary is located here |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Integrated conjugate heat transfer solver in OpenFOAM | hjasak | OpenFOAM Running, Solving & CFD | 172 | April 13, 2023 01:42 |
A problem about class OFstream | jennyrui2008 | OpenFOAM Running, Solving & CFD | 0 | December 5, 2008 04:55 |
OFstream doesnbt create directories or throw errors | brooksmoses | OpenFOAM | 3 | January 30, 2006 07:28 |