@@ -212,7 +212,7 @@ TEST_CASE("custom_hierarchies", "[core]")
212
212
213
213
auto meshesViaAlias = write.iterations [0 ].meshes ;
214
214
meshesViaAlias[" E" ][" x" ].makeEmpty <float >(2 );
215
- write.setMeshesPath (" fields" );
215
+ write.setMeshesPath (std::vector<std::string>{ " fields/ " , " .*/meshes/ " } );
216
216
auto meshesManually =
217
217
write.iterations [0 ][" fields" ].asContainerOf <Mesh>();
218
218
REQUIRE (meshesManually.contains (" E" ));
@@ -297,6 +297,89 @@ TEST_CASE("custom_hierarchies", "[core]")
297
297
REQUIRE (constant_dataset.getDatatype () == Datatype::FLOAT);
298
298
REQUIRE (constant_dataset.getExtent () == Extent{0 , 0 , 0 });
299
299
}
300
+ read.close ();
301
+
302
+ write = Series (filePath, Access::READ_WRITE);
303
+ {
304
+ std::vector<int > data (10 , 3 );
305
+
306
+ auto E_x = write.iterations [0 ][" custom_meshes" ].meshes [" E" ][" x" ];
307
+ E_x.resetDataset ({Datatype::INT, {10 }});
308
+ E_x.storeChunk (data, {0 }, {10 });
309
+
310
+ auto e_pos_x = write.iterations [0 ][" custom_particles" ]
311
+ .particles [" e" ][" position" ][" x" ];
312
+ e_pos_x.resetDataset ({Datatype::INT, {10 }});
313
+ e_pos_x.storeChunk (data, {0 }, {10 });
314
+ write.close ();
315
+ }
316
+
317
+ read = Series (filePath, Access::READ_ONLY);
318
+ {
319
+ auto it0 = read.iterations [0 ];
320
+ auto custom_meshes = it0[" custom_meshes" ];
321
+ REQUIRE (custom_meshes.meshes .size () == 1 );
322
+ REQUIRE (read.iterations [0 ][" custom_meshes" ].meshes .count (" E" ) == 1 );
323
+ auto E_x_loaded = read.iterations [0 ][" custom_meshes" ]
324
+ .meshes [" E" ][" x" ]
325
+ .loadChunk <int >();
326
+ REQUIRE (read.iterations [0 ][" custom_particles" ].particles .size () == 1 );
327
+ REQUIRE (
328
+ read.iterations [0 ][" custom_particles" ].particles .count (" e" ) == 1 );
329
+ auto e_pos_x_loaded = read.iterations [0 ][" custom_particles" ]
330
+ .particles [" e" ][" position" ][" x" ]
331
+ .loadChunk <int >();
332
+ read.flush ();
333
+
334
+ for (size_t i = 0 ; i < 10 ; ++i)
335
+ {
336
+ REQUIRE (E_x_loaded.get ()[i] == 3 );
337
+ REQUIRE (e_pos_x_loaded.get ()[i] == 3 );
338
+ }
339
+ }
340
+ }
341
+
342
+ TEST_CASE (" custom_hierarchies_no_rw" , " [core]" )
343
+ {
344
+ std::string filePath = " ../samples/custom_hierarchies_no_rw.json" ;
345
+ Series write (filePath, Access::CREATE);
346
+ write.setMeshesPath (std::vector<std::string>{" .*/meshes/" });
347
+ write.iterations [0 ][" custom" ][" hierarchy" ];
348
+ write.iterations [0 ][" custom" ].setAttribute (" string" , " attribute" );
349
+ write.iterations [0 ][" custom" ][" hierarchy" ].setAttribute (" number" , 3 );
350
+ write.iterations [0 ][" no_attributes" ];
351
+
352
+ {
353
+ write.iterations [0 ][" custom" ][" hierarchy" ];
354
+ write.iterations [0 ][" custom" ]
355
+ .asContainerOf <RecordComponent>()[" emptyDataset" ]
356
+ .makeEmpty (Datatype::FLOAT, 3 );
357
+ write.iterations [0 ][" custom" ][" hierarchy" ].setAttribute (" number" , 3 );
358
+ write.iterations [0 ][" no_attributes" ];
359
+ auto iteration_level_ds =
360
+ write.iterations [0 ]
361
+ .asContainerOf <RecordComponent>()[" iteration_level_dataset" ];
362
+ iteration_level_ds.resetDataset ({Datatype::INT, {10 }});
363
+ std::vector<int > data (10 , 5 );
364
+ iteration_level_ds.storeChunk (data);
365
+ write.flush ();
366
+ }
367
+
368
+ {
369
+ std::vector<int > data (10 , 3 );
370
+
371
+ auto E_x = write.iterations [0 ][" custom_meshes" ].meshes [" E" ][" x" ];
372
+ E_x.resetDataset ({Datatype::INT, {10 }});
373
+ E_x.storeChunk (data, {0 }, {10 });
374
+
375
+ auto e_pos_x = write.iterations [0 ][" custom_particles" ]
376
+ .particles [" e" ][" position" ][" x" ];
377
+ e_pos_x.resetDataset ({Datatype::INT, {10 }});
378
+ e_pos_x.storeChunk (data, {0 }, {10 });
379
+ write.close ();
380
+ }
381
+
382
+ Series read (filePath, Access::READ_ONLY);
300
383
}
301
384
302
385
TEST_CASE (" myPath" , " [core]" )
0 commit comments