32 logger(
DEBUG,
"IntersectionOfWalls() constructed.");
50 logger(
DEBUG,
"IntersectionOfWalls(IntersectionOfWalls&) constructed.");
56 for (
auto wall : walls)
65 logger(
DEBUG,
"~IntersectionOfWalls() has been called.");
73 wall.setSpecies(species);
82 logger(
DEBUG,
"IntersectionOfWalls::operator= called.");
87 return *(other.
copy());
131 w.
set(normal, point);
137 AB_.resize(n * (n + 1) / 2);
138 A_.resize(n * (n + 1) / 2);
139 for (std::size_t m = 0; m < n; m++)
141 std::size_t
id = (n - 1) * n / 2 + m;
144 AB_[id] /= sqrt(
AB_[
id].getLengthSquared());
162 C_.resize((n - 1) * n * (n + 1) / 6);
163 for (std::size_t m = 0; m < n; m++)
165 for (std::size_t l = 0; l < m; l++)
167 std::size_t
id = (n - 2) * (n - 1) * n / 6 + (m - 1) * m / 2 + l;
200 logger(
WARN,
"This function is deprecated, use IntersectionOfWalls::addObject(Vec3D, Vec3D) instead.");
216 for (
unsigned int i = 0; i+1 < points.size(); i++)
324 distanceCurrent =
wallObjects_[i].getDistance(position);
328 if (distanceCurrent >= wallInteractionRadius)
334 if (distanceCurrent > distance)
336 if (distance > -wallInteractionRadius)
338 if (distance2 > -wallInteractionRadius)
340 distance3 = distance;
345 distance2 = distance;
349 distance = distanceCurrent;
352 else if (distanceCurrent > -wallInteractionRadius)
354 if (distance2 > -wallInteractionRadius)
356 distance3 = distanceCurrent;
361 distance2 = distanceCurrent;
370 if (distance2 > -wallInteractionRadius)
375 bool intersection_with_id2 = (
wallObjects_[id2].getDistance(D) > 0.0);
377 if (distance3 > -wallInteractionRadius && (
wallObjects_[id3].getDistance(D) > 0.0))
379 if (intersection_with_id2)
384 (
id < id2) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id2 - 1) * id2 / 2 + id) :
385 (
id < id3) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (
id - 1) *
id / 2 + id2) :
386 ((
id - 2) * (
id - 1) *
id / 6 + (id3 - 1) * id3 / 2 + id2);
387 normal_return = position -
C_[index];
389 if (distance >= wallInteractionRadius)
391 normal_return /= -distance;
396 intersection_with_id2 =
true;
397 distance2 = distance3;
402 if (intersection_with_id2)
404 unsigned int index = (
id > id2) ? ((
id - 1) *
id / 2 + id2) : ((id2 - 1) * id2 / 2 + id);
405 Vec3D AC = position -
A_[index];
408 if (distance >= wallInteractionRadius)
410 normal_return /= -distance;
459 for (
int i = 0; i < n; i++)
461 is >> dummy >> normal >> dummy >> position;
473 os <<
" numIntersectionOfWalls " <<
wallObjects_.size();
476 os <<
" normal " << it->getNormal() <<
" position " << it->getPosition();
485 return "IntersectionOfWalls";
492 std::vector<Vec3D> points;
493 wall->createVTK (points);
498 intersectVTK(points, -other->getNormal(), other->getPosition());
501 wall->addToVTK (points, vtk);
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
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.
void writeVTK(VTKContainer &vtk) const override
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void normalize()
Makes this Vec3D unit length.
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void read(std::istream &is) override
Reads an IntersectionOfWalls from an input stream, for example a restart file.
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Vec3D getNormal() const
Access function for normal.
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".
void intersectVTK(std::vector< Vec3D > &points, const Vec3D normal, const Vec3D position) const
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
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.
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 setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
IntersectionOfWalls()
Default constructor.
MERCURY_DEPRECATED void clear() override
Removes all parts of the walls.
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
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: .
void move(const Vec3D &move) override
Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position.
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Container to store all BaseWall.
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
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.
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 setHandler(WallHandler *wallHandler) override
A function which sets the WallHandler for this BaseWall.
void write(std::ostream &os) const override
Writes an IntersectionOfWalls to an output stream, for example a restart file.
void read(std::istream &is)
Function that reads a BaseWall from an input stream, usually a restart file.
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.