WallDetailsVTKWriter Class Referencefinal

#include <WallDetailsVTKWriter.h>

+ Inheritance diagram for WallDetailsVTKWriter:

Public Member Functions

 WallDetailsVTKWriter (WallHandler &wallHandler)
 
 WallDetailsVTKWriter (const WallDetailsVTKWriter &)=default
 
void writeVTK () const override
 
std::string getName () const
 
- Public Member Functions inherited from BaseVTKWriter< WallHandler >
 BaseVTKWriter (WallHandler &handler)
 
 BaseVTKWriter (const BaseVTKWriter &other)
 
unsigned getFileCounter () const
 
void setFileCounter (unsigned fileCounter)
 

Private Member Functions

bool shouldWrite (WallHandler::DetailsVTKOptions) const
 
std::string generateFileName (std::string identifier) const
 

Additional Inherited Members

- Protected Member Functions inherited from BaseVTKWriter< WallHandler >
std::fstream makeVTKFileWithHeader () const
 
void writeVTKFooterAndClose (std::fstream &file) const
 
- Protected Attributes inherited from BaseVTKWriter< WallHandler >
WallHandlerhandler_
 particle handler from which the particles should be written More...
 
unsigned int fileCounter
 

Constructor & Destructor Documentation

◆ WallDetailsVTKWriter() [1/2]

WallDetailsVTKWriter::WallDetailsVTKWriter ( WallHandler wallHandler)
inlineexplicit

Non-default constructor; sets the handler and fileCounter

40  : BaseVTKWriter(wallHandler)
41  {}
BaseVTKWriter(WallHandler &handler)
Definition: BaseVTKWriter.h:44

◆ WallDetailsVTKWriter() [2/2]

WallDetailsVTKWriter::WallDetailsVTKWriter ( const WallDetailsVTKWriter )
default

Default copy constructor

Member Function Documentation

◆ generateFileName()

std::string WallDetailsVTKWriter::generateFileName ( std::string  identifier) const
private
102 {
103  return handler_.getDPMBase()->getName() + "WallDetails" + identifier + "_" + std::to_string(fileCounter) + ".vtu";
104 }
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
WallHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:72
unsigned int fileCounter
Definition: BaseVTKWriter.h:74
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399

References BaseVTKWriter< WallHandler >::fileCounter, BaseHandler< T >::getDPMBase(), DPMBase::getName(), and BaseVTKWriter< WallHandler >::handler_.

Referenced by writeVTK().

◆ getName()

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

The name of the class in the restart file

57  { return "WallDetailsVTKWriter"; }

◆ shouldWrite()

bool WallDetailsVTKWriter::shouldWrite ( WallHandler::DetailsVTKOptions  type) const
private
96 {
97  FileType fileType = handler_.getWriteDetailsVTK(type);
98  return (fileType == FileType::ONE_FILE && fileCounter == 0) || fileType == FileType::MULTIPLE_FILES || fileType == FileType::MULTIPLE_FILES_PADDED;
99 }
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
Definition: File.h:41
@ MULTIPLE_FILES
each time-step will be written into/read from separate files numbered consecutively: name_....
@ MULTIPLE_FILES_PADDED
each time-step will be written into/read from separate files numbered consecutively,...
@ ONE_FILE
all data will be written into/ read from a single file called name_
FileType getWriteDetailsVTK(DetailsVTKOptions) const
Definition: WallHandler.cc:494

References BaseVTKWriter< WallHandler >::fileCounter, WallHandler::getWriteDetailsVTK(), BaseVTKWriter< WallHandler >::handler_, MULTIPLE_FILES, MULTIPLE_FILES_PADDED, and ONE_FILE.

Referenced by writeVTK().

◆ writeVTK()

void WallDetailsVTKWriter::writeVTK ( ) const
overridevirtual

Writes a vtk file

Implements BaseVTKWriter< WallHandler >.

32 {
33  if (PROCESSOR_ID != 0) return;
34 
35  // For each type of wall a VTKData object needs to be created, as each type is written to a different vtu file
36  VTKData dataNurbsWall;
37  VTKData dataWearableNurbsWall;
38  //VTKData dataOtherTypeOfWall;
39 
42 
43  // Loop through all wall and check if they belong to a certain type and if the data should be written or not
44  for (const auto& w : handler_)
45  {
46  // WearableNurbsWall inherits from NurbsWall, therefore make sure to differentiate between them.
47  // To prevent many of the same castings, first check if any of the two needs to be written.
48  if (nw_sw || wnw_sw)
49  {
50  // Just a single cast to WearableNurbsWall and NurbsWall
51  auto wnw_ptr = dynamic_cast<WearableNurbsWall*>(w);
52  // NurbsWall: should be written and correct type (a valid cast is possible)
53  if (nw_sw && dynamic_cast<NurbsWall*>(w))
54  {
55  // Make sure the NurbsWall vtk data is written, not the WearableNurbsWall implementation of writeWallDetailsVTK()
56  if (wnw_ptr)
57  wnw_ptr->NurbsWall::writeWallDetailsVTK(dataNurbsWall);
58  else
59  w->writeWallDetailsVTK(dataNurbsWall);
60  }
61  // WearableNurbsWall: should be written and of type
62  if (wnw_sw && wnw_ptr)
63  {
64  w->writeWallDetailsVTK(dataWearableNurbsWall);
65  }
66  }
67  // Without inheritance differentiating a simple call could look like:
68  //else if (shouldWrite(WallHandler::DetailsVTKOptions::OTHER_TYPE_OF_WALL) && dynamic_cast<OtherTypeOfWall*>(w))
69  //{
70  // w->writeWallDetailsVTK(dataOtherTypeOfWall);
71  //}
72  }
73 
74  // Again, check if the data should be written and if so write the file(s).
75  // When a certain wall type should be written, but none of the walls the handler are of that type, the file(s) will
76  // be written anyway. This is closest to what a user would expect, even though the file(s) don't hold any data.
77  if (nw_sw)
78  dataNurbsWall.writeVTKData(generateFileName("NurbsWall"));
79  if (wnw_sw)
80  dataWearableNurbsWall.writeVTKData(generateFileName("WearableNurbsWall"));
81  //if (shouldWrite(WallHandler::DetailsVTKOptions::OTHER_TYPE_OF_WALL))
82  // dataOtherTypeOfWall.writeVTKData(generateFileName("OtherTypeOfWall"));
83 
84  // Other stuff not strictly wall specific
86  {
87  VTKData dataBoundingBox;
89  dataBoundingBox.writeVTKData(generateFileName("BoundingBox"));
90  }
91 
92  fileCounter++;
93 }
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
This function defines a wall via a NurbsSurface.
Definition: NurbsWall.h:37
Definition: Kernel/VTKWriter/VTKData.h:36
void writeVTKData(std::string fileName) const
Writes the data to a file with the given file name.
Definition: VTKData.cc:83
std::string generateFileName(std::string identifier) const
Definition: WallDetailsVTKWriter.cc:101
bool shouldWrite(WallHandler::DetailsVTKOptions) const
Definition: WallDetailsVTKWriter.cc:95
@ WEARABLENURBSWALL
Writes the debris.
@ BOUNDINGBOX
Writes a bounding box around the domain.
@ NURBSWALL
Writes the NURBS control points.
void writeWallDetailsVTKBoundingBox(VTKData &data) const
Definition: WallHandler.cc:315
Definition: WearableNurbsWall.h:32
void writeWallDetailsVTK(VTKData &data) const override
Definition: WearableNurbsWall.cc:366

References WallHandler::BOUNDINGBOX, BaseVTKWriter< WallHandler >::fileCounter, generateFileName(), BaseVTKWriter< WallHandler >::handler_, WallHandler::NURBSWALL, PROCESSOR_ID, shouldWrite(), WallHandler::WEARABLENURBSWALL, VTKData::writeVTKData(), WearableNurbsWall::writeWallDetailsVTK(), and WallHandler::writeWallDetailsVTKBoundingBox().

Referenced by DPMBase::writeVTKFiles().


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