@@ -325,32 +325,42 @@ namespace meep {
325
325
326
326
} // end namespace meep
327
327
328
- void CylindricalWeightingFieldCalculator::Calculate (std::filesystem::path outdir, std::filesystem::path tmpdir) {
328
+ void CylindricalWeightingFieldCalculator::Calculate (std::filesystem::path outdir, std::filesystem::path mergedir, std::filesystem::path tmpdir) {
329
329
330
+ // Prepare merge directory
331
+ if (mergedir.empty ()) {
332
+ mergedir = outdir;
333
+ }
334
+
330
335
// TODO: this will get a lot easier once we can have all three components together in the same array
331
- std::filesystem::path outdir_Er = outdir / " E_r" ;
332
- std::filesystem::path outdir_Ez = outdir / " E_z" ;
336
+ std::filesystem::path mergedir_E_r = mergedir / " E_r" ;
337
+ std::filesystem::path mergedir_E_z = mergedir / " E_z" ;
333
338
334
339
if (meep::am_master ()) {
335
340
336
- // Prepare output directory
337
- if (!std::filesystem::exists (outdir)) {
338
- std::filesystem::create_directory (outdir);
341
+ if (!std::filesystem::exists (mergedir)) {
342
+ std::filesystem::create_directory (mergedir);
339
343
}
340
344
341
- std::filesystem::create_directory (outdir_Er);
342
- std::filesystem::create_directory (outdir_Ez );
343
- }
345
+ if (! std::filesystem::exists (mergedir_E_r)) {
346
+ std::filesystem::create_directory (mergedir_E_r );
347
+ }
344
348
345
- meep::all_wait ();
349
+ if (!std::filesystem::exists (mergedir_E_z)) {
350
+ std::filesystem::create_directory (mergedir_E_z);
351
+ }
352
+ }
346
353
347
354
// Make sure to have a valid temporary directory to store the results as we go along
348
355
if (tmpdir.empty ()) {
349
356
char tmpdir_template[] = " /tmp/eisvogel.XXXXXX" ;
350
- tmpdir = std::string (mkdtemp (tmpdir_template));
357
+ tmpdir = std::filesystem::path (mkdtemp (tmpdir_template));
351
358
}
352
-
359
+
353
360
std::cout << " Using tmpdir = " << tmpdir << std::endl;
361
+ std::cout << " Using mergedir = " << mergedir << std::endl;
362
+
363
+ meep::all_wait ();
354
364
355
365
// This is only for cross-checking the geometry for now
356
366
// f -> output_hdf5(meep::Dielectric, gv -> surroundings());
@@ -386,7 +396,11 @@ void CylindricalWeightingFieldCalculator::Calculate(std::filesystem::path outdir
386
396
cld.ind_t = stepcnt++;
387
397
m_f -> loop_in_chunks (meep::eisvogel_saving_chunkloop, static_cast <void *>(&cld), m_f -> total_volume ());
388
398
399
+ std::cout << " LLL now on stepcnt = " << std::endl;
400
+ std::cout << stepcnt << std::endl;
401
+
389
402
if ((stepcnt % 400 ) == 0 ) {
403
+ std::cout << " BBB now merging chunks" << std::endl;
390
404
fstor -> MergeChunks (0 , 400 );
391
405
}
392
406
}
@@ -396,9 +410,9 @@ void CylindricalWeightingFieldCalculator::Calculate(std::filesystem::path outdir
396
410
// TODO: again, will get better once the three separate arrays are gone
397
411
// TODO: for large weighting fields, will have to move chunks to the permanent location continuously throughout the calculation so as not to fill up local storage
398
412
// move them so that only the complete chunks (surviving after defragmentation) are moved that won't need to be accessed anymore
399
- std::cout << " moving output into final location ..." ;
400
- std::filesystem::copy (tmpdir / " E_r" , outdir_Er , std::filesystem::copy_options::recursive);
401
- std::filesystem::copy (tmpdir / " E_z" , outdir_Ez , std::filesystem::copy_options::recursive);
413
+ std::cout << " moving output into merging location ..." ;
414
+ std::filesystem::copy (tmpdir / " E_r" , mergedir_E_r , std::filesystem::copy_options::recursive);
415
+ std::filesystem::copy (tmpdir / " E_z" , mergedir_E_z , std::filesystem::copy_options::recursive);
402
416
std::cout << " done!" << std::endl;
403
417
404
418
// Wait until everybody has finished copying
@@ -411,8 +425,10 @@ void CylindricalWeightingFieldCalculator::Calculate(std::filesystem::path outdir
411
425
std::cout << " ==============================================" << std::endl;
412
426
413
427
if (meep::am_master ()) {
414
- std::shared_ptr<CylindricalWeightingField> cwf = std::make_shared<CylindricalWeightingField>(outdir , *m_start_coords, *m_end_coords);
428
+ std::shared_ptr<CylindricalWeightingField> cwf = std::make_shared<CylindricalWeightingField>(mergedir , *m_start_coords, *m_end_coords);
415
429
cwf -> MakeMetadataPersistent ();
416
430
cwf -> RebuildChunks (requested_chunk_size);
431
+
432
+ std::filesystem::copy (mergedir, outdir, std::filesystem::copy_options::recursive);
417
433
}
418
434
}
0 commit comments