CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   magnitude of a volVectorField !!? (https://www.cfd-online.com/Forums/openfoam/86474-magnitude-volvectorfield.html)

T.D. March 23, 2011 12:12

magnitude of a volVectorField !!?
 
hi foamers,

I have a volVectorField Wrel, and a volScalarField gammadot (of same dimensions)

I need to get the volScalarField rhok,
where rhok= (2*magnitude(Wrel) ) / (gammadot+magnitude(Wrel))
so i tried the following:

volScalarField rhok=2*mag(Wrel)/(gammadot+mag(Wrel));

but it didn't work !!!! it compiles well, but when i run it it gives this error:

Quote:

.
.
.
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

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

Create mesh for time = 0

Reading transportProperties

Reading field p

Reading field U

Reading field c

Reading field gammadot

Reading/calculating face flux field phi

Reading field SigmaL

Reading field SigmaR

Reading field SigmaP

Reading field Sigma

Reading field SigmaF

Reading field J


Starting time loop

Time = 0.1

Courant Number mean: 0 max: 1.71165
#0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam171/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/opt/openfoam171/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Uninterpreted:
#3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/opt/openfoam171/lib/linuxGccDPOpt/libOpenFOAM.so"
#4 void Foam::divide<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/talib/OpenFOAM/talib-1.7.1/applications/bin/linuxGccDPOpt/TalibicoFoam2DframeInvariant"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<doub le, Foam::fvPatchField, Foam::volMesh> > const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/talib/OpenFOAM/talib-1.7.1/applications/bin/linuxGccDPOpt/TalibicoFoam2DframeInvariant"
#6
in "/home/talib/OpenFOAM/talib-1.7.1/applications/bin/linuxGccDPOpt/TalibicoFoam2DframeInvariant"
#7 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#8
in "/home/talib/OpenFOAM/talib-1.7.1/applications/bin/linuxGccDPOpt/TalibicoFoam2DframeInvariant"
Floating point exception
talib@jml-port:~/Desktop/talib/OpenFOAM/talib-1.7.1/run/tutorials/incompressible/icoFoam/ChannelFlow2Dfi30percent_constantInletVelocityTali bicoFoam2DframeInvariant$
any ideas ???

thanks

T.D.

benk March 23, 2011 13:32

I think you're going to end up with a list of values from mag(Wrel) (1 value for each point in your mesh), so you'll have to do a forAll loop to capture that:

Code:

//define rhok as a volScalarField first
forAll(rhok, i) {
rhok[i]=2*mag(Wrel[i])/(gammadot+mag(Wrel[i]));
}


akidess March 24, 2011 02:26

Are you sure gammadot+mag(Wrel) is never zero?

T.D. March 24, 2011 03:22

hi guys,
thanks benk and akidess, i tried what you said (benk you forgot "[i]" for gammadot )
finally it was a division by zero error, but i didn't pay attention, and in compiler it says 'uninterpreted error'.
Any way here it is
Quote:

forAll(rhok, i) {
rhok[i]=2*mag(Wrel[i])/(gammadot[i]+mag(Wrel[i])+epsilon);
}

where epsilon is a very small value.
It works !

Thanks

Best Regards,
T.D.

niklas March 24, 2011 03:30

try this

dimensionedScalar WSmall("WSmall", Wrel.dimension(), 1.0e-15);
volScalarField rhok=2*mag(Wrel)/max(WSmall, gammadot+mag(Wrel)));

sabin.ceuca March 24, 2011 03:54

Hi,
I would try this out:
forAll(mesh.cells(), celli)
{
rhok[celli]=2*mag(Wrel[celli])/(gammadot[celli]+mag(Wrel[celli]));
}
I was wondering why you don't user gammadot[celli], but gammadot?

Regards,

T.D. March 24, 2011 04:14

hi, sabin.ceuca
this what i have done exactly as you mensioned:
forAll(mesh.cells(), celli)
{
rhok[celli]=2*mag(Wrel[celli])/(gammadot[celli]+mag(Wrel[celli])+1e-15);
}


it worked,
thanks

fvallejog July 17, 2016 22:35

Please, tell me how define a "volVectorField".


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