67 logger(
ERROR,
"MeshTriangle::getInteractionWith not implemented for particles of type %", p->
getName());
117 bool interactionValid =
true;
119 if (
i->getTimeStamp()!=timeStamp)
122 logger(
WARN,
"Taking old interaction into account");
124 if (
i->getMultiContactIdentifier()>3)
126 id =
i->getMultiContactIdentifier() - 4;
132 if (interactionNeighbor && interactionNeighbor->getTimeStamp()==timeStamp)
134 if (interactionNeighbor->getMultiContactIdentifier() <= 3)
137 interactionValid =
false;
143 else if (
i->getMultiContactIdentifier()>0)
145 id =
i->getMultiContactIdentifier() - 1;
149 if (interactionNeighbor && interactionNeighbor->getTimeStamp()==timeStamp)
151 if (interactionNeighbor->getMultiContactIdentifier() == 0)
154 interactionValid =
false;
161 if (!interactionValid)
163 i->getP()->addForce(-
i->getForce());
166 i->getP()->addTorque(-
i->getTorque() +
Vec3D::cross(
i->getP()->getPosition() -
i->getContactPoint(),
i->getForce()));
169 i->setForce(
Vec3D(0,0,0));
176 Vec3D force = -
i->getForce();
178 for(
unsigned k=0; k<3; k++)
243 distance = std::abs(signedDistance);
246 if (distance >= distanceMax)
return false;
249 const std::array<Vec3D,3> edgeBranch {position -
vertex_[0], position - vertex_[1], position - vertex_[2]};
253 const size_t id = (edgeDistance[1] > edgeDistance[2]) ?
254 (edgeDistance[0] > edgeDistance[1] ? 0 : 1) : (edgeDistance[0] > edgeDistance[2] ? 0 : 2);
257 if (edgeDistance[
id] > distanceMax)
return false;
262 normal = (signedDistance >= 0) ? -faceNormal_ : faceNormal_;
271 const double positionAlongEdge =
Vec3D::dot(edgeBranch[
id],
edge_[
id]);
272 if (positionAlongEdge <= 0) {
274 distance = edgeBranch[id].getLength();
275 if (distance > distanceMax)
return false;
279 if (triangleId<this->
getId())
return false;
281 normal = edgeBranch[id] / -distance;
285 const size_t idRight = (
id + 1) % 3;
286 distance = edgeBranch[idRight].getLength();
287 if (distance > distanceMax)
return false;
291 if (triangleId<this->
getId())
return false;
294 normal = edgeBranch[idRight] / -distance;
298 normal =
edge_[id] * positionAlongEdge - edgeBranch[id];
300 if (distance > distanceMax)
return false;
338 m.
Z = 1.0f - m.
X - m.
Y ;
344 if (!angularVelocityDt.
isZero())
358 unsigned int i, j, s1, s2, Id;
366 std::vector<unsigned int> vN;
381 for (
int i = 0; i < 3; i++)
386 for (
int i = 0; i < 3; i++)
406 unsigned int i, j, s1, s2;
408 os <<
" vertexNeighbors " << s1;
412 os <<
" vertexNeighborsElements " << s2;
419 os <<
" vertexInLabFrame ";
420 for (
int i = 0; i < 3; i++)
424 os <<
" edgeParticleIds ";
425 for (
int i = 0; i < 3; i++)
442 const unsigned long s = vtk.
points.size();
447 std::vector<double> cell;
450 cell.push_back(s + 1);
451 cell.push_back(s + 2);
633 for (
int i = 0;
i < 3;
i++)
649 for (
int i = 0;
i < 3;
i++)
678 const Vec3D branch1 = point - vertex_[1];
679 const Vec3D branch2 = point - vertex_[2];
682 Mdouble s = sqrt(
Vec3D::cross(vertex_[1] - vertex_[0], vertex_[2] - vertex_[1]).getLengthSquared());
690 return ((1-eps) > s0 > eps && (1-eps) > s1 > eps && (1-eps) > s2 > eps) && ((1-eps) > s0+s1 > eps && (1-eps) > s1+s2 > eps && (1-eps) > s2+s0 > eps);
707 logger.assert_always(mass > 0.0,
708 "Error in MeshTriangle::setMass, the given mass to be set must be positive.");
726 for (
unsigned int j=0; j<3; j++){
742 for (
unsigned int j=0; j<3; j++){
unsigned int getId() const
Returns the unique identifier of any particular object.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
Mdouble X
the vector components
void setHandler(WallHandler *handler) override
Set the handler.
void write(std::ostream &os) const override
Writes an MeshTriangle to an output stream, for example a restart file.
virtual bool isSphericalParticle() const
std::array< Vec3D, 3 > vertexVelocity_
void setVertexVelocities(Vec3D A, Vec3D B, Vec3D C)
Sets the velocity of the vertex points.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
void normalise()
Makes this Vec3D unit length.
void setVertexIds(unsigned int i, unsigned int j, unsigned int k)
sets the ids of the vertex particles. Calls retrieveVertexParticles.
void move(const Vec3D &move) override
void handleParticleRemoval(unsigned int id) override
Handles the removal of particles to the particle Handler.
T * getObjectById(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
void checkInteractions(InteractionHandler *interactionHandler, unsigned int timeStamp) override
Checks, if the forces of all interctions should be applied.
bool isLocal(Vec3D &min, Vec3D &max) const override
Determines if the triangle is considered local.
void actionsOnRestart() override
Actions executed on restart.
const std::complex< Mdouble > i
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
bool isInsideTriangle(const Vec3D &point) const
Determines if a given point is within the triangle.
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
void applyForce(Vec3D force)
Apply the given force to the triangle.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
void rotate(Vec3D &position) const
Applies the rotation to a position.
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Returns the interaction between this wall and a given particle, nullptr if there is no interaction...
std::string getName() const override
Returns the name of the object.
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
void handleParticleAddition(unsigned int id, BaseParticle *p) override
Handles the addition of particles to the particle Handler.
std::array< double, 3 > edgeLength_
bool isZero() const
Checks if ALL elements are zero.
Mdouble & z()
RW reference to Z.
Stores information about interactions between two interactable objects; often particles but could be ...
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
std::array< Vec3D, 3 > vertexInLabFrame_
std::array< BaseParticle *, 3 > vertexParticle_
std::array< MeshTriangle *, 3 > neighbor
void actionsAfterParticleGhostUpdate() override
actionsPerformed after the position update of (ghost-) particles.
void setMultiContactIdentifier(unsigned int multiContactIdentifier_)
std::array< unsigned int, 3 > vertexIds_
std::array< Vec3D, 3 > edge_
Mdouble getWallInteractionRadius(const BaseWall *wall) const
returns the radius plus the interactionDistance
void updateVerticesFromParticles()
Retrieve new positions from updated vertex particles.
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
std::vector< std::vector< double > > triangleStrips
Container to store Interaction objects.
Mdouble & x()
RW reference to X.
void applyPressure(Mdouble presure)
Apply a force pointing in normal direction corresponding to the specified pressure.
Mdouble getArea() const
Returns the area of the triangle.
void setMass(Mdouble mass)
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Mdouble getRadius() const
Returns the particle's radius.
void setVertices(Vec3D A, Vec3D B, Vec3D C)
Sets member variables such that the wall represents a triangle with vertices A, B, C.
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
Mdouble & y()
RW reference to Y.
const Vec3D getVelocityAtContact(const Vec3D &contact) const override
Calculates the local velocity at a specified point.
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
std::vector< std::vector< unsigned int > > vertexNeighbors
unsigned getGroupId() const
void updateVertexAndNormal()
Update vertexMin_, vertexMax_ and faceNormal_ for an updated position.
Container to store all BaseWall.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
std::vector< Vec3D > points
void writeVTK(VTKContainer &vtk) const override
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...
Mdouble getInvMass() const override
virtual void rotate(const Vec3D &angularVelocityDt)
Rotates this BaseInteractable.
const Vec3D getBaricentricWeight(const Vec3D &contact) const
Calculates the barycentric weight of a specified point.
void rotate(const Vec3D &angularVelocity) override
Rotates this BaseInteractable.
std::array< Vec3D, 3 > vertex_
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
void checkActive()
Check if the triangle is considered active.
Vec3D getFaceNormal() const
Returns the face normal.
void setWallInteraction(bool flag)
void setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void retrieveVertexParticles()
Tries to get pointers to all vertex particles from the handler.
bool getDistanceNormalOverlapType(const BaseParticle &p, Mdouble &distance, Vec3D &normal, Mdouble &overlap, unsigned int &type) const
void read(std::istream &is) override
Reads an MeshTriangle from an input stream, for example a restart file.
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
BaseInteraction * getExistingInteraction(const BaseInteractable *P, const BaseInteractable *I) const
Returns the Interaction between the BaseInteractable's P and I if it exists, otherwise returns a null...
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
std::array< Vec3D, 3 > edgeNormal_
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.