352{
353
354 std::ofstream fout(fullName.c_str(), std::ios::app);
355 if (!fout) {
356 clout <<
"Error: could not open " << fullName << std::endl;
357 }
358
360 fout
361 << "<DataArray type=\"Float32\" Name=\"Radius\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
362 << std::endl;
363 fout.close();
364
365 std::ofstream ofstr(fullName.c_str(),
366 std::ios::out | std::ios::app | std::ios::binary);
367 if (!ofstr) {
368 clout <<
"Error: could not open " << fullName << std::endl;
369 }
370
371 size_t fullSize =
_psys.rankNumOfParticles();
372 size_t binarySize = size_t(fullSize * sizeof(float));
373
374 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
375 unsigned int uintBinarySize = (unsigned int) binarySize;
376 sizeEncoder.encode(&uintBinarySize, 1);
377
378 Base64Encoder<float> dataEncoder(ofstr, fullSize);
379 for (
auto pS :
_psys._pSystems) {
380 for (auto& p : pS->_particles) {
381 const float tmp = float(p.getRad());
382 dataEncoder.encode(&tmp, 1);
383 }
384 }
385 ofstr.close();
386
387 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
388 fout << "</DataArray>" << std::endl;
389 }
390
392 fout
393 << "<DataArray type=\"Float32\" Name=\"Mass\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
394 << std::endl;
395 fout.close();
396
397 std::ofstream ofstr(fullName.c_str(),
398 std::ios::out | std::ios::app | std::ios::binary);
399 if (!ofstr) {
400 clout <<
"Error: could not open " << fullName << std::endl;
401 }
402
403 size_t fullSize =
_psys.rankNumOfParticles();
404 size_t binarySize = size_t(fullSize * sizeof(float));
405
406 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
407 unsigned int uintBinarySize = (unsigned int) binarySize;
408 sizeEncoder.encode(&uintBinarySize, 1);
409
410 Base64Encoder<float> dataEncoder(ofstr, fullSize);
411 for (
auto pS :
_psys._pSystems) {
412 for (auto& p : pS->_particles) {
413 const float tmp = float(p.getMass());
414 dataEncoder.encode(&tmp, 1);
415 }
416 }
417 ofstr.close();
418
419 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
420 fout << "</DataArray>" << std::endl;
421 }
423 fout
424 << "<DataArray type=\"Int32\" Name=\"Cuboid\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
425 << std::endl;
426 fout.close();
427
428 std::ofstream ofstr(fullName.c_str(),
429 std::ios::out | std::ios::app | std::ios::binary);
430 if (!ofstr) {
431 clout <<
"Error: could not open " << fullName << std::endl;
432 }
433
434 size_t fullSize =
_psys.rankNumOfParticles();
435 size_t binarySize = size_t(fullSize * sizeof(int));
436
437 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
438 unsigned int uintBinarySize = (unsigned int) binarySize;
439 sizeEncoder.encode(&uintBinarySize, 1);
440
441 Base64Encoder<int> dataEncoder(ofstr,
442 fullSize);
443 for (
auto pS :
_psys._pSystems) {
444 for (auto& p : pS->_particles) {
445 const int tmp = int(p.getCuboid());
446 dataEncoder.encode(&tmp, 1);
447 }
448 }
449 ofstr.close();
450
451 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
452 fout << "</DataArray>" << std::endl;
453 }
455 fout
456 << "<DataArray type=\"Int32\" Name=\"Active\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
457 << std::endl;
458 fout.close();
459
460 std::ofstream ofstr(fullName.c_str(),
461 std::ios::out | std::ios::app | std::ios::binary);
462 if (!ofstr) {
463 clout <<
"Error: could not open " << fullName << std::endl;
464 }
465
466 size_t fullSize =
_psys.rankNumOfParticles();
467 size_t binarySize = size_t(fullSize * sizeof(int));
468
469 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
470 unsigned int uintBinarySize = (unsigned int) binarySize;
471 sizeEncoder.encode(&uintBinarySize, 1);
472
473 Base64Encoder<int> dataEncoder(ofstr, fullSize);
474 for (
auto pS :
_psys._pSystems) {
475 for (auto& p : pS->_particles) {
476 int tmp = 0;
477 if (p.getActive()) {
478 tmp = 1;
479 }
480 dataEncoder.encode(&tmp, 1);
481 }
482 }
483 ofstr.close();
484
485 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
486 fout << "</DataArray>" << std::endl;
487 }
488
490 fout
491 << "<DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
492 << std::endl;
493 fout.close();
494
495 std::ofstream ofstr(fullName.c_str(),
496 std::ios::out | std::ios::app | std::ios::binary);
497 if (!ofstr) {
498 clout <<
"Error: could not open " << fullName << std::endl;
499 }
500
501 size_t fullSize =
_psys.rankNumOfParticles() * 3;
502 size_t binarySize = size_t(fullSize * sizeof(float));
503
504 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
505 unsigned int uintBinarySize = (unsigned int) binarySize;
506 sizeEncoder.encode(&uintBinarySize, 1);
507
508 Base64Encoder<float> dataEncoder(ofstr, fullSize);
509 for (
auto pS :
_psys._pSystems) {
510 for (auto& p : pS->_particles) {
511 for (int iDim = 0; iDim < 3; ++iDim) {
512 const float tmp = float(p.getVel()[iDim]);
513 dataEncoder.encode(&tmp, 1);
514 }
515 }
516 }
517 ofstr.close();
518 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
519 fout << "</DataArray>" << std::endl;
520 }
522 fout
523 << "<DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
524 << std::endl;
525 fout.close();
526
527 std::ofstream ofstr(fullName.c_str(),
528 std::ios::out | std::ios::app | std::ios::binary);
529 if (!ofstr) {
530 clout <<
"Error: could not open " << fullName << std::endl;
531 }
532
533 size_t fullSize =
_psys.rankNumOfParticles() * 3;
534 size_t binarySize = size_t(fullSize * sizeof(float));
535
536 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
537 unsigned int uintBinarySize = (unsigned int) binarySize;
538 sizeEncoder.encode(&uintBinarySize, 1);
539
540 Base64Encoder<float> dataEncoder(ofstr, fullSize);
541 for (
auto pS :
_psys._pSystems) {
542 for (auto& p : pS->_particles) {
543 for (int iDim = 0; iDim < 3; ++iDim) {
544 const float tmp = float(p.getForce()[iDim]);
545 dataEncoder.encode(&tmp, 1);
546 }
547 }
548 }
549 ofstr.close();
550 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
551 fout << "</DataArray>" << std::endl;
552 }
553 fout << "</PointData>" << std::endl;
554
555 fout << "<CellData /> " << std::endl;
556 fout << "<Cells>" << std::endl;
557 fout << "<DataArray type=\"Int32\" Name=\"connectivity\" format=\"binary\" encoding=\"base64\">" << std::endl;
558 fout.close();
559 {
560 std::ofstream ofstr(fullName.c_str(),
561 std::ios::out | std::ios::app | std::ios::binary);
562 if (!ofstr) {
563 clout <<
"Error: could not open " << fullName << std::endl;
564 }
565
566 size_t fullSize =
_psys.rankNumOfParticles();
567 size_t binarySize = size_t(fullSize * sizeof(int));
568 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
569 unsigned int uintBinarySize = (unsigned int) binarySize;
570 sizeEncoder.encode(&uintBinarySize, 1);
571 Base64Encoder<int32_t> dataEncoder(ofstr, fullSize);
572 int i = 0;
573 for (
auto pS :
_psys._pSystems) {
574 for (unsigned int p=0; p<pS->_particles.size(); p++) {
575 const int32_t tmp = i++;
576 dataEncoder.encode(&tmp, 1);
577 }
578 }
579 ofstr.close();
580 }
581 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
582 fout << "</DataArray>" << std::endl;
583
584 fout << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"binary\" encoding=\"base64\">"
585 << std::endl;
586 fout.close();
587 {
588 std::ofstream ofstr(fullName.c_str(), std::ios::out | std::ios::app | std::ios::binary);
589 if (!ofstr) {
590 clout <<
"Error: could not open " << fullName << std::endl;
591 }
592
593 size_t fullSize =
_psys.rankNumOfParticles();
594 size_t binarySize = size_t(fullSize * sizeof(int));
595 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
596 unsigned int uintBinarySize = (unsigned int) binarySize;
597 sizeEncoder.encode(&uintBinarySize, 1);
598 Base64Encoder<int32_t> dataEncoder(ofstr, fullSize);
599 int i = 1;
600 for (
auto pS :
_psys._pSystems) {
601 for (unsigned int p=0; p<pS->_particles.size(); p++) {
602 const int32_t tmp = i++;
603 dataEncoder.encode(&tmp, 1);
604 }
605 }
606 ofstr.close();
607 }
608 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
609 fout << "</DataArray>" << std::endl;
610
611
612 fout << "<DataArray type=\"UInt8\" Name=\"types\" format=\"binary\" encoding=\"base64\">"
613 << std::endl;
614 fout.close();
615 {
616 std::ofstream ofstr(fullName.c_str(),
617 std::ios::out | std::ios::app | std::ios::binary);
618 if (!ofstr) {
619 clout <<
"Error: could not open " << fullName << std::endl;
620 }
621
622 size_t fullSize =
_psys.rankNumOfParticles();
623 size_t binarySize = size_t(fullSize * sizeof(int));
624 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
625 unsigned int uintBinarySize = (unsigned int) binarySize;
626 sizeEncoder.encode(&uintBinarySize, 1);
627 Base64Encoder<uint8_t> dataEncoder(ofstr, fullSize);
628 for (
auto pS :
_psys._pSystems) {
629 for (unsigned int p=0; p<pS->_particles.size(); p++) {
630 const uint8_t tmp = 1;
631 dataEncoder.encode(&tmp, 1);
632 }
633 }
634 ofstr.close();
635 }
636 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
637 fout << "</DataArray>" << std::endl;
638 fout << "</Cells>" << std::endl;
639 fout << "<Points>" << std::endl;
640 fout << "<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
641 << std::endl;
642
643 fout.close();
644
645 std::ofstream ofstr(fullName.c_str(),
646 std::ios::out | std::ios::app | std::ios::binary);
647 if (!ofstr) {
648 clout <<
"Error: could not open " << fullName << std::endl;
649 }
650
651 size_t fullSize =
_psys.rankNumOfParticles() * 3;
652 size_t binarySize = size_t(fullSize * sizeof(float));
653
654 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
655 unsigned int uintBinarySize = (unsigned int) binarySize;
656 sizeEncoder.encode(&uintBinarySize, 1);
657
658 Base64Encoder<float> dataEncoder(ofstr, fullSize);
659 for (
auto pS :
_psys._pSystems) {
660 for (auto& p : pS->_particles) {
661 for (int iDim = 0; iDim < 3; ++iDim) {
662 const float tmp = float(p.getPos()[iDim]);
663 dataEncoder.encode(&tmp, 1);
664 }
665 }
666 }
667 ofstr.close();
668 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
669
670 fout << "</DataArray>" << std::endl;
671 fout << "</Points>" << std::endl;
672 fout << "</Piece>" << std::endl;
673 fout.close();
674}