CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   About Segmentation fault (https://www.cfd-online.com/Forums/openfoam/113127-about-segmentation-fault.html)

mmkr825 February 13, 2013 01:40

About Segmentation fault
 
Hi foamers,
I prepared a solver to fit for my needs. When i compiled, it is giving no errors. But it is giving the following error when i run my case file.

Error Message:

Quote:

malli_reddy@ubuntu:~/OpenFOAM/malli_reddy-2.1.1/run/caseFile$ SBMFoam
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.1.1-221db2718bbb
Exec : SBMFoam
Date : Feb 13 2013
Time : 11:56:40
Host : "ubuntu"
PID : 5375
Case : /home/malli_reddy/OpenFOAM/malli_reddy-2.1.1/run/caseFile
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading transportProperties

Reading field Q

Reading field p

Reading field U

Reading field T

Reading/calculating face flux field phi

No field sources present


SIMPLE: convergence criteria
field p tolerance 1e-05
field U tolerance 1e-05
field T tolerance 1e-05


Starting time loop

Time = 1nl [0 0 -1 0 0 0 0] 0.005626
#0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam211/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/opt/openfoam211/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#2 Uninterpreted:
#3
in "/home/malli_reddy/OpenFOAM/malli_reddy-2.1.1/platforms/linuxGccDPOpt/bin/SBMFoam"
#4 __libc_start_main in "/lib/i386-linux-gnu/libc.so.6"
#5
in "/home/malli_reddy/OpenFOAM/malli_reddy-2.1.1/platforms/linuxGccDPOpt/bin/SBMFoam"
Segmentation fault
Can anyone tell me what this error message trying to convey. Thanks in advance.

Regards
Mallikarjuna

anishtain4 February 13, 2013 03:54

Somewhere in your solver either a divide by zero or a minus in sqrt is happening, this usually happens by setting some physical values in a bad range or some typos (like wrong parenthesis) in solver

mmkr825 February 13, 2013 04:26

Quote:

Originally Posted by anishtain4 (Post 407558)
Somewhere in your solver either a divide by zero or a minus in sqrt is happening, this usually happens by setting some physical values in a bad range or some typos (like wrong parenthesis) in solver

Hi anishtain,
Thanks very much for quick reply. In my solver due to mathematical operations using the Q tensor,
i defined Q as the following:
Quote:

Info<< "Reading field Q\n" << endl;
volTensorField Q
(
IOobject
(
"Q",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedTensor("Q",dimensionSet(0,0,0,0,0,0,0), tensor(0,0,0,0,0,0,0,0,0))
);
Actually Q is not a null matrix. Mathematically Q is (1, 0, 0, 0, 0.8, 0, 0, 0, 0.5). So i defined Q for the boundaries and internal fields inside the source code
for example in my code i did as the following:
Lets assume a boundary named "upperWall" then

Quote:

label upperWall = mesh.boundaryMesh().findPatchID("upperWall");
// upperWall
forAll(mesh.boundaryMesh()[upperWall],i)
{
Q.boundaryField()[upperWall][i].component(tensor::XX) = 1; //or any other values
Q.boundaryField()[upperWall][i].component(tensor::XY) = 0;
Q.boundaryField()[upperWall][i].component(tensor::XZ) = 0;
Q.boundaryField()[upperWall][i].component(tensor::YX) = 0;
Q.boundaryField()[upperWall][i].component(tensor::YY) = 0.8;
Q.boundaryField()[upperWall][i].component(tensor::YZ) = 0;
Q.boundaryField()[upperWall][i].component(tensor::ZX) = 0;
Q.boundaryField()[upperWall][i].component(tensor::ZY) = 0;
Q.boundaryField()[upperWall][i].component(tensor::ZZ) = 0.5;
}
in addition to the internal field:
Quote:

// assign Q on internal Field
/////////////////////////////////////////////////////////
forAll(mesh.cells(),j)
{
Q[j].component(tensor::XX) = 1;
Q[j].component(tensor::XY) = 0;
Q[j].component(tensor::XZ) = 0;
Q[j].component(tensor::YX) = 0;
Q[j].component(tensor::YY) = 0.8;
Q[j].component(tensor::YZ) = 0;
Q[j].component(tensor::ZX) = 0;
Q[j].component(tensor::ZY) = 0;
Q[j].component(tensor::ZZ) = 0.5;
}
//////////////////////////////////////////////////////////
I got this error when i defined as above.
I defined Q in the createFields.H directory and Q for the boundaries and internal fields inside the source code (in UEqn.H directory in my solver). I have doubt whether my approach is correct or not. Could you please tell me what the error message trying to convey.


Thanks
Mallikarjuna

anishtain4 February 13, 2013 05:08

I'm not sure what you're trying to do, so a comment about your solver would be somehow irrelevant. However I believe defining boundary conditions in the solver is not a good idea since you have to compile the whole solver with every change. That is not the idea behind openfoam, on the other hand you are not trying to write a solver to be included in openfoam distributions so it is not bad to first make it work and then putting some structure in it.

I suggest you to put some Info << in different lines of your solver to spot the line which is causing the break down, then you can scrutinize the line and spot the bug.

adhiraj February 13, 2013 08:52

The error seems to be a segmentation fault. This means that there is some memory issue.
I would compile the code in debug mode and use a tool like gdb to fix this.

mmkr825 February 13, 2013 16:05

Quote:

Originally Posted by adhiraj (Post 407617)
The error seems to be a segmentation fault. This means that there is some memory issue.
I would compile the code in debug mode and use a tool like gdb to fix this.

Hi,
Thanks very much for reply. Actually i am very fresher to openFoam. From your message i understood that i did message in debugging. i studied this error in http://openfoamwiki.net/index.php/Main_FAQ but i am not able to notify this error. from this i know my basics is very poor. But can you you please tell me what actually it refers to.

anishtain4 February 14, 2013 01:29

It means a mathematically illegal operation has been done

cutter February 14, 2013 04:43

No, the error message from the first post explicitly says segmentation fault. In my optinion probably illegal memory access due to wrong array indexing. Mathematically illegal operations (division by zero etc..) usually result in floating point exceptions. Consult Wikipedia for a a nice introduction to both error types.

mmkr825 February 14, 2013 08:25

Hi cutter,
I studied about the error. For the full debug i need to set
WM_COMPILE_OPTION=Debug in the bashrc. But in bashrc i am not able to edit that part. Even though it is showing "USER EDITABLE PART", but it is not editing. can you please tell me to solve this problem.

Regards
Mallikarjuna



All times are GMT -4. The time now is 13:27.