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)
 
unsigned getFileCounter () const
 
void setFileCounter (unsigned fileCounter)
 
void setOutputDirectory (const std::string &dir)
 
const std::string & getOutputDirectory () const
 
std::string getFileName () const
 

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
 
std::string outputDirectory_
 

Constructor & Destructor Documentation

◆ InteractionVTKWriter() [1/2]

InteractionVTKWriter::InteractionVTKWriter ( InteractionHandler interactionHandler)
inlineexplicit

Non-default constructor; sets the handler and fileCounter.

19  : BaseVTKWriter(interactionHandler)
20  {}
BaseVTKWriter(InteractionHandler &handler)
Definition: BaseVTKWriter.h:22

◆ 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

36  {
37  return "InteractionVTKWriter";
38  }

◆ writeVTK()

void InteractionVTKWriter::writeVTK ( ) const
overridevirtual

writes a vtk file

Implements BaseVTKWriter< InteractionHandler >.

9 {
10  std::fstream file = makeVTKFileWithHeader();
11  file << "<Piece NumberOfPoints=\"" << handler_.getNumberOfObjects() << "\" NumberOfCells=\"" << 0 << "\">\n";
12  file << "<Points>\n";
13  writeVTKPoints(file);
14  file << "</Points>\n";
15  file << "<PointData Vectors=\"vector\">\n";
16  writeVTKPointData(file);
17  file << "</PointData>\n";
19 }
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles)
Definition: BaseHandler.h:656
void writeVTKFooterAndClose(std::fstream &file) const
Definition: BaseVTKWriter.h:140
InteractionHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:71
std::fstream makeVTKFileWithHeader() const
Definition: BaseVTKWriter.h:112
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:31
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:21

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)

32 {
33  file << " <DataArray type=\"Float32\" Name=\"Normal\" NumberOfComponents=\"3\" format=\"ascii\">\n";
34  // Add velocity
35  for (const auto& p: handler_)
36  {
37  file << '\t' << p->getNormal() << '\n';
38  }
39  file << " </DataArray>\n";
40  file << " <DataArray type=\"Float32\" Name=\"Overlap\" format=\"ascii\">\n";
41 
42  // Add overlap
43  for (const auto& p: handler_)
44  {
45  file << '\t' << p->getOverlap() << '\n';
46  }
47  file << " </DataArray>\n";
48  file << " <DataArray type=\"Float32\" Name=\"ContactRadius\" format=\"ascii\">\n";
49 
50  // Add radius
51  for (const auto& p: handler_)
52  {
53  file << '\t' << p->getContactRadius() << '\n';
54  }
55  file << " </DataArray>\n";
56  file << " <DataArray type=\"Float32\" Name=\"Force\" NumberOfComponents=\"3\" format=\"ascii\">\n";
57 
58  // Add species type
59  for (const auto& p: handler_)
60  {
61  file << '\t' << p->getForce() << '\n';
62  }
63  file << " </DataArray>\n";
64  file << " <DataArray type=\"Float32\" Name=\"TangentialOverlap\" format=\"ascii\">\n";
65 
66  // Add species type
67  for (const auto& p: handler_)
68  {
69  file << '\t' << p->getTangentialOverlap() << '\n';
70  }
71  file << " </DataArray>\n";
72  file << " <DataArray type=\"Float32\" Name=\"Torque\" NumberOfComponents=\"3\" format=\"ascii\">\n";
73 
74  // Add species type
75  for (const auto& p: handler_)
76  {
77  file << '\t' << p->getTorque() << '\n';
78  }
79  file << " </DataArray>\n";
80 
81  //check if this type of Interaction has extra fields
82  if (handler_.getSize() != 0)
83  {
84  for (unsigned i = 0; i < handler_.getLastObject()->getNumberOfFieldsVTK(); i++)
85  {
86  file << " <DataArray type=\"" << handler_.getLastObject()->getTypeVTK(i) << "\" Name=\""
87  << handler_.getLastObject()->getNameVTK(i) << "\" format=\"ascii\">\n";
88  // Add species type
89  for (const auto& p: handler_)
90  {
91  for (auto f : p->getFieldVTK(i))
92  file << '\t' << f << '\n';
93  }
94  file << " </DataArray>\n";
95  }
96  }
97 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
float * p
Definition: Tutorial_Map_using.cpp:9
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:663
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
virtual std::string getTypeVTK(unsigned i) const
Definition: BaseInteraction.cc:866
virtual std::string getNameVTK(unsigned i) const
Definition: BaseInteraction.cc:871
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237

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

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)

22 {
23  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
24  for (const auto& p: handler_)
25  {
26  file << '\t' << p->getContactPoint() << '\n';
27  }
28  file << " </DataArray>\n";
29 }

References BaseVTKWriter< InteractionHandler >::handler_, and p.

Referenced by writeVTK().


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