59 #ifdef DEBUG_CONSTRUCTOR
60 std::cout<<
"BaseInteraction::BaseInteraction() finished"<<std::endl;
130 logger(
DEBUG,
"Destroying a fictitious interaction used in MPI transmissions");
135 logger.assert_debug(
P_ !=
nullptr,
"Trying to destroy an interaction with P_ = nullptr");
136 logger.assert_debug(
I_ !=
nullptr,
"Trying to destroy an interaction with I_ = nullptr");
162 if (dynamic_cast<BaseParticle*>(
I_) !=
nullptr)
173 os <<
" force " <<
force_;
202 return "BaseInteraction";
303 if (C->
getP() == original)
454 if (scalarTangentialForce != 0.0)
455 tangential = tangentialForce / scalarTangentialForce;
457 tangential =
Vec3D(0.0, 0.0, 0.0);
459 if (PParticle !=
nullptr && !PParticle->isFixed())
465 <<
" " << tangentialOverlap
466 <<
" " << scalarNormalForce
467 <<
" " << scalarTangentialForce
469 <<
" " << (IParticle ==
nullptr ? -tangential : tangential) << std::endl;
472 if (IParticle !=
nullptr && !IParticle->isFixed() && IParticle->getPeriodicFromParticle() ==
nullptr)
478 <<
" " << tangentialOverlap
479 <<
" " << scalarNormalForce
480 <<
" " << scalarTangentialForce
482 <<
" " << -tangential << std::endl;
517 return Vec3D(0.0, 0.0, 0.0);
692 if (dynamic_cast<BaseParticle*>(
I_) !=
nullptr)
694 os <<
" particleIds " <<
P_->
getId() <<
" " <<
I_->
getId() <<
" timeStamp ";
698 os <<
" particleWallIds " <<
P_->
getId() <<
" " <<
I_->
getId() <<
" timeStamp ";
748 logger.assert_debug(invEffectiveRadius>0,
749 "getEffectiveRadius(): interaction % at % has infinite effective radius",
getId(),
getContactPoint());
750 return 1.0 / invEffectiveRadius;
765 logger.assert_debug(invEffectiveMass>0,
766 "getEffectiveMass(): interaction % at % has infinite effective mass",
getId(),
getContactPoint());
767 return 1.0 / invEffectiveMass;
788 if (scalarTangentialForce != 0.0)
789 tangential = tangentialForce / scalarTangentialForce;
791 tangential =
Vec3D(0.0, 0.0, 0.0);
796 if (IParticle !=
nullptr)
801 if (!PParticle->isFixed())
810 scalarTangentialForce,
812 (IParticle ==
nullptr ? -tangential : tangential));
814 if (IParticle !=
nullptr && !IParticle->isFixed() && IParticle->getPeriodicFromParticle() ==
nullptr)
823 scalarTangentialForce,
847 return std::vector<Mdouble>();
865 logger(
ERROR,
"BaseInteraction::createMPIInteractionDataArray should never be called");
872 logger(
WARN,
"Why on earth is this function called?");
877 unsigned int& identificationI,
bool& isWallInteraction,
unsigned& timeStamp)
879 logger(
ERROR,
"Something went wrong, this function should not be called");
915 bool isWallInteraction,
const bool resetPointers)
933 Mdouble overlap, tangentialOverlap, scalarNormalForce, scalarTangentialForce;
934 Vec3D centre, normal, tangential;
935 fstat >> centre >> overlap >> tangentialOverlap >> scalarNormalForce >> scalarTangentialForce >> normal
937 const Vec3D force = scalarNormalForce * normal + scalarTangentialForce * tangential;
949 Mdouble overlap, tangentialOverlap, scalarNormalForce, scalarTangentialForce;
950 Vec3D centre, normal, tangential;
951 fstat >> centre >> overlap >> tangentialOverlap >> scalarNormalForce >> scalarTangentialForce >> normal
953 const Vec3D force = scalarNormalForce * normal + scalarTangentialForce * tangential;
unsigned int getId() const
Returns the unique identifier of any particular object.
unsigned int getIndex() const
Returns the index of the object in the handler.
Mdouble getEffectiveRadius() const
Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap) ...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
void copySwitchPointer(const BaseInteractable *original, BaseInteractable *ghost) const
This copies the interactions of the original particle and replaces the original with the ghost copy...
BaseSpecies is the class from which all other species are derived.
virtual void getInteractionDetails(void *interactionDataArray, unsigned int index, unsigned int &identificationP, unsigned int &identificationI, bool &isWallInteraction, unsigned &timeStamp)
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
File & getInteractionFile()
Return a reference to the file InteractionsFile.
virtual void * createMPIInteractionDataArray(unsigned int numberOfInteractions) const
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
InteractionHandler * getHandler() const
Gets a point to the interaction handlers to which this interaction belongs.
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
const BaseSpecies * species_
virtual BaseInteraction * copy() const =0
Makes a copy of the interaction and returns a pointer to the copy.
bool removeInteraction(BaseInteraction *I)
Removes an interaction from this BaseInteractable.
virtual void actionsAfterTimeStep()
void addInteraction(BaseInteraction *I)
Adds an interaction to this BaseInteractable.
void setI(BaseInteractable *I)
Sets the second object involved in the interaction (often particle or wall).
It is an abstract base class due to the purely virtual functions declared below. Even if the function...
const Vec3D & getRelativeVelocity() const
Returns a constant reference to a vector of relative velocity.
const std::complex< Mdouble > i
virtual void reverseHistory()
When periodic particles some interaction need certain history properties reversing. This is the function for that.
void setRelativeVelocity(Vec3D relativeVelocity)
set the relative velocity of the current of the interactions.
void setZero()
Sets all elements to zero.
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
void addTorque(Vec3D torque)
void writeToFStat(std::ostream &os, Mdouble time) const
Writes forces data to the FStat file.
void removeFromHandler()
Removes this interaction from its interaction hander.
void setForce(Vec3D force)
set total force (this is used by the normal force, tangential forces are added use addForce) ...
virtual std::vector< Mdouble > getFieldVTK(unsigned i) const
virtual void createMPIType()
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
BaseInteractable * getI()
Returns a pointer to the second object involved in the interaction (often a wall or a particle)...
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
void setNormalRelativeVelocity(Mdouble normalRelativeVelocit)
set the normal component of the relative velocity.
unsigned int identificationP_
void setFStatData(std::fstream &fstat, BaseParticle *P, BaseWall *I)
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
void setTimeStamp(unsigned timeStamp)
Updates the time step of the interacting. Note, time steps used to find completed interactions...
void gatherContactStatistics()
Stores information about interactions between two interactable objects; often particles but could be ...
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
virtual void gatherContactStatistics(unsigned int index1, int index2, Vec3D Contact, Mdouble delta, Mdouble ctheta, Mdouble fdotn, Mdouble fdott, Vec3D P1_P2_normal_, Vec3D P1_P2_tangential)
//Not unsigned index because of possible wall collisions.
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Mdouble getNormalRelativeVelocity() const
Returns a double which is the norm (length) of the relative velocity vector.
void setMultiContactIdentifier(unsigned int multiContactIdentifier_)
virtual void rotateHistory(Matrix3D &rotationMatrix)
When periodic particles are used, some interactions need certain history properties rotated (e...
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
const BaseSpecies * getBaseSpecies() const
Return a constant point to BaseSpecies of the interaction.
void setIdentificationP(unsigned int identification)
virtual void removeObject(unsigned const int index)
Removes an Object from the BaseHandler.
~BaseInteraction() override
The destructor.
all data will be written into/ read from a single file called name_
Container to store Interaction objects.
void setHandler(InteractionHandler *handler)
Sets the pointer to the interaction hander which is storing this interaction.
virtual std::string getTypeVTK(unsigned i) const
void setP(BaseInteractable *P)
Sets the first object involved in the interaction (normally a particle).
Mdouble lagrangeMultiplier_
void setTorque(Vec3D torque)
set the total force (this is used by the normal force, tangential torques are added use addTorque) ...
void setSpecies(const BaseSpecies *species)
Set the Species of the interaction; note this can either be a Species or MixedSpecies.
virtual const Vec3D getTangentialForce() const
void addObject(BaseInteraction *I) override
Adds an Interaction to the InteractionHandler.
void writeInteraction(std::ostream &os, bool created) const
Writes information about a interaction to the interaction file.
Mdouble getRadius() const
Returns the particle's radius.
bool readOptionalVariable(std::istream &is, const std::string &name, T &variable)
Reads optional variables in the restart file.
unsigned int getIdentificationP()
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
virtual std::string getNameVTK(unsigned i) const
void addForce(Vec3D force)
add an force increment to the total force.
void setAbsoluteNormalForce(Mdouble absoluteNormalForce)
the absolute values of the norm (length) of the normal force
Mdouble normalRelativeVelocity_
void importP(BaseInteractable *P)
Sets the first object involved in the interaction (normally a particle).
virtual bool isBonded() const
unsigned multiContactIdentifier_
Mdouble getDistance() const
Returns an Mdouble which is the norm (length) of distance vector.
virtual void integrate(Mdouble timeStep)
integrates variables of the interaction which need to be integrate e.g. the tangential overlap...
void read(std::istream &is) override
Interaction read function, which accepts an std::istream as input.
Mdouble getContactRadius() const
Returns a Mdouble with the current contact between the two interacting objects.
void setWallInteraction(bool flag)
Defines the basic properties that a interactable object can have.
virtual void setMPIInteraction(void *interactionDataArray, unsigned int index, bool resetPointers)
virtual Mdouble getElasticEnergy() const
Returns a Mdouble which is the current about of Elastic energy in the interaction.
Mdouble absoluteNormalForce_
virtual void computeForce()
Virtual function that contains the force law between the two objects interacting. ...
virtual Mdouble getCurvature(const Vec3D &labFixedCoordinates) const
Implementation of a 3D matrix.
void setBasicMPIInteractionValues(int P, int I, unsigned timeStamp, Vec3D force, Vec3D torque, bool isWallInteraction, bool resetPointers)
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
void write(std::ostream &os) const override
Interaction print function, which accepts an std::ostream as input.
virtual Mdouble getTangentialOverlap() const
get the length of the current tangential overlap
virtual Mdouble getInvMass() const
Mdouble getTime() const
Returns the current simulation time.
void setIdentificationI(int identification)
unsigned int getMultiContactIdentifier() const
std::string getName() const override
Virtual function which allows interactions to be named.
virtual void getMPIInteraction(void *historyDataArray, unsigned int index) const
copies the history interactions into the data array
void importI(BaseInteractable *I)
Sets the second object involved in the interaction (often particle or wall).
virtual void deleteMPIInteractionDataArray(void *dataArray)
void setNaN()
Sets all elements to NaN.
Mdouble getEffectiveMass() const
Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap) ...
InteractionHandler * handler_
virtual unsigned getNumberOfFieldsVTK() const
Mdouble getAbsoluteNormalForce() const
Returns the absolute value of the norm (length) of the Normal force vector.