ALL
0.9.4
A Loadbalacing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
ALL_Functions.hpp
Go to the documentation of this file.
1
#ifndef ALL_GENERAL_FUNCTION_HEADER_INCLUDED
2
#define ALL_GENERAL_FUNCTION_HEADER_INCLUDED
3
4
#include <mpi.h>
5
#include <cmath>
6
#include <vector>
7
8
namespace
ALL
{
9
namespace
Functions
{
10
33
template
<
typename
T,
typename
W>
34
T
borderShift1d
(
const
int
remote_rank,
const
int
local_coord,
35
const
int
global_dim,
const
W local_work,
const
W remote_work,
36
const
T local_size,
const
T remote_size,
const
T gamma,
37
const
T minSize) {
38
// calculate shift of borders:
39
// s = 0.5 * gamma * (W_r - W_l) / (W_r + W_l) * (d_r + d_l)
40
// *_r = * of neighbor (remote)
41
// *_l = * of local domain
42
43
T shift;
44
// check if a sensible shift can be made
45
if
(remote_rank != MPI_PROC_NULL && local_coord != global_dim - 1 &&
46
!(remote_work == (T)0 && local_work == (T)0)) {
47
shift = 1.0 / gamma * 0.5 * (remote_work - local_work) /
48
(remote_work + local_work) * (local_size + remote_size);
49
50
// determine a maximum move in order to avoid overlapping borders and to
51
// guarantee a stable shift of the domain borders (avoid the loss of a
52
// domain due to too large shifts of its borders [no crossing of borders])
53
T maxmove;
54
if
(shift > 0.0)
55
maxmove = 0.49 * (remote_size - minSize);
56
else
57
maxmove = 0.49 * (local_size - minSize);
58
59
if
(std::abs(shift) > maxmove) {
60
shift = (shift < 0.0) ? -maxmove : maxmove;
61
}
62
}
else
{
63
shift = (T)0;
64
}
65
66
return
shift;
67
}
68
69
}}
// namespace ALL::Functions
70
#endif
ALL::Functions
Definition
ALL_Functions.hpp:9
ALL::Functions::borderShift1d
T borderShift1d(const int remote_rank, const int local_coord, const int global_dim, const W local_work, const W remote_work, const T local_size, const T remote_size, const T gamma, const T minSize)
Definition
ALL_Functions.hpp:34
ALL
Definition
ALL.hpp:78
include
ALL_Functions.hpp
Generated by
1.17.0