CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Compiling modified patchAverage tool (

Bjw October 15, 2009 10:40

Compiling modified patchAverage tool
I'm trying to modify the patchAverage tool, so that the calculation result will be written into a simple text file. In a simple C++ app, including


#include <iostream>
#include <fstream>

and adding the following simple code:


ofstream results; ("results.dat", ios::out | ios::app);
results<< sumField << endl;

should do the job. Howewer, I cannot compile that tool. wmake will produce the following:

Making dependency list for source file patchAverageToFile.C
SOURCE=patchAverageToFile.C ;  g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3  -DNoRepository -ftemplate-depth-40 -I/home/stss2/OpenFOAM/OpenFOAM-1.5.x/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/stss2/OpenFOAM/OpenFOAM-1.5.x/src/OpenFOAM/lnInclude -I/home/stss2/OpenFOAM/OpenFOAM-1.5.x/src/OSspecific/Unix/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/patchAverageToFile.o
patchAverageToFile.C: In function ‘int main(int, char**)’:
patchAverageToFile.C:96: error: ‘ofstream’ was not declared in this scope
patchAverageToFile.C:96: error: expected `;' before ‘results’
patchAverageToFile.C:97: error: ‘results’ was not declared in this scope
patchAverageToFile.C:97: error: ‘ios’ has not been declared
patchAverageToFile.C:97: error: ‘ios’ has not been declared
make: *** [Make/linux64GccDPOpt/patchAverageToFile.o] Fehler 1

Can somebody tell me how to fix that?

Thanks, Björn

zhajingjing October 16, 2009 00:10

what's your object ?
what's the object of your modified patchAverage file? the original patchAverage tool already has the ability to produce data.If you want to get a data file,you just run the tool,

just like this: patchAverage fieldName patchName > dataFileName

then you can get the data file

So I don't know your real object.If the object is just to get a data file,you can do as above,


Bjw October 16, 2009 04:37

Well, I need to parse the calculation result with another application for automated post-processing. So it would be nice to just write out the result rather than writing the whole screen output to file.

l_r_mcglashan October 16, 2009 04:47

Try sticking 'std::' in front of ofstream, or 'using namespace std' before main.

Bjw October 16, 2009 05:31

Great, that worked, thank you very much! ofstream and ios are obviously not declared in the foam namespace.

All times are GMT -4. The time now is 23:55.