35 logger(
DEBUG,
"IntersectionOfWalls() constructed.");
53 logger(
DEBUG,
"IntersectionOfWalls(IntersectionOfWalls&) constructed.");
60 for (
auto wall : walls)
69 logger(
DEBUG,
"~IntersectionOfWalls() has been called.");
77 wall.setSpecies(species);
86 logger(
DEBUG,
"IntersectionOfWalls::operator= called.");
91 return *(other.
copy());
115 w.setHandler(wallHandler);
145 w.
set(normal, point);
160 Vec3D SubtB = PointA - PointB;
161 Vec3D SubtC = PointA - PointC;
168 "Error Building IntersectionOfWalls::add3PointObject out of 3 coordinates. Coordinates are in line, Wall not constructed.");
196 logger(
WARN,
"Error Building Plate number % out of 3 coordinates. Coordinates are in line, Wall not "
197 "constructed", wallidentifier);
203 Vec3D SubtB = PointA - PointB;
204 Vec3D SubtC = PointA - PointC;
219 Vec3D mid = (PointA + PointB + PointC) / 3.0;
222 Vec3D midT = mid - WallNormalRHR * Thickness;
234 Vec3D mid = (PointA + PointB + PointC) / 3.0;
237 Vec3D midT = mid + WallNormalRHR * Thickness;
264 Vec3D SubtB = PointA - PointB;
265 Vec3D SubtC = PointA - PointC;
273 "Error Building IntersectionOfWalls::addTetra out of 3 coordinates. "
274 "Coordinates are in line, Wall not constructed.");
279 Vec3D mid = (PointA + PointB + PointC) / 3.0;
281 Vec3D midT = mid + WallNormal * Thickness;
297 const Mdouble& Thickness,
int wallidentifier)
303 logger(
WARN,
"Error Building Plate number % out of 3 coordinates. Coordinates are in line, Wall not "
304 "constructed.", wallidentifier);
308 Vec3D PointAT = PointA - WallNormal * Thickness;
309 Vec3D PointBT = PointB - WallNormal * Thickness;
310 Vec3D PointCT = PointC - WallNormal * Thickness;
355 AB_.resize(n * (n + 1) / 2);
356 A_.resize(n * (n + 1) / 2);
357 for (std::size_t m = 0; m < n; m++)
359 std::size_t
id = (n - 1) * n / 2 + m;
362 AB_[id] /= sqrt(
AB_[
id].getLengthSquared());
392 C_.resize((n - 1) * n * (n + 1) / 6);
393 for (std::size_t m = 0; m < n; m++)
395 for (std::size_t l = 0; l < m; l++)
397 std::size_t
id = (n - 2) * (n - 1) * n / 6 + (m - 1) * m / 2 + l;
439 logger(
VERBOSE,
"wallObject %, %", w.getNormal(), w.getPosition());
454 logger(
WARN,
"This function is deprecated, use IntersectionOfWalls::addObject(Vec3D, Vec3D) instead.");
470 for (
unsigned int i = 0;
i + 1 < points.size();
i++)
567 Vec3D& normal_return)
const
580 unsigned int id2 = 0;
581 unsigned int id3 = 0;
592 if (distanceCurrent >= wallInteractionRadius)
600 if (distanceCurrent > distance)
602 if (distance > -wallInteractionRadius)
604 if (distance2 > -wallInteractionRadius)
606 distance3 = distance2;
609 distance2 = distance;
612 distance = distanceCurrent;
615 else if (distanceCurrent < -wallInteractionRadius)
619 else if (distanceCurrent > distance2)
621 if (distance2 > -wallInteractionRadius)
623 distance3 = distance2;
626 distance2 = distanceCurrent;
629 else if (distanceCurrent > distance3)
631 distance3 = distanceCurrent;
639 if (distance2 > -wallInteractionRadius)
644 bool intersection_with_id2 = (
wallObjects_[id2].getDistance(D) > 0.0);
646 if (distance3 > -wallInteractionRadius && (
wallObjects_[id3].getDistance(D) > 0.0))
651 bool intersection_with_id3 = (
wallObjects_[id3].getDistance(E) > 0.0);
653 if (intersection_with_id2)
655 if (intersection_with_id3)
666 (
id < id2) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id2 - 1) * id2 / 2 + id) :
667 (
id < id3) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (
id - 1) *
id / 2 + id2) :
668 ((
id - 2) * (
id - 1) *
id / 6 + (id3 - 1) * id3 / 2 + id2);
669 normal_return = position -
C_[index];
671 if (distance <= wallInteractionRadius)
673 normal_return /= -distance;
678 if (distance == distance)
685 intersection_with_id2 =
true;
686 distance2 = distance3;
691 if (intersection_with_id2)
693 unsigned int index = (
id > id2) ? ((
id - 1) *
id / 2 + id2) : ((id2 - 1) * id2 / 2 + id);
694 Vec3D AC = position -
A_[index];
697 if (distance <= wallInteractionRadius)
699 normal_return /= -distance;
704 if (distance == distance)
754 for (
int i = 0;
i < n;
i++)
757 if (dummy !=
"normal")
760 is >> position >> dummy >> orientation;
765 is >> normal >> dummy >> position;
778 os <<
" numIntersectionOfWalls " <<
wallObjects_.size();
781 os <<
" position " << wallObject.getPosition() <<
" orientation " << wallObject.getOrientation();
790 return "IntersectionOfWalls";
799 std::vector<Vec3D> points;
800 wall->createVTK(points, min, max);
805 intersectVTK(points, -other->getNormal(), other->getPosition());
809 for (
auto& p : points)
814 wall->addToVTK(points, vtk);
Implementation of a 3D quaternion (by Vitaliy).
void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC)
void addTetraSTL(Vec3D PointA, Vec3D PointB, Vec3D PointC, Vec3D WallNormal, Mdouble Thickness, int wallidentifier)
constructs a tetrahedron for an STL file input
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
BaseSpecies is the class from which all other species are derived.
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
void rotateBack(Vec3D &position) const
Applies the inverse rotation to a position.
void intersectVTK(std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void normalise()
Makes this Vec3D unit length.
void read(std::istream &is) override
Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position.
const std::complex< Mdouble > i
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
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 rotate(Vec3D &position) const
Applies the rotation to a position.
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
Mdouble getInteractionDistance() const
returns the largest separation distance at which adhesive short-range forces can occur.
~IntersectionOfWalls() override
Destructor.
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.
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: .
Mdouble getRadius() const
Returns the particle's radius.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
void clear()
Removes all parts of the walls.
Container to store all BaseWall.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void addPlate(const Vec3D &PointA, const Vec3D &PointB, const Vec3D &PointC, const Vec3D &WallNormal, const Mdouble &Thickness, int wallidentifier)
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...
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
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 setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
unsigned int getNumberOfObjects()
Returns the number of objects.
void addTetra(const Vec3D &PointA, const Vec3D &PointB, const Vec3D &PointC, Mdouble &Thickness)
constructs a tetrahedron from 3 input coordinates
IntersectionOfWalls & operator=(const IntersectionOfWalls &other)
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void setPointsAndLines(unsigned int n)
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
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 setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.