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

Private Member Functions

bool shouldWrite (WallHandler::DetailsVTKOptions) const
 
std::string generateFileName (const 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
 
std::string outputDirectory_
 

Constructor & Destructor Documentation

◆ WallDetailsVTKWriter() [1/2]

WallDetailsVTKWriter::WallDetailsVTKWriter ( WallHandler wallHandler)
inlineexplicit

Non-default constructor; sets the handler and fileCounter

19  : BaseVTKWriter(wallHandler)
20  {}
BaseVTKWriter(WallHandler &handler)
Definition: BaseVTKWriter.h:22

◆ WallDetailsVTKWriter() [2/2]

WallDetailsVTKWriter::WallDetailsVTKWriter ( const WallDetailsVTKWriter )
default

Default copy constructor

Member Function Documentation

◆ generateFileName()

std::string WallDetailsVTKWriter::generateFileName ( const std::string &  identifier) const
private
81 {
82  return outputDirectory_ + "/" + handler_.getDPMBase()->getName() + "WallDetails" + identifier + "_" + std::to_string(fileCounter) + ".vtu";
83 }
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
WallHandler & handler_
particle handler from which the particles should be written
Definition: BaseVTKWriter.h:71
std::string outputDirectory_
Definition: BaseVTKWriter.h:75
unsigned int fileCounter
Definition: BaseVTKWriter.h:73
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:377
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189

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

Referenced by writeVTK().

◆ getName()

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

The name of the class in the restart file

36  { return "WallDetailsVTKWriter"; }

◆ shouldWrite()

bool WallDetailsVTKWriter::shouldWrite ( WallHandler::DetailsVTKOptions  type) const
private
75 {
77  return (fileType == FileType::ONE_FILE && fileCounter == 0) || fileType == FileType::MULTIPLE_FILES || fileType == FileType::MULTIPLE_FILES_PADDED;
78 }
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:19
@ 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:472
type
Definition: compute_granudrum_aor.py:141

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

Referenced by writeVTK().

◆ writeVTK()

void WallDetailsVTKWriter::writeVTK ( ) const
overridevirtual

Writes a vtk file

Implements BaseVTKWriter< WallHandler >.

11 {
12  if (PROCESSOR_ID != 0) return;
13 
14  // For each type of wall a VTKData object needs to be created, as each type is written to a different vtu file
15  VTKData dataNurbsWall;
16  VTKData dataWearableNurbsWall;
17  //VTKData dataOtherTypeOfWall;
18 
21 
22  // Loop through all wall and check if they belong to a certain type and if the data should be written or not
23  for (const auto& w : handler_)
24  {
25  // WearableNurbsWall inherits from NurbsWall, therefore make sure to differentiate between them.
26  // To prevent many of the same castings, first check if any of the two needs to be written.
27  if (nw_sw || wnw_sw)
28  {
29  // Just a single cast to WearableNurbsWall and NurbsWall
30  auto wnw_ptr = dynamic_cast<WearableNurbsWall*>(w);
31  // NurbsWall: should be written and correct type (a valid cast is possible)
32  if (nw_sw && dynamic_cast<NurbsWall*>(w))
33  {
34  // Make sure the NurbsWall vtk data is written, not the WearableNurbsWall implementation of writeWallDetailsVTK()
35  if (wnw_ptr)
36  wnw_ptr->NurbsWall::writeWallDetailsVTK(dataNurbsWall);
37  else
38  w->writeWallDetailsVTK(dataNurbsWall);
39  }
40  // WearableNurbsWall: should be written and of type
41  if (wnw_sw && wnw_ptr)
42  {
43  w->writeWallDetailsVTK(dataWearableNurbsWall);
44  }
45  }
46  // Without inheritance differentiating a simple call could look like:
47  //else if (shouldWrite(WallHandler::DetailsVTKOptions::OTHER_TYPE_OF_WALL) && dynamic_cast<OtherTypeOfWall*>(w))
48  //{
49  // w->writeWallDetailsVTK(dataOtherTypeOfWall);
50  //}
51  }
52 
53  // Again, check if the data should be written and if so write the file(s).
54  // When a certain wall type should be written, but none of the walls the handler are of that type, the file(s) will
55  // be written anyway. This is closest to what a user would expect, even though the file(s) don't hold any data.
56  if (nw_sw)
57  dataNurbsWall.writeVTKData(generateFileName("NurbsWall"));
58  if (wnw_sw)
59  dataWearableNurbsWall.writeVTKData(generateFileName("WearableNurbsWall"));
60  //if (shouldWrite(WallHandler::DetailsVTKOptions::OTHER_TYPE_OF_WALL))
61  // dataOtherTypeOfWall.writeVTKData(generateFileName("OtherTypeOfWall"));
62 
63  // Other stuff not strictly wall specific
65  {
66  VTKData dataBoundingBox;
68  dataBoundingBox.writeVTKData(generateFileName("BoundingBox"));
69  }
70 
71  fileCounter++;
72 }
#define PROCESSOR_ID
Definition: GeneralDefine.h:42
RowVector3d w
Definition: Matrix_resize_int.cpp:3
This function defines a wall via a NurbsSurface.
Definition: NurbsWall.h:16
Definition: Kernel/VTKWriter/VTKData.h:15
void writeVTKData(std::string fileName) const
Writes the data to a file with the given file name.
Definition: VTKData.cc:62
bool shouldWrite(WallHandler::DetailsVTKOptions) const
Definition: WallDetailsVTKWriter.cc:74
std::string generateFileName(const std::string &identifier) const
Definition: WallDetailsVTKWriter.cc:80
@ 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:293
Definition: WearableNurbsWall.h:11

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

Referenced by DPMBase::writeVTKFiles().


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