TriangulatedWall Class Reference

A TriangulatedWall is a triangulation created from a set of vertices and a n-by-3 connectivity matrix defining n faces. More...

#include <TriangulatedWall.h>

+ Inheritance diagram for TriangulatedWall:

Classes

struct  Face
 

Public Member Functions

 TriangulatedWall ()
 Default constructor. More...
 
 TriangulatedWall (const TriangulatedWall &other)
 Copy constructor. More...
 
 TriangulatedWall (std::string filename, const ParticleSpecies *species)
 Constructor setting values. More...
 
 TriangulatedWall (const std::vector< Vec3D > &points, const std::vector< std::vector< unsigned >> &cells, const ParticleSpecies *species)
 Constructor setting values. More...
 
void set (const std::vector< Vec3D > &points, const std::vector< std::vector< unsigned >> &cells)
 
void readVTK (std::string filename)
 
void writeVTK (VTKContainer &vtk) const override
 
 ~TriangulatedWall () override
 Destructor. More...
 
TriangulatedWalloperator= (const TriangulatedWall &other)
 
TriangulatedWallcopy () const override
 Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism. More...
 
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. If there is a collision, also return the normal vector. More...
 
void move (const Vec3D &move) override
 Move the TriangulatedWall to a new position, which is a Vec3D from the old position. More...
 
void read (std::istream &is) override
 Reads an TriangulatedWall from an input stream, for example a restart file. More...
 
void write (std::ostream &os) const override
 Writes an TriangulatedWall to an output stream, for example a restart file. More...
 
std::string getName () const override
 Returns the name of the object, here the string "TriangulatedWall". More...
 
BaseInteractiongetInteractionWith (BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
 Get the interaction between this TriangulatedWall and given BaseParticle at a given time. More...
 
- Public Member Functions inherited from BaseWall
 BaseWall ()
 Default constructor. More...
 
 BaseWall (const BaseWall &w)
 Copy constructor. More...
 
 ~BaseWall () override
 Default destructor. More...
 
virtual bool getDistanceNormalOverlap (const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
 
virtual bool getDistanceNormalOverlapSuperquadric (const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
 
virtual Vec3D getFurthestPointSuperQuadric (const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
 
virtual void setHandler (WallHandler *handler)
 A function which sets the WallHandler for this BaseWall. More...
 
WallHandlergetHandler () const
 A function which returns the WallHandler that handles this BaseWall. More...
 
void setIndSpecies (unsigned int indSpecies) override
 Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase. More...
 
void setSpecies (const ParticleSpecies *species)
 Defines the species of the current wall. More...
 
bool isFixed () const override
 
void setForceControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity={0, 0, 0})
 Slowly adjusts the force on a wall towards a specified goal, by adjusting (prescribing) the velocity of the wall. More...
 
virtual bool isLocal (Vec3D &min, Vec3D &max) const
 
bool getLinePlaneIntersect (Vec3D &intersect, const Vec3D &p0, const Vec3D &p1, const Vec3D &n, const Vec3D &p)
 
bool isInsideWallVTK (const Vec3D &point, const Vec3D &normal, const Vec3D &position) const
 
void projectOntoWallVTK (Vec3D &point0, const Vec3D &point1, const Vec3D &normal, const Vec3D &position) const
 
void intersectVTK (std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
 
virtual BaseInteractiongetInteractionWithSuperQuad (SuperQuadricParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler)
 
void getVTK (std::vector< Vec3D > &points, std::vector< std::vector< double >> &triangleStrips)
 
const Vec3D getAxis () const
 
virtual void actionsOnRestart ()
 No implementation but can be overidden in its derived classes. More...
 
virtual void actionsAfterParticleGhostUpdate ()
 No implementation but can be overidden in its derived classes. More...
 
virtual void handleParticleAddition (unsigned int id, BaseParticle *p)
 Handles the addition of particles to the particleHandler. More...
 
virtual void handleParticleRemoval (unsigned int id)
 Handles the addition of particles to the particleHandler. More...
 
virtual void checkInteractions (InteractionHandler *interactionHandler, unsigned int timeStamp)
 Check if all interactions are valid. More...
 
bool getVTKVisibility () const
 
void setVTKVisibility (bool vtkVisibility)
 
void addRenderedWall (BaseWall *w)
 
BaseWallgetRenderedWall (size_t i) const
 
std::vector< BaseWall * > getRenderedWalls () const
 
void removeRenderedWalls ()
 
void renderWall (VTKContainer &vtk)
 
void addParticlesAtWall (unsigned numElements=50)
 
void setVelocityControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
 
virtual void writeWallDetailsVTK (VTKData &data) const
 
virtual void computeWear ()
 
- Public Member Functions inherited from BaseInteractable
 BaseInteractable ()
 Default BaseInteractable constructor. More...
 
 BaseInteractable (const BaseInteractable &p)
 Copy constructor. More...
 
 ~BaseInteractable () override
 Destructor, it simply destructs the BaseInteractable and all the objects it contains. More...
 
unsigned int getIndSpecies () const
 Returns the index of the species associated with the interactable object. More...
 
const ParticleSpeciesgetSpecies () const
 Returns a pointer to the species of this BaseInteractable. More...
 
void setSpecies (const ParticleSpecies *species)
 Sets the species of this BaseInteractable. More...
 
const Vec3DgetForce () const
 Returns the force on this BaseInteractable. More...
 
const Vec3DgetTorque () const
 Returns the torque on this BaseInteractable. More...
 
void setForce (const Vec3D &force)
 Sets the force on this BaseInteractable. More...
 
void setTorque (const Vec3D &torque)
 Sets the torque on this BaseInteractable. More...
 
void addForce (const Vec3D &addForce)
 Adds an amount to the force on this BaseInteractable. More...
 
void addTorque (const Vec3D &addTorque)
 Adds an amount to the torque on this BaseInteractable. More...
 
virtual void resetForceTorque (int numberOfOMPthreads)
 
void sumForceTorqueOMP ()
 
const Vec3DgetPosition () const
 Returns the position of this BaseInteractable. More...
 
const QuaterniongetOrientation () const
 Returns the orientation of this BaseInteractable. More...
 
virtual void setPosition (const Vec3D &position)
 Sets the position of this BaseInteractable. More...
 
void setOrientationViaNormal (Vec3D normal)
 Sets the orientation of this BaseInteractable by defining the vector that results from the rotation of the (1,0,0) vector. More...
 
void setOrientationViaEuler (Vec3D eulerAngle)
 Sets the orientation of this BaseInteractable by defining the euler angles. More...
 
virtual void setOrientation (const Quaternion &orientation)
 Sets the orientation of this BaseInteractable. More...
 
virtual void rotate (const Vec3D &angularVelocityDt)
 Rotates this BaseInteractable. More...
 
const std::vector< BaseInteraction * > & getInteractions () const
 Returns a list of interactions which belong to this interactable. More...
 
void addInteraction (BaseInteraction *I)
 Adds an interaction to this BaseInteractable. More...
 
bool removeInteraction (BaseInteraction *I)
 Removes an interaction from this BaseInteractable. More...
 
void copyInteractionsForPeriodicParticles (const BaseInteractable &p)
 Copies interactions to this BaseInteractable whenever a periodic copy made. More...
 
void setVelocity (const Vec3D &velocity)
 set the velocity of the BaseInteractable. More...
 
void setAngularVelocity (const Vec3D &angularVelocity)
 set the angular velocity of the BaseInteractble. More...
 
void addVelocity (const Vec3D &velocity)
 adds an increment to the velocity. More...
 
void addAngularVelocity (const Vec3D &angularVelocity)
 add an increment to the angular velocity. More...
 
virtual const Vec3DgetVelocity () const
 Returns the velocity of this interactable. More...
 
virtual const Vec3DgetAngularVelocity () const
 Returns the angular velocity of this interactable. More...
 
void setPrescribedPosition (const std::function< Vec3D(double)> &prescribedPosition)
 Allows the position of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedPosition (double time)
 Computes the position from the user defined prescribed position function. More...
 
void setPrescribedVelocity (const std::function< Vec3D(double)> &prescribedVelocity)
 Allows the velocity of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedVelocity (double time)
 Computes the velocity from the user defined prescribed velocity function. More...
 
void setPrescribedOrientation (const std::function< Quaternion(double)> &prescribedOrientation)
 Allows the orientation of the infinite mass interactbale to be prescribed. More...
 
void applyPrescribedOrientation (double time)
 Computes the orientation from the user defined prescribed orientation function. More...
 
void setPrescribedAngularVelocity (const std::function< Vec3D(double)> &prescribedAngularVelocity)
 Allows the angular velocity of the infinite mass interactable to be prescribed. More...
 
void applyPrescribedAngularVelocity (double time)
 Computes the angular velocity from the user defined prescribed angular velocity. More...
 
virtual const Vec3D getVelocityAtContact (const Vec3D &contact) const
 Returns the velocity at the contact point, use by many force laws. More...
 
void integrateBeforeForceComputation (double time, double timeStep)
 This is part of integrate routine for objects with infinite mass. More...
 
void integrateAfterForceComputation (double time, double timeStep)
 This is part of the integration routine for objects with infinite mass. More...
 
virtual Mdouble getInvMass () const
 
virtual Mdouble getCurvature (const Vec3D &labFixedCoordinates) const
 
virtual bool isFaceContact (const Vec3D &normal) const
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Protected Attributes

std::vector< Vec3Dvertex_
 
std::vector< Faceface_
 

Private Member Functions

void setNormalsAndNeighbours ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseWall
static void addToVTK (const std::vector< Vec3D > &points, VTKContainer &vtk)
 Takes the points provided and adds a triangle strip connecting these points to the vtk container. More...
 

Detailed Description

A TriangulatedWall is a triangulation created from a set of vertices and a n-by-3 connectivity matrix defining n faces.

It is initialised by a unstructured grid vtk file:

TriangulatedWall w("TriangulatedWallSimple.vtk",speciesHandler.getLastObject());
RowVector3d w
Definition: Matrix_resize_int.cpp:3
A TriangulatedWall is a triangulation created from a set of vertices and a n-by-3 connectivity matrix...
Definition: TriangulatedWall.h:31

The file consists of a set of vertices and a n-by-3 connectivity matrix defining n faces. Three vertices form a face; the face normal is oriented such that the vertices are ordered in anticlockwise direction around the normal.

Particles interact with a TriangulatedWall when they contact a face (from either side), a edge, or a vertex.

For a demonstration on how to use this class, see TriangulatedWallSelfTest (shown in the image below).

Constructor & Destructor Documentation

◆ TriangulatedWall() [1/4]

TriangulatedWall::TriangulatedWall ( )

Default constructor.

13 {
14  logger(DEBUG, "TriangulatedWall() constructed.");
15 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG

References DEBUG, and logger.

Referenced by copy().

◆ TriangulatedWall() [2/4]

TriangulatedWall::TriangulatedWall ( const TriangulatedWall other)

Copy constructor.

Parameters
[in]otherThe TriangulatedWall that must be copied.
21  : BaseWall(other)
22 {
23  face_ = other.face_;
24  vertex_ = other.vertex_;
25  //now reset the pointers
26  for (unsigned f = 0; f < face_.size(); f++)
27  {
28  for (unsigned i = 0; i < 3; i++)
29  {
30  if (other.face_[f].neighbor[i])
31  {
32  face_[f].neighbor[i] = &face_[other.face_[f].neighbor[i] - &other.face_[0]];
33  } //else nullptr
34  face_[f].vertex[i] = &vertex_[other.face_[f].vertex[i] - &other.vertex_[0]];
35  }
36  }
37  logger(DEBUG, "TriangulatedWall(TriangulatedWall&) constructed.");
38 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
BaseWall()
Default constructor.
Definition: BaseWall.cc:15
std::vector< Face > face_
Definition: TriangulatedWall.h:137
std::vector< Vec3D > vertex_
Definition: TriangulatedWall.h:132
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237

References DEBUG, f(), face_, i, logger, and vertex_.

◆ TriangulatedWall() [3/4]

TriangulatedWall::TriangulatedWall ( std::string  filename,
const ParticleSpecies species 
)

Constructor setting values.

41 {
42  setSpecies(species);
44 }
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:148
void readVTK(std::string filename)
Definition: TriangulatedWall.cc:49
string filename
Definition: MergeRestartFiles.py:39

References MergeRestartFiles::filename, readVTK(), and BaseWall::setSpecies().

◆ TriangulatedWall() [4/4]

TriangulatedWall::TriangulatedWall ( const std::vector< Vec3D > &  points,
const std::vector< std::vector< unsigned >> &  cells,
const ParticleSpecies species 
)

Constructor setting values.

◆ ~TriangulatedWall()

TriangulatedWall::~TriangulatedWall ( )
override

Destructor.

206 {
207  logger(DEBUG, "~TriangulatedWall() has been called.");
208 }

References DEBUG, and logger.

Member Function Documentation

◆ copy()

TriangulatedWall * TriangulatedWall::copy ( ) const
overridevirtual

Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.

Returns
pointer to a TriangulatedWall object allocated using new.

Implements BaseWall.

Reimplemented in WearableTriangulatedWall.

227 {
228  return new TriangulatedWall(*this);
229 }
TriangulatedWall()
Default constructor.
Definition: TriangulatedWall.cc:12

References TriangulatedWall().

Referenced by operator=().

◆ getDistanceAndNormal()

bool TriangulatedWall::getDistanceAndNormal ( const BaseParticle p,
Mdouble distance,
Vec3D normal_return 
) const
overridevirtual

Compute the distance from the wall for a given BaseParticle and return if there is a collision. If there is a collision, also return the normal vector.

Parameters
[in]pBaseParticle we want to calculate the distance and whether it collided of.
[out]distanceThe distance of the BaseParticle to this wall.
[out]normal_returnIf there was a collision, the normal vector to this wall will be placed here.
Returns
A boolean which says whether or not there was a collision.

This function computes whether or not there is a collision between a given BaseParticle and this TriangulatedWall. If there is a collision, this function also computes the distance between the BaseParticle and TriangulatedWall and the normal of the TriangulatedWall at the intersection point. It does this by calling TriangulatedWall::getDistanceAndNormal(const Vec3D& , Mdouble , Mdouble&, Vec3D&) const. Since this function should be called before calculating any Particle-Wall interactions, it can also be used to set the normal vector in case of curved walls.

NOTE: THIS ONLY RETURNS ONE OF POSSIBLY MANY INTERACTIONS; it's only used for finding out if interactions exist, so should be fine

Implements BaseWall.

248 {
249  Mdouble interactionRadius = p.getWallInteractionRadius(this);
250  //it's important to use a reference here, as the faces use pointers
251  for (const auto& face : face_)
252  {
253  if (face.getDistanceAndNormal(p, distance, normal_return, interactionRadius))
254  return true;
255  }
256  return false;
257 }
float * p
Definition: Tutorial_Map_using.cpp:9

References face_, and p.

◆ getInteractionWith()

BaseInteraction * TriangulatedWall::getInteractionWith ( BaseParticle p,
unsigned  timeStamp,
InteractionHandler interactionHandler 
)
overridevirtual

Get the interaction between this TriangulatedWall and given BaseParticle at a given time.

Gets the interaction with this wall. In case of multiple contact points return the one with the shortest distance (i.e. largest overlap)

Parameters
[in]pPointer to the BaseParticle which we want to check the interaction for.
[in]timeStampThe time at which we want to look at the interaction.
[in]interactionHandlerA pointer to the InteractionHandler in which the interaction can be found.
Returns
A pointer to the BaseInteraction that happened between this wall and the BaseParticle at the timeStamp.

Reimplemented from BaseWall.

336 {
337  Mdouble distance, minDistance = constants::inf;
338  Vec3D normal, minNormal;
339  Mdouble interactionRadius = p->getWallInteractionRadius(this);
340  for (const auto& face : face_)
341  {
342  if (face.getDistanceAndNormal(*p, distance, normal,interactionRadius) && distance < minDistance)
343  {
344  minDistance = distance;
345  minNormal = normal;
346  }
347  }
348 
349  if (minDistance != constants::inf)
350  {
351  distance = minDistance;
352  normal = -minNormal;
353  BaseInteraction* const c = interactionHandler->getInteraction(p, this, timeStamp, normal);
354  c->setNormal(normal);
355  c->setDistance(distance);
356  c->setOverlap(p->getRadius() - distance);
357  c->setContactPoint(p->getPosition() - distance * normal);
358  return c;
359  }
360 
361  return nullptr;
362 }
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:39
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
Definition: InteractionHandler.cc:126
Definition: Kernel/Math/Vector.h:30
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
int c
Definition: calibrate.py:100
const Mdouble inf
Definition: GeneralDefine.h:23

References calibrate::c, face_, InteractionHandler::getInteraction(), constants::inf, WallFunction::normal(), and p.

◆ getName()

std::string TriangulatedWall::getName ( ) const
overridevirtual

Returns the name of the object, here the string "TriangulatedWall".

Returns
The string "TriangulatedWall".

Implements BaseObject.

Reimplemented in WearableTriangulatedWall.

322 {
323  return "TriangulatedWall";
324 }

◆ move()

void TriangulatedWall::move ( const Vec3D move)
overridevirtual

Move the TriangulatedWall to a new position, which is a Vec3D from the old position.

Parameters
[in]moveA reference to a Vec3D that denotes the direction and length it should be moved with.

A function that moves the TriangulatedWall in a certain direction by both moving the walls and all intersections. Note that the directions of the intersections are not moved since they don't change when moving the TriangulatedWall as a whole.

Todo:
We should use the position_ and orientation_ of the TriangulatedWall; that way, TriangulatedWall can be moved with the standard BaseInteractable::move function, getting rid of an anomaly in the code and removing the virtual from the move function.
Author
weinhartt

Reimplemented from BaseInteractable.

271 {
273  for (auto& v : vertex_)
274  {
275  v += move;
276  }
277 }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:193
void move(const Vec3D &move) override
Move the TriangulatedWall to a new position, which is a Vec3D from the old position.
Definition: TriangulatedWall.cc:270

References BaseInteractable::move(), v, and vertex_.

◆ operator=()

TriangulatedWall & TriangulatedWall::operator= ( const TriangulatedWall other)

Copy assignment operator.

Parameters
[in]otherThe TriangulatedWall that must be copied.
214 {
215  logger(DEBUG, "TriangulatedWall::operator= called.");
216  if (this == &other)
217  {
218  return *this;
219  }
220  return *(other.copy());
221 }
TriangulatedWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: TriangulatedWall.cc:226

References copy(), DEBUG, and logger.

◆ read()

void TriangulatedWall::read ( std::istream &  is)
overridevirtual

Reads an TriangulatedWall from an input stream, for example a restart file.

Parameters
[in]isThe input stream from which the TriangulatedWall is read, usually a restart file.
Todo:

Reimplemented from BaseWall.

Reimplemented in WearableTriangulatedWall.

283 {
285 }

Referenced by WearableTriangulatedWall::read().

◆ readVTK()

void TriangulatedWall::readVTK ( std::string  filename)
Parameters
[in]filenamename of vtk input file, e.g. TriangulatedWallSelfTest.vtk
50 {
51  std::fstream file;
52  file.open(filename.c_str(), std::ios::in);
53  logger.assert_always(file.is_open(), "File opening failed: %", filename);
54 
55  std::string dummy;
56  getline(file, dummy);
57  getline(file, dummy);
58  getline(file, dummy);
59  getline(file, dummy);
60  //read points
61  unsigned num;
62  file >> dummy >> num >> dummy;
63  vertex_.reserve(num);
64  Vec3D v;
65  for (unsigned i = 0; i < num; i++)
66  {
67  file >> v.X >> v.Y >> v.Z;
68  vertex_.push_back(v);
69  }
70  //read faces
71  file >> dummy >> num >> dummy;
72  face_.reserve(num);
73  Face f;
74  unsigned id0, id1, id2;
75  for (unsigned i = 0; i < num; i++)
76  {
77  file >> dummy >> id0 >> id1 >> id2;
78  f.vertex[0] = &vertex_[id0];
79  f.vertex[1] = &vertex_[id1];
80  f.vertex[2] = &vertex_[id2];
81  face_.push_back(f);
82  }
83 
84  file.close();
85 
87 }
void setNormalsAndNeighbours()
Definition: TriangulatedWall.cc:117
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References f(), face_, MergeRestartFiles::filename, i, logger, setNormalsAndNeighbours(), oomph::Global_string_for_annotation::string(), v, and vertex_.

Referenced by TriangulatedWall().

◆ set()

void TriangulatedWall::set ( const std::vector< Vec3D > &  points,
const std::vector< std::vector< unsigned >> &  cells 
)
97 {
98  //points
99  vertex_ = points;
100 
101  //cells
102  unsigned num = cells.size();
103  face_.reserve(num);
104  Face f;
105  for (unsigned i = 0; i < num; i++)
106  {
107  f.vertex[0] = &vertex_[cells[i][0]];
108  f.vertex[1] = &vertex_[cells[i][1]];
109  f.vertex[2] = &vertex_[cells[i][2]];
110  face_.push_back(f);
111  }
112 
113  //normals, positions, neighbours
115 }

References f(), face_, i, setNormalsAndNeighbours(), and vertex_.

Referenced by WearableTriangulatedWall::WearableTriangulatedWall().

◆ setNormalsAndNeighbours()

void TriangulatedWall::setNormalsAndNeighbours ( )
private
118 {
119  //set normals and positions
120  for (auto& face: face_)
121  {
122  face.normal = Vec3D::getUnitVector(
123  Vec3D::cross(*face.vertex[1] - *face.vertex[0], *face.vertex[2] - *face.vertex[0]));
124  }
125  //set neighbours
126  for (auto face0 = face_.begin(); face0 + 1 != face_.end(); face0++)
127  {
128  for (auto face1 = face0 + 1; face1 != face_.end(); face1++)
129  {
130  if (face0->vertex[0] == face1->vertex[0])
131  {
132  if (face0->vertex[1] == face1->vertex[2])
133  { //edge 0=2
134  face0->neighbor[0] = &*face1;
135  face1->neighbor[2] = &*face0;
136  }
137  else if (face0->vertex[2] == face1->vertex[1])
138  { //edge 2=0
139  face0->neighbor[2] = &*face1;
140  face1->neighbor[0] = &*face0;
141  }
142  }
143  else if (face0->vertex[0] == face1->vertex[1])
144  {
145  if (face0->vertex[1] == face1->vertex[0])
146  { //edge 0=0
147  face0->neighbor[0] = &*face1;
148  face1->neighbor[0] = &*face0;
149  }
150  else if (face0->vertex[2] == face1->vertex[2])
151  { //edge 2=1
152  face0->neighbor[2] = &*face1;
153  face1->neighbor[1] = &*face0;
154  }
155  }
156  else if (face0->vertex[0] == face1->vertex[2])
157  {
158  if (face0->vertex[1] == face1->vertex[1])
159  { //edge 0=1
160  face0->neighbor[0] = &*face1;
161  face1->neighbor[1] = &*face0;
162  }
163  else if (face0->vertex[2] == face1->vertex[0])
164  { //edge 2=2
165  face0->neighbor[2] = &*face1;
166  face1->neighbor[2] = &*face0;
167  }
168  }
169  else if (face0->vertex[1] == face1->vertex[0])
170  {
171  if (face0->vertex[2] == face1->vertex[2])
172  { //edge 1=2
173  face0->neighbor[1] = &*face1;
174  face1->neighbor[2] = &*face0;
175  }
176  }
177  else if (face0->vertex[1] == face1->vertex[1])
178  {
179  if (face0->vertex[2] == face1->vertex[0])
180  { //edge 1=0
181  face0->neighbor[1] = &*face1;
182  face1->neighbor[0] = &*face0;
183  }
184  }
185  else if (face0->vertex[1] == face1->vertex[2])
186  {
187  if (face0->vertex[2] == face1->vertex[1])
188  { //edge 1=1
189  face0->neighbor[1] = &*face1;
190  face1->neighbor[1] = &*face0;
191  }
192  }
193 
194  }
195  }
196  //set edge normals (inwards facing)
197  for (auto& face: face_)
198  {
199  face.edgeNormal[0] = Vec3D::getUnitVector(Vec3D::cross(face.normal, *face.vertex[1] - *face.vertex[0]));
200  face.edgeNormal[1] = Vec3D::getUnitVector(Vec3D::cross(face.normal, *face.vertex[2] - *face.vertex[1]));
201  face.edgeNormal[2] = Vec3D::getUnitVector(Vec3D::cross(face.normal, *face.vertex[0] - *face.vertex[2]));
202  }
203 }
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:143
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:364
void face1(const Vector< double > &s, Vector< double > &s_bulk)
The translation scheme for the face s0 = 1.0.
Definition: Qelement_face_coordinate_translation_schemes.cc:44
void face0(const Vector< double > &s, Vector< double > &s_bulk)
The translation scheme for the face s0 = -1.0.
Definition: Qelement_face_coordinate_translation_schemes.cc:38

References Vec3D::cross(), oomph::QElement1FaceToBulkCoordinates::face0(), oomph::QElement1FaceToBulkCoordinates::face1(), face_, and Vec3D::getUnitVector().

Referenced by readVTK(), and set().

◆ write()

void TriangulatedWall::write ( std::ostream &  os) const
overridevirtual

Writes an TriangulatedWall to an output stream, for example a restart file.

Parameters
[in]osThe output stream where the TriangulatedWall must be written to, usually a restart file.

Reimplemented from BaseWall.

Reimplemented in WearableTriangulatedWall.

292 {
293  os << "Vertices " << vertex_.size();
294  for (const auto& vertex: vertex_)
295  {
296  os << " " << vertex;
297  }
298  os << std::endl;
299  //os << "Faces " << face_.size() << std::endl;
300  unsigned counter = 0;
301  for (const auto& face: face_)
302  {
303  os << "Face " << counter++
304  << " vertex " << face.vertex[0] - &vertex_[0]
305  << " " << face.vertex[1] - &vertex_[0]
306  << " " << face.vertex[2] - &vertex_[0]
307  << " neighbor " << (face.neighbor[0] ? (face.neighbor[0] - &face_[0]) : -1)
308  << " " << (face.neighbor[1] ? (face.neighbor[1] - &face_[0]) : -1)
309  << " " << (face.neighbor[2] ? (face.neighbor[2] - &face_[0]) : -1)
310  << " normal " << face.normal
311  << " edgeNormal " << face.edgeNormal[0]
312  << " " << face.edgeNormal[1]
313  << " " << face.edgeNormal[2]
314  << std::endl;
315  }
316 }

References face_, and vertex_.

Referenced by WearableTriangulatedWall::write().

◆ writeVTK()

void TriangulatedWall::writeVTK ( VTKContainer vtk) const
overridevirtual

adds extra information to the points and triangleStrips vectors needed to plot the wall in vtk format

Parameters
pointsCoordinates of the vertices of the triangulated surfaces (in the VTK file this is called POINTS)
triangleStripsIndices of three vertices forming one triangulated surface (in the VTK file this is called CELL)

Reimplemented from BaseWall.

472 {
473  const int s = vtk.points.size();
474  for (auto v : vertex_)
475  {
476  vtk.points.push_back(v);
477  }
478  for (auto f : face_)
479  {
480  std::vector<double> cell;
481  cell.reserve(3);
482  cell.push_back(s + f.vertex[0] - &vertex_[0]);
483  cell.push_back(s + f.vertex[1] - &vertex_[0]);
484  cell.push_back(s + f.vertex[2] - &vertex_[0]);
485  vtk.triangleStrips.push_back(cell);
486  }
487 }
RealScalar s
Definition: level1_cplx_impl.h:130
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:19
std::vector< Vec3D > points
Definition: BaseWall.h:18

References f(), face_, VTKContainer::points, s, VTKContainer::triangleStrips, v, and vertex_.

Member Data Documentation

◆ face_

◆ vertex_

std::vector<Vec3D> TriangulatedWall::vertex_
protected

stores the vertex coordinates

Referenced by move(), readVTK(), set(), TriangulatedWall(), write(), and writeVTK().


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