CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing Format & General Technical (http://www.cfd-online.com/Forums/openfoam-meshing-technical/)
-   -   Segmentation fault in map (http://www.cfd-online.com/Forums/openfoam-meshing-technical/61917-segmentation-fault-map.html)

msg30 November 27, 2007 16:06

Hi! Has anybody seen this b
 
Hi!

Has anybody seen this before:

Mapping field (internal) U_0 (ok!)
Mapping field (patch) U_0
#0 Foam::error::printStack(Foam:http://www.cfd-online.com/OpenFOAM_D...part/proud.gifstream&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/OSspecific/Unix/printStack.C:203
#1 Foam::sigSegv::sigSegvHandler(int) at ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/OSspecific/Unix/signals/sigSegv.C:59
#2 ?? in "/lib64/libc.so.6"
#3 Foam::Field<foam::vector<double> >::map(Foam::UList<foam::vector<double> > const&, Foam::List<foam::list<int> > const&, Foam::List<foam::list<double> > const&) in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/ftLMPs"
#4 Foam::Field<foam::vector<double> >::autoMap(Foam::FieldMapper const&) in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/ftLMPs"
#5 Foam::pressureInletOutletVelocityFvPatchVectorFiel d::autoMap(Foam::fvPatchFieldM apper const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/fields/fvPatchFields/derived/pressure InletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C:15 2
#6 void Foam::MapGeometricFields<foam::vector<double>, Foam::fvPatchField, Foam::fvMeshMapper, Foam::volMesh>(Foam::fvMeshMapper const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/MapGeometricFields.H:122
#7 Foam::fvMesh::mapFields(Foam::mapPolyMesh const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/fvMesh/fvMesh.C:371
#8 Foam::fvMesh::updateMesh(Foam::mapPolyMesh const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/fvMesh/fvMesh.C:443
#9 Foam::polyTopoChanger::changeMesh(bool, bool) at ~/OpenFOAM/OpenFOAM-1.4.1/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTop oChanger.C:283
#10 Foam::movingConeTopoFvMesh::update() at ~/OpenFOAM/OpenFOAM-1.4.1/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeT opoFvMesh.C:369
#11 main in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/ftLMPs"
#12 __libc_start_main in "/lib64/libc.so.6"
#13 Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType) const in


The first two lines are of course my debugging statements in the code, trying to figure out what is going on. When mapping the first vector object it segFaults.

I cannot get deeper into the code for some reason, as you can see,

pressureInletOutletVelocityFvPatchVectorField.C:15 2

is the last source code reference. I tried to switch everything to debug, but I seem to have missed the files responsible for this particular autoMap and map.

Does anybody have any idea how to get closer to the problem? Any hint greatly appreciated!!

Regards,


Markus

hjasak November 27, 2007 16:23

Yes, this file is full of such
 
Yes, this file is full of such disgraceful bugs that I am ashamed to see it in OpenFOAM. Have a look at the check-in:

pressureInletOutletVelocityFvPatchVectorField.C

I do apologise for the inconvenience,

Hrv

msg30 November 30, 2007 11:29

Dear Hrv, Many thanks for t
 
Dear Hrv,

Many thanks for the additional info. That one seems to be cleared away now and my understanding slowly increases. I have to learn some of the C++ features at the same time, which slows me down a little but should be okay. I come form a fortran HPC background, things are bit clearer there.

My current (and stubborn) problem is:

The mapping of the first surface vector field as follows:

Map all the vector surfaceFields in the objectRegistry
Mapping field (internal) S
#0 Foam::error::printStack(Foam:http://www.cfd-online.com/OpenFOAM_D...part/proud.gifstream&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/OSspecific/Unix/printStack.C:203
#1 Foam::sigSegv::sigSegvHandler(int) at ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/OSspecific/Unix/signals/sigSegv.C:59
#2 ?? in "/lib64/libc.so.6"
#3 Foam::Field<foam::vector<double> >::Field(Foam::Field<foam::vector<double> > const&) in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOA M"
#4 Foam::Field<foam::vector<double> >::autoMap(Foam::FieldMapper const&) in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOA M"
#5 Foam::MapInternalField<foam::vector<double>, Foam::fvMeshMapper, Foam::surfaceMesh>::operator()(Foam::Field<foam::v ector<double> >&, Foam::fvMeshMapper const&) const at ~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/MapFvSurfaceField.H:88
#6 void Foam::MapGeometricFields<foam::vector<double>, Foam::fvsPatchField, Foam::fvMeshMapper, Foam::surfaceMesh>(Foam::fvMeshMapper const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/MapGeometricFields.H:119
#7 Foam::fvMesh::mapFields(Foam::mapPolyMesh const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/fvMesh/fvMesh.C:379
#8 Foam::fvMesh::updateMesh(Foam::mapPolyMesh const&) at ~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/fvMesh/fvMesh.C:443
#9 Foam::polyTopoChanger::changeMesh(bool, bool) at ~/OpenFOAM/OpenFOAM-1.4.1/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTop oChanger.C:283
#10 Foam::movingConeTopoFvMesh::update() at ~/OpenFOAM/OpenFOAM-1.4.1/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeT opoFvMesh.C:369
#11 main in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOA M"
#12 __libc_start_main in "/lib64/libc.so.6"
#13 Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType) const in "/home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOA M"
Segmentation fault

It seems to be mesh dependent as well, I created a smaller mesh with only 8 cells and it does not segFault, on the mesh from the dam breaking tutorial it falls over .... may of course be as well the signature of working with uninitialized memory and writing to undefined locations - with more cells more chance of it going wrong - , as you said.

Tried to look at the constructors but did not spot similar problems as in the last post, but I may be still looking at the wrong place.

Will continue to investigate.

Many thanks for your time and help!

Regards,

Markus

Erik March 26, 2008 08:16

Hi Markus, I was wondering
 
Hi Markus,

I was wondering if you managed to resolve this issue? Since I got a similar error message when trying to run a slightly modified version of icoFoam (lambdaMicroIcoFoam) with some boundary conditions that I implemented and does not come with the standard OF package.

My error output looks like:
Starting time loop

Time = 0.005
Courant Number mean: 1e-06 max: 1e-06
#0 Foam::error::printStack(Foam:http://www.cfd-online.com/OpenFOAM_D...part/proud.gifstream&) in "/home/erik/OpenFOAM/OpenFOAM-1.4.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigSegv::sigSegvHandler(int) in "/home/erik/OpenFOAM/OpenFOAM-1.4.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 ?? in "/lib64/libc.so.6"
#3 Foam::tmp<foam::field<foam::vector<double> > > Foam::operator*<foam::vector<double> >(Foam::UList<double> const&, Foam::UList<foam::vector<double> > const&) in "/home/erik/OpenFOAM/erik-1.4.1/applications/bin/linux64GccDPOpt/lambdaMicroIcoF oam"
#4 Foam::mixedFixedValueSlipFvPatchField<foam::vector <double> >::snGrad() const in "/home/erik/OpenFOAM/erik-1.4.1/lib/linux64GccDPOpt/liblambdaMicroIcoFoam.so"
#5 Foam::transformFvPatchField<foam::vector<double> >::gradientBoundaryCoeffs() const in "/home/erik/OpenFOAM/OpenFOAM-1.4.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#6 Foam::fv::gaussLaplacianScheme<foam::vector<double > >::fvmLaplacianUncorrected(Foam::GeometricField<do uble,> const&, Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>&) in "/home/erik/OpenFOAM/OpenFOAM-1.4.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#7 Foam::fv::gaussLaplacianScheme<foam::vector<double > >::fvmLaplacian(Foam::GeometricField<double,> const&, Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>&) in "/home/erik/OpenFOAM/OpenFOAM-1.4.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#8 Foam::fv::laplacianScheme<foam::vector<double> >::fvmLaplacian(Foam::GeometricField<double,> const&, Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>&) in "/home/erik/OpenFOAM/OpenFOAM-1.4.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#9 Foam::tmp<foam::fvmatrix<foam::vector<double> > > Foam::fvm::laplacian<foam::vector<double> >(Foam::GeometricField<double,> const&, Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>&, Foam::word const&) in "/home/erik/OpenFOAM/erik-1.4.1/applications/bin/linux64GccDPOpt/lambdaMicroIcoF oam"
#10 Foam::tmp<foam::fvmatrix<foam::vector<double> > > Foam::fvm::laplacian<foam::vector<double> >(Foam::GeometricField<double,> const&, Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>&) in "/home/erik/OpenFOAM/erik-1.4.1/applications/bin/linux64GccDPOpt/lambdaMicroIcoF oam"
#11 Foam::tmp<foam::fvmatrix<foam::vector<double> > > Foam::fvm::laplacian<foam::vector<double> >(Foam::tmp<foam::geometricfield<double,> > const&, Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>&) in "/home/erik/OpenFOAM/erik-1.4.1/applications/bin/linux64GccDPOpt/lambdaMicroIcoF oam"
#12 main in "/home/erik/OpenFOAM/erik-1.4.1/applications/bin/linux64GccDPOpt/lambdaMicroIcoF oam"
#13 __libc_start_main in "/lib64/libc.so.6"
#14 Foam::regIOobject::readIfModified() in "/home/erik/OpenFOAM/erik-1.4.1/applications/bin/linux64GccDPOpt/lambdaMicroIcoF oam"
Segmentation fault

I have read on this forum that this error might be connected the geometry and mesh you use. I Haven't managed to get rid of the error messages by such methods though.

I have also read that similar error-messages may occur if there is a division by zero somewhere. So I tried to set the initial conditions to non-zero values. But it wont shake the errors.

If someone knows what the error message means or how to get by it I'd be happy to be enlightened by any information!

Cheers
Erik

gschaider March 26, 2008 10:33

Hi Erik! Is it possible to
 
Hi Erik!

Is it possible to run your case with a vanilla-iceFoam and if "yes" does the same error occur?

Anyway. As soon as you start developing your own stuff it is very handy if you have a version of OF with debugging enabled. Amongst other things it will give you exact line numbers in the stack trace. Plus it tells you if your code has an "index out of bounds"-problem (which is one of the possible causes for segmentation faults)

Bernhard

Erik March 27, 2008 11:15

sorry, "volMesh" was missing i
 
sorry, "volMesh" was missing in the post above at the lines involving how Uwall is initialised should be:

maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatc hVectorField
(
const fvPatch& p,
const DimensionedField<vector,volmesh>& iF
)
:
mixedFixedValueSlipFvPatchVectorField(p, iF),
accommodationCoeff_(1.0),
Uwall_(p.size(), vector(0.0, 0.0, 0.0)),
A1_(1.0)
{}

cheers

gschaider March 27, 2008 11:49

Sorry Eric! No idea what co
 
Sorry Eric!

No idea what could be the cause. Obviously the size of the refValue is not correctly initialized (that belongs to the mixedPatch-class, doesn't it?). should be equal to the amount of faces in the patch.

Sprinkle your boundary class with Info<< and try to find out where it went wrong (that's what I always do)

Bernhard


All times are GMT -4. The time now is 17:22.