MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 

Protected Member Functions

void writeVTKPoints (std::fstream &file) const
 writes the point data to the vtu file (i.e. More...
 
void writeVTKPointData (std::fstream &file) const
 writes the point data to the vtu file (i.e. 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
 

Detailed Description

Definition at line 33 of file InteractionVTKWriter.h.

Constructor & Destructor Documentation

InteractionVTKWriter::InteractionVTKWriter ( InteractionHandler interactionHandler)
inlineexplicit

Non-default constructor; sets the handler and fileCounter.

Definition at line 41 of file InteractionVTKWriter.h.

41  : BaseVTKWriter(interactionHandler)
42  {}
BaseVTKWriter(InteractionHandler &handler)
Definition: BaseVTKWriter.h:44
InteractionVTKWriter::InteractionVTKWriter ( const InteractionVTKWriter )
default

Default copy constructor.

Member Function Documentation

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

the name of the class in the restart file

Definition at line 57 of file InteractionVTKWriter.h.

58  {
59  return "InteractionVTKWriter";
60  }
void InteractionVTKWriter::writeVTK ( ) const
overridevirtual

writes a vtk file

Implements BaseVTKWriter< InteractionHandler >.

Definition at line 29 of file InteractionVTKWriter.cc.

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

Referenced by DPMBase::writeVTKFiles().

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 }
void writeVTKPoints(std::fstream &file) const
writes the point data to the vtu file (i.e.
InteractionHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
std::fstream makeVTKFileWithHeader() const
void writeVTKFooterAndClose(std::fstream &file) const
void writeVTKPointData(std::fstream &file) const
writes the point data to the vtu file (i.e.
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
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)

Definition at line 52 of file InteractionVTKWriter.cc.

References BaseVTKWriter< InteractionHandler >::handler_, and constants::i.

Referenced by writeVTK().

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\" 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\" 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 }
InteractionHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
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)

Definition at line 42 of file InteractionVTKWriter.cc.

References BaseVTKWriter< InteractionHandler >::handler_.

Referenced by writeVTK().

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 }
InteractionHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72

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