CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Problems initializing a turbulence model (http://www.cfd-online.com/Forums/openfoam-solving/58274-problems-initializing-turbulence-model.html)

srinath November 26, 2008 13:51

Hello I added a turbulence
 
Hello

I added a turbulence model to a compressible solver, by adding the following lines in createfields.

Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::rasmodel> turbulence
(
compressible::RASModel::New
(
rho,
U,
massPhi,
thermo()
)
);

The code compiles but i get a segfault at this location during runtime.
gdb gives the following error

(gdb) where
#0 0xb72c6f8f in Foam::compressible::RASModels::kEpsilon::kEpsilon ()
from /home/srinath/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libcompressibleRASModels.s o
#1 0xb72ecdff in Foam::compressible::RASModel::adddictionaryConstru ctorToTable<foam::compressible ::rasmodels::kepsilon>::New ()
from /home/srinath/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libcompressibleRASModels.s o
#2 0xb72a1beb in Foam::compressible::RASModel::New () from /home/srinath/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libcompressibleRASModels.s o
#3 0x080676f7 in main ()

I would appreciate it if someone, could give me some suggestions. I think i am overlooking something small, as i don't even get into the time loop

Regards
Srinath

gschaider November 27, 2008 08:17

Hi Srinath! It would be eas
 
Hi Srinath!

It would be easier, if you could give us the line number (in other words output from a debug-version would be great)

Bernhard

srinath November 27, 2008 09:42

Hi Bernhard I have attached
 
Hi Bernhard

I have attached the output of the debugger, and the relevant code fragment. The problem occurs when the constructor for turbulence is invoked.
It is right at the end of the code fragment.

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread -1232189232 (LWP 12520)]
0xb727df8f in Foam::compressible::RASModels::kEpsilon::kEpsilon ()
from /home/srinath/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libcompressibleRASModels.s o
(gdb) up
#1 0xb72a3dff in Foam::compressible::RASModel::adddictionaryConstru ctorToTable<foam::compressible ::rasmodels::kepsilon>::New ()
from /home/srinath/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libcompressibleRASModels.s o
(gdb) up
#2 0xb7258beb in Foam::compressible::RASModel::New ()
from /home/srinath/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libcompressibleRASModels.s o
(gdb) up
#3 0x0806b064 in main (argc=52, argv=0x8221c5c) at createFields.H:126

Here is createFields.H
Info<< "Reading thermophysical properties\n" << endl;

autoPtr<basicthermo> thermo
(
basicThermo::New(mesh)
);

volScalarField& p = thermo->p();
volScalarField& h = thermo->h();
const volScalarField& T = thermo->T();
const volScalarField& psi = thermo->psi();
const volScalarField& mu = thermo->mu();

bool inviscid(true);
if (max(mu.internalField()) > 0.0)
{
inviscid = false;
}

Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "rhoBoundaryTypes.H"
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh
//IOobject::NO_READ,
//IOobject::AUTO_WRITE
),
thermo->rho()
//rhoBoundaryTypes
);
/*
Info<< "Reading field T\n" << endl;
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
*/
volVectorField rhoU
(
IOobject
(
"rhoU",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*U
);

volScalarField rhoE
(
IOobject
(
"rhoE",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*(h + 0.5*magSqr(U)) - p
);
surfaceScalarField pos
(
IOobject
(
"pos",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("pos", dimless, 1.0)
);

surfaceScalarField neg
(
IOobject
(
"neg",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("neg", dimless, -1.0)
);

#include "createMassPhi.H"

Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::rasmodel> turbulence
(
compressible::RASModel::New
(
rho,
U,
massPhi,
thermo()
)
);

gschaider November 27, 2008 11:06

Hi Sinrath! It looks alrigh
 
Hi Sinrath!

It looks alright from here. But you're still using an Opt-Version so it doesn't give filenames and line numbers in kEpsilon.

DO YOURSELF A FAVOUR: compile a Debug-Version if you plan to do solver development (somewhere on the Wiki there is an explanation on it). It gives you more information and it checks for some mistakes (out of bounds access etc) that the Opt-Version does not (for performance reasons). Start the compilation this evening before you leave work and tomorrow try your solver with that version. TRUST ME: IT IS WELL INVESTED TIME

Bernhard


All times are GMT -4. The time now is 09:55.