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

OFstream backspace

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 31, 2011, 11:21
Default OFstream backspace
  #1
Member
 
Dan
Join Date: Oct 2010
Location: UK
Posts: 41
Rep Power: 15
dandalf is on a distinguished road
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);
But that resulted in the error
Code:
error: ‘class Foam::OFstream’ has no member named ‘seekp’
Is there a simple solution?
dandalf is offline   Reply With Quote

Old   March 31, 2011, 17:45
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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?
mturcios777 is offline   Reply With Quote

Old   April 1, 2011, 04:43
Default
  #3
Member
 
Dan
Join Date: Oct 2010
Location: UK
Posts: 41
Rep Power: 15
dandalf is on a distinguished road
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.
dandalf is offline   Reply With Quote

Old   April 5, 2011, 12:24
Default
  #4
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
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
mturcios777 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
Integrated conjugate heat transfer solver in OpenFOAM hjasak OpenFOAM Running, Solving & CFD 172 April 13, 2023 00:42
A problem about class OFstream jennyrui2008 OpenFOAM Running, Solving & CFD 0 December 5, 2008 03:55
OFstream doesnbt create directories or throw errors brooksmoses OpenFOAM 3 January 30, 2006 06:28


All times are GMT -4. The time now is 13:14.