MCPcopy Create free account
hub / github.com/NanoComp/meep / choose_chunkdivision

Function choose_chunkdivision

src/structure.cpp:151–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151std::unique_ptr<binary_partition> choose_chunkdivision(grid_volume &gv, volume &v,
152 int desired_num_chunks, const symmetry &S) {
153
154 if (desired_num_chunks == 0) desired_num_chunks = count_processors();
155 if (gv.dim == Dcyl && gv.get_origin().r() < 0) meep::abort("r < 0 origins are not supported");
156
157 // First, reduce overall grid_volume gv by symmetries:
158 if (S.multiplicity() > 1) {
159 bool break_this[3];
160 for (int dd = 0; dd < 3; dd++) {
161 const direction d = (direction)dd;
162 break_this[dd] = false;
163 for (int n = 0; n < S.multiplicity(); n++)
164 if (has_direction(gv.dim, d) && (S.transform(d, n).d != d || S.transform(d, n).flipped)) {
165 if (gv.num_direction(d) & 1 && !break_this[d] && verbosity > 0)
166 master_printf("Padding %s to even number of grid points.\n", direction_name(d));
167 break_this[dd] = true;
168 }
169 }
170 int break_mult = 1;
171 for (int d = 0; d < 3; d++) {
172 if (break_mult == S.multiplicity()) break_this[d] = false;
173 if (break_this[d]) {
174 break_mult *= 2;
175 if (verbosity > 0)
176 master_printf("Halving computational cell along direction %s\n",
177 direction_name(direction(d)));
178 gv = gv.halve((direction)d);
179 }
180 }
181 // Before padding, find the corresponding geometric grid_volume.
182 v = gv.surroundings();
183 // Pad the little cell in any direction that we've shrunk:
184 }
185
186 int proc_id = 0;
187 if (meep_geom::fragment_stats::resolution == 0 ||
188 meep_geom::fragment_stats::split_chunks_evenly) {
189 if (verbosity > 0 && desired_num_chunks > 1)
190 master_printf("Splitting into %d chunks by voxels\n", desired_num_chunks);
191 return split_by_cost(desired_num_chunks, gv, false, proc_id);
192 }
193 else {
194 if (verbosity > 0 && desired_num_chunks > 1)
195 master_printf("Splitting into %d chunks by cost\n", desired_num_chunks);
196 return split_by_cost(desired_num_chunks, gv, true, proc_id);
197 }
198}
199
200double structure::estimated_cost(int process) {
201 double proc_cost = 0;

Callers 2

structureMethod · 0.85
choose_chunkdivisionMethod · 0.85

Calls 14

count_processorsFunction · 0.85
abortFunction · 0.85
has_directionFunction · 0.85
master_printfFunction · 0.85
direction_nameFunction · 0.85
directionEnum · 0.85
split_by_costFunction · 0.85
get_originMethod · 0.80
multiplicityMethod · 0.80
num_directionMethod · 0.80
halveMethod · 0.80
surroundingsMethod · 0.80

Tested by

no test coverage detected