SphericalParticleVtkWriter Class Referencefinal

#include <SphericalParticleVtkWriter.h>

+ Inheritance diagram for SphericalParticleVtkWriter:

Public Member Functions

 SphericalParticleVtkWriter (ParticleHandler &particleHandler)
 
 ~SphericalParticleVtkWriter () override=default
 
void writeVTK () const override
 Writes all particles into a vtk file format (unstructured grid), consisting of particle positions, velocities, radii and type of species (IndSpecies) More...
 
std::string getName () const override
 
- Public Member Functions inherited from ParticleVtkWriter
 ParticleVtkWriter (ParticleHandler &particleHandler)
 
virtual ~ParticleVtkWriter ()=default
 
- Public Member Functions inherited from BaseVTKWriter< ParticleHandler >
 BaseVTKWriter (ParticleHandler &handler)
 
 BaseVTKWriter (const BaseVTKWriter &other)
 
unsigned getFileCounter () const
 
void setFileCounter (unsigned fileCounter)
 
void setOutputDirectory (const std::string &dir)
 
const std::string & getOutputDirectory () const
 
std::string getFileName () const
 

Private Member Functions

void writeVTKVelocity (std::fstream &file) const
 
void writeVTKAngularVelocity (std::fstream &file) const
 
void writeVTKRadius (std::fstream &file) const
 
void writeVTKId (std::fstream &file) const
 Writes the id (unique integer) of the particles to the vtu file. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ParticleVtkWriter
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
 
- Protected Attributes inherited from BaseVTKWriter< ParticleHandler >
ParticleHandlerhandler_
 particle handler from which the particles should be written More...
 
unsigned int fileCounter
 
std::string outputDirectory_
 

Constructor & Destructor Documentation

◆ SphericalParticleVtkWriter()

SphericalParticleVtkWriter::SphericalParticleVtkWriter ( ParticleHandler particleHandler)
inlineexplicit
17  : ParticleVtkWriter(particleHandler)
18  {}
ParticleVtkWriter(ParticleHandler &particleHandler)
Definition: ParticleVtkWriter.h:16

◆ ~SphericalParticleVtkWriter()

SphericalParticleVtkWriter::~SphericalParticleVtkWriter ( )
overridedefault

Member Function Documentation

◆ getName()

std::string SphericalParticleVtkWriter::getName ( ) const
inlineoverridevirtual

Implements ParticleVtkWriter.

29  {
30  return "SphericalParticleVtkWriter";
31  }

◆ writeVTK()

void SphericalParticleVtkWriter::writeVTK ( ) const
overridevirtual

Writes all particles into a vtk file format (unstructured grid), consisting of particle positions, velocities, radii and type of species (IndSpecies)

Writes all points ans cells to a file in the VTK format. The filename is hard-coded in this method, and is based on the name of the DPMBase and has a unique counter in it to ensure there are no two files with the same name.

Implements BaseVTKWriter< ParticleHandler >.

15 {
16  std::fstream file = makeVTKFileWithHeader();
17  long numberOfParticlesToWrite = std::count_if(handler_.begin(), handler_.end(),
18  [this](BaseParticle* p){return particleMustBeWritten(p);});
19  file << "<Piece NumberOfPoints=\"" << numberOfParticlesToWrite
20  << "\" NumberOfCells=\"" << 0 << "\">\n";
21  writeVTKPositions(file);
22  file << "<PointData Vectors=\"vector\">\n";
23  writeVTKVelocity(file);
25  writeVTKRadius(file);
26  writeVTKIndSpecies(file);
27  writeExtraFields(file);
28  writeVTKId(file);
29  file << "</PointData>\n";
31 }
float * p
Definition: Tutorial_Map_using.cpp:9
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:698
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:712
Definition: BaseParticle.h:33
void writeVTKFooterAndClose(std::fstream &file) const
Definition: BaseVTKWriter.h:140
ParticleHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:71
std::fstream makeVTKFileWithHeader() const
Definition: BaseVTKWriter.h:112
void writeVTKIndSpecies(std::fstream &file) const
Definition: ParticleVtkWriter.cc:28
void writeExtraFields(std::fstream &file) const
Definition: ParticleVtkWriter.cc:46
void writeVTKPositions(std::fstream &file) const
Definition: ParticleVtkWriter.cc:8
void writeVTKId(std::fstream &file) const
Writes the id (unique integer) of the particles to the vtu file.
Definition: SphericalParticleVtkWriter.cc:98
void writeVTKAngularVelocity(std::fstream &file) const
Definition: SphericalParticleVtkWriter.cc:50
void writeVTKRadius(std::fstream &file) const
Definition: SphericalParticleVtkWriter.cc:74
void writeVTKVelocity(std::fstream &file) const
Definition: SphericalParticleVtkWriter.cc:33

References BaseHandler< T >::begin(), BaseHandler< T >::end(), BaseVTKWriter< ParticleHandler >::handler_, BaseVTKWriter< ParticleHandler >::makeVTKFileWithHeader(), p, ParticleVtkWriter::writeExtraFields(), writeVTKAngularVelocity(), BaseVTKWriter< ParticleHandler >::writeVTKFooterAndClose(), writeVTKId(), ParticleVtkWriter::writeVTKIndSpecies(), ParticleVtkWriter::writeVTKPositions(), writeVTKRadius(), and writeVTKVelocity().

◆ writeVTKAngularVelocity()

void SphericalParticleVtkWriter::writeVTKAngularVelocity ( std::fstream &  file) const
private
51 {
53  {
54  file << " <DataArray type=\"Float32\" Name=\"AngularVelocity\" NumberOfComponents=\"3\" format=\"ascii\">\n";
55  // Add velocity
56  for (const auto& p: handler_) {
57 #ifdef MERCURYDPM_USE_MPI
59 #endif
60  {
61  file << '\t' << (float)p->getAngularVelocity().X << ' ' << (float)p->getAngularVelocity().Y << ' ' << (float)p->getAngularVelocity().Z << '\n';
62  }
63  }
64  file << " </DataArray>\n";
65  }
66 }
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
Definition: DPMBase.h:554
bool particleMustBeWritten(BaseParticle *particle) const
Definition: ParticleVtkWriter.h:31

References BaseHandler< T >::getDPMBase(), DPMBase::getRotation(), BaseVTKWriter< ParticleHandler >::handler_, p, and ParticleVtkWriter::particleMustBeWritten().

Referenced by writeVTK().

◆ writeVTKId()

void SphericalParticleVtkWriter::writeVTKId ( std::fstream &  file) const
private

Writes the id (unique integer) of the particles to the vtu file.

This enables the tracing of particles through multiple files.

Parameters
[in]fileOutput filestream.
Note
gmb Maybe Int64 is needed.
99 {
103  file << " <DataArray type=\"Int32\" Name=\"Id\" format=\"ascii\">\n";
104  // Add id
105  for (const auto& p: handler_) {
106 #ifdef MERCURYDPM_USE_MPI
108 #endif
109  {
110  file << '\t' << p->getId() << '\n';
111  }
112  }
113  file << " </DataArray>\n";
114 }

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

Referenced by writeVTK().

◆ writeVTKRadius()

void SphericalParticleVtkWriter::writeVTKRadius ( std::fstream &  file) const
private

Notice that we write GrainRadius in the file, since there is a bug in Paraview that defaults to the first scalar-value in lexicographic order. We therefore need a description for the radius which starts with a letter before N.

Parameters
fileThe filestream to which the radius must be written.
75 {
76  file << " <DataArray type=\"Float32\" Name=\"Radius\" format=\"ascii\">\n";
77  // Add radius
78  for (const auto& p: handler_)
79  {
80 #ifdef MERCURYDPM_USE_MPI
82 #endif
83  {
84  file << '\t' << p->getRadius() << '\n';
85  }
86 
87  }
88  file << " </DataArray>\n";
89 }

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

Referenced by writeVTK().

◆ writeVTKVelocity()

void SphericalParticleVtkWriter::writeVTKVelocity ( std::fstream &  file) const
private
34 {
35  file << " <DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"ascii\">\n";
36  // Add velocity
37  for (const auto& p: handler_) {
38 #ifdef MERCURYDPM_USE_MPI
40 #endif
41  {
42  file << ' ' << (float) p->getVelocity().X
43  << ' ' << (float) p->getVelocity().Y
44  << ' ' << (float) p->getVelocity().Z << '\n';
45  }
46  }
47  file << " </DataArray>\n";
48 }

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

Referenced by writeVTK().


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