62 logger(
DEBUG,
"Screw(const Screw&) copy constructor finished.");
84 logger(
DEBUG,
"Screw(Vec3D, Mdouble, Mdouble, Mdouble, Mdouble, Mdouble) constructor finished.");
89 logger(
DEBUG,
"~Screw() finished, destroyed the Screw.");
97 return new Screw(*
this);
172 }
while (fabs(dd / ddd) > 1e-14);
182 unsigned int steps = 0;
190 }
while (fabs(dd / ddd) > 1e-14);
220 distance = sqrt(distanceSquared) -
thickness_;
278 <<
" Radius " <<
maxR_
279 <<
" Revolutions " <<
n_
295 std::vector<Vec3D> vertices;
296 std::vector<std::array<unsigned,3>> faces;
299 std::stringstream file;
300 file <<
"# vtk DataFile Version 2.0\n"
303 "DATASET UNSTRUCTURED_GRID\n"
304 "POINTS " << vertices.size() <<
" double\n";
305 for (
const auto& vertex : vertices)
306 file << vertex <<
'\n';
307 file <<
"\nCELLS " << faces.size() <<
' ' << 4*faces.size() <<
"\n";
308 for (
const auto& face : faces)
309 file <<
"3 " << face[0] <<
' ' << face[1] <<
' ' << face[2] <<
'\n';
310 file <<
"\nCELL_TYPES " << faces.size() <<
"\n";
311 for (
const auto& face : faces)
316 void Screw::getTriangulation (std::vector<Vec3D>& vertices, std::vector<std::array<unsigned,3>>& faces,
unsigned nr,
unsigned nz)
const
319 vertices.reserve(nr*nz);
321 for (
Mdouble iz=0; iz<nz; iz++) {
322 for (
Mdouble ir=0; ir<nr; ir++) {
328 vertices.push_back(vertex);
332 faces.reserve(2*(nr-1)*(nz-1));
333 std::array<unsigned,3> face;
334 for (
unsigned iz=0; iz<nz-1; iz++) {
335 for (
unsigned ir=0; ir<nr-1; ir++) {
337 faces.push_back({iz*nr+ir,iz*nr+(ir+1),(iz+1)*nr+ir});
339 faces.push_back({iz*nr+(ir+1),(iz+1)*nr+(ir+1),(iz+1)*nr+ir});
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Mdouble X
the vector components
void read(std::istream &is) override
Reads a Screw from an input stream, for example a restart file.
Mdouble maxR_
The outer radius of the Screw.
This function defines an Archimedes' screw in the z-direction from a (constant) starting point...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void getTriangulation(std::vector< Vec3D > &vertex, std::vector< std::array< unsigned, 3 >> &face, unsigned nr=5, unsigned nz=15) const
void normalize()
Makes this Vec3D unit length.
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...
~Screw()
Default destructor.
void setZero()
Sets all elements to zero.
int sign(T val)
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0...
void move_time(Mdouble dt)
Rotate the Screw for a period dt, so that the offset_ changes with omega_*dt.
T square(T val)
squares a number
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble getWallInteractionRadius() const
Returns the interaction radius for interaction with walls. See also BaseParticle::getInteractionRadiu...
std::string getName() const final
Returns the name of the object, here the string "Screw".
void writeVTK(std::string filename) const
Vec3D start_
The centre of the lower end of the screw.
Mdouble offset_
The angle that describes how much the Screw has turned, going from 0 to 1 for a rotation.
Mdouble l_
The length of the Screw.
Screw * copy() const final
Copy this screw and return a pointer to the copy.
void write(std::ostream &os) const override
Writes this Screw to an output stream, for example a restart file.
Mdouble n_
The number of revelations.
Screw()
Default constructor: make a screw with default parameters.
Mdouble thickness_
The thickness of the Screw.
Mdouble omega_
Rotation speed in rev/s.
Implementation of a 3D vector (by Vitaliy).
void write(std::ostream &os) const
Function that writes a BaseWall to an output stream, usually a restart file.
void oldRead(std::istream &is)
Reads a Screw in the old style from an input stream, for example a restart file old style...
void read(std::istream &is)
Function that reads a BaseWall from an input stream, usually a restart file.