CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Export/Load file.txt in OpenFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/231353-export-load-file-txt-openfoam.html)

mxa261 November 2, 2020 17:40

Export/Load file.txt in OpenFoam
 
Hello,

I am writing a new BC for time varying inlet velocity.
I could write a vectorfield as a text file by following command in the .C file:

#incude <OFstream.H>
.
.
.
Ofstream myfile ("ux.txt.");
myfile << ux << endl;

However, I do not know how to load a text file! is there any way to do it? btw I am new in the OpenFoam programing. Thank you in advance.

Best,
Mehrshad

mxa261 November 3, 2020 11:47

I found the answers. See below:

#inlcude <IFstream.H>
.
.
.
.
IFstream dataStream("ux.tx")
dataStream >> ux;


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