CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Bugs

Tmp class

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 20, 2008, 12:23
Default (1) The following code produce
  #1
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 10
maka is on a distinguished road
(1) The following code produce wrong value of yFieldTmp. Only two patch faces are wrong and the rest is correct. No warning messages or error.
(2) The code works well if we replace the marked line with:
const scalarField yFieldTmp = ...
(3) The code prints an error message as expected if we replace the marked line with:
scalarField yFieldTmp = ...

The difference between case 1 and 2 is just added & which can easily be done even if you remember that you are working with tmp field.

---------------------------------------

const Foam::fvPatchList& plTmp(mesh.boundary());
label topPatch = mesh.boundaryMesh().findPatchID("topWall");
label patchII=topPatch;
const scalarField& yFieldTmp = plTmp[patchII].Cf().component(1); // marked line.
Info <<plTmp[patchII].name() << " " << gSum(yFieldTmp)/yFieldTmp.size() << endl;
Info <<plTmp[patchII].name() << " " << min(yFieldTmp) << endl;
Info <<plTmp[patchII].name() << " " << max(yFieldTmp) << endl;
maka is offline   Reply With Quote

Old   August 20, 2008, 12:26
Default V 1.3; could be tested on chan
  #2
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 10
maka is on a distinguished road
V 1.3; could be tested on channelOodles case.
maka is offline   Reply With Quote

Old   August 20, 2008, 14:53
Default const scalarField& yFieldTmp =
  #3
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 14
henry is on a distinguished road
const scalarField& yFieldTmp = plTmp[patchII].Cf().component(1); // marked line.

is incorrect in a way the compiler and the code cannot warn you about but valgrind will probably pick it up.

Correct alternatives are

scalarField yFieldTmp = ...

or

tmp<scalarfield> yFieldTmp = ...

with the latter being very slightly more efficient than the first but not so much to be something to compromise the code clarity over.

H
henry is offline   Reply With Quote

Reply

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
How to add a new class locally ville OpenFOAM 4 December 11, 2006 14:20
Class Project Tiger Main CFD Forum 5 March 13, 2006 16:58
Expanding a class fabianpk OpenFOAM 0 October 3, 2005 04:26
CFD class notes Lee Main CFD Forum 0 January 30, 2004 13:39
Fluent Class - OC, CA Chetan Kadakia FLUENT 0 September 7, 2001 19:17


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