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

Neighbour cell centre to face distance

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By KlasJ
  • 1 Post By fportela

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 15, 2013, 16:03
Default Neighbour cell centre to face distance
  #1
Member
 
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 13
fportela is on a distinguished road
Hello all,

I feel my question is rather simple, but I've trying to solve this for quite a while without any success, so maybe you guys can help.

Consider two patches which are coupled, I need to know the distance between points A and B, where A is the centre of the cells which contain faces on the neighbour patch, and B is the centre of the faces on the neighbour patch.

I could just use the distance from A to the current faces, however, this becomes a problem whenever cyclic conditions come into play...

So, any suggestions?

Cheers,
Felipe
fportela is offline   Reply With Quote

Old   July 19, 2013, 10:44
Default
  #2
New Member
 
Klas J
Join Date: Oct 2011
Location: Göteborg, Sweden
Posts: 10
Rep Power: 15
KlasJ is on a distinguished road
Hi Felipe,

I am not sure that I interpret your question correctly. You want to get the distance from the cell next to the coupled patch to face centre on the neighbouring face?

Perhaps you could be helped by looking at the implementation of the patches. For example have a look at the function delta in the cyclic patch (src/finiteVolume/lnInclude/cyclicFvPatch.C). There you can see how the distance between the cells is calculated as a sum between the distance from the cell to the face for each side of the interface.

Note that the function delta has different meaning depending on the type of patch (src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H):

Code:
//- Return cell-centre to face-centre vector
//  except for coupled patches for which the cell-centre
//  to coupled-cell-centre vector is returned
virtual tmp<vectorField> delta() const;
Hope this was of some help.

Best regards,

Klas
KlasJ is offline   Reply With Quote

Old   July 19, 2013, 11:11
Default
  #3
Member
 
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 13
fportela is on a distinguished road
Hi Klas,

In fact, what I needed was not the cell-centre to coupled-cell vector (which can be obtained directly from delta()), but rather the coupled-cell-centre to coupled-cell-face vector (the face would be that which is coupled to the original cell).

In the meanwhile the following procedure seems to work:

Code:
myPatch.fvPatch::delta() - myPatch.delta();
Where myPatch is a coupled patch.

Nevertheless, thanks for the swift reply

Cheers,
Felipe
fportela is offline   Reply With Quote

Old   July 19, 2013, 11:35
Default
  #4
New Member
 
Klas J
Join Date: Oct 2011
Location: Göteborg, Sweden
Posts: 10
Rep Power: 15
KlasJ is on a distinguished road
Hi again,

Aha, I understand now.

Yes, it seems reasonable that what you are using works. As found in cyclicFvPatch.C you could get a reference to the neighbouring patch and then ask the patch for delta:

Code:
    const cyclicFvPatch& nbrPatch = neighbFvPatch();
    const scalarField deltas(nf() & fvPatch::delta());
    const scalarField nbrDeltas(nbrPatch.nf() & nbrPatch.fvPatch::delta());
But also since the coupled delta will anyway only be the difference of the fvPatch::delta for each patch what you are doing should be the same thing.

// Klas
fportela likes this.
KlasJ is offline   Reply With Quote

Old   April 15, 2014, 12:52
Default
  #5
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear Klas,

About the returned quantities of function delta(), I also read the source files fvPatch.H and fvPatch.C. In the latter, the delta is defined as:

Code:
Cf-Cn
According to fvPatch.H, Cf is face centers while Cn is the neighboring cell centers. I have a question here. for those physical boundary faces (like inlet, outlet, wall..., not inter-processor faces), the cell that contains the boundary faces is always thought of as the owner cell. So here what does it mean by "Cn is the neighboring cell centers"?

After digging the source files, I found that

- for physical boundary faces: delat is Cf-Cn. That is, the delta vector points from the cell (which contains this face) to the face center.
- for inter-processor faces: delta is the vector from the owner (located in the local processor) to the neighbor cells (located in the neighboring processor).

Is what I am saying correct? Any comments are welcome.
~~~~
OFFO
openfoammaofnepo is offline   Reply With Quote

Old   May 28, 2018, 04:11
Default
  #6
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 17
Elham is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Dear Klas,

About the returned quantities of function delta(), I also read the source files fvPatch.H and fvPatch.C. In the latter, the delta is defined as:

Code:
Cf-Cn
According to fvPatch.H, Cf is face centers while Cn is the neighboring cell centers. I have a question here. for those physical boundary faces (like inlet, outlet, wall..., not inter-processor faces), the cell that contains the boundary faces is always thought of as the owner cell. So here what does it mean by "Cn is the neighboring cell centers"?

After digging the source files, I found that

- for physical boundary faces: delat is Cf-Cn. That is, the delta vector points from the cell (which contains this face) to the face center.
- for inter-processor faces: delta is the vector from the owner (located in the local processor) to the neighbor cells (located in the neighboring processor).

Is what I am saying correct? Any comments are welcome.
~~~~
OFFO
Hi,

Anybody knows how to get the distance between two neighbor cells?

Regards,

Elham
Elham is offline   Reply With Quote

Old   May 30, 2018, 08:10
Default
  #7
Member
 
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 13
fportela is on a distinguished road
Quote:
Originally Posted by Elham View Post
Hi,Anybody knows how to get the distance between two neighbor cells?

Regards,

Elham
Hi Elham,

If you know the cell numbers then you can get the cell centres through

Code:
mesh.C[cellI]
then subtract accordingly. You may need to use something like

Code:
mesh.cellCells()[cellI]
to get the cell numbers you want.
fportela is offline   Reply With Quote

Old   May 30, 2018, 11:14
Default
  #8
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 17
Elham is on a distinguished road
Quote:
Originally Posted by fportela View Post
Hi Elham,

If you know the cell numbers then you can get the cell centres through

Code:
mesh.C[cellI]
then subtract accordingly. You may need to use something like

Code:
mesh.cellCells()[cellI]
to get the cell numbers you want.
Thank you for the reply. The problem is that I don't know the cell number and it is not constant and changes during the simulation.

Cheers,

Elham
Elham is offline   Reply With Quote

Old   May 30, 2018, 11:20
Default
  #9
Member
 
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 13
fportela is on a distinguished road
You asked about getting the distance between two neighbour cells, how do you identify the cells between which you want to compute the distance?

Quote:
Originally Posted by Elham View Post
Thank you for the reply. The problem is that I don't know the cell number and it is not constant and changes during the simulation.

Cheers,

Elham
fportela is offline   Reply With Quote

Old   May 30, 2018, 22:01
Default
  #10
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 17
Elham is on a distinguished road
Quote:
Originally Posted by fportela View Post
You asked about getting the distance between two neighbour cells, how do you identify the cells between which you want to compute the distance?

I have multiphase flow. alpha which is the volume fraction of liquid should be less than one in one of the cells and zero in the neighbour.
Elham is offline   Reply With Quote

Old   May 31, 2018, 09:03
Default
  #11
Member
 
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 13
fportela is on a distinguished road
Quote:
Originally Posted by Elham View Post
I have multiphase flow. alpha which is the volume fraction of liquid should be less than one in one of the cells and zero in the neighbour.

Hi Elham,


Wouldn't a brute force approach consist on simply looping over all cells

Code:
forAll( mesh.C(), cellI)
check if alpha is zero, if so, loop over the neighbours
Code:
forAll( mesh.cellCells()[cellI], cellJ)
and then compute what you need?


You may want to have a look at this thread: Cells loop
Elham likes this.
fportela is offline   Reply With Quote

Old   May 31, 2018, 10:11
Default
  #12
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 17
Elham is on a distinguished road
Quote:
Originally Posted by fportela View Post
Hi Elham,


Wouldn't a brute force approach consist on simply looping over all cells

Code:
forAll( mesh.C(), cellI)
check if alpha is zero, if so, loop over the neighbours
Code:
forAll( mesh.cellCells()[cellI], cellJ)
and then compute what you need?


You may want to have a look at this thread: Cells loop
Thanks for your help.
Elham 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
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 07:09
Hydrostatic Pressure and Gravity miliante OpenFOAM Running, Solving & CFD 132 October 7, 2012 23:50
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 15:11
Cell face values computation un unstructured grids Sergio Rossi Main CFD Forum 2 May 28, 2006 11:04
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


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