OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
olb::SuperParticleSysVtuWriter< T, PARTICLETYPE > Class Template Reference

#include <superParticleSysVTUout.h>

+ Inheritance diagram for olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >:
+ Collaboration diagram for olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >:

Public Types

enum  particleProperties : unsigned short {
  velocity = 1 , radius = 2 , mass = 4 , force = 8 ,
  cuboid = 16 , active = 32
}
 

Public Member Functions

 SuperParticleSysVtuWriter (SuperParticleSystem3D< T, PARTICLETYPE > &, std::string const, unsigned short properties, bool binary=true)
 
 SuperParticleSysVtuWriter (const SuperParticleSysVtuWriter< T, PARTICLETYPE > &rhs)
 
 SuperParticleSysVtuWriter (const SuperParticleSysVtuWriter< T, PARTICLETYPE > &&rhs)
 
void write (int iT=0)
 
int numofpsys ()
 
void set (unsigned short)
 

Protected Member Functions

void preambleVTU (const std::string &fullName)
 performes <VTKFile ...>, <ImageData ...> and <PieceExtent ...>
 
void closeVTU (const std::string &fullNamePiece)
 performes </ImageData> and </VTKFile>
 
void preamblePVD (const std::string &fullNamePVD)
 performes <VTKFile ...> and <Collection>
 
void closePVD (const std::string &fullNamePVD)
 performes </Collection> and </VTKFile>
 
void dataPVD (int iT, int iR, const std::string &fullNamePVD, const std::string &namePiece)
 performes <DataSet timestep= ... file=namePiece >
 
void dataPVDmaster (int iT, int iR, const std::string &fullNamePVDMaster, const std::string &namePiece)
 performes <DataSet timestep= ... file=namePiece >
 
void dataArray (const std::string &fullName)
 writes functors stored at pointerVec
 
void dataArrayBinary (const std::string &fullName)
 writes functors stored at pointerVec
 
void preambleOneFile (const std::string &fullName)
 performes <VTKFile...> and <ImageData ...>
 
void writePieceToOneFile (const std::string &fullName)
 writes instantaniously given functor, without adding to _pointerVec
 
void createMasterFile ()
 

Protected Attributes

SuperParticleSystem3D< T, PARTICLETYPE > & _psys
 
std::string _name
 
unsigned short _properties
 
bool _binary
 
bool _haveMaster
 
OstreamManager clout
 

Detailed Description

template<typename T, template< typename U > class PARTICLETYPE>
class olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >

Definition at line 48 of file superParticleSysVTUout.h.

Member Enumeration Documentation

◆ particleProperties

template<typename T , template< typename U > class PARTICLETYPE>
enum olb::SuperParticleSysVtuWriter::particleProperties : unsigned short

Constructor & Destructor Documentation

◆ SuperParticleSysVtuWriter() [1/3]

template<typename T , template< typename U > class PARTICLETYPE>
olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::SuperParticleSysVtuWriter ( SuperParticleSystem3D< T, PARTICLETYPE > & psys,
std::string const filename,
unsigned short properties,
bool binary = true )

Definition at line 57 of file superParticleSysVTUout.hh.

59 : _psys(psys), _name(filename), _properties(properties), _binary(binary), _haveMaster(false), clout(std::cout, "SuperParticleSysVtuWriter")
60{
61}
SuperParticleSystem3D< T, PARTICLETYPE > & _psys

◆ SuperParticleSysVtuWriter() [2/3]

template<typename T , template< typename U > class PARTICLETYPE>
olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::SuperParticleSysVtuWriter ( const SuperParticleSysVtuWriter< T, PARTICLETYPE > & rhs)

Definition at line 44 of file superParticleSysVTUout.hh.

45 : _psys(rhs._psys), _name(rhs._name), _properties(rhs._properties), _binary(rhs._binary), _haveMaster(rhs._haveMaster), clout(std::cout, "SuperParticleSysVtuWriter")
46{
47}

◆ SuperParticleSysVtuWriter() [3/3]

template<typename T , template< typename U > class PARTICLETYPE>
olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::SuperParticleSysVtuWriter ( const SuperParticleSysVtuWriter< T, PARTICLETYPE > && rhs)

Definition at line 50 of file superParticleSysVTUout.hh.

51 : _psys(rhs._psys), _name(rhs._name), _properties(rhs._properties), _binary(rhs._binary), _haveMaster(rhs._haveMaster), clout(std::cout, "SuperParticleSysVtuWriter")
52{
53}

Member Function Documentation

◆ closePVD()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::closePVD ( const std::string & fullNamePVD)
protected

performes </Collection> and </VTKFile>

Definition at line 173 of file superParticleSysVTUout.hh.

175{
176 std::ofstream fout(fullNamePVD.c_str(), std::ios::app);
177 if (!fout) {
178 clout << "Error: could not open " << fullNamePVD << std::endl;
179 }
180 fout << "</Collection>\n";
181 fout << "</VTKFile>\n";
182 fout.close();
183}

◆ closeVTU()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::closeVTU ( const std::string & fullNamePiece)
protected

performes </ImageData> and </VTKFile>

Definition at line 145 of file superParticleSysVTUout.hh.

147{
148 std::ofstream fout(fullNamePiece.c_str(), std::ios::app);
149 if (!fout) {
150 clout << "Error: could not open " << fullNamePiece << std::endl;
151 }
152 fout << "</UnstructuredGrid>\n";
153 fout << "</VTKFile>\n";
154 fout.close();
155}

◆ createMasterFile()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::createMasterFile ( )
protected

Definition at line 109 of file superParticleSysVTUout.hh.

110{
111 int rank = 0;
112#ifdef PARALLEL_MODE_MPI
113 rank = singleton::mpi().getRank();
114#endif
115 if (rank == 0) {
116 std::string fullNamePVDmaster = singleton::directories().getVtkOutDir()
117 + createFileName(_name) + "_master.pvd";
118 preamblePVD(fullNamePVDmaster);
119 closePVD(fullNamePVDmaster);
120 _haveMaster = true;
121 }
122}
void preamblePVD(const std::string &fullNamePVD)
performes <VTKFile ...> and <Collection>
void closePVD(const std::string &fullNamePVD)
performes </Collection> and </VTKFile>
std::string getVtkOutDir() const
Definition singleton.h:97
int getRank() const
Returns the process ID.
MpiManager & mpi()
Directories & directories()
Definition singleton.h:150
std::string createFileName(std::string name)
for .pvd masterFile
Definition fileName.hh:34

References olb::createFileName(), olb::singleton::directories(), olb::singleton::MpiManager::getRank(), olb::singleton::Directories::getVtkOutDir(), and olb::singleton::mpi().

+ Here is the call graph for this function:

◆ dataArray()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::dataArray ( const std::string & fullName)
protected

writes functors stored at pointerVec

Definition at line 219 of file superParticleSysVTUout.hh.

221{
222 //std::cout<< "Base member accessed" << std::endl;
223 std::ofstream fout(fullName.c_str(), std::ios::app);
224 if (!fout) {
225 clout << "Error: could not open " << fullName << std::endl;
226 }
227
229 fout
230 << "<DataArray type=\"Float32\" Name=\"Radius\" NumberOfComponents=\"1\" format=\"ascii\">"
231 << std::endl;
232 for (auto pS : _psys._pSystems) {
233 for (auto& p : pS->_particles) {
234 fout << p.getRad() << " ";
235 }
236 }
237 fout << "</DataArray>" << std::endl;
238 }
240 fout
241 << "<DataArray type=\"Float32\" Name=\"Mass\" NumberOfComponents=\"1\" format=\"ascii\">"
242 << std::endl;
243 for (auto pS : _psys._pSystems) {
244 for (auto& p : pS->_particles) {
245 fout << p.getMass() << " ";
246 }
247 }
248 fout << "</DataArray>" << std::endl;
249 }
251 fout
252 << "<DataArray type=\"Int16\" Name=\"Cuboid\" NumberOfComponents=\"1\" format=\"ascii\">"
253 << std::endl;
254 for (auto pS : _psys._pSystems) {
255 for (auto& p : pS->_particles) {
256 fout << p.getCuboid() << " ";
257 }
258 }
259 fout << "</DataArray>" << std::endl;
260 }
262 fout
263 << "<DataArray type=\"Int16\" Name=\"Active\" NumberOfComponents=\"1\" format=\"ascii\">"
264 << std::endl;
265 for (auto pS : _psys._pSystems) {
266 for (auto& p : pS->_particles) {
267 if (p.getActive()) {
268 fout << "1 ";
269 }
270 else {
271 fout << "0 ";
272 }
273 }
274 }
275 fout << "</DataArray>" << std::endl;
276 }
278 fout
279 << "<DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"ascii\">"
280 << std::endl;
281 for (auto pS : _psys._pSystems) {
282 for (auto& p : pS->_particles) {
283 fout << p.getVel()[0] << " " << p.getVel()[1] << " " << p.getVel()[2]
284 << " ";
285 }
286 }
287 fout << "</DataArray>" << std::endl;
288 }
290 fout
291 << "<DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"ascii\">"
292 << std::endl;
293 for (auto pS : _psys._pSystems) {
294 for (auto& p : pS->_particles) {
295 fout << p.getForce()[0] << " " << p.getForce()[1] << " " << p.getForce()[2]
296 << " ";
297 }
298 }
299 fout << "</DataArray>" << std::endl;
300 }
301 fout << "</PointData>" << std::endl;
302
303 fout << "<CellData /> " << std::endl;
304 fout << "<Cells>" << std::endl;
305 fout << "<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">"
306 << std::endl;
307 int32_t i = 0;
308 for (auto pS : _psys._pSystems) {
309 for (unsigned int p=0; p<pS->_particles.size(); p++) {
310 fout << i++ << " ";
311 }
312 }
313 fout << "</DataArray>" << std::endl;
314 fout << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">"
315 << std::endl;
316 i = 1;
317 for (auto pS : _psys._pSystems) {
318 for (unsigned int p=0; p<pS->_particles.size(); p++) {
319 fout << i++ << " ";
320 }
321 }
322 fout << "</DataArray>" << std::endl;
323 fout << "<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">"
324 << std::endl;
325 for (auto pS : _psys._pSystems) {
326 for (unsigned int p=0; p<pS->_particles.size(); p++) {
327 fout << 1 << " ";
328 }
329 }
330 fout << "</DataArray>" << std::endl;
331 fout << "</Cells>" << std::endl;
332 fout << "<Points>" << std::endl;
333 fout
334 << "<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\">"
335 << std::endl;
336
337 for (auto pS : _psys._pSystems) {
338 for (auto& p : pS->_particles) {
339 fout << p.getPos()[0] << " " << p.getPos()[1] << " " << p.getPos()[2] << " ";
340 }
341 }
342
343 fout << "</DataArray>" << std::endl;
344 fout << "</Points>" << std::endl;
345 fout << "</Piece>" << std::endl;
346 fout.close();
347}

◆ dataArrayBinary()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::dataArrayBinary ( const std::string & fullName)
protected

writes functors stored at pointerVec

Definition at line 350 of file superParticleSysVTUout.hh.

352{
353 //std::cout<< "Base member accessed - binary" << std::endl;
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); // only used for binary output // passed to Base64Encoder
367 if (!ofstr) {
368 clout << "Error: could not open " << fullName << std::endl;
369 }
370
371 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
372 size_t binarySize = size_t(fullSize * sizeof(float));
373 // writes first number, which have to be the size(byte) of the following data
374 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
375 unsigned int uintBinarySize = (unsigned int) binarySize;
376 sizeEncoder.encode(&uintBinarySize, 1);
377 // write numbers from functor
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); // only used for binary output // passed to Base64Encoder
399 if (!ofstr) {
400 clout << "Error: could not open " << fullName << std::endl;
401 }
402
403 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
404 size_t binarySize = size_t(fullSize * sizeof(float));
405 // writes first number, which have to be the size(byte) of the following data
406 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
407 unsigned int uintBinarySize = (unsigned int) binarySize;
408 sizeEncoder.encode(&uintBinarySize, 1);
409 // write numbers from functor
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); // only used for binary output // passed to Base64Encoder
430 if (!ofstr) {
431 clout << "Error: could not open " << fullName << std::endl;
432 }
433
434 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
435 size_t binarySize = size_t(fullSize * sizeof(int));
436 // writes first number, which have to be the size(byte) of the following data
437 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
438 unsigned int uintBinarySize = (unsigned int) binarySize;
439 sizeEncoder.encode(&uintBinarySize, 1);
440 // write numbers from functor
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); // only used for binary output // passed to Base64Encoder
462 if (!ofstr) {
463 clout << "Error: could not open " << fullName << std::endl;
464 }
465
466 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
467 size_t binarySize = size_t(fullSize * sizeof(int));
468 // writes first number, which have to be the size(byte) of the following data
469 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
470 unsigned int uintBinarySize = (unsigned int) binarySize;
471 sizeEncoder.encode(&uintBinarySize, 1);
472 // write numbers from functor
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); // only used for binary output // passed to Base64Encoder
497 if (!ofstr) {
498 clout << "Error: could not open " << fullName << std::endl;
499 }
500
501 size_t fullSize = _psys.rankNumOfParticles() * 3; // how many numbers to write
502 size_t binarySize = size_t(fullSize * sizeof(float));
503 // writes first number, which have to be the size(byte) of the following data
504 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
505 unsigned int uintBinarySize = (unsigned int) binarySize;
506 sizeEncoder.encode(&uintBinarySize, 1);
507 // write numbers from functor
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); // only used for binary output // passed to Base64Encoder
529 if (!ofstr) {
530 clout << "Error: could not open " << fullName << std::endl;
531 }
532
533 size_t fullSize = _psys.rankNumOfParticles() * 3; // how many numbers to write
534 size_t binarySize = size_t(fullSize * sizeof(float));
535 // writes first number, which have to be the size(byte) of the following data
536 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
537 unsigned int uintBinarySize = (unsigned int) binarySize;
538 sizeEncoder.encode(&uintBinarySize, 1);
539 // write numbers from functor
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); // only used for binary output // passed to Base64Encoder
562 if (!ofstr) {
563 clout << "Error: could not open " << fullName << std::endl;
564 }
565
566 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
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); // only used for binary output // passed to Base64Encoder
589 if (!ofstr) {
590 clout << "Error: could not open " << fullName << std::endl;
591 }
592
593 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
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); // only used for binary output // passed to Base64Encoder
618 if (!ofstr) {
619 clout << "Error: could not open " << fullName << std::endl;
620 }
621
622 size_t fullSize = _psys.rankNumOfParticles(); // how many numbers to write
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); // only used for binary output // passed to Base64Encoder
647 if (!ofstr) {
648 clout << "Error: could not open " << fullName << std::endl;
649 }
650
651 size_t fullSize = _psys.rankNumOfParticles() * 3; // how many numbers to write
652 size_t binarySize = size_t(fullSize * sizeof(float));
653 // writes first number, which have to be the size(byte) of the following data
654 Base64Encoder<unsigned int> sizeEncoder(ofstr, 1);
655 unsigned int uintBinarySize = (unsigned int) binarySize;
656 sizeEncoder.encode(&uintBinarySize, 1);
657 // write numbers from functor
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}

References olb::Base64Encoder< T >::encode().

+ Here is the call graph for this function:

◆ dataPVD()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::dataPVD ( int iT,
int iR,
const std::string & fullNamePVD,
const std::string & namePiece )
protected

performes <DataSet timestep= ... file=namePiece >

Definition at line 186 of file superParticleSysVTUout.hh.

188{
189 std::ofstream fout(fullNamePVD.c_str(), std::ios::app);
190 if (!fout) {
191 clout << "Error: could not open " << fullNamePVD << std::endl;
192 }
193
194 fout << "<DataSet timestep=\"" << iT << "\" " << "group=\"\" part=\" " << iC
195 << "\" " << "file=\"" << namePiece << "\"/>\n";
196 fout.close();
197}

◆ dataPVDmaster()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::dataPVDmaster ( int iT,
int iR,
const std::string & fullNamePVDMaster,
const std::string & namePiece )
protected

performes <DataSet timestep= ... file=namePiece >

Definition at line 200 of file superParticleSysVTUout.hh.

202{
203 std::ofstream fout(fullNamePVDMaster.c_str(),
204 std::ios::in | std::ios::out | std::ios::ate);
205 if (fout) {
206 fout.seekp(-25, std::ios::end); // jump -25 form the end of file to overwrite closePVD
207
208 fout << "<DataSet timestep=\"" << iT << "\" " << "group=\"\" part=\" "
209 << iC << "\" " << "file=\"" << namePiece << "\"/>\n";
210 fout.close();
211 closePVD(fullNamePVDMaster);
212 }
213 else {
214 clout << "Error: could not open " << fullNamePVDMaster << std::endl;
215 }
216}

◆ numofpsys()

template<typename T , template< typename U > class PARTICLETYPE>
int olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::numofpsys ( )

Definition at line 32 of file superParticleSysVTUout.hh.

33{
34 return _psys._pSystems.size();
35}

◆ preambleOneFile()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::preambleOneFile ( const std::string & fullName)
protected

performes <VTKFile...> and <ImageData ...>

◆ preamblePVD()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::preamblePVD ( const std::string & fullNamePVD)
protected

performes <VTKFile ...> and <Collection>

Definition at line 158 of file superParticleSysVTUout.hh.

160{
161 std::ofstream fout(fullNamePVD.c_str(), std::ios::trunc);
162 if (!fout) {
163 clout << "Error: could not open " << fullNamePVD << std::endl;
164 }
165
166 fout << "<?xml version=\"1.0\"?>\n";
167 fout << "<VTKFile type=\"Collection\" version=\"0.1\" "
168 << "byte_order=\"LittleEndian\">\n" << "<Collection>\n";
169 fout.close();
170}

◆ preambleVTU()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::preambleVTU ( const std::string & fullName)
protected

performes <VTKFile ...>, <ImageData ...> and <PieceExtent ...>

Definition at line 125 of file superParticleSysVTUout.hh.

127{
128 std::ofstream fout(fullName.c_str(), std::ios::trunc);
129 if (!fout) {
130 clout << "Error: could not open " << fullName << std::endl;
131 }
132 fout << "<?xml version=\"1.0\"?>" << std::endl << std::flush;
133 fout
134 << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">"
135 << std::endl;
136 fout << "<UnstructuredGrid>" << std::endl;
137 fout << "<Piece NumberOfPoints=\"" << _psys.rankNumOfParticles()
138 << "\" NumberOfCells=\"" << _psys.rankNumOfParticles() << "\">"
139 << std::endl;
140 fout << "<PointData Vectors=\"Particles\">" << std::endl;
141 fout.close();
142}

◆ set()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::set ( unsigned short pref)

Definition at line 38 of file superParticleSysVTUout.hh.

39{
40 _properties |= pref;
41}

◆ write()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::write ( int iT = 0)

Definition at line 64 of file superParticleSysVTUout.hh.

65{
66 //std::cout << "Write base" << std::endl;
67 int rank = 0;
68 int size = 1;
69#ifdef PARALLEL_MODE_MPI
70 rank = singleton::mpi().getRank();
71 size = singleton::mpi().getSize();
72#endif
73
74 if (rank == 0) { // master only
75 if (!_haveMaster) {
77 }
78
79 std::string fullNamePVDmaster = singleton::directories().getVtkOutDir()
80 + createFileName(_name) + "_master.pvd";
81 std::string fullNamePVD = singleton::directories().getVtkOutDir() + "data/"
82 + createFileName(_name, iT) + ".pvd";
83
84 preamblePVD(fullNamePVD); // timestep
85 for (int iR = 0; iR < size; iR++) { // cuboid
86 std::string namePiece = "data/" + createFileName(_name, iT, iR) + ".vtu";
87 // puts name of .vti piece to a .pvd file [fullNamePVD]
88 dataPVD(iT, iR, fullNamePVD, namePiece);
89 // adds a namePiece to master.pvd file.
90 // To do so we overwrite closePVD() and add new entry.
91 dataPVDmaster(iT, iR, fullNamePVDmaster, namePiece);
92 } // cuboid
93 closePVD(fullNamePVD); // timestep
94 } // master only
95
96 std::string fullNameVTU = singleton::directories().getVtkOutDir()
97 + "data/" + createFileName(_name, iT, rank) + ".vtu";
98 preambleVTU(fullNameVTU);
99 if (_binary) {
100 this->dataArrayBinary(fullNameVTU);
101 }
102 else {
103 this->dataArray(fullNameVTU);
104 }
105 closeVTU(fullNameVTU);
106}
void dataPVDmaster(int iT, int iR, const std::string &fullNamePVDMaster, const std::string &namePiece)
performes <DataSet timestep= ... file=namePiece >
void closeVTU(const std::string &fullNamePiece)
performes </ImageData> and </VTKFile>
void preambleVTU(const std::string &fullName)
performes <VTKFile ...>, <ImageData ...> and <PieceExtent ...>
void dataArrayBinary(const std::string &fullName)
writes functors stored at pointerVec
void dataPVD(int iT, int iR, const std::string &fullNamePVD, const std::string &namePiece)
performes <DataSet timestep= ... file=namePiece >
void dataArray(const std::string &fullName)
writes functors stored at pointerVec
int getSize() const
Returns the number of processes.

◆ writePieceToOneFile()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::writePieceToOneFile ( const std::string & fullName)
protected

writes instantaniously given functor, without adding to _pointerVec

Member Data Documentation

◆ _binary

template<typename T , template< typename U > class PARTICLETYPE>
bool olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::_binary
protected

Definition at line 99 of file superParticleSysVTUout.h.

◆ _haveMaster

template<typename T , template< typename U > class PARTICLETYPE>
bool olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::_haveMaster
protected

Definition at line 100 of file superParticleSysVTUout.h.

◆ _name

template<typename T , template< typename U > class PARTICLETYPE>
std::string olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::_name
protected

Definition at line 97 of file superParticleSysVTUout.h.

◆ _properties

template<typename T , template< typename U > class PARTICLETYPE>
unsigned short olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::_properties
protected

Definition at line 98 of file superParticleSysVTUout.h.

◆ _psys

template<typename T , template< typename U > class PARTICLETYPE>
SuperParticleSystem3D<T, PARTICLETYPE>& olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::_psys
protected

Definition at line 96 of file superParticleSysVTUout.h.

◆ clout

template<typename T , template< typename U > class PARTICLETYPE>
OstreamManager olb::SuperParticleSysVtuWriter< T, PARTICLETYPE >::clout
mutableprotected

Definition at line 101 of file superParticleSysVTUout.h.


The documentation for this class was generated from the following files: