SphericalIndenter.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef SPHERICALINDENTER_H
6 #define SPHERICALINDENTER_H
7 
8 #include "Mercury3D.h"
9 //#include <assert.h>
10 #include "Logger.h"
11 
14 {
15 public:
16 
18  SphericalIndenter(Mdouble indenterDiameter, Mdouble indentationVelocity, Mdouble indentationForce)
19  : indenterDiameter_(indenterDiameter), indentationVelocity_(indentationVelocity),
20  indentationForce_(indentationForce)
21  {
22  logger(INFO, "Creating indenter with"
23  " diameter %"
24  " force %"
26  logger.assert_always(indenterDiameter_ >= 0.0, "");
27  logger.assert_always(indentationVelocity_ >= 0.0, "");
28  logger.assert_always(indentationForce_ >= 0.0, "");
29  }
30 
32  void setupInitialConditions() override
33  {
34  logger(VERBOSE, "Setting up indenter\n");
35 
43  logger(INFO, "Indentation Velocity %", getIndenterVelocity());
44 
46 
48  }
49 
51  {
52  return indentationForce_;
53  }
54 
55  void setIndentationForce(Mdouble indentationForce)
56  {
57  indentationForce_=indentationForce;
58  }
59 
61  {
63  }
64 
66  {
68  0.5 * (getYMax() + getYMin()),
70  }
71 
73  {
74  return indenter_.getForce().Z;
75  }
76 
78  {
80  }
81 
83  {
84  return indenter_.getVelocity().Z;
85  }
86 
89  {
91  if (!p->isFixed())
93  }
94 
96  void actionsBeforeTimeStep() override
97  {
99  }
100 
102  void outputXBallsData(std::ostream& os) const override
103  {
104  // adds one line to the particle data
105  os << particleHandler.getNumberOfObjects() + 1 << " " << getTime() << " "
106  << getXMin() << " " << getYMin() << " " << getZMin() << " "
107  << getXMax() << " " << getYMax() << " " << getZMax() << " " << std::endl;
108  // This outputs the particle data
109  for (unsigned int i = 0; i < particleHandler.getNumberOfObjects(); i++)
110  outputXBallsDataParticle(i, 14, os);
111 
112  os << indenter_.getPosition() << " "
113  << indenter_.getVelocity() << " "
114  << indenter_.getRadius() << " 0 0 0 0 0 0 0\n";
115  }
116 
117  void actionsBeforeTimeLoop() override
118  {
119  logger(INFO, "time\t"
120  "displacement\t"
121  "relForce\t"
122  "direction\t"
123  "eneRatio");
124  }
125 
127  void printTime() const override
128  {
129  //writeEneTimeStep(std::cout);
130  logger(INFO, "%.11\t"
131  "%.11\t"
132  "%.11\t"
133  "%.9\t"
135  (getIndenterVelocity() < 0 ? "down" : (getIndenterVelocity() == 0 ? "stop" : "up")),
137  }
138 
140  void writeEneHeader(std::ostream& os) const override
141  {
142  os << "time\tdisplacement\tforce\tdirection\n";
143  }
144 
146  void writeEneTimeStep(std::ostream& os) const override
147  {
148  os << std::setw(12) << getTime()
149  << "\t" << std::setw(12)<< getIndenterHeight()
150  << "\t" << std::setw(12) << getForceOnIndenter()/ indentationForce_
151  << "\t" << (getIndenterVelocity()<0?"down":(getIndenterVelocity()==0?"stop":"up"))
152  << std::endl;
153 // os << "t " << getTime()
154 // << " \t " << (getIndenterVelocity()<0?"down":"up")
155 // << "\tz " << getIndenterHeight()
156 // << "\trelForce " << getForceOnIndenter() / indentationForce_ << std::endl;
157  }
158 
159  void actionsAfterTimeStep() override
160  {
162 
163  static Mdouble timeToRetract = 0;
165 
166  if (getIndenterVelocity() < 0)
167  { //moving down
169  {
171  logger(INFO, "Lowering indentation velocity %", getIndenterVelocity());
172  }
174  {
176  timeToRetract = 1.1 * getTime();
177  logger(INFO, "stopping indenter");
178  }
179  }
180  else if (getIndenterVelocity() == 0)
181  { //stopping
182  if (getTime()>timeToRetract) {
184  logger(INFO, "retracting indenter");
187  }
188  } else
189  { //retracting
191  {
193  logger(INFO, "measured force gradient = %", measuredForceGradient);
194  } else if (getForceOnIndenter() > 0)
195  {
196  //logger(INFO, "stopping indenter");
197  setTimeMax(getTime() * 1.2);
198  }
199  else if (measuredElasticDisplacement == 0)
200  {
202  logger(INFO, "measured elastic displacement = %\n"
203  "measured Elasticity = %", measuredElasticDisplacement, Flusher::NO_FLUSH,
206  logger(INFO, "Increasing indentation velocity %", getIndenterVelocity());
207  }
208  }
209  }
210 
213  {
214  Mdouble bedHeight = getZMin();
215  for (auto p : particleHandler)
216  if (!p->isFixed())
217  bedHeight = std::max(bedHeight, p->getPosition().Z + p->getRadius());
218  logger(INFO, "bed height % N=%", bedHeight, particleHandler.getNumberOfObjects());
219  //return 1;
220  return bedHeight;
221  }
222 
223 private:
228 
233 
234 };
235 
236 #endif /* SPHERICALINDENTER_H */
237 
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO
@ VERBOSE
float * p
Definition: Tutorial_Map_using.cpp:9
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:105
void sumForceTorqueOMP()
Definition: BaseInteractable.cc:140
virtual void resetForceTorque(int numberOfOMPthreads)
Definition: BaseInteractable.cc:119
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:307
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:328
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:218
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:193
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:197
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:104
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:97
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:42
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:50
Definition: BaseParticle.h:33
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:331
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...
Definition: BaseParticle.cc:150
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
Definition: BaseParticle.cc:640
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:548
virtual void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:798
int getNumberOfOMPThreads() const
Returns the number of omp threads.
Definition: DPMBase.cc:1277
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:603
virtual void computeInternalForce(BaseParticle *, BaseParticle *)
Computes the forces between two particles (internal in the sense that the sum over all these forces i...
Definition: DPMBase.cc:3143
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:610
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:616
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1241
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1535
virtual void outputXBallsDataParticle(unsigned int i, unsigned int format, std::ostream &os) const
This function writes out the particle locations into an output stream in a format the XBalls program ...
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:622
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:864
virtual void computeExternalForces(BaseParticle *)
Computes the external forces, such as gravity, acting on particles.
Definition: DPMBase.cc:3198
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1521
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:634
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:628
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1323
Definition: SphericalIndenter.h:14
Mdouble measuredForceGradient
Definition: SphericalIndenter.h:231
Mdouble measuredElasticDisplacement
Definition: SphericalIndenter.h:232
SphericalParticle indenter_
Definition: SphericalIndenter.h:224
Mdouble indentationForce_
Definition: SphericalIndenter.h:227
void printTime() const override
Definition: SphericalIndenter.h:127
Mdouble indenterDiameter_
Definition: SphericalIndenter.h:225
Mdouble getIndenterHeight() const
Definition: SphericalIndenter.h:60
void setupInitialConditions() override
Definition: SphericalIndenter.h:32
Mdouble indentationVelocity_
Definition: SphericalIndenter.h:226
void setIndentationForce(Mdouble indentationForce)
Definition: SphericalIndenter.h:55
SphericalIndenter(Mdouble indenterDiameter, Mdouble indentationVelocity, Mdouble indentationForce)
Definition: SphericalIndenter.h:18
void setIndenterVelocity(Mdouble indentationVelocity_)
Definition: SphericalIndenter.h:77
void outputXBallsData(std::ostream &os) const override
Definition: SphericalIndenter.h:102
Mdouble getIndenterVelocity() const
Definition: SphericalIndenter.h:82
void actionsBeforeTimeStep() override
Definition: SphericalIndenter.h:96
void actionsBeforeTimeLoop() override
A virtual function. Allows one to carry out any operations before the start of the time loop.
Definition: SphericalIndenter.h:117
void actionsAfterTimeStep() override
A virtual function which allows to define operations to be executed after time step.
Definition: SphericalIndenter.h:159
Mdouble getForceOnIndenter() const
Definition: SphericalIndenter.h:72
void writeEneHeader(std::ostream &os) const override
Definition: SphericalIndenter.h:140
Mdouble measuredIndentation
Definition: SphericalIndenter.h:230
Mdouble getBedHeight()
Definition: SphericalIndenter.h:212
void setIndenterHeight(Mdouble height)
Definition: SphericalIndenter.h:65
void computeExternalForces(BaseParticle *p) override
Definition: SphericalIndenter.h:88
void writeEneTimeStep(std::ostream &os) const override
Definition: SphericalIndenter.h:146
Mdouble measuredIndentationForce
Definition: SphericalIndenter.h:229
Mdouble getIndentationForce() const
Definition: SphericalIndenter.h:50
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:16
Definition: Kernel/Math/Vector.h:30
Mdouble Z
Definition: Kernel/Math/Vector.h:45
#define max(a, b)
Definition: datatypes.h:23
double height(const double &x)
Height of domain.
Definition: simple_spine_channel.cc:429