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

How to temporarily store fields and use them in for loop

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2013, 21:50
Question How to temporarily store fields and use them in for loop
  #1
Member
 
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 12
CHARLES is on a distinguished road
Hello all,

I have implemented some changes to the k-omega model in order to update it (2006 version) but I have run into some problems... although the code compiles, the computer seems to run out of memory when I run a simulation.

I was wondering if anybody could please help me out...

Below you will find the changes I have made, I believe the problem is in the way that I have defined the volTensorFields. I think I should define them as a tmp<volTensorField> but I don't know how to do so, or how to use the values obtained from tmp in the for loop that follows the volTensorField definitions.

Commenting out the lines below allowed the code to compile.

Something I find troubling is that it seems to me like RORP_ and RORS_ should be checked at every cell but for some reason the compiler doesn't like that... so I commented them out. I'm very new to modifying OpenFOAM so I have no clue about what I'm doing most of the time.

The goal: to modify beta_ (which requires for the computer to look into RORP_,RORS_) for every cell according to the definition in the code below.

Thank you in advance!

Code:
const volTensorField& RORP_(skew(fvc::grad(U_)) & skew(fvc::grad(U_))); //O_ij O_jk
const volTensorField& RORS_(RORP_ & symm(fvc::grad(U_))); //R_ik S_ki
const volScalarField& Chi_(tr(RORS_)/pow((0.09*omega_),3));
//const volScalarField& fomega_(0.0708*((1+85*Chi_)/(1+100*Chi_)));

//modify the values of Chi,fomega, beta, for the corresponding cell, cellI:
    forAll(beta_, cellI) 
    {
    //RORP_[cellI]=(skew(fvc::grad(U_)) & skew(fvc::grad(U_)));
    //RORS_[cellI]=(RORP_[cellI] & symm(fvc::grad(U_)));
    //Chi_[cellI]=(tr(RORS_[cellI])/pow((0.09*omega_[cellI]),3));
    fomega_[cellI]=(1+85*Chi_[cellI])/(1+100*Chi_[cellI]);
    beta_[cellI]=0.0708*fomega_[cellI]; 
    }
CHARLES is offline   Reply With Quote

Old   October 2, 2013, 23:07
Default
  #2
New Member
 
Join Date: Nov 2012
Posts: 13
Rep Power: 13
lixx is on a distinguished road
At first look, the "const" key word prevents you from modifying RORP_ etc. But I don't know if there are any further problems with your code.
lixx is offline   Reply With Quote

Old   October 3, 2013, 11:46
Default
  #3
Member
 
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 12
CHARLES is on a distinguished road
I believe that may have solved the running out of memory problem... Thank you very much!!!


I still have my doubts about my implementation with the goal of checking/modifying the variables at every cell. If there is anyone who has experience modifying OpenFOAM, your input would be greatly appreciated!
CHARLES is offline   Reply With Quote

Old   October 4, 2013, 02:57
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
Fields in OpenFoam are cleverly designed, such that you do not need to use loops. In your case, you can easily

Code:
fomega_=(1.+85.*Chi_)/(1.+100.*Chi_)
beta_=0.0708*fomega_
At least as long as Chi is dimensionless.

For the latter statement for beta, I highly doubt if you really gain anything by the beta variable, as it is only a multiplication with a scalar.
Bernhard is offline   Reply With Quote

Old   October 4, 2013, 12:10
Default
  #5
Member
 
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 12
CHARLES is on a distinguished road
Thanks for replying Bernhard!

That answers my question of why OpenFOAM doesn't have any loops in any of the source files for the equations.

Could you explain what you mean by "For the latter statement for beta, I highly doubt if you really gain anything by the beta variable, as it is only a multiplication with a scalar"?

You doubt I'll gain anything in what sense?
CHARLES 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



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