MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParticleVtkWriter Class Referenceabstract

#include <ParticleVtkWriter.h>

+ Inheritance diagram for ParticleVtkWriter:

Public Member Functions

 ParticleVtkWriter (ParticleHandler &particleHandler)
 
virtual ~ParticleVtkWriter ()=default
 
virtual std::string getName () const =0
 
- Public Member Functions inherited from BaseVTKWriter< ParticleHandler >
 BaseVTKWriter (ParticleHandler &handler)
 
 BaseVTKWriter (const BaseVTKWriter &other)
 
virtual void writeVTK () const =0
 
unsigned getFileCounter () const
 
void setFileCounter (unsigned fileCounter)
 

Protected Member Functions

void writeExtraFields (std::fstream &file) const
 
void writeVTKIndSpecies (std::fstream &file) const
 
void writeVTKPositions (std::fstream &file) const
 
bool particleMustBeWritten (BaseParticle *particle) const
 
- Protected Member Functions inherited from BaseVTKWriter< ParticleHandler >
std::fstream makeVTKFileWithHeader () const
 
void writeVTKFooterAndClose (std::fstream &file) const
 

Additional Inherited Members

- Protected Attributes inherited from BaseVTKWriter< ParticleHandler >
ParticleHandlerhandler_
 particle handler from which the particles should be written More...
 
unsigned int fileCounter
 

Detailed Description

Definition at line 33 of file ParticleVtkWriter.h.

Constructor & Destructor Documentation

ParticleVtkWriter::ParticleVtkWriter ( ParticleHandler particleHandler)
inlineexplicit

Definition at line 38 of file ParticleVtkWriter.h.

38  : BaseVTKWriter(particleHandler)
39  {}
BaseVTKWriter(ParticleHandler &handler)
Definition: BaseVTKWriter.h:44
virtual ParticleVtkWriter::~ParticleVtkWriter ( )
virtualdefault

Member Function Documentation

virtual std::string ParticleVtkWriter::getName ( ) const
pure virtual
bool ParticleVtkWriter::particleMustBeWritten ( BaseParticle particle) const
inlineprotected

Definition at line 53 of file ParticleVtkWriter.h.

References BaseParticle::isMPIParticle(), and BaseParticle::isPeriodicGhostParticle().

Referenced by writeExtraFields(), SphericalParticleVtkWriter::writeVTK(), writeVTKIndSpecies(), writeVTKPositions(), SphericalParticleVtkWriter::writeVTKRadius(), and SphericalParticleVtkWriter::writeVTKVelocity().

54  {
55  return !(particle->isMPIParticle() || particle->isPeriodicGhostParticle());
56  }
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
void ParticleVtkWriter::writeExtraFields ( std::fstream &  file) const
protected

Definition at line 67 of file ParticleVtkWriter.cc.

References BaseHandler< T >::getLastObject(), BaseParticle::getNameVTK(), BaseParticle::getNumberOfFieldsVTK(), BaseHandler< T >::getSize(), BaseParticle::getTypeVTK(), BaseVTKWriter< ParticleHandler >::handler_, constants::i, and particleMustBeWritten().

Referenced by SphericalParticleVtkWriter::writeVTK().

68 {
69  //check if this type of Interaction has extra fields
70  if (handler_.getSize() != 0)
71  {
72  for (unsigned i = 0; i < handler_.getLastObject()->getNumberOfFieldsVTK(); i++)
73  {
74  file << " <DataArray type=\"" << handler_.getLastObject()->getTypeVTK(i) << "\" Name=\""
75  << handler_.getLastObject()->getNameVTK(i) << "\" format=\"ascii\">\n";
76  // Add species type
77  for (const auto& p: handler_)
78  {
79  for (auto f : p->getFieldVTK(i)) {
80 #ifdef MERCURY_USE_MPI
81  if (particleMustBeWritten(p))
82  {
83  file << '\t' << f << '\n';
84  }
85 #else
86  file << '\t' << f << '\n';
87 #endif
88  }
89  }
90  file << " </DataArray>\n";
91  }
92  }
93 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
ParticleHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
bool particleMustBeWritten(BaseParticle *particle) const
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
virtual std::string getTypeVTK(unsigned i) const
virtual std::string getNameVTK(unsigned i) const
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
virtual unsigned getNumberOfFieldsVTK() const
void ParticleVtkWriter::writeVTKIndSpecies ( std::fstream &  file) const
protected

Definition at line 49 of file ParticleVtkWriter.cc.

References BaseVTKWriter< ParticleHandler >::handler_, and particleMustBeWritten().

Referenced by SuperQuadricParticleVtkWriter::writeVTK(), and SphericalParticleVtkWriter::writeVTK().

50 {
51  file << " <DataArray type=\"Float32\" Name=\"speciesType\" format=\"ascii\">\n";
52  // Add species type
53  for (const auto& p: handler_)
54  {
55 #ifdef MERCURY_USE_MPI
56  if (particleMustBeWritten(p))
57  {
58  file << '\t' << p->getIndSpecies() << '\n';
59  }
60 #else
61  file << '\t' << p->getIndSpecies() << '\n';
62 #endif
63  }
64  file << " </DataArray>\n";
65 }
ParticleHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
bool particleMustBeWritten(BaseParticle *particle) const
void ParticleVtkWriter::writeVTKPositions ( std::fstream &  file) const
protected

Definition at line 29 of file ParticleVtkWriter.cc.

References BaseVTKWriter< ParticleHandler >::handler_, and particleMustBeWritten().

Referenced by SuperQuadricParticleVtkWriter::writeVTK(), and SphericalParticleVtkWriter::writeVTK().

30 {
31  file << "<Points>\n";
32  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
33  for (const auto& p: handler_)
34  {
35 #ifdef MERCURY_USE_MPI
36  if (particleMustBeWritten(p))
37  {
38  file << '\t' << p->getPosition() << '\n';
39  }
40 #else
41  file << '\t' << p->getPosition() << '\n';
42 #endif
43 
44  }
45  file << " </DataArray>\n";
46  file << "</Points>\n";
47 }
ParticleHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
bool particleMustBeWritten(BaseParticle *particle) const

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