8 #ifndef APF_PARTITION_H
9 #define APF_PARTITION_H
63 virtual void balance(MeshTag* weights,
double tolerance) = 0;
69 virtual int operator()(
int n) = 0;
76 int operator()(
int n) {
return n / by;}
85 int operator()(
int n) {
return n * by;}
94 int operator()(
int n) {
return n % by;}
104 offset = (original / factor) * factor;
106 int operator()(
int n) {
return n + offset;}
114 Round(
int n):factor(n) {}
115 int operator()(
int n) {
return (n / factor) * factor;}
120 struct Expand :
public Remap
122 Expand(
int nin,
int nout):
123 quotient(nout / nin),
124 remainder(nout % nin)
126 int operator()(
int in)
129 return in * quotient + in;
130 return in * quotient + remainder;
132 bool shouldOutBeIn(
int out)
134 if (out < remainder * (quotient + 1))
135 return out % (quotient + 1) == 0;
136 return (out - remainder * (quotient + 1)) % quotient == 0;
143 struct Contract :
public Remap
145 Contract(
int nin,
int nout):
146 quotient(nout / nin),
147 remainder(nout % nin)
149 int operator()(
int out)
151 if (out < remainder * (quotient + 1))
152 return out / (quotient + 1);
153 return (out - remainder * (quotient + 1)) / quotient + remainder;
155 bool isValid(
int out)
157 if (out < remainder * (quotient + 1))
158 return out % (quotient + 1) == 0;
159 return (out - remainder * (quotient + 1)) % quotient == 0;
map to nearest multiple of n
Migration plan object: local elements to destinations.
a map from old part ids to new part ids
Load balance over all mesh parts.
void remapPartition(apf::Mesh2 *m, Remap &remap)
remap all part ids in the mesh structure
The APF Mesh modification interface.
virtual void balance(MeshTag *weights, double tolerance)=0
call collective load balancing
Extended mesh interface for modification.
Splits a mesh part into many.
virtual Migration * split(MeshTag *weights, double tolerance, int multiple)=0
call the underlying split algorithm