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

Segmentation Fault error after min-max

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 2 Post By floquation
  • 1 Post By Sugajen
  • 1 Post By PVERMA

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 19, 2014, 08:52
Default Segmentation Fault error after min-max
  #1
New Member
 
Bharat Bhushan Sharma
Join Date: Nov 2014
Posts: 8
Rep Power: 12
bharat.gmail is on a distinguished road
Hello Dear Foamers,

I have been writing one of my solver and am stucked at one place due to segmentation fault error. Given below are the details about this error.

Code:
boundaryField
{
    adiabatic
    {
        type            zeroGradient;
    }
    heater
    {
        type            zeroGradient;
    }
    inlet
    {
        type            zeroGradient;
    }
    outlet
    {
        type            zeroGradient;
    }
    frontAndBack
    {
        type            empty;
    }
}

DILUPBiCG:  Solving for H, Initial residual = 1, Final residual = 1.75168e-16, No Iterations 1
Enthalpy  Min(H) = -2.5054e+23 Max(H) = 5.6046e+36
#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam230/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/opt/openfoam230/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::relativePermeabilityModels::krBrooksAndCorey::correct() in "/root/OpenFOAM/root-2.3.0/platforms/linux64GccDPOpt/lib/libporousModels.so"
#4  
 in "/root/OpenFOAM/root-2.3.0/platforms/linux64GccDPOpt/bin/impesFoam"
#5  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#6  
 in "/root/OpenFOAM/root-2.3.0/platforms/linux64GccDPOpt/bin/impesFoam"
The location mentioned in above error stack is :
Code:
                forAll(H_,i)
                {

              
                    if( ( H_[i] > -ROL_.value()*(scalar(2)*hvsat_.value() - hlsat_.value()) ) && ( (H_[i] < -ROV_.value()*hvsat_.value()) || (H_[i] == -ROV_.value()*hvsat_.value()) ) )
                    {

                        T_[i] = TSAT_.value();

                        dTdH_[i] = scalar(0.0);
                        Sb_[i] = - ( H_[i] + ROV_.value()*hvsat_.value() )/( ROL_.value()*hlg_.value() + (ROL_.value() - ROV_.value())*hvsat_.value() );
                    }

                 }

This piece of code is written inside krBrooksAndCarey.H which contains a derived class called krBrooksAndCarey. This is derived from a base abstract class wherein this H_ is declared as a volScalarField using following:

volScalarField H_

Also the H volscalarField which is a primitive variable for enthalpy equation is declared in createFields.H file as:

volScalarField H
(
IOobject
(
"H",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

I think there is something wrong with H volScalarField. I think there is no connection b/w H_ and H defined separately. I wish them to be representing same field variable. But dont know how to do so.

Can someone help me sortout this problem. I am really stucked.

Bharat
bharat.gmail is offline   Reply With Quote

Old   December 19, 2014, 09:41
Default
  #2
Member
 
Likun
Join Date: Feb 2013
Posts: 52
Rep Power: 13
Likun is on a distinguished road
Send a message via Skype™ to Likun
Hi Bharat,

Just an idea, please make sure that all the variables are properly initialized, sometimes that gives a Segmentation Fault error.

Best,
Likun
Likun is offline   Reply With Quote

Old   December 20, 2014, 01:36
Default
  #3
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 18
Tushar@cfd is on a distinguished road
Hi all,

I agree with Likun, check the initialization of the variables. I think your solver is not able to initialize the variable (in your custom BC) which leads to the segmentation fault. I am not expert on custom BC, anyways I think the error could be in this formulation:

Code:
  forAll(H_,i)  {......}
As, a suggestion I would suggest you to try something like this....

Code:
  forAll(H_.BoundaryField(),i)  {......}
Also set the required internalField for the BC in you case directory. Wish you Best Luck

-
Best Regards!

Last edited by Tushar@cfd; December 20, 2014 at 01:58. Reason: Added a line
Tushar@cfd is offline   Reply With Quote

Old   December 24, 2014, 03:31
Question
  #4
New Member
 
Bharat Bhushan Sharma
Join Date: Nov 2014
Posts: 8
Rep Power: 12
bharat.gmail is on a distinguished road
can the error be due to values out of bound as is printed below ?

Enthalpy Min(H) = -2.5054e+23 Max(H) = 5.6046e+36

Can some one tell me what is the maximum and minimum numerical value supported by openFoam in double or single precision ?
bharat.gmail is offline   Reply With Quote

Old   December 24, 2014, 09:30
Default
  #5
New Member
 
Bharat Bhushan Sharma
Join Date: Nov 2014
Posts: 8
Rep Power: 12
bharat.gmail is on a distinguished road
problem solved....

:-)

Last edited by bharat.gmail; December 24, 2014 at 10:41.
bharat.gmail is offline   Reply With Quote

Old   August 2, 2017, 19:13
Default
  #6
Member
 
Sugajen
Join Date: Jan 2012
Location: Tempe, USA
Posts: 52
Rep Power: 14
Sugajen is on a distinguished road
Hi all,

I have a similar problem. When I initialize a 3D array and run it for n=128, it crashes with Segmentation fault. The exact line where this happens is
Code:
double array[n+2][n+2][n+2];
The code does not throw an error during its compilation. But when running on a case, the error pops up. Also for smaller values of n (64, 32, 16...) it works fine. What could be the problem?

Thanks,
Sugajen
Sugajen is offline   Reply With Quote

Old   August 7, 2017, 04:53
Default
  #7
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 21
floquation will become famous soon enough
Quote:
Originally Posted by Sugajen View Post
Hi all,

I have a similar problem. When I initialize a 3D array and run it for n=128, it crashes with Segmentation fault. The exact line where this happens is
Code:
double array[n+2][n+2][n+2];
The code does not throw an error during its compilation. But when running on a case, the error pops up. Also for smaller values of n (64, 32, 16...) it works fine. What could be the problem?

Thanks,
Sugajen
https://stackoverflow.com/questions/...ge-array-sizes
Ebrahim and Sugajen like this.
floquation is offline   Reply With Quote

Old   August 7, 2017, 15:30
Default
  #8
Member
 
Sugajen
Join Date: Jan 2012
Location: Tempe, USA
Posts: 52
Rep Power: 14
Sugajen is on a distinguished road
Hi all,

I solved my problem using the following way of dynamically allocating a 3D array so that the heap memory is used. If we do a declaration as I had done on my original post, the stack memory will be used which has some memory limitations that could cause segmentation error.
Code:
double ***array = new double**[n+2];
for (int i = 0; i < n+2; i++)
{
    array[i] = new double*[n+2];
    for (int j = 0; j < n+2; j++)
    array[i][j] = new double[n+2];
}
Also, if we use heap memory, we need to explicitly release the memory later, as shown below.
Code:
for(int i = 0; i < n+2; ++i)
{
    for(int j = 0; j < n+2; ++j)
    {
	delete[] array[i][j];
    }
    delete[] array[i];
}
best,
Sugajen
Ebrahim likes this.
Sugajen is offline   Reply With Quote

Old   September 18, 2017, 08:37
Default sigsegv error
  #9
New Member
 
Pooja Verma
Join Date: May 2017
Posts: 13
Rep Power: 9
PVERMA is on a distinguished road
Quote:
Originally Posted by bharat.gmail View Post
problem solved....

:-)
how was the error solved.Iam having the same type of error.
parthigcar likes this.
PVERMA is offline   Reply With Quote

Reply


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
y+ and u+ values with low-Re RANS turbulence models: utility + testcase florian_krause OpenFOAM 114 August 23, 2023 06:37
multiphase turbulance case floating error harsha_kulkarni OpenFOAM Running, Solving & CFD 3 February 18, 2016 06:06
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 03:53
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 22:14
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 18:59.