WearableNurbsWall Class Reference

#include <WearableNurbsWall.h>

+ Inheritance diagram for WearableNurbsWall:

Public Member Functions

 WearableNurbsWall ()
 Default constructor: make a wall with default parameters. More...
 
 WearableNurbsWall (const WearableNurbsWall &other)
 Copy constructor, copies another wall. More...
 
 WearableNurbsWall (const NurbsSurface &nurbsSurface)
 Constructor in which all parameters of the wall are set. More...
 
 ~WearableNurbsWall ()
 Default destructor. More...
 
 WearableNurbsWall (Mdouble lengthU, Mdouble lengthV, Mdouble resolutionU, Mdouble resolutionV, bool periodicU=false, bool periodicV=false)
 
void set (Mdouble lengthU, Mdouble lengthV, Mdouble resolutionU, Mdouble resolutionV, bool periodicU=false, bool periodicV=false)
 
void read (std::istream &is) override
 Reads this wall from an input stream, for example a restart file. More...
 
void write (std::ostream &os) const override
 Writes this wall to an output stream, for example a restart file. More...
 
std::string getName () const final
 Returns the name of the object, here the string "WearableNurbsWall". More...
 
WearableNurbsWallcopy () const final
 Copy this wall and return a pointer to the copy. More...
 
void computeWear () override
 
void writeWallDetailsVTK (VTKData &data) const override
 
Mdouble getVolumeUnderSurface (const std::vector< Mdouble > &knotsU, const std::vector< Mdouble > &knotsV, const std::vector< std::vector< Vec3D >> &controlPoints, const std::vector< std::vector< Mdouble >> &weights) const
 
Mdouble getVolumeUnderSurfaceX (const std::vector< Mdouble > &knotsU, const std::vector< Mdouble > &knotsV, const std::vector< std::vector< Vec3D >> &controlPoints, const std::vector< std::vector< Mdouble >> &weights) const
 
void moveControlPoint (unsigned idxU, unsigned idxV, Vec3D dP)
 
Mdouble getVolumeUnderSurface ()
 
- Public Member Functions inherited from NurbsWall
 NurbsWall ()
 Default constructor: make a wall with default parameters. More...
 
 NurbsWall (const NurbsWall &other)
 Copy constructor, copies another wall. More...
 
 NurbsWall (const NurbsSurface &nurbsSurface)
 Constructor in which all parameters of the wall are set. More...
 
 ~NurbsWall ()
 Default destructor. More...
 
void set (const NurbsSurface &nurbsSurface)
 Defines a wall, given a NurbsSurface. More...
 
bool getDistanceAndNormal (const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const final
 Compute the distance from the Screw for a given BaseParticle and return if there is a collision. If there is a collision, also return the normal vector of the interaction point. More...
 
void writeVTK (VTKContainer &vtk) const override
 
- 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
 
BaseInteractiongetInteractionWith (BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
 Returns the interaction between this wall and a given particle, nullptr if there is no interaction. More...
 
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)
 
- 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 move (const Vec3D &move)
 Moves this BaseInteractable by adding an amount to the position. 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
 

Private Member Functions

void storeDebris (Vec3D P, const Mdouble debris)
 
void processDebris ()
 

Private Attributes

std::vector< std::vector< Mdouble > > localDebris_
 

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...
 
- Protected Attributes inherited from NurbsWall
NurbsSurface nurbsSurface_
 

Constructor & Destructor Documentation

◆ WearableNurbsWall() [1/4]

WearableNurbsWall::WearableNurbsWall ( )

Default constructor: make a wall with default parameters.

32 {
33  logger(DEBUG, "WearableNurbsWall() constructor finished.");
34 }
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().

◆ WearableNurbsWall() [2/4]

WearableNurbsWall::WearableNurbsWall ( const WearableNurbsWall other)

Copy constructor, copies another wall.

Parameters
[in]otherThe WearableNurbsWall that has to be copied.
40  : NurbsWall(other)
41 {
42  localDebris_ = other.localDebris_;
43  logger(DEBUG, "WearableNurbsWall(const WearableNurbsWall&) copy constructor finished.");
44 }
NurbsWall()
Default constructor: make a wall with default parameters.
Definition: NurbsWall.cc:39
std::vector< std::vector< Mdouble > > localDebris_
Definition: WearableNurbsWall.h:84

References DEBUG, localDebris_, and logger.

◆ WearableNurbsWall() [3/4]

WearableNurbsWall::WearableNurbsWall ( const NurbsSurface nurbsSurface)

Constructor in which all parameters of the wall are set.

Parameters
nurbsSurfaceThe NURBS surface which defines the shape of the wall
50  : NurbsWall(nurbsSurface)
51 {
52  logger(DEBUG, "WearableNurbsWall(const NurbsSurface&) constructor finished.");
53 }

References DEBUG, and logger.

◆ ~WearableNurbsWall()

WearableNurbsWall::~WearableNurbsWall ( )

Default destructor.

56 {
57  logger(DEBUG, "~WearableNurbsWall() finished, destroyed the wall.");
58 }

References DEBUG, and logger.

◆ WearableNurbsWall() [4/4]

WearableNurbsWall::WearableNurbsWall ( Mdouble  lengthU,
Mdouble  lengthV,
Mdouble  resolutionU,
Mdouble  resolutionV,
bool  periodicU = false,
bool  periodicV = false 
)
61 {
62  set(lengthU, lengthV, resolutionU, resolutionV, periodicU, periodicV);
63 }
void set(Mdouble lengthU, Mdouble lengthV, Mdouble resolutionU, Mdouble resolutionV, bool periodicU=false, bool periodicV=false)
Definition: WearableNurbsWall.cc:65

References set().

Member Function Documentation

◆ computeWear()

void WearableNurbsWall::computeWear ( )
overridevirtual

Reimplemented from BaseWall.

163 {
164  // From https://en.wikipedia.org/wiki/Archard_equation
165  // Q = KWL/H
166  // Q is the total volume of wear debris produced
167  // K is a dimensionless constant (typically mild wear 1e-8, severe wear 1e-2)
168  // W is the total normal load
169  // L is the sliding distance
170  // H is the hardness of the softest contacting surfaces
171 
172  const Mdouble dt = getHandler()->getDPMBase()->getTimeStep();
173 
174  for (BaseInteraction* interaction : getInteractions())
175  {
176  // Ignore interactions from periodic particles. (Although it seems Q evaluates to 0 anyway (absolute normal force equals 0), but just to be sure)
177  if (static_cast<BaseParticle*>(interaction->getP())->getPeriodicFromParticle() != nullptr)
178  continue;
179 
180  Mdouble K = 1.0e-6; // For testing only, should be set by user
181  Mdouble W = interaction->getAbsoluteNormalForce();
182  // Pythagoras to get tangential magnitude from vector and normal magnitude
183  Mdouble tangentialRelativeVelocity = std::sqrt(interaction->getRelativeVelocity().getLengthSquared() -
184  interaction->getNormalRelativeVelocity() * interaction->getNormalRelativeVelocity());
185  Mdouble L = tangentialRelativeVelocity * dt;
186  Mdouble H = 1.0; // For testing only, should be set by user
187  Mdouble Q = K * W * L / H;
188 
189  storeDebris(interaction->getContactPoint(), Q);
190  }
191 
192 // if (!getInteractions().empty() && getHandler()->getDPMBase()->getNumberOfTimeSteps() % 100 == 0)
193 // {
194 // processDebris();
195 // // Reset debris
196 // for (auto& d0 : localDebris_)
197 // for (auto& d : d0)
198 // d = 0.0;
199 // }
200 }
double Mdouble
Definition: GeneralDefine.h:34
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
Definition: BaseInteractable.h:277
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Definition: BaseParticle.h:54
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:134
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
void storeDebris(Vec3D P, const Mdouble debris)
Definition: WearableNurbsWall.cc:202

References BaseHandler< T >::getDPMBase(), BaseWall::getHandler(), BaseInteractable::getInteractions(), BaseParticle::getPeriodicFromParticle(), DPMBase::getTimeStep(), and storeDebris().

◆ copy()

WearableNurbsWall * WearableNurbsWall::copy ( ) const
finalvirtual

Copy this wall and return a pointer to the copy.

Reimplemented from NurbsWall.

158 {
159  return new WearableNurbsWall(*this);
160 }
WearableNurbsWall()
Default constructor: make a wall with default parameters.
Definition: WearableNurbsWall.cc:31

References WearableNurbsWall().

◆ getName()

std::string WearableNurbsWall::getName ( ) const
finalvirtual

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

Reimplemented from NurbsWall.

153 {
154  return "WearableNurbsWall";
155 }

◆ getVolumeUnderSurface() [1/2]

Mdouble WearableNurbsWall::getVolumeUnderSurface ( )
inline
99  {
101  }
const std::vector< std::vector< Vec3D > > & getControlPoints() const
Definition: NurbsSurface.h:141
const std::vector< std::vector< Mdouble > > & getWeights() const
Definition: NurbsSurface.h:144
const std::vector< Mdouble > & getKnotsU() const
Definition: NurbsSurface.h:147
const std::vector< Mdouble > & getKnotsV() const
Definition: NurbsSurface.h:150
NurbsSurface nurbsSurface_
Definition: NurbsWall.h:95
Mdouble getVolumeUnderSurface()
Definition: WearableNurbsWall.h:98

References NurbsSurface::getControlPoints(), NurbsSurface::getKnotsU(), NurbsSurface::getKnotsV(), NurbsSurface::getWeights(), and NurbsWall::nurbsSurface_.

Referenced by processDebris().

◆ getVolumeUnderSurface() [2/2]

Mdouble WearableNurbsWall::getVolumeUnderSurface ( const std::vector< Mdouble > &  knotsU,
const std::vector< Mdouble > &  knotsV,
const std::vector< std::vector< Vec3D >> &  controlPoints,
const std::vector< std::vector< Mdouble >> &  weights 
) const
281 {
282  // times 10 is arbitrary number for more accuracy.
283  const int numU = knotsU.size() * 10; // Was 10 lately a lot for many test simulations
284  const int numV = knotsV.size() * 10;
285 
286  const int degreeU = knotsU.size() - controlPoints.size() - 1;
287  const int degreeV = knotsV.size() - controlPoints[0].size() - 1;
288 
289  const Mdouble lbU = knotsU[degreeU];
290  const Mdouble ubU = knotsU[knotsU.size() - degreeU - 1];
291  const Mdouble lbV = knotsV[degreeV];
292  const Mdouble ubV = knotsV[knotsV.size() - degreeV - 1];
293 
294  Mdouble volume = 0.0;
295  for (int i = 0; i < numU; i++)
296  {
297  for (int j = 0; j < numV; j++)
298  {
299  const Mdouble u0 = lbU + (ubU - lbU) * static_cast<Mdouble>(i) / static_cast<Mdouble>(numU);
300  const Mdouble u1 = lbU + (ubU - lbU) * static_cast<Mdouble>(i+1) / static_cast<Mdouble>(numU);
301  const Mdouble v0 = lbV + (ubV - lbV) * static_cast<Mdouble>(j) / static_cast<Mdouble>(numV);
302  const Mdouble v1 = lbV + (ubV - lbV) * static_cast<Mdouble>(j+1) / static_cast<Mdouble>(numV);
303  const Vec3D p1 = NurbsUtils::evaluate(u0, v0, knotsU, knotsV, controlPoints, weights); // Bottom left
304  const Vec3D p2 = NurbsUtils::evaluate(u0, v1, knotsU, knotsV, controlPoints, weights); // Top left
305  const Vec3D p3 = NurbsUtils::evaluate(u1, v0, knotsU, knotsV, controlPoints, weights); // Bottom right
306  const Vec3D p4 = NurbsUtils::evaluate(u1, v1, knotsU, knotsV, controlPoints, weights); // Top right
307 
308  const Mdouble projectedArea1 = 0.5 * (p1.X * p3.Y - p3.X * p1.Y + p2.X * p1.Y - p1.X * p2.Y + p3.X * p2.Y - p2.X * p3.Y);
309  const Mdouble projectedArea2 = 0.5 * (p4.X * p3.Y - p3.X * p4.Y + p2.X * p4.Y - p4.X * p2.Y + p3.X * p2.Y - p2.X * p3.Y);
310  const Mdouble averageHeight1 = (p1.Z + p2.Z + p3.Z) / 3.0;
311  const Mdouble averageHeight2 = (p4.Z + p2.Z + p3.Z) / 3.0;
312  // Area can be negative (depending on order of points considered), and z is always negative assuming only
313  // downward movement of control points, therefore take absolute value.
314  const Mdouble volume1 = std::abs(averageHeight1 * projectedArea1);
315  const Mdouble volume2 = std::abs(averageHeight2 * projectedArea2);
316  volume += volume1 + volume2;
317  }
318  }
319  return volume;
320 }
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
Vec3D evaluate(Mdouble u, Mdouble v, std::vector< Mdouble > knotsU, std::vector< Mdouble > knotsV, std::vector< std::vector< Vec3D >> controlPoints, std::vector< std::vector< Mdouble >> weights)
Evaluate point on a NURBS surface.
Definition: NurbsUtils.cc:376
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References NurbsUtils::evaluate(), constants::i, Vec3D::X, Vec3D::Y, and Vec3D::Z.

◆ getVolumeUnderSurfaceX()

Mdouble WearableNurbsWall::getVolumeUnderSurfaceX ( const std::vector< Mdouble > &  knotsU,
const std::vector< Mdouble > &  knotsV,
const std::vector< std::vector< Vec3D >> &  controlPoints,
const std::vector< std::vector< Mdouble >> &  weights 
) const
324 {
325  // times 10 is arbitrary number for more accuracy.
326  const int numU = knotsU.size() * 10; // Was 10 lately a lot for many test simulations
327  const int numV = knotsV.size() * 10;
328 
329  const int degreeU = knotsU.size() - controlPoints.size() - 1;
330  const int degreeV = knotsV.size() - controlPoints[0].size() - 1;
331 
332  const Mdouble lbU = knotsU[degreeU];
333  const Mdouble ubU = knotsU[knotsU.size() - degreeU - 1];
334  const Mdouble lbV = knotsV[degreeV];
335  const Mdouble ubV = knotsV[knotsV.size() - degreeV - 1];
336 
337  Mdouble volume = 0.0;
338  for (int i = 0; i < numU; i++)
339  {
340  for (int j = 0; j < numV; j++)
341  {
342  const Mdouble u0 = lbU + (ubU - lbU) * static_cast<Mdouble>(i) / static_cast<Mdouble>(numU);
343  const Mdouble u1 = lbU + (ubU - lbU) * static_cast<Mdouble>(i+1) / static_cast<Mdouble>(numU);
344  const Mdouble v0 = lbV + (ubV - lbV) * static_cast<Mdouble>(j) / static_cast<Mdouble>(numV);
345  const Mdouble v1 = lbV + (ubV - lbV) * static_cast<Mdouble>(j+1) / static_cast<Mdouble>(numV);
346  const Vec3D p1 = NurbsUtils::evaluate(u0, v0, knotsU, knotsV, controlPoints, weights); // Bottom left
347  const Vec3D p2 = NurbsUtils::evaluate(u0, v1, knotsU, knotsV, controlPoints, weights); // Top left
348  const Vec3D p3 = NurbsUtils::evaluate(u1, v0, knotsU, knotsV, controlPoints, weights); // Bottom right
349  const Vec3D p4 = NurbsUtils::evaluate(u1, v1, knotsU, knotsV, controlPoints, weights); // Top right
350 
351  // Only place with differences, x and z interchanged
352  const Mdouble projectedArea1 = 0.5 * (p1.Z * p3.Y - p3.Z * p1.Y + p2.Z * p1.Y - p1.Z * p2.Y + p3.Z * p2.Y - p2.Z * p3.Y);
353  const Mdouble projectedArea2 = 0.5 * (p4.Z * p3.Y - p3.Z * p4.Y + p2.Z * p4.Y - p4.Z * p2.Y + p3.Z * p2.Y - p2.Z * p3.Y);
354  const Mdouble averageHeight1 = (p1.X + p2.X + p3.X) / 3.0;
355  const Mdouble averageHeight2 = (p4.X + p2.X + p3.X) / 3.0;
356  // Area can be negative (depending on order of points considered), and z is always negative assuming only
357  // downward movement of control points, therefore take absolute value.
358  const Mdouble volume1 = std::abs(averageHeight1 * projectedArea1);
359  const Mdouble volume2 = std::abs(averageHeight2 * projectedArea2);
360  volume += volume1 + volume2;
361  }
362  }
363  return volume;
364 }

References NurbsUtils::evaluate(), constants::i, Vec3D::X, Vec3D::Y, and Vec3D::Z.

◆ moveControlPoint()

void WearableNurbsWall::moveControlPoint ( unsigned  idxU,
unsigned  idxV,
Vec3D  dP 
)
inline
95  {
96  nurbsSurface_.moveControlPoint(idxU, idxV, dP, false);
97  }
void moveControlPoint(unsigned int indexU, unsigned int indexV, Vec3D dP, bool includingClosedOrPeriodic)
Definition: NurbsSurface.cc:658

References NurbsSurface::moveControlPoint(), and NurbsWall::nurbsSurface_.

◆ processDebris()

void WearableNurbsWall::processDebris ( )
private
251 {
252  std::vector<std::vector<Vec3D>> controlPoints = nurbsSurface_.getControlPoints();
253  Mdouble totalDebris = 0.0;
254 
255  const int numU = controlPoints.size();
256  const int numV = controlPoints[0].size();
257 
258  for (int i = 0; i < numU; i++)
259  {
260  for (int j = 0; j < numV; j++)
261  {
262  controlPoints[i][j].Z = -localDebris_[i][j];
263  totalDebris += localDebris_[i][j];
264  }
265  }
266 
268  const Mdouble ratio = totalDebris / volumeChange;
269 
270  for (int i = 0; i < numU; i++)
271  {
272  for (int j = 0; j < numV; j++)
273  {
274  nurbsSurface_.moveControlPoint(i, j, Vec3D(0.0, 0.0, -localDebris_[i][j] * ratio), true);
275  }
276  }
277 }

References NurbsSurface::getControlPoints(), NurbsSurface::getKnotsU(), NurbsSurface::getKnotsV(), getVolumeUnderSurface(), NurbsSurface::getWeights(), constants::i, localDebris_, NurbsSurface::moveControlPoint(), and NurbsWall::nurbsSurface_.

◆ read()

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

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

Parameters
[in,out]isInput stream from which the wall must be read.

Reimplemented from NurbsWall.

120 {
121  NurbsWall::read(is);
122  std::string dummy;
123  is >> dummy;
124 
125  unsigned int nu, nv;
126  is >> dummy >> nu;
127  is >> dummy >> nv;
128 
129  std::vector<std::vector<Mdouble>> localDebris;
130  localDebris.resize(nu);
131  for (auto& d0 : localDebris)
132  {
133  d0.resize(nv);
134  for (auto& d : d0) is >> d;
135  }
136 
137  localDebris_ = localDebris;
138 }
void read(std::istream &is) override
Reads this wall from an input stream, for example a restart file.
Definition: NurbsWall.cc:91

References localDebris_, and NurbsWall::read().

◆ set()

void WearableNurbsWall::set ( Mdouble  lengthU,
Mdouble  lengthV,
Mdouble  resolutionU,
Mdouble  resolutionV,
bool  periodicU = false,
bool  periodicV = false 
)
66 {
67  std::vector<std::vector<Vec3D>> controlPoints;
68  std::vector<std::vector<Mdouble>> weights;
69 
70  int numU = static_cast<int>(lengthU / resolutionU);
71  if (lengthU / numU > resolutionU)
72  {
73  numU++;
74  resolutionU = lengthU / numU;
75  }
76  int numV = static_cast<int>(lengthV / resolutionV);
77  if (lengthV / numV > resolutionV)
78  {
79  numV++;
80  resolutionV = lengthV / numV;
81  }
82 
83  for (int i = 0; i <= numU; i++)
84  {
85  std::vector<Vec3D> tempControlPoints;
86  std::vector<Mdouble> tempWeights;
87  for (int j = 0; j <= numV; j++)
88  {
89  tempControlPoints.push_back(Vec3D(i * resolutionU, j * resolutionV, 0.0));
90  tempWeights.push_back(1.0);
91  }
92  controlPoints.push_back(tempControlPoints);
93  weights.push_back(tempWeights);
94  }
95 
96  // Make periodic when asked for, only clamp when not periodic.
97  // Making periodic will unclamp it when needed, but better to start of unclamped already otherwise
98  // warning messages are given to the user.
99  NurbsSurface ns(controlPoints, weights, 3, 3, !periodicU, !periodicU, !periodicV, !periodicV);
100  if (periodicU)
101  ns.makePeriodicContinuousInU();
102  if (periodicV)
103  ns.makePeriodicContinuousInV();
104  nurbsSurface_ = ns;
105 
106  // Initialize local debris with zeros
107  const int sizeU = nurbsSurface_.getControlPoints().size();
108  const int sizeV = nurbsSurface_.getControlPoints()[0].size();
109  for (int i = 0; i < sizeU; i++)
110  {
111  std::vector<Mdouble> temp(sizeV, 0.0);
112  localDebris_.push_back(temp);
113  }
114 }
Definition: NurbsSurface.h:34

References NurbsSurface::getControlPoints(), constants::i, localDebris_, NurbsSurface::makePeriodicContinuousInU(), NurbsSurface::makePeriodicContinuousInV(), and NurbsWall::nurbsSurface_.

Referenced by WearableNurbsWall().

◆ storeDebris()

void WearableNurbsWall::storeDebris ( Vec3D  P,
const Mdouble  debris 
)
private
203 {
204  // Rotate global point back to local coordinate system.
205  P -= getPosition();
207 
208  // Snap the position to the closest grid point. Assuming the control points only ever move in z-direction, so the
209  // x- and y-position don't change, and it was created with a given resolution in u and v.
210  const std::vector<std::vector<Vec3D>>& controlPoints = nurbsSurface_.getControlPoints();
211  const Mdouble resU = std::abs(controlPoints[1][0].X - controlPoints[0][0].X);
212  const Mdouble resV = std::abs(controlPoints[0][1].Y - controlPoints[0][0].Y);
213 
214  // --- Add to closest grid point -----------------------------------------------------------------------------------
215  auto indexU = static_cast<const unsigned>(std::round((P.X - controlPoints[0][0].X) / resU));
216  auto indexV = static_cast<const unsigned>(std::round((P.Y - controlPoints[0][0].Y) / resV));
217  localDebris_[indexU][indexV] += debris;
218 
219  // --- Add to 4 closest grid points, weighted by distance ----------------------------------------------------------
220 // const Mdouble pU = (P.X - controlPoints[0][0].X) / resU;
221 // const Mdouble pV = (P.Y - controlPoints[0][0].Y) / resV;
222 //
223 // // Left and right distance in u and v
224 // const Mdouble pUL = pU - std::floor(pU);
225 // const Mdouble pVL = pV - std::floor(pV);
226 // const Mdouble pUR = 1.0 - pUL;
227 // const Mdouble pVR = 1.0 - pVL;
228 //
229 // // Power parameter
230 // const Mdouble p = 1.0;
231 //
232 // // Normalizing "length" in u and v
233 // const Mdouble lU = std::pow(pUL, p) + std::pow(pUR, p);
234 // const Mdouble lV = std::pow(pVL, p) + std::pow(pVR, p);
235 //
236 // // Weights for left and right in u and v
237 // const Mdouble wUL = 1.0 - std::pow(pUL, p) / lU;
238 // const Mdouble wUR = 1.0 - std::pow(pUR, p) / lU;
239 // const Mdouble wVL = 1.0 - std::pow(pVL, p) / lV;
240 // const Mdouble wVR = 1.0 - std::pow(pVR, p) / lV;
241 //
242 // const unsigned firstIndexU = std::floor(pU);
243 // const unsigned firstIndexV = std::floor(pV);
244 // localDebris_[firstIndexU ][firstIndexV ] += debris * wUL * wVL;
245 // localDebris_[firstIndexU ][firstIndexV + 1] += debris * wUL * wVR;
246 // localDebris_[firstIndexU + 1][firstIndexV ] += debris * wUR * wVL;
247 // localDebris_[firstIndexU + 1][firstIndexV + 1] += debris * wUR * wVR;
248 }
@ Y
Definition: StatisticsVector.h:42
@ X
Definition: StatisticsVector.h:42
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
void rotateBack(Vec3D &position) const
Definition: Quaternion.cc:610
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73
Mdouble round(Mdouble value, unsigned int precision)
rounds a floating point number with a given precision
Definition: MathHelpers.cc:28

References NurbsSurface::getControlPoints(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), localDebris_, NurbsWall::nurbsSurface_, Global_Physical_Variables::P, Quaternion::rotateBack(), helpers::round(), X, and Y.

Referenced by computeWear().

◆ write()

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

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

Parameters
[in,out]osOutput stream to which the wall must be written.

Reimplemented from NurbsWall.

144 {
145  NurbsWall::write(os);
146  os << " Debris ";
147  os << "nu " << localDebris_.size() << ' ';
148  os << "nv " << localDebris_[0].size() << ' ';
149  for (const auto& d0 : localDebris_) for (const auto d : d0) os << d << ' ';
150 }
void write(std::ostream &os) const override
Writes this wall to an output stream, for example a restart file.
Definition: NurbsWall.cc:102

References localDebris_, and NurbsWall::write().

◆ writeWallDetailsVTK()

void WearableNurbsWall::writeWallDetailsVTK ( VTKData data) const
overridevirtual

Reimplemented from NurbsWall.

367 {
368  // Visualised as a flat surface, which can be coloured according to the debris at each point.
369  // The points are simply the control points with the z-position set to 0.
370 
371  const std::vector<std::vector<Vec3D>>& points = nurbsSurface_.getControlPoints();
372 
373  // Reserve memory for number of points and cells about to be added
374  const unsigned np = points.size() * points[0].size();
375  const unsigned nc = (points.size() - 1) * (points[0].size() - 1);
376  data.reservePoints(np, { "Debris" });
377  data.reserveCells(nc);
378 
379  // Number of points in v-direction
380  size_t nv = points[0].size();
381  // Point index offset, the point indices have to be offset by the number of points already present at the start (from previously added data)
382  size_t pio = data.getPoints().size();
383 
384  for (int i = 0; i < points.size(); i++)
385  {
386  for (int j = 0; j < points[i].size(); j++)
387  {
388  Vec3D p = points[i][j];
389  p.Z = 0;
390  getOrientation().rotate(p);
391  p += getPosition();
392  data.addToPoints(p);
393  data.addToPointData("Debris", localDebris_[i][j]);
394 
395  if (i > 0 && j > 0)
396  {
397  // Basic 2D/1D mapping for indexing: nv * i + j (+ point index offset)
398  // 4 points to form a rectangle: point, point to the left, point down, point to the left and down
399  data.addToConnectivity({ nv*i+j+pio, nv*(i-1)+j+pio, nv*i+j-1+pio, nv*(i-1)+j-1+pio });
400  data.addToTypes(8);
401  }
402  }
403  }
404 }
void rotate(Vec3D &position) const
Definition: Quaternion.cc:563
void addToTypes(int type)
Adds a type to the types vector.
Definition: VTKData.cc:43
void addToPoints(Vec3D point)
Adds a point to the points vector.
Definition: VTKData.cc:28
void reserveCells(unsigned int n)
Reserves additional memory for connectivity and types vectors.
Definition: VTKData.cc:76
void addToPointData(const std::string &key, Mdouble value)
Adds a value to the pointData values vector corresponding to the given key.
Definition: VTKData.cc:33
void reservePoints(unsigned int n, const std::vector< std::string > &keys={})
Reserves additional memory for the points vector and optionally for the values vectors of the pointDa...
Definition: VTKData.cc:68
std::vector< Vec3D > getPoints() const
Definition: VTKData.cc:48
void addToConnectivity(const std::vector< size_t > &indices)
Adds a vector of indices to the connectivity vector.
Definition: VTKData.cc:38

References VTKData::addToConnectivity(), VTKData::addToPointData(), VTKData::addToPoints(), VTKData::addToTypes(), NurbsSurface::getControlPoints(), BaseInteractable::getOrientation(), VTKData::getPoints(), BaseInteractable::getPosition(), constants::i, localDebris_, NurbsWall::nurbsSurface_, VTKData::reserveCells(), VTKData::reservePoints(), Quaternion::rotate(), and Vec3D::Z.

Referenced by WallDetailsVTKWriter::writeVTK().

Member Data Documentation

◆ localDebris_

std::vector<std::vector<Mdouble> > WearableNurbsWall::localDebris_
private

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