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

multiplication printstack error

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 4, 2014, 04:33
Default multiplication printstack error
  #1
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
Hello

I declared two volScalarfields in createFields.H, namely:
Code:
volScalarField r
(
    IOobject
    (
        "r",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh,
    dimensionedScalar("0", dimLength, 1.0)
)
and

Code:
volScalarField faceCellDist
    (
        IOobject
        (
            "faceCellDist", 
            runTime.timeName(), 
            mesh, 
            IOobject::NO_READ, 
            IOobject::NO_WRITE
        ), 
        mesh, 
        dimensionedScalar
        ("0", dimLength, 1.0)
    );
Then I determine distance from cell centre to cell face and store it in "faceCellDist". This is to get delta x, y and z by multiply "faceCellDist" by 2. And assign a constant (initial value) to "r":

Code:
const surfaceVectorField& Cf  = mesh.Cf();
const volVectorField& C = mesh.C();
const labelList& own = mesh.owner();
forAll (own, I)
    {
        faceCellDist[I] = Foam::mag(C[own[I]] - Cf[I]);
        faceCellDist[I+1]=faceCellDist[I];
    }
The second line "faceCellDist[I+1]=faceCellDist[I];" is to set the last element, otherwise it stays 0 (zero).

and the initial value for "r":
Code:
r=r*id.value()/2;
where "id.value()" is just a constant from test case.

My printStack (multiply) error comes when I do:
Code:
r*faceCellDist
Any suggestions?
Vrede
PicklER is offline   Reply With Quote

Old   September 4, 2014, 12:53
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
printStack is not the error. What is the error? Was it a segmentation fault? (SigSEGV) or a floating point error? (SigFPE) The forAll(own, I) loop will cause a segmentation fault when it reaches the final index (i = faceCellDist.size()-1)... because I+1 will be out of range.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 5, 2014, 02:01
Default
  #3
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
Good morning David.

Thank you for the quick reply. The error is as follows:

#0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigSegv::sigHandler(int) at ??:?
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 Foam::multiply(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#4 void Foam::multiply<Foam::fvPatchField>(Foam::FieldFiel d<Foam::fvPatchField, double>&, Foam::FieldField<Foam::fvPatchField, double> const&, Foam::FieldField<Foam::fvPatchField, double> const&) at ??:?
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#6
at ??:?
#7 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8
at ??:?
Segmentation fault (core dumped)

Weirdly enough, the forAll loop does not give me an error, since it run successfully through the loop.

Note: When I did this for a "1D" test case (shock tube tutorial of rhoCentralFoam), I did not have this error. Only when I went to "2D" (30 cells in x-dir, 3 in y-dir and 1 cell in z-dir) that this error showed.

Kind regards
PicklER is offline   Reply With Quote

Old   September 5, 2014, 03:22
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
Ah, I see. It's a segmentation fault. Opt doesn't always throw an error exactly where the bug is. You could try running in debug mode. And you should fix your forall loop.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   December 14, 2015, 12:50
Default
  #5
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Dear all,

what if it's a floating point error?

such as

Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::multiply(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#4  
 at ??:?
#5  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
#6  
 at ??:?
#7  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8  
 at ??:?
Floating point exception (core dumped)
Best,
Sandra
sabago is offline   Reply With Quote

Old   December 28, 2015, 12:08
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick answer:
Quote:
Originally Posted by sabago View Post
what if it's a floating point error?
such as
Correct, it's a signal for Floating Point Error: "sigFpe"
Quote:
Originally Posted by sabago View Post
Code:
#1  Foam::sigFpe::sigHandler(int) at ??:?
Occurred while multiplying two lists of double values:
Quote:
Originally Posted by sabago View Post
Code:
#3  Foam::multiply(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
The two lists are actually two volume fields, identified with the type "GeometricField< ... volMesh>":
Quote:
Originally Posted by sabago View Post
Code:
#5  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
In order for this to occur, either one of the values was Not-a-Number (NaN) or Infinite (Inf).

If you have access to the source code for the equation where this product occurs, you can try using old school debugging, as... I've already explained here: http://www.cfd-online.com/Forums/ope...tml#post577363 post #3
SHUBHAM9595 likes this.
wyldckat is offline   Reply With Quote

Old   December 29, 2015, 13:15
Default
  #7
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Forgot to update that I fixed this.

Issue was that the fields being multiplied were of different sizes so I fixed that.

Best,
Sandra
sabago is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[blockMesh] blockMesh with double grading. spwater OpenFOAM Meshing & Mesh Conversion 92 January 12, 2019 09:00
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 11:39
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 18:00
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 09:17
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08


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