|
[Sponsors] |
September 11, 2017, 12:44 |
Create 2D array with all zero value
|
#1 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Hi everyone,
I want to create an array of 2 vectorField, for example, List<vectorField> Ub; If I know already the size of Ub, how can I assign all zero values for Ub? |
|
September 13, 2017, 04:36 |
|
#2 |
New Member
ANKUR GARG
Join Date: Mar 2017
Posts: 23
Rep Power: 9 |
List<vectorField> Ub(2, Zero);
Where 2 denotes the Size of the list, and Zero is like (0 0 0 ) for the two vector fields. It can also be defined as an initialization of the list. Let me know if it doesn't work. Thank you. Regards, Ankur |
|
September 13, 2017, 13:08 |
|
#3 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Hi Ankur,
Thanks a lot for your suggestion, Unfortunately, It does not work. I know about the the definition of Ub(2, vector::zero), it will give me a List of 2 vector (0 0 0) rather than two vectorField with all vectors are zero. Do you have any other idea? |
|
September 13, 2017, 13:48 |
|
#4 |
New Member
ANKUR GARG
Join Date: Mar 2017
Posts: 23
Rep Power: 9 |
Will this bunch of code will help you? Please let me know.
List<vectorField>Ub(2); forAll(Ub, Lctr) { vectorField vf(1); vf[0] = Zero; Ub[Lctr] = vf; } forAll(Ub, Lctr) { Info<< '\t' << "List = "<<Ub[Lctr]<<'\t'<<nl; } Thank you. Regards, Ankur |
|
September 14, 2017, 03:25 |
|
#5 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Hi ankur,
Thanks again for your kindness. Actually i'm using this way to define my array which is quite similar to what you said: Code:
List<vectorField> Ub(2) forAll(Ub, i) { vectorField Utemp(n, vector::zero); Ub[i] = Utemp; } I want to know if there is a shorter way to achieve that though. I've gone through the source code but couldn't find any appropriate constructor, so maybe this is the only way to do that I think |
|
September 14, 2017, 07:46 |
|
#6 |
New Member
ANKUR GARG
Join Date: Mar 2017
Posts: 23
Rep Power: 9 |
Welcome DoQuocVu. I am Sorry actually for not being able to give some shorter way. I am not that proficient with OpenFOAM till now, I am just learning, and you also taught me something by putting this query.
Thank you very much for your kindness. Regards, Ankur |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Extracting ParaView Data into Python Arrays | Jeffzda | ParaView | 30 | November 6, 2023 22:00 |
create the file *.foam | phongstar | OpenFOAM | 12 | October 14, 2018 19:06 |
[General] Contour plot: celldata2pointdata | dmaz | ParaView | 1 | April 28, 2014 17:05 |
[ICEM] how to create a 2d tri mesh with quad mesh in the boundary layer | seal2013 | ANSYS Meshing & Geometry | 3 | October 6, 2013 17:09 |
Actuator disk model | audrich | FLUENT | 0 | September 21, 2009 08:06 |