How to get cumulative summation of one field
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. 
Hi hua
Declare a field variable sum with zeros as its initial values, and add the fieldvariable you want to cumulate sum+=fileldVariable Junwei 
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 
Or I could change my question and pose one related.
If I have a volscalarfiled,How could I get different layers of the field. 
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 
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,k1]+A[i,j,k2].... but in OF,I do not know how to. 

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. 
All times are GMT 4. The time now is 23:43. 