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

working with Field

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 22, 2012, 12:18
Default working with Field
  #1
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Posts: 124
Rep Power: 8
anishtain4 is on a distinguished road
Assume you have a scalarField or vectorField named fi(K), and you want to compute its average value in a spherical shell with thickness of one, say:

sigma( magSqr(fi(K)) )
i-0.5<k<i+0.5
k=sqrt(sqr(kx)+sqr(ky)+sqr(kz))

I know you can make a loop or use forAll but this way's gonna check every label once for every shell and that is pretty time consuming. Is there any better way?
anishtain4 is offline   Reply With Quote

Old   June 22, 2012, 17:02
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by anishtain4 View Post
Assume you have a scalarField or vectorField named fi(K), and you want to compute its average value in a spherical shell with thickness of one, say:

sigma( magSqr(fi(K)) )
i-0.5<k<i+0.5
k=sqrt(sqr(kx)+sqr(ky)+sqr(kz))

I know you can make a loop or use forAll but this way's gonna check every label once for every shell and that is pretty time consuming. Is there any better way?
That is a basic programming: "memory usage buys performance" Create an array for the sums, one for every shell. Loop once over the cells. Find out to which shell the cell belongs. Increase that array. Of course you'll need a second array .... but that is left to the reader as an exercise
gschaider 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
Setting an external B0_x field in MHD module fferroni FLUENT 6 July 13, 2015 05:29
funkySetBoundaryFields - Manipulation of existing field jhertel OpenFOAM Pre-Processing 15 March 19, 2015 09:42
chtMultiRegionFoam - exchange data between flow field and temperature phsieh2005 OpenFOAM Running, Solving & CFD 0 February 7, 2012 10:16
How to get the velocity field from the pressure field Hermano Main CFD Forum 2 November 29, 2011 09:32
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 11:16


All times are GMT -4. The time now is 22:32.