|
[Sponsors] |
July 20, 2009, 10:12 |
Output file with OpenFOAM header
|
#1 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Hello again.
Is there a way of putting the standard OpenFOAM file header on top of an output file I created with something like this? Code:
OFstream os ("p"); os << faceCenterPressure;
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 22, 2009, 03:41 |
|
#2 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Sorry I have to push this, but this problem is crucial in one of my efforts.
I'm producing a lot of files with a home-made tool. Editing these files by copy&pasting file headers inside is critically affecting the whole performance ... What I'm searching for is a possibilty to put the OpenFOAM header on top of an output file. Furthermore I need to specify the class and object entry!
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 22, 2009, 08:29 |
|
#3 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
July 22, 2009, 08:45 |
|
#4 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
I'm not familiar with this Doxygen thing but I haven't found an "inheritence tree".
Just some crypical "class reference".
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 22, 2009, 08:50 |
|
#5 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
Have a look at:
IOobject::writeHeader or IOobjectWriteHeader.C That should give you enough information. To use Doxygen, have a look here: http://foam.sourceforge.net/doc/Doxy...1IOobject.html And scroll down to the public member functions section. Oh, and look at: http://foam.sourceforge.net/doc/Doxy...ph_legend.html to see how the diagrams work.
__________________
Laurence R. McGlashan :: Website |
|
July 22, 2009, 12:27 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
July 27, 2009, 12:15 |
|
#7 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
I'm afraid I can't solve this mystery on my own.
I toyed around with some strange commands. Code:
OFstream osP (directory/"p"); faceCenterPressure.writeHeader(osP); osP << faceCenterPressure; Code:
error: ‘class Foam::scalarField’ has no member named ‘writeHeader’
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 28, 2009, 09:49 |
|
#8 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
IOList<scalar> faceCenterPressure( IOobject( "faceCenterPressure", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ) ); |
||
July 28, 2009, 10:25 |
|
#9 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
This faceCenterPressure is a scalarField!
Code:
scalarField faceCenterPressure(facesSet.size()); Have a look: (Note: surfaceScalarField ps = fvc::interpolate(p);) Code:
for (label k=0; k<facesSet.size(); k++) { int faceNumber = faces[k]; faceCenterPressure[k] = ps[faceNumber]; fileName directory = runTime.path()/"boundaryData"/setName/runTime.timeName(); mkDir(directory); OFstream osP (directory/"p"); osP << faceCenterPressure; } Code:
Make/linux64GccDPOpt/listFaceSet.o: In function `Foam::IOList<double>::type() const': listFaceSet.C:(.text._ZNK4Foam6IOListIdE4typeEv[Foam::IOList<double>::type() const]+0x3): undefined reference to `Foam::IOList<double>::typeName' Make/linux64GccDPOpt/listFaceSet.o: In function `Foam::IOList<double>::IOList(Foam::IOobject const&)': listFaceSet.C:(.text._ZN4Foam6IOListIdEC1ERKNS_8IOobjectE[Foam::IOList<double>::IOList(Foam::IOobject const&)]+0x46): undefined reference to `Foam::IOList<double>::typeName' collect2: ld returned 1 exit status Still big question: Will your suggestion render this OFstream-output-command useless ?!
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 28, 2009, 13:40 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
My example was done without knowing this
Quote:
Definitly. Use it the way stuff in the createFields.H of any solver is used |
||
July 28, 2009, 14:45 |
|
#11 | |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Quote:
I appreciate your didactic intention. But this inheritance diagram is filling two pages on my screen. I have to confess I'm totally swamped with this. Maybe this is not the right choice for starting to learn how to read the Doxygen guide. I don't even have the slightest idea where to look, not to talk about finding a solution... Sorry, I need further input ...
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
||
July 28, 2009, 14:59 |
|
#12 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
This is the way I would see it (correct if I'm wrong).
scalarField is just a typedef: Field<scalar>. If you look at the inheritance diagrams, you should be able to see that all the dimensioned fields, IOList, IOField and other things all inherit from regIOobject which inherits from IOobject. So you may have: scalarField faceCentrePressure(IOobject..blah..); IOField<scalar> faceCentrePressure(IOobject..blah..); Does that help?
__________________
Laurence R. McGlashan :: Website |
|
July 28, 2009, 15:22 |
|
#13 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Yes.
Code:
IOField<scalar> faceCentrePressure(IOobject..blah..); When running my code Code:
surfaceScalarField ps = fvc::interpolate(p); scalarField faceCenterPressure(facesSet.size()); for (label k=0; k<facesSet.size(); k++) { int faceNumber = faces[k]; faceCenterPressure[k] = ps[faceNumber]; fileName directory = runTime.path()/"boundaryData"/setName/runTime.timeName(); mkDir(directory); IOField<scalar> faceCenterPressure ( IOobject ( "faceCenterPressure", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ) ); OFstream osP (directory/"p"); osP << faceCenterPressure; } };
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 29, 2009, 06:19 |
|
#14 | |||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
Quote:
And currently you're writing stuff at every iteration of the loop. Basically you only need one faceCenterPressure (outside the loop) Code:
IOField<scalar> faceCenterPressure ( IOobject ( "faceCenterPressure", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ) ,facesSet.size() ); Code:
faceCenterPressure.write() |
||||
July 29, 2009, 10:48 |
|
#15 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Yes. Thats working. Just great!
The files containing the correct values from the faceCenterPressure variable are written in the time directories with headers! If you can point out to me how to write these files into a different location, this would round up this part of the problem. The next problem is the following: The output file hast to have two specific entries in its header
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 30, 2009, 07:47 |
|
#16 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
Does changing the second argument of IOobject to the folder you want the field to be saved to not work? So instead of runTime.timeName() having, say, "thisFolder".
Not sure how you would write different entries to your header. You could either change the IOobjectWriteHeader.C file or write to the file directly.
__________________
Laurence R. McGlashan :: Website |
|
July 31, 2009, 12:42 |
|
#17 | ||
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Quote:
Quote:
So all other fields will also be written in the manner I specify there? Thats definitefly not what I intend to do, as this should be limited to the special case I'm working with ... So, what do you mean by "writing directly to the file"?
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF with output text file | manu | Fluent UDF and Scheme Programming | 18 | December 12, 2018 23:46 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
Statically Compiling OpenFOAM Issues | herzfeldd | OpenFOAM Installation | 21 | January 6, 2009 10:38 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |
Reduce output file size!! | Jonac | CFX | 1 | September 15, 2000 04:24 |