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/)
-   -   Don't know if this is a bug or (http://www.cfd-online.com/Forums/openfoam-solving/67660-dont-know-if-bug.html)

thiart August 22, 2009 07:40

Don't know if this is a bug or
 
if I am just plain dumb (probably the latter) but can somebody please help:

The offending piece of code I am trying to create in a modified turbulence model reads

void kEpsilonSwirl::updateSwirlSource()
{
Info << "Here 0" << endl;
const volVectorField& rP0 = mesh_.C()-axisPoint_;
Info << "Here 1" << endl;
const volVectorField& rProj0 = (rP0 & axisDir_)*axisDir_/magSqr(axisDir_);
Info << "Here 2 " << endl;
.....

As you see I have instrumented it to see where things go wrong: the code compiles OK but when I run it I get the following:

....

Selecting incompressible transport model Newtonian
Selecting turbulence model type RASModel
Selecting RAS turbulence model kEpsilonSwirl
kEpsilonSwirlCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
axisDir axisDir [ 0 1 0 0 0 0 0 ] ( 1 0 0 );
axisPoint axisPoint [ 0 1 0 0 0 0 0 ] ( 0 0 0 );
sigmaEps 1.3;
}


Starting time loop

Time = 0.01

Courant Number mean: 0.0176233 max: 0.39971
DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 2.55993e-10, No Iterations 3
DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 1.37146e-06, No Iterations 2
DILUPBiCG: Solving for Uz, Initial residual = 1, Final residual = 3.3967e-07, No Iterations 2
DICPCG: Solving for p, Initial residual = 1, Final residual = 0.0558327, No Iterations 2
time step continuity errors : sum local = 1.42616e-05, global = -6.28859e-08, cumulative = -6.28859e-08
DICPCG: Solving for p, Initial residual = 0.0989443, Final residual = 7.7364e-07, No Iterations 57
time step continuity errors : sum local = 3.95132e-10, global = -1.68916e-12, cumulative = -6.28876e-08
Here 0
Here 1
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create

I've tried a number of different options, which either don't compile or don't run.

Help!!

Gerrie Thiart

hjasak August 24, 2009 06:51

Your code is wrong: you are taking a reference to a temporary. Do:

volVectorField rP0 = mesh_.C()-axisPoint_;

volVectorField rProj0 = (rP0 & xisDir_)*axisDir_/magSqr(axisDir_);

You cannot take a reference to a result of field algebra - it will be a new field.

Enjoy,

Hrv

thiart August 24, 2009 06:56

Great! Thanks,
 
from a bedraggled C++ wannabee.

:-] Gerrie Thiart


All times are GMT -4. The time now is 04:24.