One dimensional array in OF21(Segmentation fault (core dumped))
Hello all
I am defining a one dimensional parameter which has 2 million elements; Code:
int nCounter = U.size(); Code:
1 |
I afraid that maybe i counter goes beyond the limits so I change it to
Code:
for(int i=1 i<100; i++) { AAAA[i] = 0;} Thanks, Farzad Quote:
|
I don't understand the source of your error, but there is no reason to be using raw C arrays instead of an OpenFOAM list or even a std vector. Give the following a try:
Code:
scalarField AAA(U.size()); Code:
scalarField AAA(U.size(), Zero); |
Thanks a lot for your advice. I did it like this as you said and it works;
Code:
int nCounter = U.size(); and since I need it to set zero every time step, I set it zero like this every time step; Code:
Thanks, Farzad Quote:
|
Quote:
You can either use the vectorized method to make the for loop obsolete (but I think the compiler automatically using SIMD and might be that an overloaded operator[] will prohibit this operation) or I know for the GeometricField<T> class there is an overloaded operator= which sets the whole Field with a particular value. Since GeometricField is inhereting from Field class (if you go for Field<scalar>) I think there should be something similiar Code:
AAA[:] = 0 //vectorized |
All times are GMT -4. The time now is 17:29. |