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

read scalar field phi, get flux through faces

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 28, 2010, 14:23
Default read scalar field phi, get flux through faces
  #1
New Member
 
Peter Wiemeyer
Join Date: Sep 2009
Location: Germany, Munich
Posts: 22
Rep Power: 17
peterwy is on a distinguished road
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>
peterwy is offline   Reply With Quote

Old   July 28, 2010, 15:33
Default
  #2
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22
MartinB will become famous soon enough
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
MartinB is offline   Reply With Quote

Old   July 29, 2010, 03:30
Default
  #3
New Member
 
Peter Wiemeyer
Join Date: Sep 2009
Location: Germany, Munich
Posts: 22
Rep Power: 17
peterwy is on a distinguished road
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
peterwy is offline   Reply With Quote

Old   August 3, 2010, 04:44
Default
  #4
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   August 4, 2010, 17:36
Default
  #5
New Member
 
Peter Wiemeyer
Join Date: Sep 2009
Location: Germany, Munich
Posts: 22
Rep Power: 17
peterwy is on a distinguished road
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
peterwy is offline   Reply With Quote

Old   April 28, 2017, 20:40
Default
  #6
Member
 
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10
pvpnrao is on a distinguished road
Peter

Can you share your code. Here is my problem:
in each pressure loop
I need to find the fluxes through the faces lying in a particular cellZone and then multiply them with zero. And then pass this upadted velocity field to the next pressure loop.
pvpnrao is offline   Reply With Quote

Reply


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
dieselFoam problem!! trying to introduce a new heat transfer model vivek070176 OpenFOAM Programming & Development 10 December 24, 2014 00:48
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43
Can I specify a passive scalar flux source in ccm+ eric Siemens 0 June 11, 2008 15:48
from a vecor field to get a gradient of scalar dusky.he Main CFD Forum 4 March 30, 2007 10:08


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