76 std::getline(
pFile_, line);
77 if (!line.compare(
""))
86 std::getline(
pFile_, line);
89 std::getline(
pFile_, line);
92 logger(
INFO,
"Reading % particles at time %",N,time);
95 for (
unsigned i = 0; i < N; ++i) {
98 Vec3D position, velocity;
99 pFile_ >>
id >> species >> volume >> mass >> position >> velocity;
100 std::getline(
pFile_, line);
108 species.setAdhesionForceMax(1e20);
109 species.setAdhesionStiffness(1);
123 std::getline(
cFile_, line);
124 if (!line.compare(
""))
132 std::getline(
cFile_, line);
135 std::getline(
cFile_, line);
139 for (
unsigned i=0; i<N; ++i) {
141 Vec3D force, contact;
145 logger.assert(p1!=
nullptr,
"Particle % does not exist",id1);
146 logger.assert(p2!=
nullptr,
"Particle % does not exist",id1);
149 logger.assert(!c.empty() && c[0],
"Particle-particle interaction % % does not exist",p1,p2);
151 c[0]->setNormal(P1ToP2/c[0]->getDistance());
152 c[0]->setOverlap(c[0]->getDistance()-p1->getRadius()-p2->
getRadius());
155 contact = p1->getPosition()-P1ToP2*((p1->getRadius()-0.5*c[0]->getOverlap())/c[0]->getDistance());
157 cFile_ >> contact >> force;
159 std::getline(
cFile_, line);
160 c[0]->setContactPoint(contact);
161 c[0]->setForce(force);
162 if (i%(N/10)==0) {std::cout <<
"\r " << std::round((
double)i/N*100) <<
'%'; std::cout.flush();}
167 std::getline(
wFile_, line);
168 if (!line.compare(
""))
174 logger(
ERROR,
"Timesteps in p3w and p3p do not agree");
176 std::getline(
wFile_, line);
179 std::getline(
wFile_, line);
187 logger(
INFO,
"Reading % wall contacts",N,time);
188 for (
unsigned i=0; i<N; ++i) {
190 Vec3D force, contact, particleToContact;
193 logger.assert(p!=
nullptr,
"Particle % does not exist",
id);
195 logger.assert(!c.empty() && c[0],
"Particle-wall interaction % % does not exist",p,w);
197 wFile_ >> force >> particleToContact;
198 contact = p->getPosition()-particleToContact;
200 wFile_ >> contact >> force;
201 particleToContact = p->getPosition()-contact;
203 std::getline(
wFile_, line);
204 c[0]->setContactPoint(contact);
205 c[0]->setDistance(particleToContact.
getLength());
206 c[0]->setNormal(particleToContact/c[0]->getDistance());
207 c[0]->setOverlap(c[0]->getDistance()-p->getRadius());
208 c[0]->setForce(force);
245 int main(
int argc,
char** argv)
252 logger(
FATAL,
"This program converts Particle Analytics (.p3* or p4*) to MercuryDPM files.\n"
254 "Usage: Call the executable with the base name as argument.\n"
255 "E.g. to convert name.p* call\n"
256 " ./ParticleAnalytics2Mercury name\n", argv[0]);
259 while (fileReader.
read());
void setTime(Mdouble time)
Access function for the time.
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
void setNextSavedTimeStep(unsigned int nextSavedTimeStep)
Sets the next time step for all the files (ene, data, fstat, restart, stat) at which the data is to b...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
T * getObjectById(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Vec3D getMin() const
Return the "bottom left" corner of the domain, a vector with xMin_, yMin_ and zMin_.
Version
The version number of the particle analytics files.
std::ifstream pFile_
Pointers for the input files.
void setSpecies(const ParticleSpecies *species)
virtual void writeOutputFiles()
Writes the simulation data onto all the files i.e. .data, .ene, .fstat ...
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
void clear()
Empties the whole ParticleHandler by removing all BaseParticle.
int main(int argc, char **argv)
~FileReader()
Destructor, simple closes the file.
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
This adds on the hierarchical grid code for 3D problems.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
unsigned int getNtimeSteps() const
Returns the current counter of time steps.
void setDensity(Mdouble density)
Allows density_ to be changed.
This gives functionality to read information from binary formats like STL etc. This class is complete...
LL< Log::FATAL > FATAL
Fatal log level.
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Mdouble getRadius() const
Returns the particle's radius_.
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Vec3D getMax() const
Return the "upper right" corner of the domain, a vector with xMin_, yMin_ and zMin_.
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
FileReader(std::string name)
Default constuction, requires to users to prove the name of the file that will be opened...
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void setMin(Vec3D min)
Sets the values xMin, yMin, zMin of the problem domain, which is [xMin,xMax]x[yMin,yMax]x[zMin,zMax].
This is a class defining walls.
Mdouble getDensity() const
Allows density_ to be accessed.
Contains material and contact force properties.
Implementation of a 3D vector (by Vitaliy).
Mdouble getTime() const
Access function for the time.
enum FileReader::Version version_
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.
void setMax(Vec3D max)
Sets the values xMax, yMax, zMax of the problem domain, which is [xMin,xMax]x[yMin,yMax]x[zMin,zMax].
std::vector< BaseInteraction * > getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler *interactionHandler)
Checks if particle is in interaction with given particle P, and if so, returns pointer to the associa...