CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

ScalarField division

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 26, 2007, 18:57
Default I do the following operation b
  #1
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
I do the following operation but it gives wrong result (1.22005e-312):

const scalarField& ry = patch().deltaCoeffs();
// magnitude of patch-normal distance from face to cell centers:
const scalarField& yn= 1.0/ry;

but if I make a loop and use:

const scalarField& yn= 1.0/ry[facei];

it gives correct result. How can I do mathematical operations that contain scalarFields and scalars without looping? Thanks.

Best regards,
Maka
maka is offline   Reply With Quote

Old   August 26, 2007, 19:16
Default Classic mistake: reference to
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Classic mistake: reference to a temporary: if you do:

scalarField yn= 1.0/ry;

all will be well. Operation 1/ry will return a COPY, i.e. a new field. You took a reference to it, which is a memory error - that's the little & bit after the scalarField.

I bet you already know this - if not, time for a careful look at a good C++ book.

Got it?

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   August 27, 2007, 06:10
Default Thanks Hrv for the explanation
  #3
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Thanks Hrv for the explanation.
Best regards,
Maka.
maka is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sum up scalarField wese OpenFOAM Running, Solving & CFD 2 August 19, 2019 18:30
How to set up an AUTO_WRITE scalarField xiao OpenFOAM Running, Solving & CFD 9 July 22, 2010 04:23
max for scalarField maka OpenFOAM Bugs 9 February 19, 2009 10:43
Division by zero vitke OpenFOAM Running, Solving & CFD 5 September 1, 2008 06:35
[CGNS] Computing a cellcentered scalarField from a vertexcentered scalarField mbeaudoin OpenFOAM Meshing & Mesh Conversion 10 February 22, 2007 08:43


All times are GMT -4. The time now is 18:02.