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.

11 {
12  logger(DEBUG, "WearableNurbsWall() constructor finished.");
13 }
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.
19  : NurbsWall(other)
20 {
21  localDebris_ = other.localDebris_;
22  logger(DEBUG, "WearableNurbsWall(const WearableNurbsWall&) copy constructor finished.");
23 }
NurbsWall()
Default constructor: make a wall with default parameters.
Definition: NurbsWall.cc:18
std::vector< std::vector< Mdouble > > localDebris_
Definition: WearableNurbsWall.h:63

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
29  : NurbsWall(nurbsSurface)
30 {
31  logger(DEBUG, "WearableNurbsWall(const NurbsSurface&) constructor finished.");
32 }

References DEBUG, and logger.

◆ ~WearableNurbsWall()

WearableNurbsWall::~WearableNurbsWall ( )

Default destructor.

35 {
36  logger(DEBUG, "~WearableNurbsWall() finished, destroyed the wall.");
37 }

References DEBUG, and logger.

◆ WearableNurbsWall() [4/4]

WearableNurbsWall::WearableNurbsWall ( Mdouble  lengthU,
Mdouble  lengthV,
Mdouble  resolutionU,
Mdouble  resolutionV,
bool  periodicU = false,
bool  periodicV = false 
)
40 {
41  set(lengthU, lengthV, resolutionU, resolutionV, periodicU, periodicV);
42 }
void set(Mdouble lengthU, Mdouble lengthV, Mdouble resolutionU, Mdouble resolutionV, bool periodicU=false, bool periodicV=false)
Definition: WearableNurbsWall.cc:44

References set().

Member Function Documentation

◆ computeWear()

void WearableNurbsWall::computeWear ( )
overridevirtual

Reimplemented from BaseWall.

142 {
143  // From https://en.wikipedia.org/wiki/Archard_equation
144  // Q = KWL/H
145  // Q is the total volume of wear debris produced
146  // K is a dimensionless constant (typically mild wear 1e-8, severe wear 1e-2)
147  // W is the total normal load
148  // L is the sliding distance
149  // H is the hardness of the softest contacting surfaces
150 
151  const Mdouble dt = getHandler()->getDPMBase()->getTimeStep();
152 
153  for (BaseInteraction* interaction : getInteractions())
154  {
155  // Ignore interactions from periodic particles. (Although it seems Q evaluates to 0 anyway (absolute normal force equals 0), but just to be sure)
156  if (static_cast<BaseParticle*>(interaction->getP())->getPeriodicFromParticle() != nullptr)
157  continue;
158 
159  Mdouble K = 1.0e-6; // For testing only, should be set by user
160  Mdouble W = interaction->getAbsoluteNormalForce();
161  // Pythagoras to get tangential magnitude from vector and normal magnitude
162  Mdouble tangentialRelativeVelocity = std::sqrt(interaction->getRelativeVelocity().getLengthSquared() -
163  interaction->getNormalRelativeVelocity() * interaction->getNormalRelativeVelocity());
164  Mdouble L = tangentialRelativeVelocity * dt;
165  Mdouble H = 1.0; // For testing only, should be set by user
166  Mdouble Q = K * W * L / H;
167 
168  storeDebris(interaction->getContactPoint(), Q);
169  }
170 
171 // if (!getInteractions().empty() && getHandler()->getDPMBase()->getNumberOfTimeSteps() % 100 == 0)
172 // {
173 // processDebris();
174 // // Reset debris
175 // for (auto& d0 : localDebris_)
176 // for (auto& d : d0)
177 // d = 0.0;
178 // }
179 }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
MatrixXf H
Definition: HessenbergDecomposition_matrixH.cpp:4
MatrixXf Q
Definition: HouseholderQR_householderQ.cpp:1
MatrixXd L
Definition: LLT_example.cpp:6
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
Definition: BaseInteractable.h:256
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:39
Definition: BaseParticle.h:33
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:324
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:113
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1241
void storeDebris(Vec3D P, const Mdouble debris)
Definition: WearableNurbsWall.cc:181
double K
Wave number.
Definition: sphere_scattering.cc:115
@ W
Definition: quadtree.h:63

References BaseHandler< T >::getDPMBase(), BaseWall::getHandler(), BaseInteractable::getInteractions(), BaseParticle::getPeriodicFromParticle(), DPMBase::getTimeStep(), H, PlanarWave::K, L, Q, sqrt(), storeDebris(), and oomph::QuadTreeNames::W.

◆ copy()

WearableNurbsWall * WearableNurbsWall::copy ( ) const
finalvirtual

Copy this wall and return a pointer to the copy.

Reimplemented from NurbsWall.

137 {
138  return new WearableNurbsWall(*this);
139 }
WearableNurbsWall()
Default constructor: make a wall with default parameters.
Definition: WearableNurbsWall.cc:10

References WearableNurbsWall().

◆ getName()

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

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

Reimplemented from NurbsWall.

132 {
133  return "WearableNurbsWall";
134 }

◆ getVolumeUnderSurface() [1/2]

Mdouble WearableNurbsWall::getVolumeUnderSurface ( )
inline
78  {
80  }
const std::vector< std::vector< Vec3D > > & getControlPoints() const
Definition: NurbsSurface.h:120
const std::vector< std::vector< Mdouble > > & getWeights() const
Definition: NurbsSurface.h:123
const std::vector< Mdouble > & getKnotsU() const
Definition: NurbsSurface.h:126
const std::vector< Mdouble > & getKnotsV() const
Definition: NurbsSurface.h:129
NurbsSurface nurbsSurface_
Definition: NurbsWall.h:74
Mdouble getVolumeUnderSurface()
Definition: WearableNurbsWall.h:77

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
260 {
261  // times 10 is arbitrary number for more accuracy.
262  const int numU = knotsU.size() * 10; // Was 10 lately a lot for many test simulations
263  const int numV = knotsV.size() * 10;
264 
265  const int degreeU = knotsU.size() - controlPoints.size() - 1;
266  const int degreeV = knotsV.size() - controlPoints[0].size() - 1;
267 
268  const Mdouble lbU = knotsU[degreeU];
269  const Mdouble ubU = knotsU[knotsU.size() - degreeU - 1];
270  const Mdouble lbV = knotsV[degreeV];
271  const Mdouble ubV = knotsV[knotsV.size() - degreeV - 1];
272 
273  Mdouble volume = 0.0;
274  for (int i = 0; i < numU; i++)
275  {
276  for (int j = 0; j < numV; j++)
277  {
278  const Mdouble u0 = lbU + (ubU - lbU) * static_cast<Mdouble>(i) / static_cast<Mdouble>(numU);
279  const Mdouble u1 = lbU + (ubU - lbU) * static_cast<Mdouble>(i+1) / static_cast<Mdouble>(numU);
280  const Mdouble v0 = lbV + (ubV - lbV) * static_cast<Mdouble>(j) / static_cast<Mdouble>(numV);
281  const Mdouble v1 = lbV + (ubV - lbV) * static_cast<Mdouble>(j+1) / static_cast<Mdouble>(numV);
282  const Vec3D p1 = NurbsUtils::evaluate(u0, v0, knotsU, knotsV, controlPoints, weights); // Bottom left
283  const Vec3D p2 = NurbsUtils::evaluate(u0, v1, knotsU, knotsV, controlPoints, weights); // Top left
284  const Vec3D p3 = NurbsUtils::evaluate(u1, v0, knotsU, knotsV, controlPoints, weights); // Bottom right
285  const Vec3D p4 = NurbsUtils::evaluate(u1, v1, knotsU, knotsV, controlPoints, weights); // Top right
286 
287  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);
288  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);
289  const Mdouble averageHeight1 = (p1.Z + p2.Z + p3.Z) / 3.0;
290  const Mdouble averageHeight2 = (p4.Z + p2.Z + p3.Z) / 3.0;
291  // Area can be negative (depending on order of points considered), and z is always negative assuming only
292  // downward movement of control points, therefore take absolute value.
293  const Mdouble volume1 = std::abs(averageHeight1 * projectedArea1);
294  const Mdouble volume2 = std::abs(averageHeight2 * projectedArea2);
295  volume += volume1 + volume2;
296  }
297  }
298  return volume;
299 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Vector3f p1
Definition: MatrixBase_all.cpp:2
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
Definition: Kernel/Math/Vector.h:30
Mdouble Y
Definition: Kernel/Math/Vector.h:45
Mdouble Z
Definition: Kernel/Math/Vector.h:45
Mdouble X
the vector components
Definition: Kernel/Math/Vector.h:45
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:355
list weights
Definition: calibrate.py:94
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References abs(), NurbsUtils::evaluate(), i, j, p1, v1(), calibrate::weights, 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
303 {
304  // times 10 is arbitrary number for more accuracy.
305  const int numU = knotsU.size() * 10; // Was 10 lately a lot for many test simulations
306  const int numV = knotsV.size() * 10;
307 
308  const int degreeU = knotsU.size() - controlPoints.size() - 1;
309  const int degreeV = knotsV.size() - controlPoints[0].size() - 1;
310 
311  const Mdouble lbU = knotsU[degreeU];
312  const Mdouble ubU = knotsU[knotsU.size() - degreeU - 1];
313  const Mdouble lbV = knotsV[degreeV];
314  const Mdouble ubV = knotsV[knotsV.size() - degreeV - 1];
315 
316  Mdouble volume = 0.0;
317  for (int i = 0; i < numU; i++)
318  {
319  for (int j = 0; j < numV; j++)
320  {
321  const Mdouble u0 = lbU + (ubU - lbU) * static_cast<Mdouble>(i) / static_cast<Mdouble>(numU);
322  const Mdouble u1 = lbU + (ubU - lbU) * static_cast<Mdouble>(i+1) / static_cast<Mdouble>(numU);
323  const Mdouble v0 = lbV + (ubV - lbV) * static_cast<Mdouble>(j) / static_cast<Mdouble>(numV);
324  const Mdouble v1 = lbV + (ubV - lbV) * static_cast<Mdouble>(j+1) / static_cast<Mdouble>(numV);
325  const Vec3D p1 = NurbsUtils::evaluate(u0, v0, knotsU, knotsV, controlPoints, weights); // Bottom left
326  const Vec3D p2 = NurbsUtils::evaluate(u0, v1, knotsU, knotsV, controlPoints, weights); // Top left
327  const Vec3D p3 = NurbsUtils::evaluate(u1, v0, knotsU, knotsV, controlPoints, weights); // Bottom right
328  const Vec3D p4 = NurbsUtils::evaluate(u1, v1, knotsU, knotsV, controlPoints, weights); // Top right
329 
330  // Only place with differences, x and z interchanged
331  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);
332  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);
333  const Mdouble averageHeight1 = (p1.X + p2.X + p3.X) / 3.0;
334  const Mdouble averageHeight2 = (p4.X + p2.X + p3.X) / 3.0;
335  // Area can be negative (depending on order of points considered), and z is always negative assuming only
336  // downward movement of control points, therefore take absolute value.
337  const Mdouble volume1 = std::abs(averageHeight1 * projectedArea1);
338  const Mdouble volume2 = std::abs(averageHeight2 * projectedArea2);
339  volume += volume1 + volume2;
340  }
341  }
342  return volume;
343 }

References abs(), NurbsUtils::evaluate(), i, j, p1, v1(), calibrate::weights, Vec3D::X, Vec3D::Y, and Vec3D::Z.

◆ moveControlPoint()

void WearableNurbsWall::moveControlPoint ( unsigned  idxU,
unsigned  idxV,
Vec3D  dP 
)
inline
74  {
75  nurbsSurface_.moveControlPoint(idxU, idxV, dP, false);
76  }
void moveControlPoint(unsigned int indexU, unsigned int indexV, Vec3D dP, bool includingClosedOrPeriodic)
Definition: NurbsSurface.cc:637

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

◆ processDebris()

void WearableNurbsWall::processDebris ( )
private
230 {
231  std::vector<std::vector<Vec3D>> controlPoints = nurbsSurface_.getControlPoints();
232  Mdouble totalDebris = 0.0;
233 
234  const int numU = controlPoints.size();
235  const int numV = controlPoints[0].size();
236 
237  for (int i = 0; i < numU; i++)
238  {
239  for (int j = 0; j < numV; j++)
240  {
241  controlPoints[i][j].Z = -localDebris_[i][j];
242  totalDebris += localDebris_[i][j];
243  }
244  }
245 
247  const Mdouble ratio = totalDebris / volumeChange;
248 
249  for (int i = 0; i < numU; i++)
250  {
251  for (int j = 0; j < numV; j++)
252  {
253  nurbsSurface_.moveControlPoint(i, j, Vec3D(0.0, 0.0, -localDebris_[i][j] * ratio), true);
254  }
255  }
256 }

References NurbsSurface::getControlPoints(), NurbsSurface::getKnotsU(), NurbsSurface::getKnotsV(), getVolumeUnderSurface(), NurbsSurface::getWeights(), i, j, 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.

99 {
100  NurbsWall::read(is);
101  std::string dummy;
102  is >> dummy;
103 
104  unsigned int nu, nv;
105  is >> dummy >> nu;
106  is >> dummy >> nv;
107 
108  std::vector<std::vector<Mdouble>> localDebris;
109  localDebris.resize(nu);
110  for (auto& d0 : localDebris)
111  {
112  d0.resize(nv);
113  for (auto& d : d0) is >> d;
114  }
115 
116  localDebris_ = localDebris;
117 }
void read(std::istream &is) override
Reads this wall from an input stream, for example a restart file.
Definition: NurbsWall.cc:70
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References localDebris_, NurbsWall::read(), and oomph::Global_string_for_annotation::string().

◆ set()

void WearableNurbsWall::set ( Mdouble  lengthU,
Mdouble  lengthV,
Mdouble  resolutionU,
Mdouble  resolutionV,
bool  periodicU = false,
bool  periodicV = false 
)
45 {
46  std::vector<std::vector<Vec3D>> controlPoints;
47  std::vector<std::vector<Mdouble>> weights;
48 
49  int numU = static_cast<int>(lengthU / resolutionU);
50  if (lengthU / numU > resolutionU)
51  {
52  numU++;
53  resolutionU = lengthU / numU;
54  }
55  int numV = static_cast<int>(lengthV / resolutionV);
56  if (lengthV / numV > resolutionV)
57  {
58  numV++;
59  resolutionV = lengthV / numV;
60  }
61 
62  for (int i = 0; i <= numU; i++)
63  {
64  std::vector<Vec3D> tempControlPoints;
65  std::vector<Mdouble> tempWeights;
66  for (int j = 0; j <= numV; j++)
67  {
68  tempControlPoints.push_back(Vec3D(i * resolutionU, j * resolutionV, 0.0));
69  tempWeights.push_back(1.0);
70  }
71  controlPoints.push_back(tempControlPoints);
72  weights.push_back(tempWeights);
73  }
74 
75  // Make periodic when asked for, only clamp when not periodic.
76  // Making periodic will unclamp it when needed, but better to start of unclamped already otherwise
77  // warning messages are given to the user.
78  NurbsSurface ns(controlPoints, weights, 3, 3, !periodicU, !periodicU, !periodicV, !periodicV);
79  if (periodicU)
80  ns.makePeriodicContinuousInU();
81  if (periodicV)
82  ns.makePeriodicContinuousInV();
83  nurbsSurface_ = ns;
84 
85  // Initialize local debris with zeros
86  const int sizeU = nurbsSurface_.getControlPoints().size();
87  const int sizeV = nurbsSurface_.getControlPoints()[0].size();
88  for (int i = 0; i < sizeU; i++)
89  {
90  std::vector<Mdouble> temp(sizeV, 0.0);
91  localDebris_.push_back(temp);
92  }
93 }
Definition: NurbsSurface.h:13

References NurbsSurface::getControlPoints(), i, j, localDebris_, NurbsSurface::makePeriodicContinuousInU(), NurbsSurface::makePeriodicContinuousInV(), NurbsWall::nurbsSurface_, and calibrate::weights.

Referenced by WearableNurbsWall().

◆ storeDebris()

void WearableNurbsWall::storeDebris ( Vec3D  P,
const Mdouble  debris 
)
private
182 {
183  // Rotate global point back to local coordinate system.
184  P -= getPosition();
186 
187  // Snap the position to the closest grid point. Assuming the control points only ever move in z-direction, so the
188  // x- and y-position don't change, and it was created with a given resolution in u and v.
189  const std::vector<std::vector<Vec3D>>& controlPoints = nurbsSurface_.getControlPoints();
190  const Mdouble resU = std::abs(controlPoints[1][0].X - controlPoints[0][0].X);
191  const Mdouble resV = std::abs(controlPoints[0][1].Y - controlPoints[0][0].Y);
192 
193  // --- Add to closest grid point -----------------------------------------------------------------------------------
194  auto indexU = static_cast<const unsigned>(std::round((P.X - controlPoints[0][0].X) / resU));
195  auto indexV = static_cast<const unsigned>(std::round((P.Y - controlPoints[0][0].Y) / resV));
196  localDebris_[indexU][indexV] += debris;
197 
198  // --- Add to 4 closest grid points, weighted by distance ----------------------------------------------------------
199 // const Mdouble pU = (P.X - controlPoints[0][0].X) / resU;
200 // const Mdouble pV = (P.Y - controlPoints[0][0].Y) / resV;
201 //
202 // // Left and right distance in u and v
203 // const Mdouble pUL = pU - std::floor(pU);
204 // const Mdouble pVL = pV - std::floor(pV);
205 // const Mdouble pUR = 1.0 - pUL;
206 // const Mdouble pVR = 1.0 - pVL;
207 //
208 // // Power parameter
209 // const Mdouble p = 1.0;
210 //
211 // // Normalizing "length" in u and v
212 // const Mdouble lU = std::pow(pUL, p) + std::pow(pUR, p);
213 // const Mdouble lV = std::pow(pVL, p) + std::pow(pVR, p);
214 //
215 // // Weights for left and right in u and v
216 // const Mdouble wUL = 1.0 - std::pow(pUL, p) / lU;
217 // const Mdouble wUR = 1.0 - std::pow(pUR, p) / lU;
218 // const Mdouble wVL = 1.0 - std::pow(pVL, p) / lV;
219 // const Mdouble wVR = 1.0 - std::pow(pVR, p) / lV;
220 //
221 // const unsigned firstIndexU = std::floor(pU);
222 // const unsigned firstIndexV = std::floor(pV);
223 // localDebris_[firstIndexU ][firstIndexV ] += debris * wUL * wVL;
224 // localDebris_[firstIndexU ][firstIndexV + 1] += debris * wUL * wVR;
225 // localDebris_[firstIndexU + 1][firstIndexV ] += debris * wUR * wVL;
226 // localDebris_[firstIndexU + 1][firstIndexV + 1] += debris * wUR * wVR;
227 }
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:209
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:197
void rotateBack(Vec3D &position) const
Definition: Quaternion.cc:597
#define X
Definition: icosphere.cpp:20
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 round(const bfloat16 &a)
Definition: BFloat16.h:646
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77
const char Y
Definition: test/EulerAngles.cpp:32

References abs(), NurbsSurface::getControlPoints(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), localDebris_, NurbsWall::nurbsSurface_, Global_Physical_Variables::P, Quaternion::rotateBack(), Eigen::bfloat16_impl::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.

123 {
124  NurbsWall::write(os);
125  os << " Debris ";
126  os << "nu " << localDebris_.size() << ' ';
127  os << "nv " << localDebris_[0].size() << ' ';
128  for (const auto& d0 : localDebris_) for (const auto d : d0) os << d << ' ';
129 }
void write(std::ostream &os) const override
Writes this wall to an output stream, for example a restart file.
Definition: NurbsWall.cc:81

References localDebris_, and NurbsWall::write().

◆ writeWallDetailsVTK()

void WearableNurbsWall::writeWallDetailsVTK ( VTKData data) const
overridevirtual

Reimplemented from NurbsWall.

346 {
347  // Visualised as a flat surface, which can be coloured according to the debris at each point.
348  // The points are simply the control points with the z-position set to 0.
349 
350  const std::vector<std::vector<Vec3D>>& points = nurbsSurface_.getControlPoints();
351 
352  // Reserve memory for number of points and cells about to be added
353  const unsigned np = points.size() * points[0].size();
354  const unsigned nc = (points.size() - 1) * (points[0].size() - 1);
355  data.reservePoints(np, { "Debris" });
356  data.reserveCells(nc);
357 
358  // Number of points in v-direction
359  size_t nv = points[0].size();
360  // Point index offset, the point indices have to be offset by the number of points already present at the start (from previously added data)
361  size_t pio = data.getPoints().size();
362 
363  for (int i = 0; i < points.size(); i++)
364  {
365  for (int j = 0; j < points[i].size(); j++)
366  {
367  Vec3D p = points[i][j];
368  p.Z = 0;
370  p += getPosition();
371  data.addToPoints(p);
372  data.addToPointData("Debris", localDebris_[i][j]);
373 
374  if (i > 0 && j > 0)
375  {
376  // Basic 2D/1D mapping for indexing: nv * i + j (+ point index offset)
377  // 4 points to form a rectangle: point, point to the left, point down, point to the left and down
378  data.addToConnectivity({ nv*i+j+pio, nv*(i-1)+j+pio, nv*i+j-1+pio, nv*(i-1)+j-1+pio });
379  data.addToTypes(8);
380  }
381  }
382  }
383 }
int data[]
Definition: Map_placement_new.cpp:1
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
void rotate(Vec3D &position) const
Definition: Quaternion.cc:550

References data, NurbsSurface::getControlPoints(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), i, j, localDebris_, NurbsWall::nurbsSurface_, p, Quaternion::rotate(), and size.

Member Data Documentation

◆ localDebris_

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

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