Conversation
| } | ||
|
|
||
| template <BalanceElement_t elem, class Mesh_t, class Field_t> | ||
| static double compute_load(const Mesh_t& mesh, const Field_t& weight) |
There was a problem hiding this comment.
Since the mesh is already available in the weight filed. It's probably not necessary to add it in the parameters.
| static auto from_field(const Field& f) | ||
| { | ||
| auto weight = samurai::make_scalar_field<double>("weight", f.mesh()); | ||
| weight.fill(0.); | ||
| samurai::for_each_cell(f.mesh(), | ||
| [&](auto cell) | ||
| { | ||
| weight[cell] = f[cell]; | ||
| }); | ||
| return weight; | ||
| } |
There was a problem hiding this comment.
In samurai, when we want to access to the mesh, we use the given syntax:
auto& mesh = f.mesh();And then we use it. Could you make this change to have a uniform implementation ?
| static auto from_field(const Field& f) | ||
| { | ||
| auto weight = samurai::make_scalar_field<double>("weight", f.mesh()); | ||
| weight.fill(0.); |
There was a problem hiding this comment.
Why the weight is initialised to 0 here and to 1 in the uniform method ?
There was a problem hiding this comment.
The code is already in the namespace samurai. Therefore, all samurai:: must be removed.
| new_field.fill(0); | ||
|
|
||
| auto& old_mesh = field.mesh(); | ||
| // TODO : check if this is correct |
There was a problem hiding this comment.
update_fields should be set as a function as we have done in the file algorithm/update.hpp. You can add it to this file. We will split it after.
| enum BalanceElement_t | ||
| { | ||
| CELL | ||
| }; |
There was a problem hiding this comment.
Could you use an enum class instead ?
| }; | ||
|
|
||
| template <class Flavor> | ||
| class LoadBalancer |
There was a problem hiding this comment.
It seems that all the element of this class are public. Maybe we can change it as struct and remove the public keyword.
| bool all_fluxes_zero = true; | ||
| for (std::size_t neighbour_idx = 0; neighbour_idx < n_neighbours; ++neighbour_idx) | ||
| { | ||
| std::size_t neighbour_rank = static_cast<std::size_t>(neighbourhood[neighbour_idx].rank); |
There was a problem hiding this comment.
Since you make a static_cast, auto can be used.
| auto center_a = a.center(); | ||
| auto center_b = b.center(); | ||
| if (center_a(1) != center_b(1)) | ||
| { | ||
| return center_a(1) > center_b(1); // First, cells with highest y coordinate | ||
| } | ||
| return center_a(0) < center_b(0); // Then, cells with lowest x coordinate |
There was a problem hiding this comment.
How does it work for
Description
Here is the newest proposal for load balancing.
There is a new testcase named advection-2d-load-balancing to show how to use it. I will use internal load balancing parameters in it in the future. Or, if wanted, we can directly introduce the load_balancing onto the
advection_2d.cpptestcase.The
load_balancingfile is for general routinesThe
load_balancing_diffusionis specific for diffusion strategyThe load balancing is working with a diffusion strategy that equilibrates by taking into account cell weights.
The load balancing overhead is near minimal.
In the near future :
This is not an intrusive PR, I purpose to push it now and to improve it in a weekly manner.
How has this been tested?
With advection-2d
Code of Conduct
By submitting this PR, you agree to follow our Code of Conduct