SphericalIndenter.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef SPHERICALINDENTER_H
27 #define SPHERICALINDENTER_H
28 
29 #include "Mercury3D.h"
30 //#include <assert.h>
31 #include "Logger.h"
32 
35 {
36 public:
37 
39  SphericalIndenter(Mdouble indenterDiameter, Mdouble indentationVelocity, Mdouble indentationForce)
40  : indenterDiameter_(indenterDiameter), indentationVelocity_(indentationVelocity),
41  indentationForce_(indentationForce)
42  {
43  logger(INFO, "Creating indenter with"
44  " diameter %"
45  " force %"
47  logger.assert_always(indenterDiameter_ >= 0.0, "");
48  logger.assert_always(indentationVelocity_ >= 0.0, "");
49  logger.assert_always(indentationForce_ >= 0.0, "");
50  }
51 
53  void setupInitialConditions() override
54  {
55  logger(VERBOSE, "Setting up indenter\n");
56 
64  logger(INFO, "Indentation Velocity %", getIndenterVelocity());
65 
67 
69  }
70 
72  {
73  return indentationForce_;
74  }
75 
76  void setIndentationForce(Mdouble indentationForce)
77  {
78  indentationForce_=indentationForce;
79  }
80 
82  {
84  }
85 
87  {
89  0.5 * (getYMax() + getYMin()),
90  height+indenter_.getRadius()));
91  }
92 
94  {
95  return indenter_.getForce().Z;
96  }
97 
99  {
101  }
102 
104  {
105  return indenter_.getVelocity().Z;
106  }
107 
110  {
112  if (!p->isFixed())
114  }
115 
117  void actionsBeforeTimeStep() override
118  {
120  }
121 
123  void outputXBallsData(std::ostream& os) const override
124  {
125  // adds one line to the particle data
126  os << particleHandler.getNumberOfObjects() + 1 << " " << getTime() << " "
127  << getXMin() << " " << getYMin() << " " << getZMin() << " "
128  << getXMax() << " " << getYMax() << " " << getZMax() << " " << std::endl;
129  // This outputs the particle data
130  for (unsigned int i = 0; i < particleHandler.getNumberOfObjects(); i++)
131  outputXBallsDataParticle(i, 14, os);
132 
133  os << indenter_.getPosition() << " "
134  << indenter_.getVelocity() << " "
135  << indenter_.getRadius() << " 0 0 0 0 0 0 0\n";
136  }
137 
138  void actionsBeforeTimeLoop() override
139  {
140  logger(INFO, "time\t"
141  "displacement\t"
142  "relForce\t"
143  "direction\t"
144  "eneRatio");
145  }
146 
148  void printTime() const override
149  {
150  //writeEneTimeStep(std::cout);
151  logger(INFO, "%.11\t"
152  "%.11\t"
153  "%.11\t"
154  "%.9\t"
156  (getIndenterVelocity() < 0 ? "down" : (getIndenterVelocity() == 0 ? "stop" : "up")),
158  }
159 
161  void writeEneHeader(std::ostream& os) const override
162  {
163  os << "time\tdisplacement\tforce\tdirection\n";
164  }
165 
167  void writeEneTimeStep(std::ostream& os) const override
168  {
169  os << std::setw(12) << getTime()
170  << "\t" << std::setw(12)<< getIndenterHeight()
171  << "\t" << std::setw(12) << getForceOnIndenter()/ indentationForce_
172  << "\t" << (getIndenterVelocity()<0?"down":(getIndenterVelocity()==0?"stop":"up"))
173  << std::endl;
174 // os << "t " << getTime()
175 // << " \t " << (getIndenterVelocity()<0?"down":"up")
176 // << "\tz " << getIndenterHeight()
177 // << "\trelForce " << getForceOnIndenter() / indentationForce_ << std::endl;
178  }
179 
180  void actionsAfterTimeStep() override
181  {
183 
184  static Mdouble timeToRetract = 0;
186 
187  if (getIndenterVelocity() < 0)
188  { //moving down
190  {
192  logger(INFO, "Lowering indentation velocity %", getIndenterVelocity());
193  }
195  {
197  timeToRetract = 1.1 * getTime();
198  logger(INFO, "stopping indenter");
199  }
200  }
201  else if (getIndenterVelocity() == 0)
202  { //stopping
203  if (getTime()>timeToRetract) {
205  logger(INFO, "retracting indenter");
208  }
209  } else
210  { //retracting
212  {
214  logger(INFO, "measured force gradient = %", measuredForceGradient);
215  } else if (getForceOnIndenter() > 0)
216  {
217  //logger(INFO, "stopping indenter");
218  setTimeMax(getTime() * 1.2);
219  }
220  else if (measuredElasticDisplacement == 0)
221  {
223  logger(INFO, "measured elastic displacement = %\n"
224  "measured Elasticity = %", measuredElasticDisplacement, Flusher::NO_FLUSH,
227  logger(INFO, "Increasing indentation velocity %", getIndenterVelocity());
228  }
229  }
230  }
231 
234  {
235  Mdouble bedHeight = getZMin();
236  for (auto p : particleHandler)
237  if (!p->isFixed())
238  bedHeight = std::max(bedHeight, p->getPosition().Z + p->getRadius());
239  logger(INFO, "bed height % N=%", bedHeight, particleHandler.getNumberOfObjects());
240  //return 1;
241  return bedHeight;
242  }
243 
244 private:
249 
254 
255 };
256 
257 #endif /* SPHERICALINDENTER_H */
258 
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO
@ VERBOSE
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:126
void sumForceTorqueOMP()
Definition: BaseInteractable.cc:162
virtual void resetForceTorque(int numberOfOMPthreads)
Definition: BaseInteractable.cc:141
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:215
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:64
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:72
Definition: BaseParticle.h:54
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...
Definition: BaseParticle.cc:167
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
Definition: BaseParticle.cc:663
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
int getNumberOfOMPThreads() const
Definition: DPMBase.cc:1286
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
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:3104
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:632
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1544
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:1437
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
virtual void computeExternalForces(BaseParticle *)
Computes the external forces, such as gravity, acting on particles.
Definition: DPMBase.cc:3159
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1530
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:650
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:644
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
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:1325
Definition: SphericalIndenter.h:35
Mdouble measuredForceGradient
Definition: SphericalIndenter.h:252
Mdouble measuredElasticDisplacement
Definition: SphericalIndenter.h:253
SphericalParticle indenter_
Definition: SphericalIndenter.h:245
Mdouble indentationForce_
Definition: SphericalIndenter.h:248
void printTime() const override
Definition: SphericalIndenter.h:148
Mdouble indenterDiameter_
Definition: SphericalIndenter.h:246
Mdouble getIndenterHeight() const
Definition: SphericalIndenter.h:81
void setupInitialConditions() override
Definition: SphericalIndenter.h:53
Mdouble indentationVelocity_
Definition: SphericalIndenter.h:247
void setIndentationForce(Mdouble indentationForce)
Definition: SphericalIndenter.h:76
SphericalIndenter(Mdouble indenterDiameter, Mdouble indentationVelocity, Mdouble indentationForce)
Definition: SphericalIndenter.h:39
void setIndenterVelocity(Mdouble indentationVelocity_)
Definition: SphericalIndenter.h:98
void outputXBallsData(std::ostream &os) const override
Definition: SphericalIndenter.h:123
Mdouble getIndenterVelocity() const
Definition: SphericalIndenter.h:103
void actionsBeforeTimeStep() override
Definition: SphericalIndenter.h:117
void actionsBeforeTimeLoop() override
A virtual function. Allows one to carry out any operations before the start of the time loop.
Definition: SphericalIndenter.h:138
void actionsAfterTimeStep() override
A virtual function which allows to define operations to be executed after time step.
Definition: SphericalIndenter.h:180
Mdouble getForceOnIndenter() const
Definition: SphericalIndenter.h:93
void writeEneHeader(std::ostream &os) const override
Definition: SphericalIndenter.h:161
Mdouble measuredIndentation
Definition: SphericalIndenter.h:251
Mdouble getBedHeight()
Definition: SphericalIndenter.h:233
void setIndenterHeight(Mdouble height)
Definition: SphericalIndenter.h:86
void computeExternalForces(BaseParticle *p) override
Definition: SphericalIndenter.h:109
void writeEneTimeStep(std::ostream &os) const override
Definition: SphericalIndenter.h:167
Mdouble measuredIndentationForce
Definition: SphericalIndenter.h:250
Mdouble getIndentationForce() const
Definition: SphericalIndenter.h:71
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
Mdouble Z
Definition: Vector.h:66
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51