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

Reference to tmp as input argument

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 22, 2009, 09:36
Default Hi, I following message (he
  #1
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Hi,

I following message (here) an error was reported that is suspected to be a bug. Thanks.
Best regards,
Maka.
maka is offline   Reply With Quote

Old   January 22, 2009, 10:04
Default I do not believe there is a bu
  #2
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
I do not believe there is a bug in tmp but care and understanding is needed to avoid premature deallocation.

H
henry is offline   Reply With Quote

Old   January 22, 2009, 10:31
Default I do not think the bug is in t
  #3
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
I do not think the bug is in tmp. The bug seems to be in the declaration of: correct(..) memeber function of LES models for example:

void Smagorinsky::correct(const tmp<voltensorfield>& gradU).

In the above discussion it was mentioned that one should not use a reference to tmp since it is subject to be deallocated.

I'm not an expert of using tmp but adding the following three lines at the start of correct() implementation will cause the code to crash:

Info <<"1" << average(mag(gradU)) << endl;
Info <<"2" << average(mag(gradU)) << endl;
Info <<"3" << average(mag(gradU)) << endl;

You may refer to the above link for details. Thanks for your response.

Best regards,
Maka.
maka is offline   Reply With Quote

Old   January 22, 2009, 11:11
Default void Smagorinsky::correct(cons
  #4
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
void Smagorinsky::correct(const tmp<voltensorfield>& gradU)
is correct.

Info <<"1" << average(mag(gradU)) << endl;
Info <<"2" << average(mag(gradU)) << endl;
Info <<"3" << average(mag(gradU)) << endl;

should be

Info <<"1" << average(mag(gradU())) << endl;
Info <<"2" << average(mag(gradU())) << endl;
Info <<"3" << average(mag(gradU())) << endl;

to avoid premature de-allocation of the tmp-field.
Alternatively you can create a local reference:

const volTensorField& gradU_ = gradU();

Info <<"1" << average(mag(gradU_)) << endl;
Info <<"2" << average(mag(gradU_)) << endl;
Info <<"3" << average(mag(gradU_)) << endl;

or perhaps

void Smagorinsky::correct(const tmp<voltensorfield>& tgradU)
{
.
.
.
const volTensorField& gradU = tgradU();

Info <<"1" << average(mag(gradU)) << endl;
Info <<"2" << average(mag(gradU)) << endl;
Info <<"3" << average(mag(gradU)) << endl;
.
.
.
}

H
henry is offline   Reply With Quote

Old   January 22, 2009, 14:04
Default Thanks Henry for your comments
  #5
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Thanks Henry for your comments. One small remark is that in the standard release gradU is used without the gradU(). Perhaps any of the above modifications to all SGS models in the future release will help new users to avoid such problem in the future. Many thanks for you help.

Best regards,
Maka.
maka is offline   Reply With Quote

Old   January 22, 2009, 15:07
Default The use of a tmp
  #6
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
The use of a tmp<voltensorfield>& rather than a volTensorField& is to allow the recipient code to clear or reuse the storage of the gradU field which can give a substantial gain in memory efficiency. The choice of a gradU rather than a gradU() argument in the SGS models is deliberate and facilitates this clear or reuse. If you are making changes to these models and want to stop or delay this storage clear or reuse please use one of the methods I suggested above.

H
henry is offline   Reply With Quote

Old   January 23, 2009, 14:14
Default Many thanks for the explanatio
  #7
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Many thanks 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
greater-than- invalid argument 2- nan - UDS Ali FLUENT 0 May 8, 2008 13:49
invalid argument--why? wanghong FLUENT 0 March 13, 2006 02:19
How to defined the argument in porous media??? kevin FLUENT 1 February 26, 2002 13:14
how to define argument of inlet ??? kevin FLUENT 0 February 8, 2002 05:09
invalid argument Zhang_clement FLUENT 0 July 20, 2001 01:36


All times are GMT -4. The time now is 19:00.