|
[Sponsors] |
December 20, 2010, 12:09 |
find the hanging pointer ...
|
#1 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
hi,
this is concerning the very general question about how to find a hanging pointer. I am working on a MultiRegion-Solver, so i was starting from chtMultiRegionsFoam. I followed the pattern in the solver by addressing the pointers first with the appropriate size of the meshRegion with Code:
PtrList<basicPsiThermo> thermoFluid(fluidRegions.size()); Code:
Info<< " Adding to KFluid\n" << endl; KFluid.set ( i, new volScalarField ( IOobject ( "K", runTime.timeName(), fluidRegions[i], IOobject::NO_READ, IOobject::NO_WRITE ), thermoFluid[i].Cp()*thermoFluid[i].alpha() ) ); Code:
fvScalarMatrix tEqn ( -fvm::laplacian(K, T) ); tEqn.relax(); TEqnResidual = tEqn.solve().initialResidual(); The code is compiling but i am receiving an ERROR about: hanging pointer, cannot dereference . So. How to solve this since there are plenty of pointers. Is there a way to find the "bad" one? I just need some general advice where to search or how to look at that problem ... and maybe solving it the next time on my own. Thanks in advance... neewbie |
|
December 21, 2010, 06:43 |
|
#2 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
When I had that error it was always because I got the range of a 'for' loop incorrect and I was trying to access an element in the pointer list that didn't exist. I would check the rangess of the loops you have in your program.
__________________
Laurence R. McGlashan :: Website |
|
January 3, 2011, 04:35 |
|
#3 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
hi,
thanks a lot. I did as you said and ended up in deleting EVERYTHING not necessary ... i´ve made a similar mistake by commenting over more than one line. took me a while to riddle that one out. neewbie |
|
January 23, 2019, 13:38 |
hanging pointer at index 0 (size 3), cannot dereference
|
#4 |
Member
Join Date: Apr 2016
Posts: 30
Rep Power: 10 |
Hi all,
I have been getting this error while my running twoPhaseEulerFoam code. I have added a file called scalarTransport.H that solves for Scalar Transport Equation in addition to solving of the phases. My scalarTransport.H is as follows: Code:
dimensionedScalar dimen ( "dimen", dimensionSet(0,0,1,0,0,0,0), scalar(1.0) ); dimensionedScalar dimen1 ( "dimen1", dimensionSet(0,0,-1,0,0,0,0), scalar(1.0) ); volTensorField grU_2 = (fvc::grad(U2))*dimen; volScalarField sc = grU_2 && (grU_2 + grU_2.T()); const scalar a = 4e-6; dimensionedScalar dir_ste ( "dir_ste", dimensionSet(0,0,2,0,0,0,0), scalar(1.0) ); //const scalar a = 4e-6; const scalar K = 1; volScalarField dsid = 0.7*.3*a*a*sc*alpha2*alpha2*dir_ste*dimen1*dimen1; const scalar dbr = (1.380648e-23)*300/(6*3.142*(1.5e-3)*(4e-6)); volScalarField dbro = ((1.0-alpha2)/(1+0.95*alpha2))*(dbr/K); volScalarField dnp = (dsid + dbro)*DT; fvScalarMatrix scalarEqn ( fvm::ddt(psi) + fvm::div(phi2,psi) - fvm::laplacian(dnp,psi) ); scalarEqn.solve(); Code:
--> FOAM FATAL ERROR: hanging pointer at index 0 (size 3), cannot dereference From function const T& Foam::UPtrList<T>::operator[](Foam::label) const [with T = Foam::fvPatchField<double>; Foam::label = int] in file /usr/local/apps/OpenFOAM/gcc482-v1706/OpenFOAM-v1706/src/OpenFOAM/lnInclude/UPtrListI.H at line 107. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::error::abort() at ??:? #2 Foam::UPtrList<Foam::fvPatchField<double> >::operator[](int) const at ??:? #3 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary::Boundary(Foam::DimensionedField<double, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary const&) at ??:? #4 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:? #5 ? at ??:? #6 __libc_start_main in "/lib64/libc.so.6" #7 ? at ??:? Your help in this matter is greatly appreciated. Thanks and Regards, Shantanu |
|
December 15, 2019, 19:51 |
Hello
|
#5 |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
Dear Shantanu
did you find the answer for your question? thanks, Farzad |
|
August 30, 2020, 09:46 |
|
#6 |
New Member
wanghongjie
Join Date: Apr 2020
Posts: 28
Rep Power: 6 |
||
September 16, 2021, 21:43 |
|
#7 |
New Member
XinZhou
Join Date: Apr 2018
Posts: 10
Rep Power: 8 |
Hi Matthias, Did you find the answer for the same question?
|
|
Tags |
multiregion, pointer |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
FATAL ERROR hanging pointer cannot dereference | tsencic | OpenFOAM Running, Solving & CFD | 8 | January 7, 2021 04:10 |
Hanging pointer | fabianpk | OpenFOAM Running, Solving & CFD | 8 | January 28, 2011 11:29 |
YPlus nowhere to be find | Daniel | CFX | 3 | May 1, 2006 17:22 |
Can U find this Solution Report N°229 | Mohamed | FLUENT | 5 | June 19, 2003 04:28 |
hanging node | Ludovit | FLUENT | 0 | March 26, 2003 13:42 |