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

Open a file at first time step to write data in it(and restart)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2022, 20:08
Default Open a file at first time step to write data in it(and restart)
  #1
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 204
Rep Power: 7
farzadmech is on a distinguished road
Hello everyone
How can I open a file only at first time step and write my data there? The problem is that, I need to restart the code, and when I restart the code, it opens a new file and write from "restartTime" there and I loose the transient data until "restartTime".
I want to use "if";

Code:
        label curTimeIndex = mesh.time().timeIndex();
        if(curTimeIndex == 1) {
	ofstream myfile1;
        myfile1.open ("kineticEnergyFFD.txt");
        }
but it give me this error(without if everything is correct, but I have a problem in restarting the code as I explained earlier);

Code:
postprocessingFFD.H:731:3: error: ‘myfile1’ was not declared in this scope
   myfile1 << runTime.timeName() << "          " << avekineticEnergy0 << "          " << minkineticEnergyNew << "          " << maxkineticEnergyNew <<
Thanks,
Farzad
farzadmech is offline   Reply With Quote

Reply

Tags
data file, first time step, openfoam, restart


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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 06:42
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 11:32
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46


All times are GMT -4. The time now is 17:01.