@@ -168,12 +168,18 @@ void HDF5Writer::writeArray(hid_t group, const std::string& name, int patch,
168
168
space = H5Screate_simple (1 ,& siz ,nullptr );
169
169
std ::stringstream str ;
170
170
str << patch ;
171
- set = H5Dcreate2 (group1 ,str .str ().c_str (),
172
- type ,space ,H5P_DEFAULT ,H5P_DEFAULT ,H5P_DEFAULT );
171
+ if (checkGroupExistence (group1 ,str .str ().c_str ()))
172
+ set = H5Dopen2 (group1 ,str .str ().c_str (),H5P_DEFAULT );
173
+ else
174
+ set = H5Dcreate2 (group1 ,str .str ().c_str (),
175
+ type ,space ,H5P_DEFAULT ,H5P_DEFAULT ,H5P_DEFAULT );
173
176
} else {
174
177
space = H5Screate_simple (1 ,& siz ,nullptr );
175
- set = H5Dcreate2 (group ,name .c_str (),
176
- type ,space ,H5P_DEFAULT ,H5P_DEFAULT ,H5P_DEFAULT );
178
+ if (checkGroupExistence (group ,name .c_str ()))
179
+ set = H5Dopen2 (group ,name .c_str (),H5P_DEFAULT );
180
+ else
181
+ set = H5Dcreate2 (group ,name .c_str (),
182
+ type ,space ,H5P_DEFAULT ,H5P_DEFAULT ,H5P_DEFAULT );
177
183
}
178
184
if (len > 0 ) {
179
185
hid_t file_space = H5Dget_space (set );
@@ -185,6 +191,7 @@ void HDF5Writer::writeArray(hid_t group, const std::string& name, int patch,
185
191
H5Sclose (mem_space );
186
192
H5Sclose (file_space );
187
193
}
194
+ H5Dflush (set );
188
195
H5Dclose (set );
189
196
H5Sclose (space );
190
197
if (group1 != -1 )
@@ -241,6 +248,14 @@ void HDF5Writer::writeBasis (int level, const DataEntry& entry,
241
248
242
249
void HDF5Writer ::writeSIM (int level , const DataEntry & entry ,
243
250
bool geometryUpdated , const std ::string & prefix )
251
+ {
252
+ this -> writeSIMInt (level , entry , geometryUpdated , prefix , false);
253
+ }
254
+
255
+
256
+ void HDF5Writer ::writeSIMInt (int level , const DataEntry & entry ,
257
+ bool geometryUpdated ,
258
+ const std ::string & prefix , bool noData )
244
259
{
245
260
if (!entry .second .enabled || !entry .second .data || entry .second .data2 .empty ())
246
261
return ;
@@ -336,7 +351,7 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
336
351
(!(results & DataExporter ::REDUNDANT ) || sim -> getGlobalProcessID () == 0 )) // we own the patch
337
352
{
338
353
ASMbase * pch = sim -> getPatch (loc );
339
- if (results & DataExporter ::PRIMARY && !sol -> empty ()) {
354
+ if (results & DataExporter ::PRIMARY && !sol -> empty () && ! noData ) {
340
355
Vector psol ;
341
356
size_t ndof1 = sim -> extractPatchSolution (* sol ,psol ,pch ,entry .second .ncmps ,
342
357
usedescription ? 1 : 0 );
@@ -357,7 +372,7 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
357
372
i + 1 , ndof1 , data , H5T_NATIVE_DOUBLE );
358
373
}
359
374
360
- if (results & DataExporter ::SECONDARY && !sol -> empty ()) {
375
+ if (results & DataExporter ::SECONDARY && !sol -> empty () && ! noData ) {
361
376
Matrix field ;
362
377
SIM ::SolutionMode mode = prob -> getMode ();
363
378
const_cast < SIMbase * > (sim )-> setMode (SIM ::RECOVERY );
@@ -369,7 +384,7 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
369
384
i + 1 , field .cols (), field .getRow (j + 1 ).ptr (), H5T_NATIVE_DOUBLE );
370
385
}
371
386
372
- if (proj )
387
+ if (proj && ! noData )
373
388
for (size_t p = 0 ; p < proj -> size (); ++ p ) {
374
389
if (proj -> at (p ).empty ())
375
390
continue ;
@@ -394,7 +409,7 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
394
409
i + 1 , field .cols (), field .getRow (j + 1 ).ptr (), H5T_NATIVE_DOUBLE );
395
410
}
396
411
397
- if (results & DataExporter ::NORMS && eNorm ) {
412
+ if (results & DataExporter ::NORMS && eNorm && ! noData ) {
398
413
Matrix patchEnorm ;
399
414
sim -> extractPatchElmRes (* eNorm ,patchEnorm ,loc - 1 );
400
415
for (size_t j = 1 , l = 1 ; l < eNorm -> rows (); j ++ )
@@ -405,7 +420,7 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
405
420
i + 1 , patchEnorm .cols (), patchEnorm .getRow (l ++ ).ptr (), H5T_NATIVE_DOUBLE );
406
421
}
407
422
408
- if (results & DataExporter ::EIGENMODES ) {
423
+ if (results & DataExporter ::EIGENMODES && ! noData ) {
409
424
size_t iMode = 0 ;
410
425
const std ::vector < Mode > * modes = static_cast < const std ::vector < Mode > * > (entry .second .data2 .front ());
411
426
for (const Mode & mode : * modes )
@@ -440,7 +455,7 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
440
455
else // must write empty dummy records for the other patches
441
456
{
442
457
double dummy = 0.0 ;
443
- if (results & DataExporter ::PRIMARY ) {
458
+ if (results & DataExporter ::PRIMARY && ! noData ) {
444
459
if (usedescription )
445
460
writeArray (group .front (), entry .second .description ,
446
461
i + 1 , 0 , & dummy , H5T_NATIVE_DOUBLE );
@@ -453,18 +468,18 @@ void HDF5Writer::writeSIM (int level, const DataEntry& entry,
453
468
i + 1 , 0 , & dummy , H5T_NATIVE_DOUBLE );
454
469
}
455
470
456
- if (results & DataExporter ::SECONDARY )
471
+ if (results & DataExporter ::SECONDARY && ! noData )
457
472
for (size_t j = 0 ; j < prob -> getNoFields (2 ); j ++ )
458
473
writeArray (group .front (), prefix + prob -> getField2Name (j ),
459
474
i + 1 , 0 , & dummy ,H5T_NATIVE_DOUBLE );
460
475
461
- if (proj )
476
+ if (proj && ! noData )
462
477
for (size_t p = 0 ; p < proj -> size (); p ++ )
463
478
for (size_t j = 0 ; j < prob -> getNoFields (2 ); j ++ )
464
479
writeArray (group .front (), m_prefix [p ]+ " " + prob -> getField2Name (j ),
465
480
i + 1 , 0 , & dummy ,H5T_NATIVE_DOUBLE );
466
481
467
- if (results & DataExporter ::NORMS && eNorm )
482
+ if (results & DataExporter ::NORMS && eNorm && ! noData )
468
483
for (size_t j = 1 ; j <= norm -> getNoFields (0 ); j ++ )
469
484
for (size_t k = 1 ; k <= norm -> getNoFields (j ); k ++ )
470
485
if (norm -> hasElementContributions (j ,k ))
0 commit comments