|
[Sponsors] |
May 15, 2009, 07:18 |
How to get cumulative summation of one field
|
#1 |
Senior Member
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17 |
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, 08:12 |
|
#2 |
Senior Member
|
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, 09:58 |
|
#3 |
Senior Member
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17 |
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, 10:00 |
|
#4 |
Senior Member
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17 |
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, 05:28 |
|
#5 |
Senior Member
|
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, 09:42 |
|
#6 |
Senior Member
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17 |
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 17, 2009, 10:52 |
|
#8 |
Senior Member
Hua Zen
Join Date: Mar 2009
Posts: 138
Rep Power: 17 |
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. |
|
|
|
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 |