CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Dynamic Ofstream Filenames

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By deepsterblue

Reply
 
LinkBack Thread Tools Display Modes
Old   July 12, 2013, 12:17
Default Dynamic Ofstream Filenames
  #1
Member
 
Join Date: Aug 2012
Posts: 74
Rep Power: 5
HakikiCanakkaleli is on a distinguished road
Hi

== 1 ==
I would like to generate numerous
Code:
const scalar
names in which the prefix of these will be identical.

e.g. radius1, radius2, radius3 ... .

== 2 ==
To this end, I tried to use the standard library.

Code:
#include <string>
#include <sstream>

...

string fileNAme( const string& prefix, int index) // In order to name the output files dynamically.
  {
  ostringstream finalName;
  finalName << prefix << index;
  return finalName.str();
  }
== 3 ==

Code:
for (int i = 0; i < 100; i++)
{
fileNAme( "radius", i).c_str()
}
== 4 ==

I would like to re-write such a code in the OpenFOAM context. Is there anyone can suggest where I can start or how I can do this?

Many thanks in advance.
HakikiCanakkaleli is offline   Reply With Quote

Old   July 12, 2013, 12:24
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 386
Rep Power: 15
deepsterblue will become famous soon enough
Simple.

Code:
word fileName = "radius"

for (label i = 0; i < nRadius; ++i)
{
  word newName = fileName + name(i);
}
HakikiCanakkaleli likes this.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   July 12, 2013, 14:05
Default
  #3
Member
 
Join Date: Aug 2012
Posts: 74
Rep Power: 5
HakikiCanakkaleli is on a distinguished road
Many thanks!
HakikiCanakkaleli is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding Negative volume detected in Dynamic mesh Vinay Morabad FLUENT 9 April 10, 2015 23:00
dynamic mesh or dynamic grid adaptation?? IndrajitW FLUENT 3 May 23, 2013 03:38
Dynamic Mesh on Pintle type injector. herntan FLUENT 15 January 4, 2012 04:31
Dynamic Mesh moving interface help akash.iitb FLUENT 0 August 23, 2010 23:53
Dynamic Mesh Problem. Tom Clark FLUENT 9 July 7, 2010 07:56


All times are GMT -4. The time now is 19:34.