Hello Foamers,
In my work, I accessed neighbor cells. Here is the sample code for 1D problem.
//************************************************//
Foam::Map<label> niTableW, niTableE; // index tables
forAll(T_, cellI)
{
const Foam::List<label> neigbhorcellI = regionMesh().cellCells(cellI);
label nIW = -1, nIE = -1;
forAll(neigbhorcellI, I)
{
const label nI = neigbhorcellI[I];
if (regionMesh().cellCentres()[nI][0] < regionMesh().cellCentres()[cellI][0])
{
nIW = nI;
}
if (regionMesh().cellCentres()[nI][0] > regionMesh().cellCentres()[cellI][0])
{
nIE = nI;
}
//if (nIW >= 0 && nIE >= 0) break;
}
niTableW.insert(cellI, nIW);
niTableE.insert(cellI, nIE);
///////////////////////////////////////////
if (T_[cellI] == Tliq && alpha_[cellI] > scalar(0.0)
{
QB_[cellI] = K_[nIW]* ((T_[nIW] - Tliq) /DX.value());
QBMAX_[cellI] = (Lboil.value()* (DX.value() - XB_[cellI]) *RHOO.value() *alpha_[cellI] ) /dtime;
}
if (T_[nIE] < Tliq)
{
QC_[cellI] = K_[nIE]* ((Tliq - T_[nIE]) /DX.value());
QERR_[cellI] = QB_[cellI] - QC_[cellI];
}
//************************************************//
Hereby attaching the figure, where
nI = reference plane at 100deg (from where neighbor cells are accessed)
nIW = west node
nIE = east node
As per the figure and above description of code, when the OpenFOAM try to access east node (nIE) at the end of the domain, the error appears as following,
//************************************************//
-->
FOAM FATAL ERROR:
index -1 out of range 0 ... 13From function UList<T>::checkIndex(const label)
in file /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/UListI.H at line 109.
//************************************************//
And this error is reasonable. How to inform/code OpenFOAM not to access the last node (near the boundary), in order to avoid this error..
If someone can share the thoughts to resolve this error, it will be highly helpful.Thank you