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

find the hanging pointer ...

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By l_r_mcglashan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 20, 2010, 12:09
Question find the hanging pointer ...
  #1
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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());
and then setting the pointerlists to the IOobjects by e.g.
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()
                    )
                );
and finally use the local-"region"-variables in the normal manner.
Code:
fvScalarMatrix tEqn
        (
            -fvm::laplacian(K, T)
        );
        tEqn.relax();
        TEqnResidual = tEqn.solve().initialResidual();
Then i added the "solve"-part by including some working header-files.
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
mvoss is offline   Reply With Quote

Old   December 21, 2010, 06:43
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
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.
Kummi and vishalgarg474 like this.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   January 3, 2011, 04:35
Default
  #3
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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
mvoss is offline   Reply With Quote

Old   January 23, 2019, 13:38
Default hanging pointer at index 0 (size 3), cannot dereference
  #4
Member
 
Join Date: Apr 2016
Posts: 30
Rep Power: 10
shanvach is on a distinguished road
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();
The code compiles correctly but gives the following error at runtime.

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 ??:?
How do I rectify this?
Your help in this matter is greatly appreciated.

Thanks and Regards,
Shantanu
shanvach is offline   Reply With Quote

Old   December 15, 2019, 19:51
Default Hello
  #5
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Dear Shantanu
did you find the answer for your question?



thanks,
Farzad
farzadmech is offline   Reply With Quote

Old   August 30, 2020, 09:46
Default
  #6
New Member
 
wanghongjie
Join Date: Apr 2020
Posts: 28
Rep Power: 6
wanghongjie is on a distinguished road
Quote:
Originally Posted by farzadmech View Post
Dear Shantanu
did you find the answer for your question?



thanks,
Farzad
Did you find the answer for the same question?

Thanks!
wanghongjie is offline   Reply With Quote

Old   September 16, 2021, 21:43
Default
  #7
New Member
 
XinZhou
Join Date: Apr 2018
Posts: 10
Rep Power: 8
XinXin is on a distinguished road
Hi Matthias, Did you find the answer for the same question?
XinXin is online now   Reply With Quote

Reply

Tags
multiregion, pointer


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
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


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