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

how to identify neighbors of neighbour cell in openfoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 10, 2021, 00:50
Question how to identify neighbors of neighbour cell in openfoam
  #1
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 355
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Hello Foamers,
Assuming a 1D mesh. Lets say,

P = point (Actual)
nW = west point
nE = east point
nW2 = west neighbor of west point - unable to access ?

Here is the sample code:

//************************************************** ************************//
Foam::Map<label> niTable0, niTable1, niTable2; // index tables
forAll(T_, cellI)
{
const Foam::List<label> neigbhorcellI = regionMesh().cellCells(cellI);
label nW = -1, nE = -1, nW2 = -1;

forAll(neigbhorcellI, I)
{
const label nI = neigbhorcellI[I];
if (regionMesh().cellCentres()[nI][0] < regionMesh().cellCentres()[cellI][0])
{
nW = nI; // accessing WEST point
}

if (regionMesh().cellCentres()[nI][0] > regionMesh().cellCentres()[cellI][0])
{
nE = nI; // accessing EAST point
}

if (regionMesh().cellCentres()[nI][1] < regionMesh().cellCentres()[cellI][0])
{
nW2 = nI; // couldn't able to access neighbor of WEST point
}
//if (nW >= 0 && nE >= 0&& nW2 >= 0) break;
}
niTable0.insert(cellI, nW);
niTable1.insert(cellI, nE);
niTable2.insert(cellI, nW2);

Info << "check: " << nW2 << " " << nW << " " << cellI << " " << nE << endl;

if (T_[cellI] =100)
{
T_[nW] = T_[nW] - XX *(T_[nW2] - T_[cellI]) / 2; ----> EQU. (1)
//T(I)=T(I)- XX*(T(I-1)-T(I+1))/2;
}
}

No errors during compilation. But while running the case file, the following ERROR occurs at EQU. (1):


//************************************************** ***********//
--> FOAM FATAL ERROR:
index -1 out of range 0 ... 11

From function UList<T>::checkIndex(const label)
in file /home/kummi/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/UListI.H at line 109.

FOAM aborting

#0 Foam::error:rintStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-2.1.1/src/OSspecific/POSIX/printStack.C:201
#1 Foam::error::abort() at ~/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/error.C:249
#2 Foam::Ostream& Foam:perator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) at ~/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/errorManip.H:85 (discriminator 3)
#3 Foam::UList<double>::checkIndex(int) const at ~/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/UListI.H:113
#4 Foam::UList<double>:perator[](int) at ~/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/UListI.H:168
//************************************************** ***********//

The above error says that @UlistI.H at line 109,

FatalErrorIn("UList<T>::checkIndex(const label)")
<< "index " << i << " out of range 0 ... " << size_-1
<< abort(FatalError);


So, ERROR is related to the size. I'm trying to access something which is out of range.



LOG file printed while running the case:

//************************************************** ***********//
Time = 1
Solving for solid region furnace
Min/max T:min(T) [0 0 0 1 0 0 0] 293 max(T) [0 0 0 1 0 0 0] 1323

Solving for pyrosolid region oven

Evolving reactingOneDim for region oven

Evolving pyrolysis in region: oven
Initial/final volumes = 0.151494, 0.151494 [m3]
Initialisation
check: -1 -1 0 1
check: -1 0 1 2
check: -1 1 2 3
check: -1 2 3 4
check: -1 3 4 5
check: -1 4 5 6
check: -1 5 6 7
check: -1 6 7 8
check: -1 7 8 9
check: -1 8 9 10
check: -1 9 10 11
check: -1 10 11 -1
//Info << "check: " << nW2 << " " << nW << " " << cellI << " " << nE << endl;

Here the log file clearly says that, nW2 = west neighbor of west point is not accessed at EQU. (1).
//************************************************** ***********//
Can someone help me out here ?
Thank you
Kummi is offline   Reply With Quote

Old   July 10, 2021, 01:17
Default
  #2
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 355
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Following the above post, I declared nW2 in different way as,

if (T_[cellI] =100)
{
label nW = niTable0[cellI]; //T(I-1)
label nW2 = niTable0[nW]; //T(I-2)
Info << "check2: " << nW2 << " " << nW << " " << cellI << endl;

T_[nW] = T_[nW] - XX *(T_[nW2] - T_[cellI]) / 2; ----> EQU. (1)
//T(I)=T(I)- XX*(T(I-1)-T(I+1))/2;
}

The error continue prevailing at EQU. (1):

and here is the LOG file printed while running the case:
//************************************************** ***********//
Time = 740
Solving for solid region furnace
Min/max T:min(T) [0 0 0 1 0 0 0] 293 max(T) [0 0 0 1 0 0 0] 1323

check2: -1 0 1

//Info << "check2: " << nW2 << " " << nW << " " << cellI << endl;
//************************************************** ***********//
The printed statement at check 2 looks reasonable accessing nW2 = west neighbor of west point.

But, I don't know why the case suddenly stops at t =740s after printing check2 statement. Kindly someone share your ideas please.
Thank you
Kummi 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
UDF in case with DPM modle POSTHU Fluent UDF and Scheme Programming 0 March 3, 2021 08:21
[Technical] How to identify cell neighbours booz OpenFOAM Meshing & Mesh Conversion 59 November 20, 2017 01:40
Neighboring cells in tetrahedral mesh vishwesh OpenFOAM Programming & Development 9 November 10, 2017 08:06
How to identify boundary cell and internal cell dbxmcf OpenFOAM Running, Solving & CFD 2 November 6, 2016 10:11
[Other] cgnsToFoam problems with "QUAD_4" cells lentschi OpenFOAM Meshing & Mesh Conversion 1 March 9, 2011 05:49


All times are GMT -4. The time now is 14:53.