CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM

magnitude of a volVectorField !!?

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   March 23, 2011, 13:12
Post magnitude of a volVectorField !!?
Senior Member
Join Date: Sep 2010
Location: France
Posts: 224
Rep Power: 9
T.D. is on a distinguished road
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:

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:rintStack(Foam::Ostream&) in "/opt/openfoam171/lib/linuxGccDPOpt/"
#1 Foam::sigFpe::sigFpeHandler(int) in "/opt/openfoam171/lib/linuxGccDPOpt/"
#2 Uninterpreted:
#3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/opt/openfoam171/lib/linuxGccDPOpt/"
#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:perator/<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"
in "/home/talib/OpenFOAM/talib-1.7.1/applications/bin/linuxGccDPOpt/TalibicoFoam2DframeInvariant"
#7 __libc_start_main in "/lib/tls/i686/cmov/"
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 ???


T.D. is offline   Reply With Quote

Old   March 23, 2011, 14:32
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 12
benk is on a distinguished road
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:

//define rhok as a volScalarField first
forAll(rhok, i) {
benk is offline   Reply With Quote

Old   March 24, 2011, 03:26
Senior Member
akidess's Avatar
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,194
Rep Power: 21
akidess will become famous soon enough
Are you sure gammadot+mag(Wrel) is never zero?
akidess is online now   Reply With Quote

Old   March 24, 2011, 04:22
Senior Member
Join Date: Sep 2010
Location: France
Posts: 224
Rep Power: 9
T.D. is on a distinguished road
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
forAll(rhok, i) {

where epsilon is a very small value.
It works !

Best Regards,
T.D. is offline   Reply With Quote

Old   March 24, 2011, 04:30
Super Moderator
niklas's Avatar
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 22
niklas will become famous soon enoughniklas will become famous soon enough
try this

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

Old   March 24, 2011, 04:54
Sabin Ceuca
Join Date: Mar 2010
Location: Munich
Posts: 42
Rep Power: 9
sabin.ceuca is on a distinguished road
I would try this out:
forAll(mesh.cells(), celli)
I was wondering why you don't user gammadot[celli], but gammadot?

sabin.ceuca is offline   Reply With Quote

Old   March 24, 2011, 05:14
Senior Member
Join Date: Sep 2010
Location: France
Posts: 224
Rep Power: 9
T.D. is on a distinguished road
hi, sabin.ceuca
this what i have done exactly as you mensioned:
forAll(mesh.cells(), celli)

it worked,
T.D. is offline   Reply With Quote

Old   July 17, 2016, 22:35
New Member
Fidel Vallejo
Join Date: Dec 2015
Location: Santiago
Posts: 6
Rep Power: 3
fvallejog is on a distinguished road
Please, tell me how define a "volVectorField".
fvallejog is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stresseq vs stress magnitude watashiwa OpenFOAM 1 October 14, 2010 12:02
strain rate magnitude ahmadbakri STAR-CCM+ 1 June 3, 2010 13:03
Initialize a uniform 0 volVectorField Schag OpenFOAM 3 August 26, 2009 10:08
formula for velocity magnitude Hai Duc FLUENT 0 January 9, 2008 08:39
To get the magnitude of volVectorField susana OpenFOAM Pre-Processing 5 November 16, 2006 07:53

All times are GMT -4. The time now is 08:12.