TriangulatedWall.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 #ifndef TriangulatedWall_H
27 #define TriangulatedWall_H
28 
29 #include <vector>
30 #include "BaseWall.h"
31 #include "Math/Vector.h"
32 #include <array>
33 
51 class TriangulatedWall : public BaseWall
52 {
53 public:
54 
59  struct Face
60  {
62  std::array<Vec3D*, 3> vertex;
64  std::array<Face*, 3> neighbor = {{nullptr}};
66  std::array<Vec3D, 3> edgeNormal;
69 
71  Mdouble getDistance(const Vec3D& otherPosition) const;
72 
74  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return, Mdouble interactionRadius) const;
75  };
76 
81 
85  TriangulatedWall(const TriangulatedWall& other);
86 
90  TriangulatedWall(std::string filename, const ParticleSpecies* species);
91 
95  TriangulatedWall(const std::vector<Vec3D>& points, const std::vector<std::vector<unsigned>>& cells, const ParticleSpecies* species);
96 
97  void set(const std::vector<Vec3D>& points, const std::vector<std::vector<unsigned>>& cells);
98 
99  void readVTK(std::string filename);
100 
101  void writeVTK(VTKContainer& vtk) const override;
102 
106  ~TriangulatedWall() override;
107 
112 
116  TriangulatedWall* copy() const override;
117 
121  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const override;
122 
126  void move(const Vec3D& move) override;
127 
131  void read(std::istream& is) override;
132 
136  void write(std::ostream& os) const override;
137 
141  std::string getName() const override;
142 
146  BaseInteraction* getInteractionWith(BaseParticle* p, unsigned timeStamp,
147  InteractionHandler* interactionHandler) override;
148 
149 protected:
153  std::vector<Vec3D> vertex_;
154 
158  std::vector<Face> face_;
159 
160 private:
162 
163 };
164 
165 
166 #endif
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Definition: BaseParticle.h:54
Basic class for walls.
Definition: BaseWall.h:49
Container to store Interaction objects.
Definition: InteractionHandler.h:45
Definition: ParticleSpecies.h:37
A TriangulatedWall is a triangulation created from a set of vertices and a n-by-3 connectivity matrix...
Definition: TriangulatedWall.h:52
std::vector< Face > face_
Definition: TriangulatedWall.h:158
~TriangulatedWall() override
Destructor.
Definition: TriangulatedWall.cc:226
TriangulatedWall & operator=(const TriangulatedWall &other)
Definition: TriangulatedWall.cc:234
void read(std::istream &is) override
Reads an TriangulatedWall from an input stream, for example a restart file.
Definition: TriangulatedWall.cc:303
void write(std::ostream &os) const override
Writes an TriangulatedWall to an output stream, for example a restart file.
Definition: TriangulatedWall.cc:312
void readVTK(std::string filename)
Definition: TriangulatedWall.cc:70
void writeVTK(VTKContainer &vtk) const override
Definition: TriangulatedWall.cc:492
std::string getName() const override
Returns the name of the object, here the string "TriangulatedWall".
Definition: TriangulatedWall.cc:342
void move(const Vec3D &move) override
Move the TriangulatedWall to a new position, which is a Vec3D from the old position.
Definition: TriangulatedWall.cc:291
void setNormalsAndNeighbours()
Definition: TriangulatedWall.cc:138
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
Compute the distance from the wall for a given BaseParticle and return if there is a collision....
Definition: TriangulatedWall.cc:268
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Get the interaction between this TriangulatedWall and given BaseParticle at a given time.
Definition: TriangulatedWall.cc:355
TriangulatedWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: TriangulatedWall.cc:247
std::vector< Vec3D > vertex_
Definition: TriangulatedWall.h:153
TriangulatedWall()
Default constructor.
Definition: TriangulatedWall.cc:33
void set(const std::vector< Vec3D > &points, const std::vector< std::vector< unsigned >> &cells)
Definition: TriangulatedWall.cc:117
TriangulatedWall(const std::vector< Vec3D > &points, const std::vector< std::vector< unsigned >> &cells, const ParticleSpecies *species)
Constructor setting values.
Definition: Vector.h:51
Definition: TriangulatedWall.h:60
Mdouble getDistance(const Vec3D &otherPosition) const
computes the signed distance to the face in normal direction
Definition: TriangulatedWall.cc:385
std::array< Face *, 3 > neighbor
For each edge, stores the neighboring face (nullptr if none)
Definition: TriangulatedWall.h:64
std::array< Vec3D, 3 > edgeNormal
For each edge, stores the vector normal to the face normal and the edge direction (vector between the...
Definition: TriangulatedWall.h:66
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble interactionRadius) const
Returns true if contact with the face exists, false if not. If contact exists, then the distance and ...
Definition: TriangulatedWall.cc:394
Vec3D normal
face normal (vertices are ordered anticlockwise direction around the normal)
Definition: TriangulatedWall.h:68
std::array< Vec3D *, 3 > vertex
defines the three vertices (anticlockwise direction around the normal)
Definition: TriangulatedWall.h:62
Definition: BaseWall.h:38