This page describes the management of loops over material and environment entities.
In the rest of this page, the generic term component is used to describe a material or an environment.
A component's entities can be divided into two parts: pure entities and impure entities. By definition, entities that are not pure are impure. The notion of purity varies depending on the component type:
- for an environment, an entity is pure if there is only one environment in that entity.
- for a material, an entity is pure if there is only one material AND only one environment.
At the memory storage level for a given variable, accessing a pure entity is equivalent to accessing the global value of that variable.
Loop Generalization
Since version 2.7.0 of Arcane, the generic macro ENUMERATE_COMPONENTITEM() allows iteration over a component's entities globally or by part (pure/impure). It can replace the macros ENUMERATE_COMPONENTCELL(), ENUMERATE_MATCELL(), and ENUMERATE_ENVCELL().
The following values are available for iteration:
ENUMERATE_COMPONENTITEM(MatCell,icell,container) with container of type IMeshMaterial* or MatCellVector.
It is possible to iterate only over the pure or impure part of a component.
- Note
- Currently, the traversal order of loops by pure or impure part is not defined and may evolve later. This means that if there are dependencies between loop iterations, the result may vary from one execution to another.
The following examples show the different variants of the ENUMERATE_COMPONENTITEM() macro
Loops over environments
mat_pressure[c] = mat_temperature[ienvcell];
}
mat_pressure[c] = mat_temperature[ienvcell];
}
mat_pressure[c] = mat_temperature[ienvcell];
}
mat_pressure[c] = mat_temperature[ienvcell];
}
mat_pressure[c] = mat_temperature[ienvcell];
}
mat_pressure[c] = mat_temperature[ienvcell];
}
Loops over materials
mat_pressure[c] = mat_temperature[imatcell];
}
mat_pressure[c] = mat_temperature[imatcell];
}
mat_pressure[c] = mat_temperature[imatcell];
}
mat_pressure[c] = mat_temperature[imatcell];
}
mat_pressure[c] = mat_temperature[imatcell];
}
mat_pressure[c] = mat_temperature[imatcell];
}
Generic loops over components
Arcane::Materials::ComponentCell c = *iccell;
mat_pressure[c] = mat_temperature[iccell];
}
Arcane::Materials::ComponentCell c = *iccell;
mat_pressure[c] = mat_temperature[iccell];
}
Arcane::Materials::ComponentCell c = *iccell;
mat_pressure[c] = mat_temperature[iccell];
}
Arcane::Materials::ComponentCell c = *iccell;
mat_pressure[c] = mat_temperature[iccell];
}
Arcane::Materials::ComponentCell c = *iccell;
mat_pressure[c] = mat_temperature[iccell];
}
Arcane::Materials::ComponentCell c = *iccell;
mat_pressure[c] = mat_temperature[iccell];
}
Vector loops over components
- Note
- In the current version of Arcane (2.7.0), vector loops are only supported for environments (but not yet for materials).
To be able to use vectorization on components, you must include the following file:
Always enables tracing in Arcane parts concerning materials.
It is necessary to use the C++11 lambda mechanism to iterate over components via vector iterators. This is done using the following macro:
};
#define ENUMERATE_COMPONENTITEM_LAMBDA(iter_type, iter, container)
Macro to iterate over the entities of a component via a C++11 lambda function.
- Warning
- Do not forget the final semicolon ';'. For more information, refer to the documentation for this macro.
- Note
- This mechanism is experimental and may evolve later.
For example, with the following variable declarations:
It is possible to use vector loops as follows:
auto in_volume =
viewIn(mat_volume);
auto in_temperature =
viewIn(mat_temperature);
auto out_pressure =
viewOut(mat_pressure);
{
out_pressure[scell] = nr * in_temperature[scell] / in_volume[scell];
};
- Warning
- For performance reasons, the order of iterations may be arbitrary. It is therefore essential that there are no relationships between the iterations. In particular, if non-associative operations such as sums on real numbers are used, the result may vary between two executions.
- Note
- The current implementation has several limitations: