BaseVTKWriter< H > Class Template Referenceabstract

#include <BaseVTKWriter.h>

Public Member Functions

 BaseVTKWriter (H &handler)
 
 BaseVTKWriter (const BaseVTKWriter &other)
 
virtual void writeVTK () const =0
 
unsigned getFileCounter () const
 
void setFileCounter (unsigned fileCounter)
 

Protected Member Functions

std::fstream makeVTKFileWithHeader () const
 
void writeVTKFooterAndClose (std::fstream &file) const
 

Protected Attributes

H & handler_
 particle handler from which the particles should be written More...
 
unsigned int fileCounter
 

Detailed Description

template<typename H>
class BaseVTKWriter< H >

Template Parameters
Hsome handler, e.g. particleHandler

Constructor & Destructor Documentation

◆ BaseVTKWriter() [1/2]

template<typename H >
BaseVTKWriter< H >::BaseVTKWriter ( H &  handler)
inline
44  : handler_(handler)
45  {
46  fileCounter = 0;
47  }
H & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
unsigned int fileCounter
Definition: BaseVTKWriter.h:74

References BaseVTKWriter< H >::fileCounter.

◆ BaseVTKWriter() [2/2]

template<typename H >
BaseVTKWriter< H >::BaseVTKWriter ( const BaseVTKWriter< H > &  other)
inline
49  : handler_(other.handler_)
50  {
51  fileCounter = other.fileCounter;
52  }

References BaseVTKWriter< H >::fileCounter.

Member Function Documentation

◆ getFileCounter()

template<typename H >
unsigned BaseVTKWriter< H >::getFileCounter ( ) const
inline
57  {
58  return fileCounter;
59  }

References BaseVTKWriter< H >::fileCounter.

Referenced by DPMBase::write(), and DPMBase::writeVTKFiles().

◆ makeVTKFileWithHeader()

template<typename T >
std::fstream BaseVTKWriter< T >::makeVTKFileWithHeader
protected
Todo:
vtw wall files only need to be written by one processor
81 {
82  //extract the word "Wall" or "Particle" from the VTK writer name
83  std::string name = handler_.getName();
84  name = name.substr(0, name.length() - 7);
85 
86  //determine name of output file
87  std::string fileName;
88 #ifdef MERCURYDPM_USE_MPI
89  if (NUMBER_OF_PROCESSORS > 1 && name != "Wall")
90  {
91  fileName = handler_.getDPMBase()->getName() + "Processor_" + std::to_string(PROCESSOR_ID) +
92  '_' + name + '_' + std::to_string(fileCounter++) + ".vtu";
93  }
94  else
95  {
96  fileName = handler_.getDPMBase()->getName() +
97  name + '_' +
98  std::to_string(fileCounter++) + ".vtu";
99  }
100 #else
101  fileName = handler_.getDPMBase()->getName() +
102  name + '_' +
103  std::to_string(fileCounter++) + ".vtu";
104 #endif
105 
106  //open output file
107  std::fstream file;
108  file.open(fileName.c_str(), std::ios_base::out);
109  if (file.fail())
110  {
111  logger(WARN, "File % could not be opened", fileName);
112  }
113 
114  // write output file header
115  file << "<?xml version=\"1.0\"?>\n";
116  file << "<!-- time " << handler_.getDPMBase()->getTime() << "-->\n";
117  file << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
118  file << "<UnstructuredGrid>\n";
119  return file;
120 }
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ WARN
std::string name
Definition: MercuryProb.h:48

References logger, units::name, NUMBER_OF_PROCESSORS, PROCESSOR_ID, and WARN.

◆ setFileCounter()

template<typename H >
void BaseVTKWriter< H >::setFileCounter ( unsigned  fileCounter)
inline
62  {
63  this->fileCounter = fileCounter;
64  }

References BaseVTKWriter< H >::fileCounter.

Referenced by DPMBase::read(), and DPMBase::resetFileCounter().

◆ writeVTK()

template<typename H >
virtual void BaseVTKWriter< H >::writeVTK ( ) const
pure virtual

◆ writeVTKFooterAndClose()

template<typename T >
void BaseVTKWriter< T >::writeVTKFooterAndClose ( std::fstream &  file) const
protected
124 {
125  // write output file footer
126  file << "<Cells>\n";
127  file << " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
128  file << " </DataArray>\n";
129  file << " <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
130  file << " </DataArray>\n";
131  file << " <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
132  file << " </DataArray>\n";
133  file << "</Cells>\n";
134  file << "</Piece>\n";
135  file << "</UnstructuredGrid>\n";
136  file << "</VTKFile>\n";
137  // close output file
138  file.close();
139 }

Member Data Documentation

◆ fileCounter

template<typename H >
unsigned int BaseVTKWriter< H >::fileCounter
mutableprotected

◆ handler_

template<typename H >
H& BaseVTKWriter< H >::handler_
protected

particle handler from which the particles should be written


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