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

Dynamic Ofstream Filenames

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By deepsterblue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 12, 2013, 12:17
Default Dynamic Ofstream Filenames
  #1
Senior Member
 
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 13
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: 403
Rep Power: 25
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
Senior Member
 
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 13
HakikiCanakkaleli is on a distinguished road
Many thanks!
HakikiCanakkaleli 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
Dynamic Mesh Problem. Tom Clark FLUENT 10 June 21, 2021 04:27
Dynamic Mesh on Pintle type injector. herntan FLUENT 16 September 4, 2020 08:27
Regarding Negative volume detected in Dynamic mesh Vinay Morabad FLUENT 10 December 16, 2015 00:31
dynamic mesh or dynamic grid adaptation?? IndrajitW FLUENT 3 May 23, 2013 03:38
Dynamic Mesh moving interface help akash.iitb FLUENT 0 August 23, 2010 23:53


All times are GMT -4. The time now is 06:46.