# How to get cumulative summation of one field

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

 May 15, 2009, 06:18 How to get cumulative summation of one field #1 Senior Member   Hua Zen Join Date: Mar 2009 Posts: 126 Rep Power: 10 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.

 May 15, 2009, 07:12 #2 Senior Member     su junwei Join Date: Mar 2009 Location: Xi'an China Posts: 151 Rep Power: 12 Hi hua Declare a field variable sum with zeros as its initial values, and add the fieldvariable you want to cumulate sum+=fileldVariable Junwei

 May 15, 2009, 08:58 #3 Senior Member   Hua Zen Join Date: Mar 2009 Posts: 126 Rep Power: 10 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

 May 15, 2009, 09:00 #4 Senior Member   Hua Zen Join Date: Mar 2009 Posts: 126 Rep Power: 10 Or I could change my question and pose one related. If I have a volscalarfiled,How could I get different layers of the field.

 May 16, 2009, 04:28 #5 Senior Member     su junwei Join Date: Mar 2009 Location: Xi'an China Posts: 151 Rep Power: 12 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

 May 16, 2009, 08:42 #6 Senior Member   Hua Zen Join Date: Mar 2009 Posts: 126 Rep Power: 10 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.

 May 16, 2009, 15:18 #7 Senior Member     su junwei Join Date: Mar 2009 Location: Xi'an China Posts: 151 Rep Power: 12 Hi lin the class "probes" may give you some hits. this class is located at src » sampling » probes Junwei

 May 17, 2009, 09:52 #8 Senior Member   Hua Zen Join Date: Mar 2009 Posts: 126 Rep Power: 10 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33 matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51 msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58 liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07

All times are GMT -4. The time now is 01:45.