OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
field_iteration.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
34#ifndef PFC_UTILS_FIELD_ITERATION_HPP
35#define PFC_UTILS_FIELD_ITERATION_HPP
36
39#include <functional>
40
41namespace pfc {
42namespace utils {
43
70template <typename Func> void iterate_inbox(const Box3D &inbox, Func &&func) {
71 int linear_idx = 0;
72 for (int k = inbox.low[2]; k <= inbox.high[2]; k++) {
73 for (int j = inbox.low[1]; j <= inbox.high[1]; j++) {
74 for (int i = inbox.low[0]; i <= inbox.high[0]; i++) {
75 func(Int3{i, j, k}, linear_idx++);
76 }
77 }
78 }
79}
80
81} // namespace utils
82} // namespace pfc
83
84#endif // PFC_UTILS_FIELD_ITERATION_HPP
3D integer bounding box for grid index space
Multi-dimensional indexing utilities.