NetDEM v1.0
Loading...
Searching...
No Matches
1_membrane_case.cpp

This is an example of how to use the netdem library.

#include "data_dumper.hpp"
#include "gen_pack.hpp"
#include "gravity.hpp"
#include "shape_sphere.hpp"
#include "simulation.hpp"
#include <iostream>
#include <unordered_map>
using namespace netdem;
using namespace std;
int MembraneCase(int argc, char **argv) {
int self_rank, total_rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &self_rank);
MPI_Comm_size(MPI_COMM_WORLD, &total_rank);
Simulation *sim = new Simulation();
sim->domain_manager.SetBound(-0.6, -0.6, -0.6, 0.6, 0.6, 0.6);
sim->domain_manager.SetDecomposition(total_rank, 1, 1);
sim->domain_manager.SetCellSpacing(0.01, 0.01, 0.01);
// // solver
// sim->dem_solver.contact_solver_factory.settings.solver_type =
// ContactSolverSettings::SolverType::sdf;
// sim->dem_solver.contact_solver_factory.settings.sdf_potential_type = 0;
// material model
auto cnt_model_0 = LinearSpring(2.0e5, 1.0e5, 0.3, 0.0);
cnt_model_0.label = "particle_&_wall";
auto cnt_model_0_prt = sim->scene.InsertContactModel(&cnt_model_0);
auto cnt_model_1 = LinearSpring(2.0e5, 1.0e5, 0.5, 0.0);
cnt_model_1.label = "membrane";
auto cnt_model_1_prt = sim->scene.InsertContactModel(&cnt_model_1);
sim->scene.SetCollisionModel(0, 0, cnt_model_0_prt);
sim->scene.SetCollisionModel(0, 1, cnt_model_1_prt);
sim->scene.SetCollisionModel(1, 1, cnt_model_1_prt);
// particle shape
auto sphere = Sphere(0.004);
sim->scene.InsertShape(&sphere);
// pack of particles to be inserted
auto particle_list = PackGenerator::GetGridPack(
0.035, 0.035, 0.06, 0, 0, 0.12, 5, 5, 8, sim->scene.GetShapes());
for (auto &p : particle_list) {
p.SetDensity(2650e3);
p.SetVelocity(0, 0, -0.6);
p.damp_numerical = 0.7;
}
// bottom wall
auto plane_bot = Plane(0, 0, -0.05, 0, 0, 1);
plane_bot.SetExtent(0.1); // make sure the plane extent is inside the domain
auto plane_bot_ptr = sim->scene.InsertShape(&plane_bot);
auto wall_bot = Wall(plane_bot_ptr);
auto wall_bot_ptr = sim->scene.InsertWall(wall_bot);
// membrane
auto membrane_wall = MembraneWall(0.025, 0.2, 0.0025);
membrane_wall.neo_k = 6.94e6;
membrane_wall.neo_mu = 5.21e6;
membrane_wall.density = 500e3;
membrane_wall.damp_coef = 0.7;
membrane_wall.timestep = 1.0e-5;
membrane_wall.enable_deformation = false; // no deformation during packing
membrane_wall.dump_info = true;
membrane_wall.Init(sim);
membrane_wall.SetRootPath("tmp/out_tri_comp/");
membrane_wall.SetSaveByCycles(100);
auto modifier_ptr = sim->modifier_manager.Insert(&membrane_wall);
auto membrane_wall_ptr = static_cast<MembraneWall *>(modifier_ptr);
sim->modifier_manager.Enable(membrane_wall.label);
for (auto &w : membrane_wall_ptr->wall_list) {
w->material_type = 1;
}
// gravity
sim->scene.gravity_coef[2] = -9.81;
auto grav = Gravity();
grav.Init(sim);
sim->modifier_manager.Insert(&grav);
sim->modifier_manager.Enable(grav.label);
// out particle, wall and contact data
auto data_dumper = DataDumper();
data_dumper.Init(sim);
data_dumper.SetRootPath("tmp/out_tri_comp/");
data_dumper.SetSaveByCycles(100);
data_dumper.dump_contact_info = true;
data_dumper.dump_wall_info = true;
sim->modifier_manager.Insert(&data_dumper);
sim->modifier_manager.Enable(data_dumper.label);
// insert 20 packs of particles
sim->dem_solver.timestep = 1.0e-4;
for (int i = 0; i < 20; i++) {
sim->scene.InsertParticle(particle_list);
sim->Run(0.1);
}
// rest for 1.0 s
sim->Run(1.0);
// remove extra particles
sim->scene.gravity_coef[2] = 0.0;
for (auto p_ptr : sim->scene.particle_list) {
if (p_ptr->pos[2] > 0.05 - 0.5 * p_ptr->shape->GetSize()) {
sim->scene.RemoveParticle(p_ptr);
}
}
// add top wall
auto plane_top = Plane(0, 0, 0.05, 0, 0, -1);
plane_top.SetExtent(0.1);
auto plane_top_ptr = sim->scene.InsertShape(&plane_top);
auto wall_top = Wall(plane_top_ptr);
auto wall_top_ptr = sim->scene.InsertWall(wall_top);
// reset the membrane dimensions
membrane_wall_ptr->SetDimensions(0.025, 0.10);
// fix the bottom and top of the membrane wall
for (int i = 0; i < membrane_wall_ptr->nodes.size(); i++) {
if (abs(membrane_wall_ptr->nodes[i][2] + 0.5 * membrane_wall_ptr->height) <
1.0e-4 ||
abs(membrane_wall_ptr->nodes[i][2] - 0.5 * membrane_wall_ptr->height) <
1.0e-4) {
membrane_wall_ptr->SetBCNodalVelocity(i, 0, 0, 0, 1, 1, 1);
}
}
// gradually increase confining pressure
membrane_wall_ptr->enable_deformation = true;
for (int i = 0; i < 10; i++) {
membrane_wall_ptr->SetPressure(-1.0e4 * (i + 1));
sim->Run(0.1);
}
// add deformation drived loading for top wall
auto disp_control = WallMotionControl();
disp_control.Init(sim);
disp_control.SetWall({wall_top_ptr->id});
disp_control.SetVelocity(0, 0, -0.001);
sim->modifier_manager.Insert(&disp_control);
sim->modifier_manager.Enable(disp_control.label);
// press the top of membrane to move with the compression top wall
for (int i = 0; i < membrane_wall_ptr->nodes.size(); i++) {
if (abs(membrane_wall_ptr->nodes[i][2] - 0.5 * membrane_wall_ptr->height) <
1.0e-4) {
membrane_wall_ptr->SetBCNodalVelocity(i, 0, 0, -0.001, 1, 1, 1);
}
}
// sim->Run(2.0);
sim->Run(20.0);
delete sim;
MPI_Finalize();
return 0;
}
double timestep
Definition dem_solver.hpp:42
A class used to dump particle data into vtk files. This is a post-modifier, which will be executed at...
Definition data_dumper.hpp:12
void SetBound(double bmin_x, double bmin_y, double bmin_z, double bmax_x, double bmax_y, double bmax_z)
Sets the lower and upper bounds of the domain.
Definition domain_manager.cpp:83
void SetCellSpacing(double s_x, double s_y, double s_z)
Sets the spacing between cells in each dimension.
Definition domain_manager.cpp:105
void SetDecomposition(int num_div_x, int num_div_y, int num_div_z)
Sets the number of domain divisions in each dimension.
Definition domain_manager.cpp:96
A class used to apply gravity to particles in a DEM simulation.
Definition gravity.hpp:10
Contact model that uses linear spring elements to evaluate contact forces and moments.
Definition model_linear_spring.hpp:16
A class used to model a membrane wall in a DEM simulation.
Definition membrane_wall.hpp:14
Modifier * Insert(Modifier *e)
Inserts new modifier into the simulation.
Definition modifier_manager.cpp:17
void Enable(std::string const &label)
Enables a modifier in the simulation.
A class for representing a plane with a center point and normal vector.
Definition shape_plane.hpp:22
ContactModel * InsertContactModel(const ContactModel *const cm_ptr)
Insert a contact model into this scene.
Definition scene.cpp:290
Vec3d gravity_coef
The gravity acceleration vector applied to all particles in this scene.
Definition scene.hpp:65
void SetNumberOfMaterials(int num)
Set the number of materials in this scene and initialize the contact lookup table accordingly.
Definition scene.cpp:346
Shape * InsertShape(const Shape *const s_ptr)
Insert a single shape into this scene.
Definition scene.cpp:19
VecXT< Particle * > particle_list
A list of pointers to all particles that belong to this sub-domain (scene).
Definition scene.hpp:93
void SetCollisionModel(int mat_type_1, int mat_type_2, ContactModel *const cnt_model)
Set the collision model between two materials.
Definition scene.cpp:397
Particle * InsertParticle(const Particle *const p_ptr)
Insert a single particle into this scene.
Definition scene.cpp:76
VecXT< Shape * > GetShapes()
Return a vector of pointers to all shapes in this scene.
Definition scene.cpp:316
Wall * InsertWall(const Wall *const w_ptr)
Insert a single wall into this scene.
Definition scene.cpp:194
void RemoveParticle(Particle *p_ptr)
Remove the given particle from this scene.
Definition scene.cpp:238
Class for managing a DEM simulation.
Definition simulation.hpp:21
DEMSolver dem_solver
Implements DEM algorithms to solve the scene.
Definition simulation.hpp:47
void Run(double time)
Runs the simulation for a specified period of time.
Definition simulation.cpp:28
DomainManager domain_manager
Manager for domain and sub-domain calculations.
Definition simulation.hpp:31
ModifierManager modifier_manager
Manages add-on features (i.e., customized evaluations not hard-coded in the DEM calculation cycle).
Definition simulation.hpp:53
Scene scene
Contains and manages basic DEM objects (e.g., shapes, particles, walls) for a DEM simulation.
Definition simulation.hpp:42
A class representing a sphere.
Definition shape_sphere.hpp:17
A class representing a wall object in a physics simulation.
Definition wall.hpp:32
A class used to control the displacement of walls in a DEM simulation.
Definition wall_motion_control.hpp:16
Definition bond_entry.hpp:7