|
[Sponsors] |
how to identify neighbors of neighbour cell in openfoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 10, 2021, 00:50 |
how to identify neighbors of neighbour cell in openfoam
|
#1 |
Senior Member
|
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 |
|
July 10, 2021, 01:17 |
|
#2 |
Senior Member
|
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 |
|
|
|
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 |