15 #ifndef CORE_ENVIRONMENT_ENVIRONMENT_H_
16 #define CORE_ENVIRONMENT_ENVIRONMENT_H_
49 assert(!omp_in_parallel() &&
"Update called in parallel region.");
73 const Agent& query,
void* criteria) = 0;
83 const Real3& query_position,
85 const Agent* query_agent =
nullptr) = 0;
87 virtual void Clear() = 0;
136 :
public Functor<void, Agent*, AgentHandle> {
137 using Type = std::vector<std::array<real_t, 8>>;
151 auto tid = omp_get_thread_num();
154 if (position[0] <
xmin_[tid][0]) {
155 xmin_[tid][0] = position[0];
157 if (position[0] >
xmax_[tid][0]) {
158 xmax_[tid][0] = position[0];
161 if (position[1] <
ymin_[tid][0]) {
162 ymin_[tid][0] = position[1];
164 if (position[1] >
ymax_[tid][0]) {
165 ymax_[tid][0] = position[1];
168 if (position[2] <
zmin_[tid][0]) {
169 zmin_[tid][0] = position[2];
171 if (position[2] >
zmax_[tid][0]) {
172 zmax_[tid][0] = position[2];
194 std::array<real_t, 6>* ret_grid_dimensions) {
197 const auto max_threads = omp_get_max_threads();
200 std::vector<std::array<real_t, 8>> xmin(max_threads, {{
Math::kInfinity}});
201 std::vector<std::array<real_t, 8>> xmax(max_threads, {{-
Math::kInfinity}});
203 std::vector<std::array<real_t, 8>> ymin(max_threads, {{
Math::kInfinity}});
204 std::vector<std::array<real_t, 8>> ymax(max_threads, {{-
Math::kInfinity}});
206 std::vector<std::array<real_t, 8>> zmin(max_threads, {{
Math::kInfinity}});
207 std::vector<std::array<real_t, 8>> zmax(max_threads, {{-
Math::kInfinity}});
209 std::vector<std::array<real_t, 8>> largest(max_threads, {{0}});
213 rm->ForEachAgentParallel(1000, functor);
216 real_t& gxmin = (*ret_grid_dimensions)[0];
217 real_t& gxmax = (*ret_grid_dimensions)[1];
218 real_t& gymin = (*ret_grid_dimensions)[2];
219 real_t& gymax = (*ret_grid_dimensions)[3];
220 real_t& gzmin = (*ret_grid_dimensions)[4];
221 real_t& gzmax = (*ret_grid_dimensions)[5];
222 for (
int tid = 0; tid < max_threads; tid++) {
224 if (xmin[tid][0] < gxmin) {
225 gxmin = xmin[tid][0];
227 if (xmax[tid][0] > gxmax) {
228 gxmax = xmax[tid][0];
231 if (ymin[tid][0] < gymin) {
232 gymin = ymin[tid][0];
234 if (ymax[tid][0] > gymax) {
235 gymax = ymax[tid][0];
238 if (zmin[tid][0] < gzmin) {
239 gzmin = zmin[tid][0];
241 if (zmax[tid][0] > gzmax) {
242 gzmax = zmax[tid][0];
256 #endif // CORE_ENVIRONMENT_ENVIRONMENT_H_