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

How to find downwind cells of a cell in OpenFOAM ?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2019, 05:40
Default How to find downwind cells of a cell in OpenFOAM ?
  #1
Member
 
Paul Palladium
Join Date: Jan 2016
Posts: 93
Rep Power: 10
Fauster is on a distinguished road
Dear Foamers

I would like to know how to find the downwind cells of a cell. As mentionned here : owner and neighbor #4 :
Quote:
A positive flux goes from "owner" to "neighbour".
.

At the moment I do the folowing thing :

Quote:
forAll(T.internalField(),celli) // loop over cell
{
const labelList& own = mesh.faceOwner();
const labelList& nei = mesh.faceNeighbour();
const labelList& faces = mesh.cells()[celli];

forAll(faces,facei) // loop over faces of celli
{
if (own[facei] == celli)
{
///// Is nei[facei] a downwind cell of celli ?
Pout << "phi[facei] = " << phi[facei] << endl ;
// Problem : phi[facei] can be positive or negative.
}
}
}
If we assume that a "positive flux goes from "owner" to "neighbour" " I don't understant why phi[facei] can be positive or negative in a face if own[facei] == celli ?
So I suppose I am doing wrong something. Has anyone an idea how to solve this problem ?

Another question :
what is the difference between
Quote:
mesh.neighbour()[facei] AND mesh.faceNeighbour()[facei]
?

Huge thanks
Fauster is offline   Reply With Quote

Old   October 7, 2019, 07:36
Default
  #2
Member
 
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10
frobaux is on a distinguished road
Hi,
I think there is a problem with your indices, you should do own[faces[facei]] instead of faces[facei] if you want the owner cell of the facei-th face of the cell. Same applies to Phi[facei]=> Phi[faces[facei]]. (otherwise facei goes from 1 to not much - like 10 max)



I think that a positive flux goes from owner to neighbor just means that, when the flux is positive, the flow effectively goes from owner to neighbour. When it is negative, the flow is reversed. Basically, that just means that the normal of a face is oriented outwards (from its owner to its neighbour)


for the faceNeighbour() vs neighbour() I don't know where you find the "neighbour()" function.

faceNeighbour()[f] is returning the neighbouring cell of the face of label f (again you should use "label f=faces[facei]").



I hope I'm clear,
Fabien
frobaux is offline   Reply With Quote

Old   October 8, 2019, 09:58
Default
  #3
Member
 
Paul Palladium
Join Date: Jan 2016
Posts: 93
Rep Power: 10
Fauster is on a distinguished road
Dear Frobaux,

Thank you for you message. I am going to use your solution and see if it's ok. Since my first message I found out that in isoadvector there is a function wich seems to calculate downwindFaces :

Quote:
void Foam::isoAdvection::setDownwindFaces
(
const label celli,
DynamicLabelList& downwindFaces
) const
{
DebugInFunction << endl;

// Get necessary mesh data and cell information
const labelList& own = mesh_.faceOwner();
const cellList& cells = mesh_.cells();
const cell& c = cells[celli];

downwindFaces.clear();

// Check all faces of the cell
forAll(c, fi)
{
// Get face and corresponding flux
const label facei = c[fi];
const scalar phi = faceValue(phi_, facei);

if (own[facei] == celli)
{
if (phi > 10*SMALL)
{
downwindFaces.append(facei);
}
}
else if (phi < -10*SMALL)
{
downwindFaces.append(facei);
}
}

downwindFaces.shrink();
}
I understand that this function fill a list with the downwind faces of a cell. If I look at the way of looping over cell and then faces I don't see so much difference with my code. What am I missing ?

For example in the code of linearUpwind :
The build of the surfaceScalarField returned by the "correction" function is obtained by looping over all faces of the mesh. From my understanding there is no [faces[facei]]. Clearly I am missig something. Could you go more in details please ?

Quote:
for the faceNeighbour() vs neighbour() I don't know where you find the "neighbour()" function.
It seems that neighbour() is for example here : Huge thank for you answer.
P
Fauster is offline   Reply With Quote

Old   October 8, 2019, 10:09
Default
  #4
Member
 
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10
frobaux is on a distinguished road
Yes, you are right faceNeighbour() is defined in polyMesh.H and neighbour() is defined in fvMesh.H. I don't know the difference, but as fvMesh is a child of polyMesh, you have access to both of them..
and the same is true for owner() and faceOwner() by the way. However be careful, the type they return are different, faceOwner returns a list of face when owner returns a list of labels.

The difference between your code and the downwind cell is the indexing:
you do

Code:
forAll(c, fi) // fi goes from 0->8 if 8 faces on cell c


        const scalar phi = faceValue(phi_, fi); // whatever the cell, you wil get only phi[0] .. phi[8] so the 8 first flux of the faces of mesh 

            if (own[fi] == celli)
    {
         ....

    }

}
when they convert to global index: (line facei=c[fi])

Code:
forAll(c, fi)

         const label facei = c[fi];   // for the, lets say 3rd face of the cell c, c[3] is the global index of that face! 
        const scalar phi = faceValue(phi_, facei);

            if (own[facei] == celli)
    {
         ....

    }

}
frobaux 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
[snappyHexMesh] snappyHexMesh sticking point natty_king OpenFOAM Meshing & Mesh Conversion 11 February 20, 2024 10:12
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 06:29
[blockMesh] Create internal faces as patch in blockMesh m.delta68 OpenFOAM Meshing & Mesh Conversion 14 July 12, 2018 15:43
interFoam running blowing up sandy13 OpenFOAM Running, Solving & CFD 2 May 5, 2015 08:16
Suggestion for a new sub-forum at OpenFOAM's Forum wyldckat Site Help, Feedback & Discussions 20 October 28, 2014 10:04


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