|
[Sponsors] |
How to temporarily store fields and use them in for loop |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 2, 2013, 21:50 |
How to temporarily store fields and use them in for loop
|
#1 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 12 |
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]; } |
|
October 2, 2013, 23:07 |
|
#2 |
New Member
Join Date: Nov 2012
Posts: 13
Rep Power: 13 |
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.
|
|
October 3, 2013, 11:46 |
|
#3 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 12 |
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! |
|
October 4, 2013, 02:57 |
|
#4 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
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_ 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. |
|
October 4, 2013, 12:10 |
|
#5 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 12 |
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? |
|
|
|