32 logger(
DEBUG,
"IntersectionOfWalls() constructed.");
45 logger(
DEBUG,
"IntersectionOfWalls(IntersectionOfWalls&) constructed.");
50 logger(
DEBUG,
"~IntersectionOfWalls() has been called.");
58 logger(
DEBUG,
"IntersectionOfWalls::operator= called.");
63 return *(other.
copy());
102 AB_.resize(n * (n + 1) / 2);
103 A_.resize(n * (n + 1) / 2);
104 for (std::size_t m = 0; m < n; m++)
106 std::size_t
id = (n - 1) * n / 2 + m;
109 AB_[id] /= sqrt(
AB_[
id].getLengthSquared());
127 C_.resize((n - 1) * n * (n + 1) / 6);
128 for (std::size_t m = 0; m < n; m++)
130 for (std::size_t l = 0; l < m; l++)
132 std::size_t
id = (n - 2) * (n - 1) * n / 6 + (m - 1) * m / 2 + l;
150 logger(
VERBOSE,
"wallObject %, %", w.getNormal(), w.getPosition());
165 logger(
WARN,
"This function is deprecated, use IntersectionOfWalls::addObject(Vec3D, Vec3D) instead.");
181 for (
unsigned int i = 0; i+1 < points.size(); i++)
283 distanceCurrent =
wallObjects_[i].getDistance(position);
287 if (distanceCurrent >= wallInteractionRadius)
293 if (distanceCurrent > distance)
295 if (distance > -wallInteractionRadius)
297 if (distance2 > -wallInteractionRadius)
299 distance3 = distance;
304 distance2 = distance;
308 distance = distanceCurrent;
311 else if (distanceCurrent > -wallInteractionRadius)
313 if (distance2 > -wallInteractionRadius)
315 distance3 = distanceCurrent;
320 distance2 = distanceCurrent;
329 if (distance2 > -wallInteractionRadius)
334 bool intersection_with_id2 = (
wallObjects_[id2].getDistance(D) > 0.0);
336 if (distance3 > -wallInteractionRadius && (
wallObjects_[id3].getDistance(D) > 0.0))
338 if (intersection_with_id2)
343 (
id < id2) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id2 - 1) * id2 / 2 + id) :
344 (
id < id3) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (
id - 1) *
id / 2 + id2) :
345 ((
id - 2) * (
id - 1) *
id / 6 + (id3 - 1) * id3 / 2 + id2);
346 normal_return = position -
C_[index];
348 if (distance >= wallInteractionRadius)
350 normal_return /= -distance;
355 intersection_with_id2 =
true;
356 distance2 = distance3;
361 if (intersection_with_id2)
363 unsigned int index = (
id > id2) ? ((
id - 1) *
id / 2 + id2) : ((id2 - 1) * id2 / 2 + id);
364 Vec3D AC = position -
A_[index];
367 if (distance >= wallInteractionRadius)
369 normal_return /= -distance;
418 for (
int i = 0; i < n; i++)
420 is >> dummy >> normal >> dummy >> position;
432 os <<
" numIntersectionOfWalls " <<
wallObjects_.size();
435 os <<
" normal " << it->getNormal() <<
" position " << it->getPosition();
444 return "IntersectionOfWalls";
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
void normalize()
Makes this Vec3D unit length.
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
BaseInteraction * getInteractionWith(BaseParticle *p, Mdouble timeStamp, InteractionHandler *interactionHandler)
Get the interaction between this IntersectionOfWalls and given BaseParticle at a given time...
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
void move(const Vec3D &move)
Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position.
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...
std::string getName() const override
Returns the name of the object, here the string "IntersectionOfWalls".
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given an outward normal vector s.t. normal*x=normal*point.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Stores information about interactions between two interactable objects; often particles but could be ...
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
void createOpenPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points, except the first and last point...
void read(std::istream &is)
Reads an IntersectionOfWalls from an input stream, for example a restart file.
IntersectionOfWalls()
Default constructor.
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
Container to store Interaction objects.
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Mdouble getRadius() const
Returns the particle's radius_.
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
MERCURY_DEPRECATED void clear()
Removes all parts of the walls.
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
void createPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points and extends infinitely in the PrismAxis d...
This is a class defining walls.
void write(std::ostream &os) const
Writes an IntersectionOfWalls to an output stream, for example a restart file.
virtual ~IntersectionOfWalls()
Destructor.
Implementation of a 3D vector (by Vitaliy).
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
IntersectionOfWalls & operator=(const IntersectionOfWalls &other)
void write(std::ostream &os) const
Function that writes a BaseWall to an output stream, usually a restart file.
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
void read(std::istream &is)
Function that reads a BaseWall from an input stream, usually a restart file.