AutoPas  3.0.0
Loading...
Searching...
No Matches
CompatibleLoadEstimators.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <array>
11#include <set>
12#include <vector>
13
17
22
29static std::set<autopas::LoadEstimatorOption> allCompatibleLoadEstimators(autopas::ContainerOption container) {
30 switch (container) {
31 case ContainerOption::linkedCells: {
32 return std::set<autopas::LoadEstimatorOption>{LoadEstimatorOption::none,
34 }
35 case ContainerOption::verletListsCells: {
36 return std::set<autopas::LoadEstimatorOption>{LoadEstimatorOption::none,
39 }
40 case ContainerOption::verletClusterLists: {
41 return std::set<autopas::LoadEstimatorOption>{LoadEstimatorOption::none, LoadEstimatorOption::neighborListLength};
42 }
43 default: {
44 return std::set<autopas::LoadEstimatorOption>{};
45 }
46 }
47}
48
55static bool usesLoadEstimator(autopas::TraversalOption traversal) {
56 switch (traversal) {
57 case TraversalOption::lc_sliced_balanced:
58 [[fallthrough]];
59 case TraversalOption::vcl_sliced_balanced:
60 [[fallthrough]];
61 case TraversalOption::vlc_sliced_balanced: {
62 return true;
63 }
64 default: {
65 return false;
66 }
67 }
68}
69
79[[maybe_unused]] static std::set<autopas::LoadEstimatorOption> getApplicableLoadEstimators(
80 autopas::ContainerOption container, autopas::TraversalOption traversal,
81 const std::set<autopas::LoadEstimatorOption> &allowedOptions) {
82 if (usesLoadEstimator(traversal)) {
83 auto compatible = allCompatibleLoadEstimators(container);
84 std::set<autopas::LoadEstimatorOption> intersection;
85 std::set_intersection(allowedOptions.begin(), allowedOptions.end(), compatible.begin(), compatible.end(),
86 std::inserter(intersection, intersection.begin()));
87 if (not intersection.empty()) {
88 return intersection;
89 }
90 }
91 return std::set<autopas::LoadEstimatorOption>{LoadEstimatorOption::none};
92}
93
94} // namespace autopas::loadEstimators
@ squaredParticlesPerCell
Number of particles per cell squared.
Definition: LoadEstimatorOption.h:31
@ neighborListLength
Sum of neighbor list lengths.
Definition: LoadEstimatorOption.h:35
@ none
No load estimator.
Definition: LoadEstimatorOption.h:27
Collection of functions for estimating the load required to update a specific region within a contain...
Definition: CompatibleLoadEstimators.h:21
static std::set< autopas::LoadEstimatorOption > allCompatibleLoadEstimators(autopas::ContainerOption container)
Returns set of load estimators compatible with the container.
Definition: CompatibleLoadEstimators.h:29
static std::set< autopas::LoadEstimatorOption > getApplicableLoadEstimators(autopas::ContainerOption container, autopas::TraversalOption traversal, const std::set< autopas::LoadEstimatorOption > &allowedOptions)
If traversal uses load estimation, returns all load estimators in allowedOptions, that are compatible...
Definition: CompatibleLoadEstimators.h:79
static bool usesLoadEstimator(autopas::TraversalOption traversal)
returns whether or not the given traversal uses load estimation.
Definition: CompatibleLoadEstimators.h:55