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

Write scalar in file in every timeFolder

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 19, 2013, 09:48
Default Write scalar in file in every timeFolder
  #1
Member
 
Martin
Join Date: Aug 2010
Location: Germany
Posts: 55
Rep Power: 7
RugbyGandalf is on a distinguished road
Dear Foam-Community,

i'd like to calculate the surface-area of the inlet-patch for a moving domain for every time step and write out the calculated value in a file in each time-folder.

For now i have the following code:

Code:
label inletPatchID = mesh.boundaryMesh().findPatchID("inlet"); 
    std::ofstream file("inlet_area.txt");
    file << gSum(mesh.magSf().boundaryField()[inletPatchID]) << std::endl;
    file.close();
But it only gives out a file in the case-directory (and overwrites it???)

Does anyone has any idea how to solve this?

Regards,
Martin
RugbyGandalf is offline   Reply With Quote

Old   September 19, 2013, 11:03
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
You will have to change the filename, something like this?
Code:
std::ofstream file(runTime.timeName(),"inlet_area.txt");
(This will probably not work due to string concatenation)

You also have alternative solutions
- Write to logfile (Info<<) and extract data afterwards from the log file (awk)
- Use a function object. functionObjects run during run time. I am not sure if you can do this with the default ones, but with the swak functionObjects by Bernhard Gschaider you can obtain this information easily for sure.
Bernhard is offline   Reply With Quote

Old   September 20, 2013, 08:29
Default
  #3
Member
 
Martin
Join Date: Aug 2010
Location: Germany
Posts: 55
Rep Power: 7
RugbyGandalf is on a distinguished road
Dear Bernhard,

thank you very much for your answer.
Unfortunately your hint did not work for me. The wmake-compiler gives out the following error:
CarreauYasudaIcoFoam.C:91:59: error: no suitable function for calling »std::basic_ofstream<char>::basic_ofstream(Foam::w ord, const char [15])«

the log-file hint migth work, although i'd really like to add it in the code.

Martin
RugbyGandalf is offline   Reply With Quote

Old   September 20, 2013, 08:37
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
The string concatenation is something I am not to sure about, this is something to dig into, maybe you could use something like "runTime.timeName().string()", but you wil have to experiment a bit.
Bernhard 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
groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM 24 August 23, 2015 22:41
Helyx-OS (GUI for SnappyHexMesh elvis OpenFOAM Native Meshers: snappyHexMesh and Others 176 July 10, 2015 16:50
what is swap4foam ?? AB08 OpenFOAM 27 July 1, 2013 09:17
error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Native Meshers: blockMesh 2 March 14, 2012 10:56
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00


All times are GMT -4. The time now is 03:58.