Parameter study using a protective wall

Problem description

Particles are released from a specific height, roll through a slope and then a protective wall retains them. The user controls the number of particles inserted, the height of release, slope angle, grain size. The output data contain the .fstat file, which includes the information of numbers of grains contained by the wall and overflowing the wall, total force on the wall, volume fraction, stress inside the retained material. An illustrative description is presented in the figure below.

Schematic representation of the parameter study including a protective wall, h: height of release, l: length, w: width, s: slope angle.

Quick explanation:

There are two ways to run the tutorial. First, input parameters set directly in the main file: ProtectiveWall.cpp. Second, input parameters are read from the command line after the compilation, for instance: ./protectiveWall -Np 500 -r 0.01 -h 0.1 -w 0.25 -l 1.0 -s 15.0 -t 20.0, where -Np: Number of particles, -r: particle radius.

Some initial setups:

Three different examples changing the initial setup.

Simulation:

Particles are released from a specific height, roll through a slope, and they are retained by a protective wall.

Headers

The following headers are included:

These are the headers needed for this tutorial. Further explanation can be found in Beginner tutorials.

Main class:

The main class contains the constructor and member functions.

class protectiveWall : public Mercury3D
{
public:
protectiveWall(int Nump, Mdouble pRadius, Mdouble height, Mdouble width,Mdouble Length, Mdouble slopeAngle)
{
setNumParticles = Nump; //Number of particles
setGlobalRadius = pRadius; //Particle radius
setParticleHeight = height; //Height of release
setSlopeAngle = constants::pi / 180.0 * slopeAngle; //Slope angle
setParticlesWriteVTK(true); //For visualization
setGravity(Vec3D(0.0, 0.0, -9.81)); //Set gravity
Mdouble Hipo = Length/cos(setSlopeAngle); //Slope length
setXMax(Length); //Boundary length
setYMax(width); //Boundary width
setZMax(Hipo*sin(setSlopeAngle)); //Boundary height using slope length
slopeSpecies->setDensity(2500.0); //set the species density
slopeSpecies->setStiffness(20058.5);//set the spring stiffness.
slopeSpecies->setDissipation(0.01); //set the dissipation.
particleSpecies->setDensity(2500.0); //set the species density
particleSpecies->setStiffness(258.5);//set the spring stiffness.
particleSpecies->setDissipation(0.5); //set the dissipation.
speciesHandler.getMixedObject(0,1)->mixAll(slopeSpecies,slopeSpecies); //Particle-wall interactions
SphericalParticle particles;
&particles,
1,
Vec3D(0.9 * getXMax(), 0.45 * getYMax(), getZMax() + 0.97 * setParticleHeight), //Minimum position
Vec3D(getXMax(), 0.55 * getYMax(), getZMax() + setParticleHeight), //Maximum position
Vec3D(0, 0, 0), //Minimum velocity
Vec3D(0, 0, 0));
//To delete particles
delb->set(Vec3D(-1,0,0), getXMin());
}
void setupInitialConditions() override
{
InfiniteWall slope,lateralwall1, lateralwall2, lateralwall3;
lateralwall1.setSpecies(slopeSpecies);
lateralwall1.set(Vec3D(0.0, 1.0, 0.0), Vec3D(0.0,getYMax(),0.0));
lateralwall2.setSpecies(slopeSpecies);
lateralwall2.set(Vec3D(0.0, -1.0, 0.0), Vec3D(0.0,getYMin(),0.0));
IntersectionOfWalls roarWall, proctWall;
//Rear wall.
roarWall.addObject(Vec3D(1.0, 0.0, 0.0), Vec3D(getXMax(), 0.0, 0.0));
roarWall.addObject(Vec3D(0.0, 0.0, -1.0), Vec3D(getXMax(), 0.0, getZMax()+setParticleHeight));
//Protective wall
proctWall.addObject(Vec3D(-1.0, 0.0, 0.0), Vec3D(getXMin(), 0.0, 0.0));
proctWall.addObject(Vec3D(0.0, 0.0, -1.0), Vec3D(getXMin(), 0.0, heightProtWall));
}
void actionsAfterTimeStep() override {
//Specific number of particles
//Stop inserting particles
removed_insb = true;
}
//Wall force and pressure
}
//Criterion to stop the simulation, otherwise the simulation stops at maxTime.
bool continueSolve() const override
{
static unsigned int counter = 0;
if (++counter>100)
{
counter=0;
return false;
}
return true;
}
//Print varaibles in the console/terminal
void printTime()const override
{
logger(INFO, "t=%3, "
"tmax=%3, "
"# Particles inserted=%3, "
"# Particles deleted=%3, "
"Volume inserted=%3.6, "
"WallForce=%3.6, "
"WallPressure=%3.6",
}
//Write variables in the fstat file
void writeFstatHeader(std::ostream &os) const override {
os<< getTime() //Current time
<< " " << getTimeMax() //MaxTime
<< " " << setNumParticles - partDel //Particles inserted
<< " " << partDel //Partilcles deleted
<< " " << vol_inserted //Volume inserted
<< " " << wallForce //Wall force
<< " " << wallPressure //Wall pressure
<< std::endl;
}
private:
Mdouble setGlobalRadius = 1.0; //By default
Mdouble setParticleHeight = 0.1; //By default
Mdouble setSlopeAngle = 20.0; //By default
Mdouble heightProtWall = 1.0; //By default
int partDel = 0;
bool removed_insb = false;
};
@ ONE_FILE
all data will be written into/ read from a single file called name_
double Mdouble
Definition: GeneralDefine.h:34
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO
virtual void removeObject(unsigned const int index)
Removes an Object from the BaseHandler.
Definition: BaseHandler.h:472
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.
Definition: BaseHandler.h:379
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:126
virtual void setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
Definition: BaseInteractable.h:260
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Definition: CubeInsertionBoundary.h:42
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin={0, 0, 0}, Vec3D velMax={0, 0, 0})
Sets the properties of the InsertionBoundary for mutliple different particle types.
Definition: CubeInsertionBoundary.cc:107
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
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 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
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1452
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 setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:942
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 getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
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
Used for removing particles from the problem. Inherits from BaseBoundary. By default,...
Definition: DeletionBoundary.h:44
unsigned int getNumberOfParticlesDeleted() const
Gets the number of particles deleted by the boundary.
Definition: DeletionBoundary.cc:295
void set(const Vec3D &normal, Mdouble distance)
Sets boundary position based on a normal and distance.
Definition: DeletionBoundary.cc:85
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:118
Mdouble getVolumeOfParticlesInserted() const
Gets the volume of particles inserted by the boundary.
Definition: InsertionBoundary.cc:356
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Definition: IntersectionOfWalls.h:59
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i....
Definition: IntersectionOfWalls.cc:138
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
Definition: IntersectionOfWalls.cc:72
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:117
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
Mdouble X
the vector components
Definition: Vector.h:66
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
[AT_PW:headers]
Definition: ProtectiveWall.cpp:40
Mdouble vol_inserted
Definition: ProtectiveWall.cpp:219
Mdouble wallPressure
Definition: ProtectiveWall.cpp:218
DeletionBoundary * delb
Definition: ProtectiveWall.cpp:214
bool continueSolve() const override
A virtual function for deciding whether to continue the simulation, based on a user-specified criteri...
Definition: ProtectiveWall.cpp:166
Mdouble setGlobalRadius
[AT_PW:MemberFunctions]
Definition: ProtectiveWall.cpp:208
void printTime() const override
Displays the current simulation time and the maximum simulation duration.
Definition: ProtectiveWall.cpp:179
int setNumParticles
Definition: ProtectiveWall.cpp:216
int partDel
Definition: ProtectiveWall.cpp:215
Mdouble setVolume
Definition: ProtectiveWall.cpp:220
Mdouble heightProtWall
Definition: ProtectiveWall.cpp:211
void writeFstatHeader(std::ostream &os) const override
Writes a header with a certain format for FStat file.
Definition: ProtectiveWall.cpp:193
void setupInitialConditions() override
[AT_PW:Constructor]
Definition: ProtectiveWall.cpp:103
LinearViscoelasticSpecies * slopeSpecies
Definition: ProtectiveWall.cpp:223
Mdouble setSlopeAngle
Definition: ProtectiveWall.cpp:210
Mdouble setParticleHeight
Definition: ProtectiveWall.cpp:209
CubeInsertionBoundary * insb
Definition: ProtectiveWall.cpp:213
Mdouble wallForce
Definition: ProtectiveWall.cpp:217
LinearViscoelasticSpecies * particleSpecies
Definition: ProtectiveWall.cpp:224
void actionsAfterTimeStep() override
A virtual function which allows to define operations to be executed after time step.
Definition: ProtectiveWall.cpp:144
bool removed_insb
Definition: ProtectiveWall.cpp:221
protectiveWall(int Nump, Mdouble pRadius, Mdouble height, Mdouble width, Mdouble Length, Mdouble slopeAngle)
[AT_PW:Constructor]
Definition: ProtectiveWall.cpp:44
const Mdouble pi
Definition: ExtendedMath.h:45
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44

Main function

int main(int argc, char* argv[])
{
//Helper
"Write in the terminal after the compilation'./protectiveWall -Np 500 -r 0.01 -h 0.1 -w 0.25 -l 1.0 -s 15.0 -t "
"20.0' to run the program");
int Nump = helpers::readFromCommandLine(argc, argv, "-Np", 50); //50 particles
Mdouble pRadius = helpers::readFromCommandLine(argc, argv, "-r", 0.01); //0.01 [m]
Mdouble height = helpers::readFromCommandLine(argc, argv, "-h", 0.1); //0.1 [m]
Mdouble width = helpers::readFromCommandLine(argc, argv, "-w", 0.25); //0.25 [m]
Mdouble length = helpers::readFromCommandLine(argc, argv, "-l", 1.0); //1.0 [m]
Mdouble slopeAngle = helpers::readFromCommandLine(argc, argv, "-s", 15.0); //15 grades
protectiveWall problem(Nump, pRadius, height, width, length, slopeAngle); //Object
Mdouble simTime = helpers::readFromCommandLine(argc, argv, "-t", 5.0); // 5.0 [s]
problem.setTimeMax(simTime);
std::string simName = helpers::readFromCommandLine(argc,argv,"-name",std::string("protectiveWall"));
problem.setName(simName);
problem.setSaveCount(400);
problem.setTimeStep(0.005 / 50.0); // (collision time)/50.0
problem.removeOldFiles();
problem.solve();
return 0;
}
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
int main(int argc, char *argv[])
Definition: T_protectiveWall.cpp:215
bool readFromCommandLine(int argc, char *argv[], std::string varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:103