SoA of item variables or view of item variable with a memory area
Goal: to have or to "manipulate" a dynamic number of item variables
Choice 1: Array of MeshVariableArrayRefT< ItemTypeT, DataTypeT>
We could have a N-dimensional array of MeshVariableArrayRefT<>
Here, an example with a two-dimensional array.
// Pseudo-code
"UniqueArray2< VariableCellArrayReal >" m_aof_arr;
Integer dim1 = 8;
Integer dim2 = 100;
m_aof_arr.resize(dim1, dim2, VariableBuildInfo(mesh(), "MyCellArray"));
// m_aof_arr is a two-dimensional array of VariableCellArrayReal
// named String::format("MyCellArray_{0}_{1}", i1, i2)
for(Integer i1=0 ; i1<dim1 ; ++i1) {
for(Integer i2=0 ; i2<dim2 ; ++i2) {
ENUMERATE_CELL(icell, allCells()) {
m_aof_arr[i1][i2][icell] = ... ;
}
}
}
// We could synchronize just one Cell variable array
m_aof_arr[1][2].synchronize();
Choice 2: a view MeshVariableArrayViewT< ItemTypeT, DataTypeT>
Thanks to a memory area, we could create a kind of view on a Cell variable array.
Here an example, I don't know if we could use NumArray to pre-allocate data.
// Psuedo-code
Integer dim1 = 8;
Integer dim2 = 100;
NumArray<Real, 3> num_arr(dim1, dim2, allCells().size());
for(Integer i1=0 ; i1<dim1 ; ++i1) {
for(Integer i2=0 ; i2<dim2 ; ++i2) {
MeshVariableArrayViewT<Cell, Real> arr_i1_i2(num_arr(i1,i2).data(), mesh());
ENUMERATE_CELL(icell, allCells()) {
arr_i1_i2[icell] = ... ;
}
}
}
MeshVariableArrayViewT<Cell, Real> arr_1_2(num_arr(1,2).data(), mesh());
arr_1_2.synchronize();
Thanks for the issue. I'm gonna think about it. I have several questions:
- What kind of operation do you need ? Is
synchronize()the only needed operation ? - Are the number
dim1anddim2allowed to change during the simulation ?
I think we could consider dim1 and dim2 are not allowed to change during the simulation.
Note: the number of dimensions is not limited to 2, we could have 2 or more dimensions (dim3, dim4 and so on).
I don't know if synchronize would be the only needed operation.
Of course, we need to read and/or write at item in a loop ...
Maybe, we need to dump/restore the array so, at the end, the only right choice could be "choice 1" ("choice 2" is only a temporary view so we couldn't dump/restore).