CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Programming in OpenFoam.. help! (http://www.cfd-online.com/Forums/openfoam/108532-programming-openfoam-help.html)

adriana.nino October 25, 2012 13:49

Programming in OpenFoam.. help!
 
Good morning!


I have some problems programming in OpenFoam.. I'm trying to modify a program to resolve PBE (population balances equations), but I have a problem with createfields.H file in this part:


//- Calculating the Sauter diameter
scalar twoDivThree = 2.0/3.0;
volScalarField num(eta[0]);
volScalarField den(pow(absc[0],twoDivThree)*weight[0]);
dimensionedScalar small("small", den.dimensions(), SMALL);

volScalarField ds("ds",CC * num/(den + small));

volScalarField alpha("alpha", Vo*num);
volScalarField beta("beta",scalar(1)-alpha);

surfaceScalarField phi = fvc::interpolate(alpha)*phia +

fvc::interpolate(beta) *phib;

The program compiles well but when I try to simulate a specific case appear this error:


Reading abscissas

Reading field ABSC1
Reading field ABSC2
Reading field ABSC3
Reading field ABSC4

Constructing matrix for DQMOM

#0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 in "/lib/x86_64-linux-gnu/libc.so.6"
#4 std::string::append(std::string const&) in "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
#5 std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /usr/include/c++/4.6/bits/basic_string.h:2311
#6 Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::operator*<Foam::fvsPatchField, Foam::surfaceMesh>(Foam::tmp<Foam::GeometricField< double, Foam::fvsPatchField, Foam::surfaceMesh> > const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricScalarField.C:113
#7
at ~/Documents/OpenFoam/24_10_2012/pbeDev/fields/fields2/createFields.H:227
#8 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9
in "/home/adriana/OpenFOAM/adriana-2.1.1/platforms/linux64GccDPOpt/bin/fields2"
Segmentation fault (core dumped)


I did different tests and I have found that the error is when I try to define surfacialScalarField phi. If I delete this part of the code, the case runs without problem, but I can't do it because I need to define this variable to continue with the algorithm..


some suggestions??


thanks


Adriana

Hisham October 26, 2012 14:23

Hi Adriana,

A Segmentation fault or a "sigSegv" error is issued when one tries to access invalid memory. Most likely trying to access a non existing element in a field. To try to figure out what is wrong you can make output of the fields that may have caused the error to see what is wrong with them (e.g.)
Code:

Info << "Alpha Field: " << alpha << endl;
Are phia and phib just scalars or are they fields?

Best regards,
Hisham

adriana.nino October 29, 2012 12:49

Thanks Hisham, I have checked output of the phia field and appears this error:

phia Field: dimensions [1.67997141555e-316 6.91767529931e-310 6.91767529931e-310 6.91767529931e-310 6.95321237182e-310 4.94065645841e-324 0];

internalField nonuniform 0();

boundaryField
{
#0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 Foam::OSstream::write(Foam::word const&) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#4 Foam::operator<<(Foam::Ostream&, Foam::word const&) in "/opt/openfoam211/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#5 Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::GeometricBoundaryField::writeE ntry(Foam::word const&, Foam::Ostream&) const at /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricBoundaryField.C:461
#6 Foam::Ostream& Foam::operator<< <double, Foam::fvsPatchField, Foam::surfaceMesh>(Foam::Ostream&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at /opt/openfoam211/src/OpenFOAM/lnInclude/GeometricField.C:1237
#7
at ~/Documents/OpenFoam/24_10_2012/pbeDev/fields/fields2/createFields.H:228
#8 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9


I defined phia and phib as is defined in twoPhaseEulerFoam:

surfaceScalarField& phia = phasea->phi();

Any idea about that?? I'm confused!

Hisham October 29, 2012 12:59

Hi

It seems that this field is (among) the one(s) causing trouble. It is clear that it is not filled with any values or dimensions and hence the error occurs. I guess you have to post more of your code to get better ideas!

Best regards,
Hisham

adriana.nino October 29, 2012 13:18

1 Attachment(s)
Thanks! I'm attaching the file createfields.h, I'm sure that here is the problem.. :confused:

Regards,

Hisham October 29, 2012 13:54

Maybe you should try to register the phi surfaceField as in the original solver:
Code:

00109    surfaceScalarField phi
00110    (
00111        IOobject
00112        (
00113            "phi",
00114            runTime.timeName(),
00115            mesh
00116        ),
00117        fvc::interpolate(alpha)*phia + fvc::interpolate(beta)*phib
00118    );
00119

To my eyes, this is the only difference from the original creatFields.H

Hisham

adriana.nino October 29, 2012 14:44

I tried to do it but doesn't work..:(

adriana.nino October 29, 2012 15:38

Hi Hisham!

you are right! I found the error, it was in "Phase Model" file.. It was by difference between version 1.6 and 2.1. I put the updated file and works perflecty!! thanks very much!!,
P.S I found the error using ;)
Info << "Phia Field: " << phia << endl;


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