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

Neighboring cells in tetrahedral mesh

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 7, 2017, 02:22
Default Neighboring cells in tetrahedral mesh
  #1
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
Hi!

I have made a solver which detects bubbles by processing alpha values in neighboring cells of a cell. The solver was able to detect bubbles perfectly fine in case of hexahedral mesh but since I had to use solidParticleCloud, I had to shift to tet mesh.

Possibly because of different mesh shapes, the solver is not working now. To give an idea, refer to the output below:

Code:
celli: 2039
Ln:
4(345369 345434 564382 634467)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18412
Ln:
4(260796 420035 573797 727185)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18414
Ln:
4(6960 189210 548341 707410)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18416
Ln:
4(425818 580563 592269 689665)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18420
Ln:
4(260822 419775 420033 523705)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18448
Ln:
3(16048 196727 778818)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18452
Ln:
4(667653 772748 772760 790930)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18457
Ln:
4(14174 362795 974648 974793)
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
[0] numFound = 0
celli: 18459
Here numFound refers to the number of neighboring cells (Ln) found in a table HT. Now, though it will sound absurd, the cell ID 18457, 18459, and similarly 18412,18414,18416, etc. should be close enough to belong one bubble only. This method was working fine in hex mesh because the neighboring cells used to be one cell up, down, left, right, but in tet mesh this is not the case.

Does anyone have any idea how I can deal with this issue?
I am using OF-3.0.x.
Thanks
vishwesh is offline   Reply With Quote

Old   November 7, 2017, 02:29
Default
  #2
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
To give a further insight into the problem, please refer to the output below:

Code:
[3] alpha: 1
[3] cell index: 13133
[3] cell coordinates: (0.163688 0.101267 0.1049)
[3] Cell ID: 13133
[3] L after appending:
[3] 1(13133)
[3] alpha: 1
[3] cell index: 13140
[3] cell coordinates: (0.161886 0.106077 0.105283)
[3] Cell ID: 13140
[3] L after appending:
[3] 2(13133 13140)
[3] alpha: 1
[3] cell index: 14816
[3] cell coordinates: (0.162433 0.105709 0.0988331)
[3] Cell ID: 14816
[3] L after appending:
[3] 3(13133 13140 14816)
[3] alpha: 1
[3] cell index: 14848
[3] cell coordinates: (0.162409 0.104484 0.094236)
[3] Cell ID: 14848
[3] L after appending:
[3] 4(13133 13140 14816 14848)
[3] alpha: 1
[3] cell index: 14862
[3] cell coordinates: (0.160048 0.105785 0.0953162)
[3] Cell ID: 14862
[3] L after appending:
[3] 5(13133 13140 14816 14848 14862)
[3] alpha: 1
[3] cell index: 16860
[3] cell coordinates: (0.148356 0.109793 0.106328)
[3] Cell ID: 16860
[3] L after appending:
[3] 6(13133 13140 14816 14848 14862 16860)
[3] alpha: 1
[3] cell index: 16879
[3] cell coordinates: (0.147008 0.109767 0.107035)
[3] Cell ID: 16879
[3] L after appending:
[3] 7(13133 13140 14816 14848 14862 16860 16879)
[3] alpha: 1
[3] cell index: 16883
[3] cell coordinates: (0.148723 0.108188 0.104843)
[3] Cell ID: 16883
[3] L after appending:
[3] 8(13133 13140 14816 14848 14862 16860 16879 16883)
[3] alpha: 1
[3] cell index: 16910
[3] cell coordinates: (0.146382 0.109608 0.106518)
[3] Cell ID: 16910
[3] L after appending:
[3] 9(13133 13140 14816 14848 14862 16860 16879 16883 16910)
[3] alpha: 1
[3] cell index: 19050
[3] cell coordinates: (0.141517 0.109738 0.0960398)
[3] Cell ID: 19050
[3] L after appending:
[3] 10(13133 13140 14816 14848 14862 16860 16879 16883 16910 19050)
[3] alpha: 1
[3] cell index: 19067
[3] cell coordinates: (0.141351 0.110091 0.0991054)
As you can see from the cell Index and cell coordinates, there are plenty of cells close to each other and having alpha 1.
vishwesh is offline   Reply With Quote

Old   November 7, 2017, 04:54
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi Vishwesh,

FOAM gives you the possibility to get the ID`s of your cell neighbors directly (e.g. we need that information in the solvers too). You should be able to access the ID`s using the cellCells() function:

Code:
const labelList& neighborCells = mesh.cellCells()[cellID]
It is a while ago I was using that but it should be the function you are searching for. Let us know if that was what you were searching for. The function is inherit by the primitiveMesh class.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   November 7, 2017, 05:44
Default
  #4
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hi Vishwesh,

FOAM gives you the possibility to get the ID`s of your cell neighbors directly (e.g. we need that information in the solvers too). You should be able to access the ID`s using the cellCells() function:

Code:
const labelList& neighborCells = mesh.cellCells()[cellID]
It is a while ago I was using that but it should be the function you are searching for. Let us know if that was what you were searching for. The function is inherit by the primitiveMesh class.
Hi Tobi!

I am using that only. The only trouble I am having is that when I am using hex mesh and cellCells(), I am able to detect the cells belonging to a droplet by processing the alpha value of neighboring cells but when I am using tet mesh on the same geometry, it's showing that there are no neighboring cells having alpha > 0, which is not possible.
vishwesh is offline   Reply With Quote

Old   November 8, 2017, 00:21
Default
  #5
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
Hi!

I tried printing the alpha values of the neighboring cells of various cellIDs which already have alpha.water 1.

Here are the results (just a part of it. Rest of the results are exactly same with different celli, Ln and cellni)

Code:
celli: 453512
Ln:
4(156990 283120 431180 453513)
[0] cellni: 156990 alpha: 0
[0] numFound = 0
[0] cellni: 283120 alpha: 0
[0] numFound = 0
[0] cellni: 431180 alpha: 0
[0] numFound = 0
[0] cellni: 453513 alpha: 0
[0] numFound = 0
celli: 453513
Ln:
4(109571 453510 453512 471764)
[0] cellni: 109571 alpha: 0
[0] numFound = 0
[0] cellni: 453510 alpha: 0
[0] numFound = 0
[0] cellni: 453512 alpha: 0
[0] numFound = 1
[0] cellni: 471764 alpha: 0
[0] numFound = 1
celli: 453515
Ln:
4(182847 283134 453514 738318)
[0] cellni: 182847 alpha: 0
[0] numFound = 0
[0] cellni: 283134 alpha: 0
[0] numFound = 0
[0] cellni: 453514 alpha: 0
[0] numFound = 0
[0] cellni: 738318 alpha: 0
[0] numFound = 0
celli: 453789
Ln:
4(297385 297413 414867 456010)
[0] cellni: 297385 alpha: 0
[0] numFound = 0
[0] cellni: 297413 alpha: 0
[0] numFound = 0
[0] cellni: 414867 alpha: 0
[0] numFound = 0
[0] cellni: 456010 alpha: 0
[0] numFound = 0
I am also attaching a wiremesh representation of the droplet. As you can see there are neighboring cells with non-zero alpha.

And the code that I am using to print the above output:

Code:
        forAll(Lnew,celli){

                DynamicList<label> Ln(0); //Initialization
                if (DEBUG){
                Info<<"celli: "<<Lnew[celli]<<endl;
                }

                Ln.append(mesh.cellCells()[Lnew[celli]]);

                if(DEBUG){
                        Info<<"Ln:"<<endl<<Ln<<endl;
                }

                int numFound=0;

                forAll(Ln, cellni){ //neighbors
                        Pout<<"cellni: "<<Ln[cellni]<<" alpha: "<<alpha1[Ln[cellni]]<<endl;
                        if(HT.found(Ln[cellni])){
                                numFound++;
                                LnHT.append(Ln[cellni]);
                        }
                        Pout<<"numFound = " << numFound << endl;
                }
Here, Lnew is the list of all cells with alpha more than ALPHA_LIM (0.3 in my case).
Attached Images
File Type: jpg drop.jpg (195.0 KB, 14 views)
vishwesh is offline   Reply With Quote

Old   November 8, 2017, 03:56
Default
  #6
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

so as far as I understand this, you could have cells as neighbors having alpha equal to zero or larger than that value? If I think about a droplet placed in a mesh, there are some cells (at the interface) which might have 0.4 and the neighbor cells might have zero or values larger than zero. I am sorry but I did not get the problematic?
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   November 8, 2017, 04:02
Default
  #7
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hi,

so as far as I understand this, you could have cells as neighbors having alpha equal to zero or larger than that value? If I think about a droplet placed in a mesh, there are some cells (at the interface) which might have 0.4 and the neighbor cells might have zero or values larger than zero. I am sorry but I did not get the problematic?
Hi Tobi!

So basically, I should have some neighboring cells with alpha value more than 0.3. But after using cellCells, it looks as if I have no neighboring cell with alpha value not 0.
I understand that cellCells should work properly, so there are a few possibilities I think where I am going wrong:

1. The geometry is wrong. It's the first time I used SALOME, so I might be wrong. But I don't think this is the case. I viewed my geometry and everything in Paraview and it looks okay.
2. Somehow the cellIDs are changing during runtime which I don't think is possible.
3. cellCells() is giving me incorrect neighboring cells or there is some issue related to it.

Frankly speaking I have no clue what is the reason...
vishwesh is offline   Reply With Quote

Old   November 10, 2017, 00:27
Default
  #8
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
I think I have found out the problem. It looks like the issue is with the parallel run which decomposes the domain and is causing some problems with either the cell index or something else.

I tried the same solver for domain without parallel run and it works fine. Any ideas what might the issue?

Thanks
vishwesh is offline   Reply With Quote

Old   November 10, 2017, 08:01
Default
  #9
Member
 
Rodrigo
Join Date: Mar 2010
Posts: 98
Rep Power: 16
guin is on a distinguished road
Check: did you try using globalIndex ? Here you have an example for the cell number "0" at every process (keep in mind that code is executed by every process simultaneously)

Code:
#include "globalIndex.H"

...

globalIndex globalNumbering (mesh.nCells());

...

label localCellID (0);
//Note that every process will have a different cell at the initial position
//however, every process refers the 1st cell in his sub-domain as ID "0"

...

label globalCelllID = globalNumbering.toGlobal(localCellID);

...

label localCellIDagain= globalNumbering.toLocal(globalCelllID);
guin is offline   Reply With Quote

Old   November 10, 2017, 08:06
Default
  #10
Member
 
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 9
vishwesh is on a distinguished road
Thank you for the reply. I will definitely give it a shot. Now my query is how do I use global index to find out let's say alpha for some cell even if assume that the cell doesn't belong to the domain of the master processor that i am using for calculation. More details are here: Doubt about parallel processing
vishwesh is offline   Reply With Quote

Reply

Tags
lagrangian, tet mesh


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
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 06:38
Problem with divergence TDK FLUENT 13 December 14, 2018 07:00
[snappyHexMesh] Number of cells in mesh don't match with size of cellLevel colinB OpenFOAM Meshing & Mesh Conversion 14 December 12, 2018 09:07
[snappyHexMesh] sHM layer process keeps getting killed MBttR OpenFOAM Meshing & Mesh Conversion 4 August 15, 2016 04:21
[snappyHexMesh] SnappyHexMesh for internal Flow vishwa OpenFOAM Meshing & Mesh Conversion 24 June 27, 2016 09:54


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