revision: v0.14
InteractionVTKWriter Class Referencefinal

#include <InteractionVTKWriter.h>

+ Inheritance diagram for InteractionVTKWriter:

Public Member Functions

 InteractionVTKWriter (InteractionHandler &interactionHandler)
 Non-default constructor; sets the handler and fileCounter. More...
 
 InteractionVTKWriter (const InteractionVTKWriter &)=default
 Default copy constructor. More...
 
void writeVTK () const override
 writes a vtk file More...
 
std::string getName () const
 the name of the class in the restart file More...
 
- Public Member Functions inherited from BaseVTKWriter< InteractionHandler >
 BaseVTKWriter (InteractionHandler &handler)
 
 BaseVTKWriter (const BaseVTKWriter &other)
 
virtual void writeVTK () const=0
 
unsigned getFileCounter () const
 
void setFileCounter (unsigned fileCounter)
 

Protected Member Functions

void writeVTKPoints (std::fstream &file) const
 writes the point data to the vtu file (i.e. the vertices of the mesh displayed in paraview) More...
 
void writeVTKPointData (std::fstream &file) const
 writes the point data to the vtu file (i.e. options how to color the interactions displayed in paraview) More...
 
- Protected Member Functions inherited from BaseVTKWriter< InteractionHandler >
std::fstream makeVTKFileWithHeader () const
 
void writeVTKFooterAndClose (std::fstream &file) const
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ InteractionVTKWriter() [1/2]

InteractionVTKWriter::InteractionVTKWriter ( InteractionHandler interactionHandler)
inlineexplicit

Non-default constructor; sets the handler and fileCounter.

41  : BaseVTKWriter(interactionHandler)
42  {}

◆ InteractionVTKWriter() [2/2]

InteractionVTKWriter::InteractionVTKWriter ( const InteractionVTKWriter )
default

Default copy constructor.

Member Function Documentation

◆ getName()

std::string InteractionVTKWriter::getName ( ) const
inline

the name of the class in the restart file

58  {
59  return "InteractionVTKWriter";
60  }

◆ writeVTK()

void InteractionVTKWriter::writeVTK ( ) const
override

writes a vtk file

30 {
31  std::fstream file = makeVTKFileWithHeader();
32  file << "<Piece NumberOfPoints=\"" << handler_.getNumberOfObjects() << "\" NumberOfCells=\"" << 0 << "\">\n";
33  file << "<Points>\n";
34  writeVTKPoints(file);
35  file << "</Points>\n";
36  file << "<PointData Vectors=\"vector\">\n";
37  writeVTKPointData(file);
38  file << "</PointData>\n";
40 }

References BaseHandler< T >::getNumberOfObjects(), BaseVTKWriter< InteractionHandler >::handler_, BaseVTKWriter< InteractionHandler >::makeVTKFileWithHeader(), BaseVTKWriter< InteractionHandler >::writeVTKFooterAndClose(), writeVTKPointData(), and writeVTKPoints().

Referenced by DPMBase::writeVTKFiles().

◆ writeVTKPointData()

void InteractionVTKWriter::writeVTKPointData ( std::fstream &  file) const
protected

writes the point data to the vtu file (i.e. options how to color the interactions displayed in paraview)

53 {
54  file << " <DataArray type=\"Float32\" Name=\"Normal\" NumberOfComponents=\"3\" format=\"ascii\">\n";
55  // Add velocity
56  for (const auto& p: handler_)
57  {
58  file << '\t' << p->getNormal() << '\n';
59  }
60  file << " </DataArray>\n";
61  file << " <DataArray type=\"Float32\" Name=\"Overlap\" format=\"ascii\">\n";
62 
63  // Add overlap
64  for (const auto& p: handler_)
65  {
66  file << '\t' << p->getOverlap() << '\n';
67  }
68  file << " </DataArray>\n";
69  file << " <DataArray type=\"Float32\" Name=\"ContactRadius\" format=\"ascii\">\n";
70 
71  // Add radius
72  for (const auto& p: handler_)
73  {
74  file << '\t' << p->getContactRadius() << '\n';
75  }
76  file << " </DataArray>\n";
77  file << " <DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"ascii\">\n";
78 
79  // Add species type
80  for (const auto& p: handler_)
81  {
82  file << '\t' << p->getForce() << '\n';
83  }
84  file << " </DataArray>\n";
85  file << " <DataArray type=\"Float32\" Name=\"TangentialOverlap\" format=\"ascii\">\n";
86 
87  // Add species type
88  for (const auto& p: handler_)
89  {
90  file << '\t' << p->getTangentialOverlap() << '\n';
91  }
92  file << " </DataArray>\n";
93  file << " <DataArray type=\"Float32\" Name=\"Torque\" NumberOfComponents=\"3\" format=\"ascii\">\n";
94 
95  // Add species type
96  for (const auto& p: handler_)
97  {
98  file << '\t' << p->getTorque() << '\n';
99  }
100  file << " </DataArray>\n";
101 
102  //check if this type of Interaction has extra fields
103  if (handler_.getSize() != 0)
104  {
105  for (unsigned i = 0; i < handler_.getLastObject()->getNumberOfFieldsVTK(); i++)
106  {
107  file << " <DataArray type=\"" << handler_.getLastObject()->getTypeVTK(i) << "\" Name=\""
108  << handler_.getLastObject()->getNameVTK(i) << "\" format=\"ascii\">\n";
109  // Add species type
110  for (const auto& p: handler_)
111  {
112  for (auto f : p->getFieldVTK(i))
113  file << '\t' << f << '\n';
114  }
115  file << " </DataArray>\n";
116  }
117  }
118 }

References BaseHandler< T >::getLastObject(), BaseInteraction::getNameVTK(), BaseHandler< T >::getSize(), BaseInteraction::getTypeVTK(), BaseVTKWriter< InteractionHandler >::handler_, and constants::i.

Referenced by writeVTK().

◆ writeVTKPoints()

void InteractionVTKWriter::writeVTKPoints ( std::fstream &  file) const
protected

writes the point data to the vtu file (i.e. the vertices of the mesh displayed in paraview)

43 {
44  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
45  for (const auto& p: handler_)
46  {
47  file << '\t' << p->getContactPoint() << '\n';
48  }
49  file << " </DataArray>\n";
50 }

References BaseVTKWriter< InteractionHandler >::handler_.

Referenced by writeVTK().


The documentation for this class was generated from the following files:
BaseVTKWriter< InteractionHandler >::writeVTKFooterAndClose
void writeVTKFooterAndClose(std::fstream &file) const
Definition: BaseVTKWriter.h:123
BaseHandler::getSize
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
BaseVTKWriter< InteractionHandler >::BaseVTKWriter
BaseVTKWriter(InteractionHandler &handler)
Definition: BaseVTKWriter.h:44
BaseVTKWriter< InteractionHandler >::makeVTKFileWithHeader
std::fstream makeVTKFileWithHeader() const
Definition: BaseVTKWriter.h:80
BaseHandler::getNumberOfObjects
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles)
Definition: BaseHandler.h:648
constants::i
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
BaseHandler::getLastObject
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
BaseVTKWriter< InteractionHandler >::handler_
InteractionHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
BaseInteraction::getTypeVTK
virtual std::string getTypeVTK(unsigned i) const
Definition: BaseInteraction.cc:835
BaseInteraction::getNameVTK
virtual std::string getNameVTK(unsigned i) const
Definition: BaseInteraction.cc:840
InteractionVTKWriter::writeVTKPoints
void writeVTKPoints(std::fstream &file) const
writes the point data to the vtu file (i.e. the vertices of the mesh displayed in paraview)
Definition: InteractionVTKWriter.cc:42
InteractionVTKWriter::writeVTKPointData
void writeVTKPointData(std::fstream &file) const
writes the point data to the vtu file (i.e. options how to color the interactions displayed in paravi...
Definition: InteractionVTKWriter.cc:52