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

How to get cumulative summation of one field

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 15, 2009, 07:18
Default How to get cumulative summation of one field
  #1
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17
lin is on a distinguished road
Hi,foamers

I have a question whether I could do cumulative summation in openfoam.For example

original field

1 2 3
4 5 6
7 8 9

after the cumulative summation,I want to get

1 2 3
5 7 9
12 15 18


Is it possible?Anybody could give me a hint.Thanks.
lin is offline   Reply With Quote

Old   May 15, 2009, 08:12
Default
  #2
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Hi hua

Declare a field variable sum with zeros as its initial values, and add the fieldvariable you want to cumulate

sum+=fileldVariable

Junwei
su_junwei is offline   Reply With Quote

Old   May 15, 2009, 09:58
Default
  #3
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17
lin is on a distinguished road
Hi, Junwei

Thanks for your reply.but I do not get the point.Your method is ok for summing different variables,but what I want is to sum the different part of the same variable.

For example.Take one scalar filed. A
The surface layer values are a1 a2 a3 ...
The layer next to the surface layer b1 b2 b3 ....
and next c1 c2 c3 ...

All are in one volscalarfield.I want to get

a1 a2 a3 ....
a1+b1 a2+b2 a3+b3 ....
a1+b1+c1 a2+b2+c2 a3+b3+c3
lin is offline   Reply With Quote

Old   May 15, 2009, 10:00
Default
  #4
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17
lin is on a distinguished road
Or I could change my question and pose one related.

If I have a volscalarfiled,How could I get different layers of the field.
lin is offline   Reply With Quote

Old   May 16, 2009, 05:28
Default
  #5
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Hi Hua

I think a possible way is that
Get the locations of the points in different layers, and using interpolation to get the values you want to sum, and do the following operation.

Junwei
su_junwei is offline   Reply With Quote

Old   May 16, 2009, 09:42
Default
  #6
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17
lin is on a distinguished road
Thanks Junwei.

Yes,I know the principle how to do it.But I do not know exactly how to get it.

I have seen some posts introducing how to get one exact grid data,but as to how to get the data in one grid layer,I'm still confused how to get it.

This addition is quite simple for some codes those use subscript to identify the grid,in which I could simply do A[i,j,k]+A[i,j,k-1]+A[i,j,k-2].... but in OF,I do not know how to.
lin is offline   Reply With Quote

Old   May 16, 2009, 16:18
Default
  #7
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Hi lin

the class "probes" may give you some hits.
this class is located at
src » sampling » probes

Junwei
su_junwei is offline   Reply With Quote

Old   May 17, 2009, 10:52
Default
  #8
lin
Senior Member
 
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17
lin is on a distinguished road
Thanks for your hints,Junwei.

I will try to get it. One more thing,I guess there maybe some misunderstanding. The new field I want to get is still for other calculation in OF,not for post processing.
lin 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
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 03:58
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 15:02.