CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Retrieving boundary patch values adjacent to a given cell

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes
  • 7 Post By hjasak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 16, 2006, 18:06
Default So, I have an OpenFOAM code th
  #1
brooksmoses
Guest
 
Posts: n/a
So, I have an OpenFOAM code that's creating output files based on the values in a mesh created using blockMesh on a single block. At this point, everything's working reasonably nicely for the cell-centered values.

What I'd now like to include is values on the outer boundaries of the block. Specifically, given a cell that I happen to know is on a face of the block, I'd like to get the values of U and p on its face that's on the boundary patch. (Or, if it's on an edge or corner, the values on all of the relevant faces.) Is this possible? How would I go about it? What bits of code should I look at for a starting point?

Thanks!
  Reply With Quote

Old   March 17, 2006, 03:19
Default Two ways (the clever one and t
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,906
Rep Power: 33
hjasak will become famous soon enough
Two ways (the clever one and the round-about one).

If you want lots of faces and cells, go onto the boundary patch and as for faceCells(), which gives you cells on the inside of the patch. This is good if you want to do lots of them, but if you only want one face of one cell, that would involve search, which is not good.

This would look something like:

const fvPatchVectorField& patchU = U.boundaryField()[patchI];

const labelList::subList fc = patchU.patch().faceCells();


blah blah.

The second way is to go directly from the cell to the patch face. So assuming you know the cell index, you will ask for its faces and then go through them and ask "which patch does this face belong to". Because of my clever ordering stuff :-) this does not involve searching. So:

faces of cell

const cell& c = mesh.cells()[cellI]; // a cell is a list of faces

forAll (c, i)
{
// This gives you the patch ID for a face. If the face is internal, you get -1
label patchID = mesh.boundaryMesh().whichPatch(c[i]);

if (patchID > -1)
{
label faceID = mesh.boundaryMesh()[patchID].whichFace(c[i]);

blah blah
}
}

The faceID gives you the face index in the patch. You can now recover the boundary face value as:

U.boundaryField()[patchID][faceID];

For internal faces, (say, if you want the flux), you firs find out that it is internal (whichPatch gives -1), and then you ash phi.internalField()[c[i]]; to get the value. Beware, the internalField() function is not trivial and if you're doing this lots, you should take a local reference.

Enjoy,

Hrv

P.S. Nice question!
kaifu, fumiya, hasret95 and 4 others like this.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   December 8, 2008, 10:00
Default Hi, I have written a postpr
  #3
Member
 
Niklas Winkler
Join Date: Mar 2009
Location: Stockholm, Stockholm, Sweden
Posts: 73
Rep Power: 17
nikwin is on a distinguished road
Hi,

I have written a postprocessing solver for which I want to set some boundaries as fixed and some as zeroGradient. To check that the zeroGradient boundaries actually are zeroGradient after the postprocessing step I've used the function fvc::snGrad at the faces on the specific boundary found according to the 2nd method suggested above. I believe snGrad should give me the gradient normal to each face and if it's numerically zero then the zeroGradient condition is fulfilled.

As a test I've tried to calculate snGrad for all faces, both internal and external for a totally uniform field. The problem is that snGrad gives me zero within numerical accuracy for the internal faces, approx. 0.16 for most faces on the boundary and zero for some faces on the boundary. Is there an explanation for this? Is it ok. to use snGrad on the boundary since it normally uses the 2 cells closest to the face? Is there a better or more correct way of checking that the zeroGradient condition is numerically fulfilled?

Thanks (and I'm really enjoying OF!)
/NW
nikwin is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
In reply to: "only one adjacent cell thread." Krystian FLUENT 0 August 27, 2008 20:39
adjacent cell zones Louisa FLUENT 4 August 31, 2007 06:49
Retrieving the values stored in UDM Sri FLUENT 2 March 1, 2007 16:48
Adjacent cell number Jing Siemens 5 October 21, 2002 06:29
two adjacent cell zones. Thejasvi FLUENT 3 November 26, 2001 08:35


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