WallHandler.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 
27 #ifndef WALLHANDLER_H
28 #define WALLHANDLER_H
29 
30 #include "BaseHandler.h"
31 #include "Walls/BaseWall.h"
32 #include "File.h"
33 
34 class BaseWall;
35 
43 class WallHandler final : public BaseHandler<BaseWall>
44 {
45 public:
49  WallHandler();
50 
54  WallHandler(const WallHandler& BH);
55 
59  WallHandler& operator=(const WallHandler& rhs);
60 
64  ~WallHandler() final;
65 
69  void addObject(BaseWall* W) final;
70 
74  static BaseWall* createObject(const std::string& type);
75 
79  BaseWall* readAndCreateObject(std::istream& is);
80 
84  void readAndAddObject(std::istream& is) final;
85 
89  std::string getName() const final;
90 
95  unsigned readTriangleWall(std::string filename, ParticleSpecies* species, Mdouble scaleFactor = 1, Vec3D centerOfRotation = {0,0,0}, Vec3D velocity = {0,0,0}, Vec3D angularVelocity = {0,0,0});
96 
101 
105  void setWriteVTK(FileType);
106 
110  void setWriteVTK(bool);
111 
115  FileType getWriteVTK() const;
116 
117  enum class DetailsVTKOptions
118  {
119  // Used as keys for an unordered_map.
120  // The actual enum values are written to the restart file and their meaning should therefore never change.
121  // So when adding new options, be sure to hardcode a unique enum value!
122  // The options can be in any order and their values are completely free to choose, as long as they're unique.
123 
127  BOUNDINGBOX = 0,
128 
132  NURBSWALL = 1,
133 
138  };
139 
141 
143 
145 
146  bool getWriteDetailsVTKAny() const;
147 
148  std::unordered_map<DetailsVTKOptions, FileType> getWriteWallDetailsVTKAll() const;
149 
150  void writeWallDetailsVTKBoundingBox(VTKData& data) const;
151 
155  void setWriteWallSurfaceAreaVTK(bool writeWallSurfaceAreaVTK);
156 
157  bool getWriteWallSurfaceAreaVTK() const;
158 
159 private:
160 
164  BaseWall* readAndCreateOldObject(std::istream& is);
165 
167 
173  std::unordered_map<DetailsVTKOptions, FileType> writeDetailsVTK_;
174 };
175 
176 #endif
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
Container to store the pointers to all objects that one creates in a simulation.
Definition: BaseHandler.h:51
Basic class for walls.
Definition: BaseWall.h:49
Definition: ParticleSpecies.h:37
Definition: Kernel/VTKWriter/VTKData.h:36
Definition: Vector.h:51
Container to store all BaseWall.
Definition: WallHandler.h:44
std::unordered_map< DetailsVTKOptions, FileType > getWriteWallDetailsVTKAll() const
Definition: WallHandler.cc:515
void setWriteDetailsVTK(DetailsVTKOptions, FileType)
Definition: WallHandler.cc:482
BaseWall * readAndCreateObject(std::istream &is)
Create a new wall, based on the information provided in a restart file.
Definition: WallHandler.cc:213
FileType getWriteVTK() const
Returns whether walls are written in a VTK file.
Definition: WallHandler.cc:477
WallHandler()
Default constructor, it creates an empty WallHandler.
Definition: WallHandler.cc:54
void addObject(BaseWall *W) final
Adds a BaseWall to the WallHandler.
Definition: WallHandler.cc:115
void setWriteWallSurfaceAreaVTK(bool writeWallSurfaceAreaVTK)
Enables/disables the calculation and writing of the surface area of the cells.
Definition: WallHandler.cc:520
FileType writeVTK_
Definition: WallHandler.h:166
void readAndAddObject(std::istream &is) final
Create a new wall in the WallHandler, based on the information provided in a restart file.
Definition: WallHandler.cc:299
bool getWriteWallSurfaceAreaVTK() const
Definition: WallHandler.cc:525
std::unordered_map< DetailsVTKOptions, FileType > writeDetailsVTK_
unordered_map storing the file types corresponding to each of the enum DetailsVTKOptions
Definition: WallHandler.h:173
bool getWriteDetailsVTKAny() const
Definition: WallHandler.cc:508
DetailsVTKOptions
Definition: WallHandler.h:118
@ WEARABLENURBSWALL
Writes the debris.
@ BOUNDINGBOX
Writes a bounding box around the domain.
@ NURBSWALL
Writes the NURBS control points.
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
FileType getWriteDetailsVTK(DetailsVTKOptions) const
Definition: WallHandler.cc:494
std::string getName() const final
Returns the name of the handler, namely the string "WallHandler".
Definition: WallHandler.cc:310
~WallHandler() final
Destructor, it destructs the WallHandler and all BaseWall it contains.
Definition: WallHandler.cc:103
BaseWall * readAndCreateOldObject(std::istream &is)
Create a new wall, based on the information from old-style restart data.
Definition: WallHandler.cc:259
void actionsAfterParticleGhostUpdate()
Calls the method actionsAfterParticleGhostUpdate of every wall in the handler.
Definition: WallHandler.cc:458
WallHandler & operator=(const WallHandler &rhs)
Assignment operator that copies the pointer to the DPMBase and all BaseWall in the given WallHandler.
Definition: WallHandler.cc:88
unsigned readTriangleWall(std::string filename, ParticleSpecies *species, Mdouble scaleFactor=1, Vec3D centerOfRotation={0, 0, 0}, Vec3D velocity={0, 0, 0}, Vec3D angularVelocity={0, 0, 0})
Reads triangulated walls from vtk or stl files, and converts them into a set of TriangleWalls.
Definition: WallHandler.cc:341
void writeWallDetailsVTKBoundingBox(VTKData &data) const
Definition: WallHandler.cc:315
static BaseWall * createObject(const std::string &type)
Create a new wall, with the type given as a string (required for restarting).
Definition: WallHandler.cc:129