-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73a722d
commit 5ad4e2b
Showing
38 changed files
with
1,400 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# | ||
|
||
from dataclasses import dataclass, field | ||
from . import global_vars as gv | ||
|
||
|
||
@dataclass | ||
class LoadBalancer: | ||
# whether or not load balancing is performed | ||
active: bool = field(default_factory=lambda: False) | ||
|
||
# which way load is assessed | ||
mode: str = field(default_factory=lambda: "nppc") | ||
|
||
# acceptable imbalance essentially | ||
tol: float = field(default_factory=lambda: 0.05) | ||
|
||
# whether to rebalance/check imbalance on init | ||
on_init: bool = field(default_factory=lambda: True) | ||
|
||
# if auto, other values are not used if active | ||
auto: bool = field(default_factory=lambda: True) | ||
next_rebalance_backoff_multiplier: int = field(default_factory=lambda: 2) | ||
next_rebalance: int = field(default_factory=lambda: 200) | ||
max_next_rebalance: int = field(default_factory=lambda: 1000) | ||
|
||
# if !auto these values are used if active | ||
every: int = field(default_factory=lambda: 1) | ||
|
||
# internal, allows not registering object for default init | ||
_register: bool = field(default_factory=lambda: True) | ||
|
||
def __post_init__(self): | ||
allowed_modes = [ | ||
"nppc", # count particles per rank | ||
"homogeneous", # count cells per rank | ||
] | ||
|
||
if self.mode not in allowed_modes: | ||
raise RuntimeError(f"LoadBalancer mode '{self.mode}' is not valid") | ||
|
||
if self._register: | ||
if not gv.sim: | ||
raise RuntimeError( | ||
f"LoadBalancer cannot be registered as no simulation exists" | ||
) | ||
if gv.sim.load_balancer: | ||
raise RuntimeError(f"LoadBalancer is already registered to simulation") | ||
gv.sim.load_balancer = self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_geometry_3d.py |
Oops, something went wrong.