84 preamblePVD(fullNamePVD);
85 for (
int iR = 0; iR < size; iR++) {
88 dataPVD(iT, iR, fullNamePVD, namePiece);
91 dataPVDmaster(iT, iR, fullNamePVDmaster, namePiece);
93 closePVD(fullNamePVD);
98 preambleVTU(fullNameVTU);
100 this->dataArrayBinary(fullNameVTU);
103 this->dataArray(fullNameVTU);
105 closeVTU(fullNameVTU);
108template<
typename T,
template<
typename U>
class PARTICLETYPE>
112#ifdef PARALLEL_MODE_MPI
118 preamblePVD(fullNamePVDmaster);
119 closePVD(fullNamePVDmaster);
124template<
typename T,
template<
typename U>
class PARTICLETYPE>
126 const std::string& fullName)
128 std::ofstream fout(fullName.c_str(), std::ios::trunc);
130 clout <<
"Error: could not open " << fullName << std::endl;
132 fout <<
"<?xml version=\"1.0\"?>" << std::endl << std::flush;
134 <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">"
136 fout <<
"<UnstructuredGrid>" << std::endl;
137 fout <<
"<Piece NumberOfPoints=\"" << _psys.rankNumOfParticles()
138 <<
"\" NumberOfCells=\"" << _psys.rankNumOfParticles() <<
"\">"
140 fout <<
"<PointData Vectors=\"Particles\">" << std::endl;
144template<
typename T,
template<
typename U>
class PARTICLETYPE>
146 const std::string& fullNamePiece)
148 std::ofstream fout(fullNamePiece.c_str(), std::ios::app);
150 clout <<
"Error: could not open " << fullNamePiece << std::endl;
152 fout <<
"</UnstructuredGrid>\n";
153 fout <<
"</VTKFile>\n";
157template<
typename T,
template<
typename U>
class PARTICLETYPE>
159 const std::string& fullNamePVD)
161 std::ofstream fout(fullNamePVD.c_str(), std::ios::trunc);
163 clout <<
"Error: could not open " << fullNamePVD << std::endl;
166 fout <<
"<?xml version=\"1.0\"?>\n";
167 fout <<
"<VTKFile type=\"Collection\" version=\"0.1\" "
168 <<
"byte_order=\"LittleEndian\">\n" <<
"<Collection>\n";
172template<
typename T,
template<
typename U>
class PARTICLETYPE>
174 const std::string& fullNamePVD)
176 std::ofstream fout(fullNamePVD.c_str(), std::ios::app);
178 clout <<
"Error: could not open " << fullNamePVD << std::endl;
180 fout <<
"</Collection>\n";
181 fout <<
"</VTKFile>\n";
185template<
typename T,
template<
typename U>
class PARTICLETYPE>
187 const std::string& fullNamePVD,
const std::string& namePiece)
189 std::ofstream fout(fullNamePVD.c_str(), std::ios::app);
191 clout <<
"Error: could not open " << fullNamePVD << std::endl;
194 fout <<
"<DataSet timestep=\"" << iT <<
"\" " <<
"group=\"\" part=\" " << iC
195 <<
"\" " <<
"file=\"" << namePiece <<
"\"/>\n";
199template<
typename T,
template<
typename U>
class PARTICLETYPE>
201 const std::string& fullNamePVDMaster,
const std::string& namePiece)
203 std::ofstream fout(fullNamePVDMaster.c_str(),
204 std::ios::in | std::ios::out | std::ios::ate);
206 fout.seekp(-25, std::ios::end);
208 fout <<
"<DataSet timestep=\"" << iT <<
"\" " <<
"group=\"\" part=\" "
209 << iC <<
"\" " <<
"file=\"" << namePiece <<
"\"/>\n";
211 closePVD(fullNamePVDMaster);
214 clout <<
"Error: could not open " << fullNamePVDMaster << std::endl;
218template<
typename T,
template<
typename U>
class PARTICLETYPE>
220 const std::string& fullName)
223 std::ofstream fout(fullName.c_str(), std::ios::app);
225 clout <<
"Error: could not open " << fullName << std::endl;
228 if (_properties & particleProperties::radius) {
230 <<
"<DataArray type=\"Float32\" Name=\"Radius\" NumberOfComponents=\"1\" format=\"ascii\">"
232 for (
auto pS : _psys._pSystems) {
233 for (
auto& p : pS->_particles) {
234 fout << p.getRad() <<
" ";
237 fout <<
"</DataArray>" << std::endl;
239 if (_properties & particleProperties::mass) {
241 <<
"<DataArray type=\"Float32\" Name=\"Mass\" NumberOfComponents=\"1\" format=\"ascii\">"
243 for (
auto pS : _psys._pSystems) {
244 for (
auto& p : pS->_particles) {
245 fout << p.getMass() <<
" ";
248 fout <<
"</DataArray>" << std::endl;
250 if (_properties & particleProperties::cuboid) {
252 <<
"<DataArray type=\"Int16\" Name=\"Cuboid\" NumberOfComponents=\"1\" format=\"ascii\">"
254 for (
auto pS : _psys._pSystems) {
255 for (
auto& p : pS->_particles) {
256 fout << p.getCuboid() <<
" ";
259 fout <<
"</DataArray>" << std::endl;
261 if (_properties & particleProperties::active) {
263 <<
"<DataArray type=\"Int16\" Name=\"Active\" NumberOfComponents=\"1\" format=\"ascii\">"
265 for (
auto pS : _psys._pSystems) {
266 for (
auto& p : pS->_particles) {
275 fout <<
"</DataArray>" << std::endl;
277 if (_properties & particleProperties::velocity) {
279 <<
"<DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"ascii\">"
281 for (
auto pS : _psys._pSystems) {
282 for (
auto& p : pS->_particles) {
283 fout << p.getVel()[0] <<
" " << p.getVel()[1] <<
" " << p.getVel()[2]
287 fout <<
"</DataArray>" << std::endl;
289 if (_properties & particleProperties::force) {
291 <<
"<DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"ascii\">"
293 for (
auto pS : _psys._pSystems) {
294 for (
auto& p : pS->_particles) {
295 fout << p.getForce()[0] <<
" " << p.getForce()[1] <<
" " << p.getForce()[2]
299 fout <<
"</DataArray>" << std::endl;
301 fout <<
"</PointData>" << std::endl;
303 fout <<
"<CellData /> " << std::endl;
304 fout <<
"<Cells>" << std::endl;
305 fout <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">"
308 for (
auto pS : _psys._pSystems) {
309 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
313 fout <<
"</DataArray>" << std::endl;
314 fout <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">"
317 for (
auto pS : _psys._pSystems) {
318 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
322 fout <<
"</DataArray>" << std::endl;
323 fout <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">"
325 for (
auto pS : _psys._pSystems) {
326 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
330 fout <<
"</DataArray>" << std::endl;
331 fout <<
"</Cells>" << std::endl;
332 fout <<
"<Points>" << std::endl;
334 <<
"<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\">"
337 for (
auto pS : _psys._pSystems) {
338 for (
auto& p : pS->_particles) {
339 fout << p.getPos()[0] <<
" " << p.getPos()[1] <<
" " << p.getPos()[2] <<
" ";
343 fout <<
"</DataArray>" << std::endl;
344 fout <<
"</Points>" << std::endl;
345 fout <<
"</Piece>" << std::endl;
349template<
typename T,
template<
typename U>
class PARTICLETYPE>
351 const std::string& fullName)
354 std::ofstream fout(fullName.c_str(), std::ios::app);
356 clout <<
"Error: could not open " << fullName << std::endl;
359 if (_properties & particleProperties::radius) {
361 <<
"<DataArray type=\"Float32\" Name=\"Radius\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
365 std::ofstream ofstr(fullName.c_str(),
366 std::ios::out | std::ios::app | std::ios::binary);
368 clout <<
"Error: could not open " << fullName << std::endl;
371 size_t fullSize = _psys.rankNumOfParticles();
372 size_t binarySize = size_t(fullSize *
sizeof(
float));
375 unsigned int uintBinarySize = (
unsigned int) binarySize;
376 sizeEncoder.
encode(&uintBinarySize, 1);
379 for (
auto pS : _psys._pSystems) {
380 for (
auto& p : pS->_particles) {
381 const float tmp = float(p.getRad());
382 dataEncoder.
encode(&tmp, 1);
387 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
388 fout <<
"</DataArray>" << std::endl;
391 if (_properties & particleProperties::mass) {
393 <<
"<DataArray type=\"Float32\" Name=\"Mass\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
397 std::ofstream ofstr(fullName.c_str(),
398 std::ios::out | std::ios::app | std::ios::binary);
400 clout <<
"Error: could not open " << fullName << std::endl;
403 size_t fullSize = _psys.rankNumOfParticles();
404 size_t binarySize = size_t(fullSize *
sizeof(
float));
407 unsigned int uintBinarySize = (
unsigned int) binarySize;
408 sizeEncoder.
encode(&uintBinarySize, 1);
411 for (
auto pS : _psys._pSystems) {
412 for (
auto& p : pS->_particles) {
413 const float tmp = float(p.getMass());
414 dataEncoder.
encode(&tmp, 1);
419 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
420 fout <<
"</DataArray>" << std::endl;
422 if (_properties & particleProperties::cuboid) {
424 <<
"<DataArray type=\"Int32\" Name=\"Cuboid\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
428 std::ofstream ofstr(fullName.c_str(),
429 std::ios::out | std::ios::app | std::ios::binary);
431 clout <<
"Error: could not open " << fullName << std::endl;
434 size_t fullSize = _psys.rankNumOfParticles();
435 size_t binarySize = size_t(fullSize *
sizeof(
int));
438 unsigned int uintBinarySize = (
unsigned int) binarySize;
439 sizeEncoder.
encode(&uintBinarySize, 1);
443 for (
auto pS : _psys._pSystems) {
444 for (
auto& p : pS->_particles) {
445 const int tmp = int(p.getCuboid());
446 dataEncoder.
encode(&tmp, 1);
451 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
452 fout <<
"</DataArray>" << std::endl;
454 if (_properties & particleProperties::active) {
456 <<
"<DataArray type=\"Int32\" Name=\"Active\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
460 std::ofstream ofstr(fullName.c_str(),
461 std::ios::out | std::ios::app | std::ios::binary);
463 clout <<
"Error: could not open " << fullName << std::endl;
466 size_t fullSize = _psys.rankNumOfParticles();
467 size_t binarySize = size_t(fullSize *
sizeof(
int));
470 unsigned int uintBinarySize = (
unsigned int) binarySize;
471 sizeEncoder.
encode(&uintBinarySize, 1);
474 for (
auto pS : _psys._pSystems) {
475 for (
auto& p : pS->_particles) {
480 dataEncoder.
encode(&tmp, 1);
485 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
486 fout <<
"</DataArray>" << std::endl;
489 if (_properties & particleProperties::velocity) {
491 <<
"<DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
495 std::ofstream ofstr(fullName.c_str(),
496 std::ios::out | std::ios::app | std::ios::binary);
498 clout <<
"Error: could not open " << fullName << std::endl;
501 size_t fullSize = _psys.rankNumOfParticles() * 3;
502 size_t binarySize = size_t(fullSize *
sizeof(
float));
505 unsigned int uintBinarySize = (
unsigned int) binarySize;
506 sizeEncoder.
encode(&uintBinarySize, 1);
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);
518 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
519 fout <<
"</DataArray>" << std::endl;
521 if (_properties & particleProperties::force) {
523 <<
"<DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
527 std::ofstream ofstr(fullName.c_str(),
528 std::ios::out | std::ios::app | std::ios::binary);
530 clout <<
"Error: could not open " << fullName << std::endl;
533 size_t fullSize = _psys.rankNumOfParticles() * 3;
534 size_t binarySize = size_t(fullSize *
sizeof(
float));
537 unsigned int uintBinarySize = (
unsigned int) binarySize;
538 sizeEncoder.
encode(&uintBinarySize, 1);
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);
550 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
551 fout <<
"</DataArray>" << std::endl;
553 fout <<
"</PointData>" << std::endl;
555 fout <<
"<CellData /> " << std::endl;
556 fout <<
"<Cells>" << std::endl;
557 fout <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"binary\" encoding=\"base64\">" << std::endl;
560 std::ofstream ofstr(fullName.c_str(),
561 std::ios::out | std::ios::app | std::ios::binary);
563 clout <<
"Error: could not open " << fullName << std::endl;
566 size_t fullSize = _psys.rankNumOfParticles();
567 size_t binarySize = size_t(fullSize *
sizeof(
int));
569 unsigned int uintBinarySize = (
unsigned int) binarySize;
570 sizeEncoder.
encode(&uintBinarySize, 1);
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);
581 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
582 fout <<
"</DataArray>" << std::endl;
584 fout <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"binary\" encoding=\"base64\">"
588 std::ofstream ofstr(fullName.c_str(), std::ios::out | std::ios::app | std::ios::binary);
590 clout <<
"Error: could not open " << fullName << std::endl;
593 size_t fullSize = _psys.rankNumOfParticles();
594 size_t binarySize = size_t(fullSize *
sizeof(
int));
596 unsigned int uintBinarySize = (
unsigned int) binarySize;
597 sizeEncoder.
encode(&uintBinarySize, 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);
608 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
609 fout <<
"</DataArray>" << std::endl;
612 fout <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"binary\" encoding=\"base64\">"
616 std::ofstream ofstr(fullName.c_str(),
617 std::ios::out | std::ios::app | std::ios::binary);
619 clout <<
"Error: could not open " << fullName << std::endl;
622 size_t fullSize = _psys.rankNumOfParticles();
623 size_t binarySize = size_t(fullSize *
sizeof(
int));
625 unsigned int uintBinarySize = (
unsigned int) binarySize;
626 sizeEncoder.
encode(&uintBinarySize, 1);
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);
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\">"
645 std::ofstream ofstr(fullName.c_str(),
646 std::ios::out | std::ios::app | std::ios::binary);
648 clout <<
"Error: could not open " << fullName << std::endl;
651 size_t fullSize = _psys.rankNumOfParticles() * 3;
652 size_t binarySize = size_t(fullSize *
sizeof(
float));
655 unsigned int uintBinarySize = (
unsigned int) binarySize;
656 sizeEncoder.
encode(&uintBinarySize, 1);
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);
668 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
670 fout <<
"</DataArray>" << std::endl;
671 fout <<
"</Points>" << std::endl;
672 fout <<
"</Piece>" << std::endl;
692 std::string
const filename,
const std::bitset<9>& properties,
bool binary) :
698 const std::string& fullName)
701 std::ofstream fout(fullName.c_str(), std::ios::app);
703 this->clout <<
"Error: could not open " << fullName << std::endl;
706 if (_properties.test(pPropRadius)) {
708 <<
"<DataArray type=\"Float32\" Name=\"Radius\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
712 std::ofstream ofstr(fullName.c_str(),
713 std::ios::out | std::ios::app | std::ios::binary);
715 this->clout <<
"Error: could not open " << fullName << std::endl;
718 size_t fullSize = this->_psys.rankNumOfParticles();
719 size_t binarySize = size_t(fullSize *
sizeof(
float));
721 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
722 unsigned int uintBinarySize = (
unsigned int) binarySize;
723 sizeEncoder.encode(&uintBinarySize, 1);
725 Base64Encoder<float> dataEncoder(ofstr, fullSize);
726 for (
auto pS : this->_psys._pSystems) {
727 for (
auto& p : pS->_particles) {
728 const float tmp = float(p.getRad());
729 dataEncoder.encode(&tmp, 1);
734 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
735 fout <<
"</DataArray>" << std::endl;
738 if (_properties.test(pPropMass)) {
740 <<
"<DataArray type=\"Float32\" Name=\"Mass\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
744 std::ofstream ofstr(fullName.c_str(),
745 std::ios::out | std::ios::app | std::ios::binary);
747 this->clout <<
"Error: could not open " << fullName << std::endl;
750 size_t fullSize = this->_psys.rankNumOfParticles();
751 size_t binarySize = size_t(fullSize *
sizeof(
float));
753 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
754 unsigned int uintBinarySize = (
unsigned int) binarySize;
755 sizeEncoder.encode(&uintBinarySize, 1);
757 Base64Encoder<float> dataEncoder(ofstr, fullSize);
758 for (
auto pS : this->_psys._pSystems) {
759 for (
auto& p : pS->_particles) {
760 const float tmp = float(p.getMass());
761 dataEncoder.encode(&tmp, 1);
766 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
767 fout <<
"</DataArray>" << std::endl;
769 if (_properties.test(pPropCuboid)) {
771 <<
"<DataArray type=\"Int32\" Name=\"Cuboid\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
775 std::ofstream ofstr(fullName.c_str(),
776 std::ios::out | std::ios::app | std::ios::binary);
778 this->clout <<
"Error: could not open " << fullName << std::endl;
781 size_t fullSize = this->_psys.rankNumOfParticles();
782 size_t binarySize = size_t(fullSize *
sizeof(
int));
784 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
785 unsigned int uintBinarySize = (
unsigned int) binarySize;
786 sizeEncoder.encode(&uintBinarySize, 1);
788 Base64Encoder<int> dataEncoder(ofstr, fullSize);
789 for (
auto pS : this->_psys._pSystems) {
790 for (
auto& p : pS->_particles) {
791 const int tmp = int(p.getCuboid());
792 dataEncoder.encode(&tmp, 1);
797 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
798 fout <<
"</DataArray>" << std::endl;
800 if (_properties.test(pPropActive)) {
802 <<
"<DataArray type=\"Int32\" Name=\"Active\" NumberOfComponents=\"1\" format=\"binary\" encoding=\"base64\">"
806 std::ofstream ofstr(fullName.c_str(),
807 std::ios::out | std::ios::app | std::ios::binary);
809 this->clout <<
"Error: could not open " << fullName << std::endl;
812 size_t fullSize = this->_psys.rankNumOfParticles();
813 size_t binarySize = size_t(fullSize *
sizeof(
int));
815 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
816 unsigned int uintBinarySize = (
unsigned int) binarySize;
817 sizeEncoder.encode(&uintBinarySize, 1);
819 Base64Encoder<int> dataEncoder(ofstr, fullSize);
820 for (
auto pS : this->_psys._pSystems) {
821 for (
auto& p : pS->_particles) {
826 dataEncoder.encode(&tmp, 1);
831 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
832 fout <<
"</DataArray>" << std::endl;
835 if (_properties.test(pPropVelocity)) {
837 <<
"<DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
841 std::ofstream ofstr(fullName.c_str(),
842 std::ios::out | std::ios::app | std::ios::binary);
844 this->clout <<
"Error: could not open " << fullName << std::endl;
847 size_t fullSize = this->_psys.rankNumOfParticles() * 3;
848 size_t binarySize = size_t(fullSize *
sizeof(
float));
850 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
851 unsigned int uintBinarySize = (
unsigned int) binarySize;
852 sizeEncoder.encode(&uintBinarySize, 1);
854 Base64Encoder<float> dataEncoder(ofstr, fullSize);
855 for (
auto pS : this->_psys._pSystems) {
856 for (
auto& p : pS->_particles) {
857 for (
int iDim = 0; iDim < 3; ++iDim) {
858 const float tmp = float(p.getVel()[iDim]);
859 dataEncoder.encode(&tmp, 1);
864 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
865 fout <<
"</DataArray>" << std::endl;
868 if (_properties.test(pPropForce)) {
870 <<
"<DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
874 std::ofstream ofstr(fullName.c_str(),
875 std::ios::out | std::ios::app | std::ios::binary);
877 this->clout <<
"Error: could not open " << fullName << std::endl;
880 size_t fullSize = this->_psys.rankNumOfParticles() * 3;
881 size_t binarySize = size_t(fullSize *
sizeof(
float));
883 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
884 unsigned int uintBinarySize = (
unsigned int) binarySize;
885 sizeEncoder.encode(&uintBinarySize, 1);
887 Base64Encoder<float> dataEncoder(ofstr, fullSize);
888 for (
auto pS : this->_psys._pSystems) {
889 for (
auto& p : pS->_particles) {
890 for (
int iDim = 0; iDim < 3; ++iDim) {
891 const float tmp = float(p.getForce()[iDim]);
892 dataEncoder.encode(&tmp, 1);
897 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
898 fout <<
"</DataArray>" << std::endl;
900 if (_properties.test(pPropMoment)) {
902 <<
"<DataArray type=\"Float32\" Name=\"Moment\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
906 std::ofstream ofstr(fullName.c_str(),
907 std::ios::out | std::ios::app | std::ios::binary);
909 this->clout <<
"Error: could not open " << fullName << std::endl;
912 size_t fullSize = this->_psys.rankNumOfParticles() * 3;
913 size_t binarySize = size_t(fullSize *
sizeof(
float));
915 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
916 unsigned int uintBinarySize = (
unsigned int) binarySize;
917 sizeEncoder.encode(&uintBinarySize, 1);
919 Base64Encoder<float> dataEncoder(ofstr, fullSize);
920 for (
auto pS : this->_psys._pSystems) {
921 for (
auto& p : pS->_particles) {
922 for (
int iDim = 0; iDim < 3; ++iDim) {
923 const float tmp = float(p.getMoment()[iDim]);
924 dataEncoder.encode(&tmp, 1);
929 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
930 fout <<
"</DataArray>" << std::endl;
932 if (_properties.test(pPropAVel)) {
934 <<
"<DataArray type=\"Float32\" Name=\"AngularVelocity\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
938 std::ofstream ofstr(fullName.c_str(),
939 std::ios::out | std::ios::app | std::ios::binary);
941 this->clout <<
"Error: could not open " << fullName << std::endl;
944 size_t fullSize = this->_psys.rankNumOfParticles() * 3;
945 size_t binarySize = size_t(fullSize *
sizeof(
float));
947 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
948 unsigned int uintBinarySize = (
unsigned int) binarySize;
949 sizeEncoder.encode(&uintBinarySize, 1);
951 Base64Encoder<float> dataEncoder(ofstr,
953 for (
auto pS : this->_psys._pSystems) {
954 for (
auto p : pS->_particles) {
955 for (
int iDim = 0; iDim < 3; ++iDim) {
956 const float tmp = float(p.getAVel()[iDim]);
957 dataEncoder.encode(&tmp, 1);
962 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
963 fout <<
"</DataArray>" << std::endl;
965 if (_properties.test(pPropTorque)) {
967 <<
"<DataArray type=\"Float32\" Name=\"Torque\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
971 std::ofstream ofstr(fullName.c_str(),
972 std::ios::out | std::ios::app | std::ios::binary);
974 this->clout <<
"Error: could not open " << fullName << std::endl;
977 size_t fullSize = this->_psys.rankNumOfParticles() * 3;
978 size_t binarySize = size_t(fullSize *
sizeof(
float));
980 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
981 unsigned int uintBinarySize = (
unsigned int) binarySize;
982 sizeEncoder.encode(&uintBinarySize, 1);
984 Base64Encoder<float> dataEncoder(ofstr,
986 for (
auto pS : this->_psys._pSystems) {
987 for (
auto p : pS->_particles) {
988 for (
int iDim = 0; iDim < 3; ++iDim) {
989 const float tmp = float(p.getTorque()[iDim]);
990 dataEncoder.encode(&tmp, 1);
995 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
996 fout <<
"</DataArray>" << std::endl;
998 fout <<
"</PointData>" << std::endl;
1000 fout <<
"<CellData /> " << std::endl;
1001 fout <<
"<Cells>" << std::endl;
1002 fout <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"binary\" encoding=\"base64\">" << std::endl;
1005 std::ofstream ofstr(fullName.c_str(),
1006 std::ios::out | std::ios::app | std::ios::binary);
1008 this->clout <<
"Error: could not open " << fullName << std::endl;
1011 size_t fullSize = this->_psys.rankNumOfParticles();
1012 size_t binarySize = size_t(fullSize *
sizeof(
int));
1013 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
1014 unsigned int uintBinarySize = (
unsigned int) binarySize;
1015 sizeEncoder.encode(&uintBinarySize, 1);
1016 Base64Encoder<int32_t> dataEncoder(ofstr,
1019 for (
auto pS : this->_psys._pSystems) {
1020 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
1021 const int32_t tmp = i++;
1022 dataEncoder.encode(&tmp, 1);
1027 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
1028 fout <<
"</DataArray>" << std::endl;
1030 fout <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"binary\" encoding=\"base64\">"
1034 std::ofstream ofstr(fullName.c_str(),
1035 std::ios::out | std::ios::app | std::ios::binary);
1037 this->clout <<
"Error: could not open " << fullName << std::endl;
1040 size_t fullSize = this->_psys.rankNumOfParticles();
1041 size_t binarySize = size_t(fullSize *
sizeof(
int));
1042 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
1043 unsigned int uintBinarySize = (
unsigned int) binarySize;
1044 sizeEncoder.encode(&uintBinarySize, 1);
1045 Base64Encoder<int32_t> dataEncoder(ofstr, fullSize);
1047 for (
auto pS : this->_psys._pSystems) {
1048 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
1049 const int32_t tmp = i++;
1050 dataEncoder.encode(&tmp, 1);
1055 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
1056 fout <<
"</DataArray>" << std::endl;
1059 fout <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"binary\" encoding=\"base64\">"
1063 std::ofstream ofstr(fullName.c_str(),
1064 std::ios::out | std::ios::app | std::ios::binary);
1066 this->clout <<
"Error: could not open " << fullName << std::endl;
1069 size_t fullSize = this-> _psys.rankNumOfParticles();
1070 size_t binarySize = size_t(fullSize *
sizeof(
int));
1071 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
1072 unsigned int uintBinarySize = (
unsigned int) binarySize;
1073 sizeEncoder.encode(&uintBinarySize, 1);
1074 Base64Encoder<uint8_t> dataEncoder(ofstr, fullSize);
1075 for (
auto pS : this->_psys._pSystems) {
1076 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
1077 const uint8_t tmp = 1;
1078 dataEncoder.encode(&tmp, 1);
1083 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
1084 fout <<
"</DataArray>" << std::endl;
1085 fout <<
"</Cells>" << std::endl;
1086 fout <<
"<Points>" << std::endl;
1087 fout <<
"<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"binary\" encoding=\"base64\">"
1092 std::ofstream ofstr(fullName.c_str(),
1093 std::ios::out | std::ios::app | std::ios::binary);
1095 this->clout <<
"Error: could not open " << fullName << std::endl;
1098 size_t fullSize = this->_psys.rankNumOfParticles() * 3;
1099 size_t binarySize = size_t(fullSize *
sizeof(
float));
1101 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
1102 unsigned int uintBinarySize = (
unsigned int) binarySize;
1103 sizeEncoder.encode(&uintBinarySize, 1);
1105 Base64Encoder<float> dataEncoder(ofstr, fullSize);
1106 for (
auto pS : this->_psys._pSystems) {
1107 for (
auto& p : pS->_particles) {
1108 for (
int iDim = 0; iDim < 3; ++iDim) {
1109 const float tmp = float(p.getPos()[iDim]);
1110 dataEncoder.encode(&tmp, 1);
1115 fout.open(fullName.c_str(), std::ios::out | std::ios::app);
1117 fout <<
"</DataArray>" << std::endl;
1118 fout <<
"</Points>" << std::endl;
1119 fout <<
"</Piece>" << std::endl;
1124void SuperParticleSysVtuWriterMag<T>::dataArray(
1125 const std::string& fullName)
1127 std::cout<<
"Special member accessed" << std::endl;
1128 std::ofstream fout(fullName.c_str(), std::ios::app);
1130 this->clout <<
"Error: could not open " << fullName << std::endl;
1133 if (_properties.test(pPropRadius)) {
1135 <<
"<DataArray type=\"Float32\" Name=\"Radius\" NumberOfComponents=\"1\" format=\"ascii\">"
1137 for (
auto pS : this->_psys._pSystems) {
1138 for (
auto& p : pS->_particles) {
1139 fout << p.getRad() <<
" ";
1142 fout <<
"</DataArray>" << std::endl;
1144 if (_properties.test(pPropMass)) {
1146 <<
"<DataArray type=\"Float32\" Name=\"Mass\" NumberOfComponents=\"1\" format=\"ascii\">"
1148 for (
auto pS : this->_psys._pSystems) {
1149 for (
auto& p : pS->_particles) {
1150 fout << p.getMass() <<
" ";
1153 fout <<
"</DataArray>" << std::endl;
1155 if (_properties.test(pPropCuboid)) {
1157 <<
"<DataArray type=\"Int16\" Name=\"Cuboid\" NumberOfComponents=\"1\" format=\"ascii\">"
1159 for (
auto pS : this->_psys._pSystems) {
1160 for (
auto& p : pS->_particles) {
1161 fout << p.getCuboid() <<
" ";
1164 fout <<
"</DataArray>" << std::endl;
1166 if (_properties.test(pPropActive)) {
1168 <<
"<DataArray type=\"Int16\" Name=\"Active\" NumberOfComponents=\"1\" format=\"ascii\">"
1170 for (
auto pS : this->_psys._pSystems) {
1171 for (
auto& p : pS->_particles) {
1172 if (p.getActive()) {
1180 fout <<
"</DataArray>" << std::endl;
1182 if (_properties.test(pPropVelocity)) {
1184 <<
"<DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"ascii\">"
1186 for (
auto pS : this->_psys._pSystems) {
1187 for (
auto& p : pS->_particles) {
1188 fout << p.getVel()[0] <<
" " << p.getVel()[1] <<
" " << p.getVel()[2]
1192 fout <<
"</DataArray>" << std::endl;
1194 if (_properties.test(pPropForce)) {
1196 <<
"<DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"ascii\">"
1198 for (
auto pS : this->_psys._pSystems) {
1199 for (
auto& p : pS->_particles) {
1200 fout << p.getForce()[0] <<
" " << p.getForce()[1] <<
" " << p.getForce()[2]
1204 fout <<
"</DataArray>" << std::endl;
1206 if (_properties.test(pPropMoment)) {
1208 <<
"<DataArray type=\"Float32\" Name=\"Moment\" NumberOfComponents=\"3\" format=\"ascii\">"
1210 for (
auto pS : this->_psys._pSystems) {
1211 for (
auto& p : pS->_particles) {
1212 fout << p.getMoment()[0] <<
" " << p.getMoment()[1] <<
" " << p.getMoment()[2]
1216 fout <<
"</DataArray>" << std::endl;
1218 if (_properties.test(pPropTorque)) {
1220 <<
"<DataArray type=\"Float32\" Name=\"Torque\" NumberOfComponents=\"3\" format=\"ascii\">"
1222 for (
auto pS : this->_psys._pSystems) {
1223 for (
auto p : pS->_particles) {
1224 fout << p.getTorque()[0] <<
" " << p.getTorque()[1] <<
" " << p.getTorque()[2]
1228 fout <<
"</DataArray>" << std::endl;
1230 fout <<
"</PointData>" << std::endl;
1232 fout <<
"<CellData /> " << std::endl;
1233 fout <<
"<Cells>" << std::endl;
1234 fout <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">"
1237 for (
auto pS : this->_psys._pSystems) {
1238 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
1242 fout <<
"</DataArray>" << std::endl;
1243 fout <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">"
1246 for (
auto pS : this->_psys._pSystems) {
1247 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
1251 fout <<
"</DataArray>" << std::endl;
1252 fout <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">"
1254 for (
auto pS : this->_psys._pSystems) {
1255 for (
unsigned int p=0; p<pS->_particles.size(); p++) {
1259 fout <<
"</DataArray>" << std::endl;
1260 fout <<
"</Cells>" << std::endl;
1261 fout <<
"<Points>" << std::endl;
1263 <<
"<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\">"
1266 for (
auto pS : this->_psys._pSystems) {
1267 for (
auto& p : pS->_particles) {
1268 fout << p.getPos()[0] <<
" " << p.getPos()[1] <<
" " << p.getPos()[2] <<
" ";
1272 fout <<
"</DataArray>" << std::endl;
1273 fout <<
"</Points>" << std::endl;
1274 fout <<
"</Piece>" << std::endl;
1284#ifdef PARALLEL_MODE_MPI
1290 if (!this->_haveMaster) {
1291 this->createMasterFile();
1299 this->preamblePVD(fullNamePVD);
1300 for (
int iR = 0; iR < size; iR++) {
1301 std::string namePiece =
"data/" +
createFileName(this->_name, iT, iR) +
".vtu";
1303 this->dataPVD(iT, iR, fullNamePVD, namePiece);
1306 this->dataPVDmaster(iT, iR, fullNamePVDmaster, namePiece);
1308 this->closePVD(fullNamePVD);
1313 this->preambleVTU(fullNameVTU);
1314 if (this->_binary) {
1315 this->dataArrayBinary(fullNameVTU);
1318 this->dataArray(fullNameVTU);
1320 this->closeVTU(fullNameVTU);
1326 _properties.set(pref);