CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   read scalar field phi, get flux through faces (http://www.cfd-online.com/Forums/openfoam-programming-development/78637-read-scalar-field-phi-get-flux-through-faces.html)

peterwy July 28, 2010 14:23

read scalar field phi, get flux through faces
 
Hello,

I've a question.

I write a program with the target to read the flux phi through some faces.
(I need this for a special report. The code is already able to find the necessary faces. So the import of the mesh itself works.)

But now I've no idea, how to read the flux phi through the faces, and especially everything I tried to source the field phi was not really successfully. Probably it's easy but I've no idea, how to do?

Thanks a lot already for your help & best Regards,
Peter



<code>


#include "argList.H"
#include "cellSet.H"
#include "topoSetSource.H"
#include "Time.H"
#include "globalMeshData.H"
#include <fstream> //to write out the stl file
#include <malloc.h>
#include <string.h>

using namespace Foam;
using namespace std; // for input/output file


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();

#include "setRootCase.H"

fileName sourceRootDir = ".";
fileName sourceCaseDir = ".";

Time runTime
(
Time::controlDictName,
sourceRootDir,
sourceCaseDir
);
#include "createPolyMesh.H"
</code>

MartinB July 28, 2010 15:33

Hi Peter,
can't you simply use:
Code:

surfaceScalarField phi
(
    IOobject
    (
        "phi",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    linearInterpolate(U) & mesh.Sf()
);

Or if there is at least "U" in your time step:
Code:

#  include "createPhi.H"
Martin

peterwy July 29, 2010 03:30

phi is already present in the time step (from data side), but

in the program there're no fields sourced at the moment.

The point is that the class(?) surfaceScalarField is not known.
Probably the right #include file is missing but here I've the problem if I take other programs like simpleFoam (or someome with phi present, that swallow... thing) I get a couple of more errors. Than the topo functions working no longer because at the end of the code I build a cellset.

I need a method so that I can simple read the fields, especially the phi one, at that moment when I read the time step.

Hope it's clear what I want. I'm not a real c++ expert, but my knowledge becomes better by day ;-)

Thx & Best Regards,
Peter

kathrin_kissling August 3, 2010 04:44

Hi Peter,

is this a postprocessing routine or do you need to have the output in your solver?
If it is a postprocessing routine you could try to have a look in the applications/utilities/postprocessing routines. Mayby you could use a foam::calc function or you could try to just add
#include fvCFD.H

Maybe this could work.

Best Kathrin

peterwy August 4, 2010 17:36

Hello,

thanks for your help.
I began again with the simpleFoam.C and beginning from this code I tried to solve my problem. At the end it was in fact the simple point to add fvCFD but additionaly the order of the include files was important as well.

Now it works.

Thanks a lot and bye
Peter


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