StressStrainControlBoundary Class Reference

A cuboid box consists of periodic boundaries that can be strain/stress controlled and achieve different deformation modes. User needs to define target stress/strainrate matrix, gain_factor and a boolean parameter isStrainRateControlled to True/False to activate/deactivate strainrate control. More...

#include <StressStrainControlBoundary.h>

+ Inheritance diagram for StressStrainControlBoundary:

Public Member Functions

 StressStrainControlBoundary ()
 default constructor. More...
 
 StressStrainControlBoundary (const StressStrainControlBoundary &b)=default
 copy constructor. More...
 
virtual ~StressStrainControlBoundary ()=default
 destructor. More...
 
void read (std::istream &is) override
 Reads the object's id_ from given istream. More...
 
void write (std::ostream &os) const override
 Adds object's id_ to given ostream. More...
 
std::string getName () const override
 Sets the name of the boundary. More...
 
StressStrainControlBoundarycopy () const override
 Used to create a copy of the object. More...
 
void checkBoundaryAfterParticlesMove (ParticleHandler &particleHandler) override
 Virtual function that does things to particles, each timestep after particles have moved. More...
 
void set (const Matrix3D &stressGoal, const Matrix3D &strainRate, const Matrix3D &gainFactor, bool isStrainRateControlled)
 Sets all boundary inputs at once and determines which deformation mode it is, then combine the right boundaries to assemble the cuboid box/domain. More...
 
void setStrainRate (const Matrix3D &strainRate)
 
void createPeriodicParticles (ParticleHandler &particleHandler) override
 Create the periodic particles after read in from a restart file to attain right information. More...
 
void checkPeriodicLeesEdwardsBoundariesAfterParticlesMove (ParticleHandler &particleHandler)
 Call the boundary and update them based on the new domain size after the stress-control movement. More...
 
void determineLengthAndCentre ()
 Determine the length in x,y,z and center location of domain. More...
 
void activateStrainRateControl (const ParticleHandler &particleHandler)
 Activate the strainrate control for particle movement based on user's boolean input. More...
 
void computeStrainRate ()
 Compute the change of strainrate tensor based on the stress difference and then update the tensor. More...
 
void determineStressControlledShearBoundaries ()
 Determines stress-controlled shear Lees-Edwards boundary in x-y direction and normal periodic in z direction. More...
 
void updateDomainSize ()
 Update the domain to new sizes. More...
 
Matrix3D getStrainRate () const
 Accesses the strainrate tensor. More...
 
Matrix3D getStressGoal () const
 Accesses the target stress tensor. More...
 
Matrix3D getGainFactor () const
 Accesses the gainFactor. More...
 
Mdouble computeStressError ()
 
double getIntegratedShift () const
 
- Public Member Functions inherited from BaseBoundary
 BaseBoundary ()
 default constructor. More...
 
 BaseBoundary (const BaseBoundary &b)
 copy constructor More...
 
 ~BaseBoundary () override
 destructor More...
 
virtual void createPeriodicParticle (BaseParticle *p UNUSED, ParticleHandler &pH UNUSED)
 Creates a periodic particle in case of periodic boundaries in serial build. More...
 
virtual void createPeriodicParticles (ParticleHandler &pH UNUSED)
 Creates periodic copies of given particle in case of periodic boundaries. More...
 
virtual void checkBoundaryBeforeTimeStep (DPMBase *md)
 Virtual function that does things before each time step. More...
 
virtual void actionsBeforeTimeLoop ()
 Virtual function that does something after DPMBase::setupInitialConditions but before the first time step. More...
 
virtual void modifyGhostAfterCreation (BaseParticle *particle, int i)
 
virtual void writeVTK (std::fstream &file)
 
void setHandler (BoundaryHandler *handler)
 Sets the boundary's BoundaryHandler. More...
 
BoundaryHandlergetHandler () const
 Returns the boundary's BoundaryHandler. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Private Attributes

Matrix3D stressGoal_
 Stores the stress value the boundary should attain. More...
 
Matrix3D strainRate_
 
Matrix3D gainFactor_
 
bool isStrainRateControlled_
 The boolean input, true means switch on the strain rate control for particles affine movements. More...
 
Mdouble integratedShift_
 Shift integrated for all the time when using Lees-Edwards Boundary. More...
 
std::vector< LeesEdwardsBoundaryleesEdwardsBoundaries_
 
std::vector< PeriodicBoundaryperiodicBoundaries_
 

Detailed Description

A cuboid box consists of periodic boundaries that can be strain/stress controlled and achieve different deformation modes. User needs to define target stress/strainrate matrix, gain_factor and a boolean parameter isStrainRateControlled to True/False to activate/deactivate strainrate control.

Inherits from BaseObject, combining the PeriodicBoundary and LeesEdwardsBoundary. This boundary takes matrices inputs from user and determine which boundaries should be combined together and therefore achieve different deformation mode: e.g. triaxial, bi-aixial, uni-axial and simple shear. The Lees-Edwards boundary is only activated when there is a target shear stress/strainrate set in the matrix. Note that the same component can only be set in either target stress matrix or strainrate matrix, i.e. if the target shear stress XY is set to a constant, the strainrate_XY has to be set to 0, or just leave it free, it is by default set to 0. Note also there are 9 components in the stress/strainrate tensor but we only support the following components due to the boundary inheritance: XX, YY, ZZ, XY

Constructor & Destructor Documentation

◆ StressStrainControlBoundary() [1/2]

StressStrainControlBoundary::StressStrainControlBoundary ( )

default constructor.

constructor, set all the parameters that boundary needs as inputs to zero.

38  : BaseBoundary()
39 {
44  integratedShift_ = 0.0;
45  //
46  logger(DEBUG, "StressStrainControlBoundary::StressStrainControlBoundary() finished");
47 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
void setZero()
Sets all elements to zero.
Definition: Matrix.cc:75
Matrix3D gainFactor_
Definition: StressStrainControlBoundary.h:143
bool isStrainRateControlled_
The boolean input, true means switch on the strain rate control for particles affine movements.
Definition: StressStrainControlBoundary.h:146
Mdouble integratedShift_
Shift integrated for all the time when using Lees-Edwards Boundary.
Definition: StressStrainControlBoundary.h:149
Matrix3D strainRate_
Definition: StressStrainControlBoundary.h:143
Matrix3D stressGoal_
Stores the stress value the boundary should attain.
Definition: StressStrainControlBoundary.h:143

References DEBUG, gainFactor_, integratedShift_, isStrainRateControlled_, logger, Matrix3D::setZero(), strainRate_, and stressGoal_.

Referenced by copy().

◆ StressStrainControlBoundary() [2/2]

StressStrainControlBoundary::StressStrainControlBoundary ( const StressStrainControlBoundary b)
default

copy constructor.

◆ ~StressStrainControlBoundary()

virtual StressStrainControlBoundary::~StressStrainControlBoundary ( )
virtualdefault

destructor.

Member Function Documentation

◆ activateStrainRateControl()

void StressStrainControlBoundary::activateStrainRateControl ( const ParticleHandler particleHandler)

Activate the strainrate control for particle movement based on user's boolean input.

This function activate the strain rate control based on user inputs, it takes only the strainRate_ tensor and move particles based on this tensor, also move boundaries based on the new domain size.

200 {
201  const DPMBase* const dpm = getHandler()->getDPMBase();
202  // update the domain size based on the new strain rate tensor
204 
205  // Move the boundaries to next time step
206  if (strainRate_.XY != 0 || stressGoal_.XY != 0)
207  {
209  }
210  else
211  {
212  // Move the boundary in x direction to next time step
213  periodicBoundaries_[0].set(Vec3D(1.0, 0.0, 0.0), dpm->getXMin(), dpm->getXMax());
214  // Move the boundary in y direction to next time step
215  periodicBoundaries_[1].set(Vec3D(0.0, 1.0, 0.0), dpm->getYMin(), dpm->getYMax());
216  // Move the boundary in z direction to next time step
217  periodicBoundaries_[2].set(Vec3D(0.0, 0.0, 1.0), dpm->getZMin(), dpm->getZMax());
218  }
219 
220  // Give the strain-rate for all particles and move them to next time step before integration
222  {
223  for (auto& p : particleHandler)
224  {
225  // Box length Lx, Ly and Lz, and center point C of the box
226  Vec3D centerBox;
227  centerBox.X = (dpm->getXMax() + dpm->getXMin()) / 2.0;
228  centerBox.Y = (dpm->getYMax() + dpm->getYMin()) / 2.0;
229  centerBox.Z = (dpm->getZMax() + dpm->getZMin()) / 2.0;
230  Vec3D relativeToCenter;
231  relativeToCenter.X = p->getPosition().X - centerBox.X;
232  relativeToCenter.Y = p->getPosition().Y - centerBox.Y;
233  relativeToCenter.Z = p->getPosition().Z - centerBox.Z;
234  p->move(Vec3D(strainRate_.XX * dpm->getTimeStep() * relativeToCenter.X +
235  strainRate_.XY * dpm->getTimeStep() * relativeToCenter.Y,
236  strainRate_.YY * dpm->getTimeStep() * relativeToCenter.Y,
237  strainRate_.ZZ * dpm->getTimeStep() * relativeToCenter.Z));
238  }
239  }
240 }
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:143
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
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 getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
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
Mdouble XY
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
std::vector< PeriodicBoundary > periodicBoundaries_
Definition: StressStrainControlBoundary.h:157
void determineStressControlledShearBoundaries()
Determines stress-controlled shear Lees-Edwards boundary in x-y direction and normal periodic in z di...
Definition: StressStrainControlBoundary.cc:268
void updateDomainSize()
Update the domain to new sizes.
Definition: StressStrainControlBoundary.cc:246
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66

References determineStressControlledShearBoundaries(), BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), DPMBase::getTimeStep(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), DPMBase::getZMin(), isStrainRateControlled_, periodicBoundaries_, strainRate_, stressGoal_, updateDomainSize(), Vec3D::X, Matrix3D::XX, Matrix3D::XY, Vec3D::Y, Matrix3D::YY, Vec3D::Z, and Matrix3D::ZZ.

Referenced by checkBoundaryAfterParticlesMove().

◆ checkBoundaryAfterParticlesMove()

void StressStrainControlBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler particleHandler)
overridevirtual

Virtual function that does things to particles, each timestep after particles have moved.

This is where the stress-strain control is implemented and the boundary will be checked at each time step to make sure the target stress/strain rate are achieved.

Reimplemented from BaseBoundary.

116 {
118 
119  //Real Stress and StrainRate Control every time step
120  logger.assert_debug(getHandler() != nullptr,
121  "you need to set the handler of this boundary before the parameters can be set");
122 
124 
125  //this checks if stressGoal matrix is non-zero and then activate only the stress control
126  if (stressGoal_.XX != 0 || stressGoal_.YY != 0 || stressGoal_.ZZ != 0 ||
127  stressGoal_.XY != 0)
128  {
129  //the strain rate in the corresponding direction will be calculated
131  }
132  activateStrainRateControl(particleHandler);
133 }
void checkPeriodicLeesEdwardsBoundariesAfterParticlesMove(ParticleHandler &particleHandler)
Call the boundary and update them based on the new domain size after the stress-control movement.
Definition: StressStrainControlBoundary.cc:139
void activateStrainRateControl(const ParticleHandler &particleHandler)
Activate the strainrate control for particle movement based on user's boolean input.
Definition: StressStrainControlBoundary.cc:199
void determineLengthAndCentre()
Determine the length in x,y,z and center location of domain.
Definition: StressStrainControlBoundary.cc:156
void computeStrainRate()
Compute the change of strainrate tensor based on the stress difference and then update the tensor.
Definition: StressStrainControlBoundary.cc:165

References activateStrainRateControl(), checkPeriodicLeesEdwardsBoundariesAfterParticlesMove(), computeStrainRate(), determineLengthAndCentre(), BaseBoundary::getHandler(), logger, stressGoal_, Matrix3D::XX, Matrix3D::XY, Matrix3D::YY, and Matrix3D::ZZ.

◆ checkPeriodicLeesEdwardsBoundariesAfterParticlesMove()

void StressStrainControlBoundary::checkPeriodicLeesEdwardsBoundariesAfterParticlesMove ( ParticleHandler particleHandler)

Call the boundary and update them based on the new domain size after the stress-control movement.

This function checks the boundaries after the particles are moved, to serve the stress-control for the following steps.

140 {
141  // Call Boundaries
143  {
144  b.checkBoundaryAfterParticlesMove(particleHandler);
145  }
147  {
148  b.checkBoundaryAfterParticlesMove(particleHandler);
149  }
150 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Definition: LeesEdwardsBoundary.h:47
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
std::vector< LeesEdwardsBoundary > leesEdwardsBoundaries_
Definition: StressStrainControlBoundary.h:156

References leesEdwardsBoundaries_, and periodicBoundaries_.

Referenced by checkBoundaryAfterParticlesMove().

◆ computeStrainRate()

void StressStrainControlBoundary::computeStrainRate ( )

Compute the change of strainrate tensor based on the stress difference and then update the tensor.

This function is used to compute the new strain rate tensor based on the stress differences between the actual and user set target values.

166 {
167  // calculate the stress total and average over the volume
168  Matrix3D stress = getHandler()->getDPMBase()->getTotalStress();
169 
170  // controller
171  // amount by which the strain rate tensor has to be changed
172  if (stressGoal_.XX != 0)
173  {
174 // Mdouble stressError=(stress.XX- stressGoal_.XX); // Calculate the Error
175 // static PIController xx(0.1,gainFactor_.XX);
176 // strainRate_.XX = xx.apply(stressError,timeStep); // Controller Command
177 // logger(VERBOSE, "StressXX = %",stress.XX);
178  strainRate_.XX = gainFactor_.XX * (stress.XX - stressGoal_.XX);
179  }
180  if (stressGoal_.YY != 0)
181  {
182  strainRate_.YY = gainFactor_.YY * (stress.YY - stressGoal_.YY);
183  }
184  if (stressGoal_.ZZ != 0)
185  {
186  strainRate_.ZZ = gainFactor_.ZZ * (stress.ZZ - stressGoal_.ZZ);
187  }
188  if (stressGoal_.XY != 0)
189  {
190  strainRate_.XY = gainFactor_.XY * (stress.XY - stressGoal_.XY);
191  }
192 }
Matrix3D getTotalStress() const
Calculate the total stress tensor in the system averaged over the whole volume.
Definition: DPMBase.cc:5421
Implementation of a 3D matrix.
Definition: Matrix.h:38

References gainFactor_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), DPMBase::getTotalStress(), strainRate_, stressGoal_, Matrix3D::XX, Matrix3D::XY, Matrix3D::YY, and Matrix3D::ZZ.

Referenced by checkBoundaryAfterParticlesMove().

◆ computeStressError()

Mdouble StressStrainControlBoundary::computeStressError ( )

◆ copy()

StressStrainControlBoundary * StressStrainControlBoundary::copy ( ) const
overridevirtual

Used to create a copy of the object.

Copy method; creates a copy on the boundary and returns its pointer.

Implements BaseBoundary.

56 {
57  return new StressStrainControlBoundary(*this);
58 }
StressStrainControlBoundary()
default constructor.
Definition: StressStrainControlBoundary.cc:37

References StressStrainControlBoundary().

◆ createPeriodicParticles()

void StressStrainControlBoundary::createPeriodicParticles ( ParticleHandler particleHandler)
override

Create the periodic particles after read in from a restart file to attain right information.

This function is used to create ghost particles such that the stress are calculated correctly after restart from another configuration.

385 {
386  // Call Boundaries
388  {
389  b.createPeriodicParticles(particleHandler);
390  }
392  {
393  b.createPeriodicParticles(particleHandler);
394  }
395 }

References leesEdwardsBoundaries_, and periodicBoundaries_.

◆ determineLengthAndCentre()

void StressStrainControlBoundary::determineLengthAndCentre ( )

Determine the length in x,y,z and center location of domain.

This function determines both the length in x,y,z direction and center location of the domain.

157 {
158 // const DPMBase* const dpm = getHandler()->getDPMBase();
159 }

Referenced by checkBoundaryAfterParticlesMove().

◆ determineStressControlledShearBoundaries()

void StressStrainControlBoundary::determineStressControlledShearBoundaries ( )

Determines stress-controlled shear Lees-Edwards boundary in x-y direction and normal periodic in z direction.

This function determines the boundary for stress-controlled shear situation. In this case, the Lees-Edwards boundary in x-y directions and normal periodic boundary in z direction are combined together as a cuboid shear box.

269 {
270  const DPMBase* const dpm = getHandler()->getDPMBase();
271  //Determine the current shear velocity and shift of the Lees-Edwards boundary
272  const Mdouble velocity_xy = strainRate_.XY * (dpm->getXMax() - dpm->getXMin());
273  integratedShift_ += velocity_xy * dpm->getTimeStep();
274 
275  // Determine how to move boundaries based on strain rate control or boundary control
277  {
278  // Move the Lees-Edwards boundary in z direction to next time step
279  leesEdwardsBoundaries_[0].set(
280  [this](Mdouble time)
281  { return integratedShift_; },
282  [](Mdouble time UNUSED)
283  { return 0; },
284  dpm->getXMin(), dpm->getXMax(), dpm->getYMin(), dpm->getYMax());
285  }
286  else
287  {
288  // Update the velocity of Lees-Edwards boundary in x-y direction to next time step
289  leesEdwardsBoundaries_[0].set(
290  [this](Mdouble time)
291  { return integratedShift_; },
292  [velocity_xy](Mdouble time UNUSED)
293  { return velocity_xy; },
294  dpm->getXMin(), dpm->getXMax(), dpm->getYMin(), dpm->getYMax());
295  }
296  // Move the boundary in z direction to next time step
297  periodicBoundaries_[0].set(Vec3D(0.0, 0.0, 1.0), dpm->getZMin(), dpm->getZMax());
298 }
double Mdouble
Definition: GeneralDefine.h:34
#define UNUSED
Definition: GeneralDefine.h:39

References BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), DPMBase::getTimeStep(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), DPMBase::getZMin(), integratedShift_, isStrainRateControlled_, leesEdwardsBoundaries_, periodicBoundaries_, strainRate_, UNUSED, and Matrix3D::XY.

Referenced by activateStrainRateControl().

◆ getGainFactor()

Matrix3D StressStrainControlBoundary::getGainFactor ( ) const
inline

Accesses the gainFactor.

120 {return gainFactor_;}

References gainFactor_.

◆ getIntegratedShift()

double StressStrainControlBoundary::getIntegratedShift ( ) const
inline
127 {return integratedShift_;}

References integratedShift_.

◆ getName()

std::string StressStrainControlBoundary::getName ( ) const
overridevirtual

Sets the name of the boundary.

Returns the name of the object class.

Returns
the object class' name.

Implements BaseObject.

106 {
107  return "StressStrainControlBoundary";
108 }

◆ getStrainRate()

Matrix3D StressStrainControlBoundary::getStrainRate ( ) const
inline

Accesses the strainrate tensor.

114 {return strainRate_;}

References strainRate_.

Referenced by ShearStage::actionsAfterTimeStep(), ShearStage::printTime(), and ShearStage::ShearStage().

◆ getStressGoal()

Matrix3D StressStrainControlBoundary::getStressGoal ( ) const
inline

Accesses the target stress tensor.

117 {return stressGoal_;}

References stressGoal_.

◆ read()

void StressStrainControlBoundary::read ( std::istream &  is)
overridevirtual

Reads the object's id_ from given istream.

Reads the boundary properties from an istream.

Parameters
[in]isthe istream.

Implements BaseBoundary.

90 {
92  std::string dummy;
93  is >> dummy >> stressGoal_;
94  is >> dummy >> strainRate_;
95  is >> dummy >> gainFactor_;
96  is >> dummy >> isStrainRateControlled_;
98  is >> dummy >> integratedShift_;
99 }
void read(std::istream &is) override=0
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:61
void set(const Matrix3D &stressGoal, const Matrix3D &strainRate, const Matrix3D &gainFactor, bool isStrainRateControlled)
Sets all boundary inputs at once and determines which deformation mode it is, then combine the right ...
Definition: StressStrainControlBoundary.cc:310

References gainFactor_, integratedShift_, isStrainRateControlled_, BaseBoundary::read(), set(), strainRate_, and stressGoal_.

◆ set()

void StressStrainControlBoundary::set ( const Matrix3D stressGoal,
const Matrix3D strainRate,
const Matrix3D gainFactor,
bool  isStrainRateControlled 
)

Sets all boundary inputs at once and determines which deformation mode it is, then combine the right boundaries to assemble the cuboid box/domain.

This function sets the inputs for the whole StressStrainControlBoundary based on the user inputs.

Parameters
[in]stressGoalThe target stress tensor that needs to achieve at the end of the deformation.
[in]strainRateThe target strain rate tensor, cannot be set non-zero with target Stress, i.e. stressGoal.XX != 0, then strainRate.XX = 0.
[in]gainFactorThe incremental factor for the stress control, usually a very small value ~ 0.0001.
[in]isStrainRateControlledThe boolean key to determine whether particles are moved by strain rate affine movement (true) or dragged by boundary itself (false).
311 {
312  periodicBoundaries_.clear();
313  leesEdwardsBoundaries_.clear();
314 
315  isStrainRateControlled_ = isStrainRateControlled;
316  stressGoal_ = stressGoal;
317  strainRate_ = strainRate;
318  gainFactor_ = gainFactor;
319 
320  logger.assert_always(stressGoal.XZ == 0, "Shear stress in XZ cannot be controlled; use shear stress in XY instead");
321  logger.assert_always(stressGoal.ZX == 0, "Shear stress in ZX cannot be controlled; use shear stress in XY instead");
322  logger.assert_always(stressGoal.YZ == 0, "Shear stress in YZ cannot be controlled; use shear stress in XY instead");
323  logger.assert_always(stressGoal.ZY == 0, "Shear stress in ZY cannot be controlled; use shear stress in XY instead");
324  logger.assert_always(strainRate.XZ == 0, "Strain rate in XZ cannot be controlled; use strain rate in XY instead");
325  logger.assert_always(strainRate.ZX == 0, "Strain rate in ZX cannot be controlled; use strain rate in XY instead");
326  logger.assert_always(strainRate.YZ == 0, "Strain rate in YZ cannot be controlled; use strain rate in XY instead");
327  logger.assert_always(strainRate.ZY == 0, "Strain rate in ZY cannot be controlled; use strain rate in XY instead");
328  logger.assert_always(stressGoal.XZ != 0 ? gainFactor.XZ != 0 : true,
329  "You need to set a gain factor in XZ in order to control stress");
330  logger.assert_always(stressGoal.XX != 0 ? gainFactor.XX != 0 : true,
331  "You need to set a gain factor in XX in order to control stress");
332  logger.assert_always(stressGoal.YY != 0 ? gainFactor.YY != 0 : true,
333  "You need to set a gain factor in YY in order to control stress");
334  logger.assert_always(stressGoal.ZZ != 0 ? gainFactor.ZZ != 0 : true,
335  "You need to set a gain factor in ZZ in order to control stress");
336 
337  logger.assert_always(getHandler() != nullptr, "You need to set the handler of this boundary");
338  const DPMBase *dpm = getHandler()->getDPMBase();
339 
340  // if there is no shear (compression only)
341  if (stressGoal_.XY == 0 && strainRate_.XY == 0)
342  {
343  logger(INFO, "Shear rate is zero, setting up three periodic boundaries");
344  // Set up new box periodic boundaries, no simple shear activated
345  PeriodicBoundary boundary;
346  boundary.setHandler(getHandler());
347  boundary.set(Vec3D(1.0, 0.0, 0.0), dpm->getXMin(), dpm->getXMax());
348  periodicBoundaries_.push_back(boundary);
349  boundary.set(Vec3D(0.0, 1.0, 0.0), dpm->getYMin(), dpm->getYMax());
350  periodicBoundaries_.push_back(boundary);
351  boundary.set(Vec3D(0.0, 0.0, 1.0), dpm->getZMin(), dpm->getZMax());
352  periodicBoundaries_.push_back(boundary);
353  }
354  else
355  {
356  logger(INFO, "Shear rate is not zero, setting up Lees-Edwards in xy and a periodic boundary in z");
357 
358  PeriodicBoundary boundary;
359  boundary.setHandler(getHandler());
360  boundary.set(Vec3D(0.0, 0.0, 1.0), dpm->getZMin(), dpm->getZMax());
361  periodicBoundaries_.push_back(boundary);
362 
363  // Lees Edwards bc in y direction & periodic boundary in x direction, simple shear boundary activated
364  LeesEdwardsBoundary leesEdwardsBoundary;
365  leesEdwardsBoundary.setHandler(getHandler());
366  double integratedShift = integratedShift_;
367  leesEdwardsBoundary.set(
368  [&integratedShift](Mdouble time UNUSED) { return integratedShift; },
369  [](Mdouble time UNUSED) { return 0; },
370  dpm->getXMin(), dpm->getXMax(), dpm->getYMin(), dpm->getYMax());
371  leesEdwardsBoundaries_.push_back(leesEdwardsBoundary);
372  }
373 }
@ INFO
void setHandler(BoundaryHandler *handler)
Sets the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:134
void set(std::function< Mdouble(Mdouble)> shift, std::function< Mdouble(Mdouble)> velocity, Mdouble left, Mdouble right, Mdouble down, Mdouble up)
Sets all boundary properties.
Definition: LeesEdwardsBoundary.cc:50
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84

References gainFactor_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), DPMBase::getZMin(), INFO, integratedShift_, isStrainRateControlled_, leesEdwardsBoundaries_, logger, periodicBoundaries_, LeesEdwardsBoundary::set(), PeriodicBoundary::set(), BaseBoundary::setHandler(), strainRate_, stressGoal_, UNUSED, Matrix3D::XX, Matrix3D::XY, Matrix3D::XZ, Matrix3D::YY, Matrix3D::YZ, Matrix3D::ZX, Matrix3D::ZY, and Matrix3D::ZZ.

Referenced by ShearStage::actionsAfterTimeStep(), read(), StressStrainControl::setupInitialConditions(), and ShearStage::ShearStage().

◆ setStrainRate()

void StressStrainControlBoundary::setStrainRate ( const Matrix3D strainRate)
376 {
377  strainRate_ = strainRate;
378 }

References strainRate_.

◆ updateDomainSize()

void StressStrainControlBoundary::updateDomainSize ( )

Update the domain to new sizes.

This function is used to update the domain size based on the strainRate tensor, note that the system is symmetric and therefore we have to update boundary in both Min and Max.

247 {
248  DPMBase* const dpm = getHandler()->getDPMBase();
249  // Box length Lx, Ly and Lz for next time step
250  Vec3D lengthBox;
251  lengthBox.X = (dpm->getXMax() - dpm->getXMin());
252  lengthBox.Y = (dpm->getYMax() - dpm->getYMin());
253  lengthBox.Z = (dpm->getZMax() - dpm->getZMin());
254  // Change the system size according to next time step
255  dpm->setXMax(dpm->getXMax() + 0.5 * lengthBox.X * strainRate_.XX * dpm->getTimeStep());
256  dpm->setXMin(dpm->getXMin() - 0.5 * lengthBox.X * strainRate_.XX * dpm->getTimeStep());
257  dpm->setYMax(dpm->getYMax() + 0.5 * lengthBox.Y * strainRate_.YY * dpm->getTimeStep());
258  dpm->setYMin(dpm->getYMin() - 0.5 * lengthBox.Y * strainRate_.YY * dpm->getTimeStep());
259  dpm->setZMax(dpm->getZMax() + 0.5 * lengthBox.Z * strainRate_.ZZ * dpm->getTimeStep());
260  dpm->setZMin(dpm->getZMin() - 0.5 * lengthBox.Z * strainRate_.ZZ * dpm->getTimeStep());
261 }
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1034
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1058
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1165
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1217
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1010

References BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), DPMBase::getTimeStep(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), DPMBase::getZMin(), DPMBase::setXMax(), DPMBase::setXMin(), DPMBase::setYMax(), DPMBase::setYMin(), DPMBase::setZMax(), DPMBase::setZMin(), strainRate_, Vec3D::X, Matrix3D::XX, Vec3D::Y, Matrix3D::YY, Vec3D::Z, and Matrix3D::ZZ.

Referenced by activateStrainRateControl().

◆ write()

void StressStrainControlBoundary::write ( std::ostream &  os) const
overridevirtual

Adds object's id_ to given ostream.

Writes boundary's properties to an ostream.

Parameters
[in]osthe ostream.

Implements BaseBoundary.

65 {
67  os << " stressGoal " << stressGoal_;
68  os << " strainRate " << strainRate_;
69  os << " gainFactor " << gainFactor_;
70  os << " isStrainRateControlled " << isStrainRateControlled_;
71  os << " integratedShift " << integratedShift_;
72 // os << leesEdwardsBoundaries_.size() << ' ';
73 // for (const LeesEdwardsBoundary& b : leesEdwardsBoundaries_)
74 // {
75 // os << b << ' ';
76 // }
77 //
78 // os << periodicBoundaries_.size() << ' ';
79 // for (const PeriodicBoundary& b : periodicBoundaries_)
80 // {
81 // os << b << ' ';
82 // }
83 }
void write(std::ostream &os) const override=0
Adds object's id_ to given ostream NB: purely virtual function, overriding the version of BaseObject.
Definition: BaseBoundary.cc:70

References gainFactor_, integratedShift_, isStrainRateControlled_, strainRate_, stressGoal_, and BaseBoundary::write().

Member Data Documentation

◆ gainFactor_

Matrix3D StressStrainControlBoundary::gainFactor_
private

◆ integratedShift_

Mdouble StressStrainControlBoundary::integratedShift_
private

Shift integrated for all the time when using Lees-Edwards Boundary.

Referenced by determineStressControlledShearBoundaries(), getIntegratedShift(), read(), set(), StressStrainControlBoundary(), and write().

◆ isStrainRateControlled_

bool StressStrainControlBoundary::isStrainRateControlled_
private

The boolean input, true means switch on the strain rate control for particles affine movements.

Referenced by activateStrainRateControl(), determineStressControlledShearBoundaries(), read(), set(), StressStrainControlBoundary(), and write().

◆ leesEdwardsBoundaries_

std::vector<LeesEdwardsBoundary> StressStrainControlBoundary::leesEdwardsBoundaries_
private

Store boundaries into a vector for the pushback. Note, there is always either 0 LeesEdwardsBoundary (XY) and 3 PeriodicBoundary (XYZ), or 1 LeesEdwardsBoundary (XY) and 1 PeriodicBoundary (Z).

Referenced by checkPeriodicLeesEdwardsBoundariesAfterParticlesMove(), createPeriodicParticles(), determineStressControlledShearBoundaries(), and set().

◆ periodicBoundaries_

◆ strainRate_

◆ stressGoal_

Matrix3D StressStrainControlBoundary::stressGoal_
private

Stores the stress value the boundary should attain.

Unused if the all stressGoal values are set to zero.

Referenced by activateStrainRateControl(), checkBoundaryAfterParticlesMove(), computeStrainRate(), computeStressError(), getStressGoal(), read(), set(), StressStrainControlBoundary(), and write().


The documentation for this class was generated from the following files: