NetDEM v1.0
Loading...
Searching...
No Matches
scene.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "bonded_spheres.hpp"
4#include "bonded_voronois.hpp"
5#include "contact_model.hpp"
6#include "contact_pp.hpp"
7#include "contact_pw.hpp"
8#include "particle.hpp"
9#include "shape.hpp"
10#include "wall.hpp"
11#include <list>
12#include <unordered_map>
13#include <unordered_set>
14
15namespace netdem {
16
17class Simulation;
18class DEMSolver;
19class MPIManager;
20
56class Scene {
57 friend class DEMSolver;
58 friend class MPIManager;
59
60public:
65 Vec3d gravity_coef{0, 0, -9.81};
66
72
78
88
94
95protected:
105
114
123
131 std::unordered_map<int, Particle *> particle_map;
132
139 std::unordered_map<int, Shape *> shape_map;
140
146
147public:
151 Scene();
152
158 void Init(Simulation *const sim);
159
166 Shape *InsertShape(const Shape *const s_ptr);
167
175
183 Particle *InsertParticleLocal(const Particle *const p_ptr);
184
191 Particle *InsertParticle(const Particle *const p_ptr);
192
200
208
218
224 void InsertParticle(const BondedSpheres *const p_ptr);
225
232 void InsertParticle(const VecXT<BondedSpheres *> &p_list);
233
241 void InsertParticle(const VecXT<BondedSpheres> &p_list);
242
248 void InsertParticle(const BondedVoronois *const p_ptr);
249
256 void InsertParticle(const VecXT<BondedVoronois *> &p_list);
257
265 void InsertParticle(const VecXT<BondedVoronois> &p_list);
266
276
286
293 Wall *InsertWall(const Wall *const w_ptr);
294
301 Wall *InsertWall(Wall const &w);
302
310
318 VecXT<Wall *> InsertWall(const VecXT<Wall> &w_list);
319
325 void RemoveShape(Shape *s_ptr);
326
332 void RemoveParticle(Particle *p_ptr);
333
339 void RemoveParticle(int id);
340
346 void RemoveWall(Wall *w_ptr);
347
353 void RemoveWall(int id);
354
361 ContactModel *InsertContactModel(const ContactModel *const cm_ptr);
362
371
378
385 bool InScene(const Shape *const s_ptr);
386
395 bool InScene(const ContactModel *const cnt_ptr);
396
403 void SetNumberOfMaterials(int num);
404
413 void SetBondModel(int mat_type_1, int mat_type_2,
414 ContactModel *const cnt_model);
415
425 void SetBondModel(int mat_type_1, int mat_type_2, std::string const &label);
426
435 void SetCollisionModel(int mat_type_1, int mat_type_2,
436 ContactModel *const cnt_model);
437
447 void SetCollisionModel(int mat_type_1, int mat_type_2,
448 std::string const &label);
449
457 void SetGravity(double gx, double gy, double gz);
458
467
473 Domain *GetDomain() const;
474
483
492
501
513 void AutoReadRestart(std::string const &path, int mech_cyc,
514 int shape_info_case = 0, std::string filecase = "vtk");
515
522 void ReadRestartShapesVTK(std::string const &file);
523
530 void ReadRestartParticlesVTK(std::string const &file);
531
537 void ReadRestartWallsVTK(std::string const &file);
538
545 void ReadRestartContactsVTK(std::string const &file);
546
553 void ReadRestartShapesJSON(std::string const &file);
554
561 void ReadRestartParticlesJSON(std::string const &file);
562
568 void ReadRestartWallsJSON(std::string const &file);
569
576 void ReadRestartContactsJSON(std::string const &file);
577
582
586 VecXT<Wall *> const &GetWalls();
587
595
602
606 std::unordered_map<int, Shape *> const &GetShapeMap();
607
613
617 void ClearShape();
618
622 void ClearParticle();
623
627 void ClearWall();
628
632 void ClearContactModels();
633
637 void ClearContacts();
638
646 Particle *FindParticle(int id);
647
656
664 Wall *FindWall(int id);
665
669 ~Scene();
670
671private:
673 Simulation *sim{nullptr};
674
684 static const int max_num_particles{2000000};
685
695 static const int max_num_shapes{2000000};
696
698 int max_id_particles{-1};
699
701 int max_id_walls{-1};
702
704 int max_id_shapes{-1};
705};
706
707} // namespace netdem
A class representing a sphere bonded to other spheres through contact pairs.
Definition bonded_spheres.hpp:18
A class representing a set of bonded Voronoi cells generated from an STL file.
Definition bonded_voronois.hpp:19
An abstract base class for contact models.
Definition contact_model.hpp:25
A solver class for performing discrete element method (DEM) simulations.
Definition dem_solver.hpp:23
Class for managing the simulation domain and particles that belong to it.
Definition domain.hpp:24
Manages the data exchange in a DEM simulation.
Definition mpi_manager.hpp:39
Definition mini_map.hpp:17
Definition particle.hpp:26
A class for managing the elements in a DEM simulation. Scene behaves as a std container:
Definition scene.hpp:56
VecXT< VecXT< ContactModel * > > collision_model_table
Definition scene.hpp:87
VecXT< Wall * > wall_ghost_list
A list of pointers to all walls that do not physically exist, but are introduced to provide well-defi...
Definition scene.hpp:122
std::unordered_map< int, Particle * > particle_map
A map from integer IDs to pointers to particles, used for MPI particle reconstruction.
Definition scene.hpp:131
void SetGravity(double gx, double gy, double gz)
Set the gravity acceleration vector for all particles in this scene.
Definition scene.cpp:426
void ClearParticle()
Clear all particles from this scene.
Definition scene.cpp:1148
ContactModel * InsertContactModel(const ContactModel *const cm_ptr)
Insert a contact model into this scene.
Definition scene.cpp:290
Particle * FindParticleWithProxy(int id)
Find the particle with the given ID in this scene.
Definition scene.cpp:1216
Vec3d gravity_coef
The gravity acceleration vector applied to all particles in this scene.
Definition scene.hpp:65
VecXT< Particle * > GetParticlesWithProxy()
Get the particles, along with the particle proxyes, in the scene. (for debugging only)
Definition scene.cpp:1081
void ReadRestartContactsJSON(std::string const &file)
Read in the contact model information from a restart file.
Definition scene.cpp:961
VecXT< ContactPP * > GetContactPPs()
Get all particle-particle contacts in this scene.
Definition scene.cpp:1089
VecXT< Particle * > particle_ghost_list
A list of pointers to all particles that do not physically exist, but are introduced to provide well-...
Definition scene.hpp:104
std::unordered_map< int, Shape * > shape_map
A map from shape IDs to pointers to shapes defined in this scene.
Definition scene.hpp:139
VecXT< Wall * > const & GetWalls()
Get the walls in the scene.
Definition scene.cpp:1079
void ReadRestartParticlesJSON(std::string const &file)
Read in the particle information from a restart file.
Definition scene.cpp:883
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
~Scene()
Destroy this scene and free all associated memory.
Definition scene.cpp:1236
Particle * InsertDerivedParticle(Particle const *p_ptr)
Insert a derived particle into this scene by copying the given particle.
Definition scene.cpp:162
VecXT< VecXT< ContactModel * > > bond_model_table
A lookup table for contact models based on the two materials in contact.
Definition scene.hpp:86
Domain * GetDomain() const
Get the domain.
Definition scene.cpp:432
void ReadRestartShapesJSON(std::string const &file)
Read in the particle shape information from a restart file.
Definition scene.cpp:855
void ReadRestartShapesVTK(std::string const &file)
Read in the particle shape information from a restart file.
Definition scene.cpp:534
void ClearContactModels()
Clear all contact models from this scene.
Definition scene.cpp:1185
VecXT< Particle * > particle_list
A list of pointers to all particles that belong to this sub-domain (scene).
Definition scene.hpp:93
Wall * FindWall(int id)
Find the wall with the given ID in this scene.
Definition scene.cpp:1225
void ClearShape()
Clear all shapes from this scene.
Definition scene.cpp:1139
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
ContactModel * GetBondModel(Particle *p1, Particle *p2)
Get the bond model between two particles.
Definition scene.cpp:436
void ClearContacts()
Clear all contacts from this scene.
Definition scene.cpp:1196
ContactModel * GetCollisionModel(Particle *p1, Particle *p2)
Get the collision model between two particles.
Definition scene.cpp:444
void ReadRestartWallsVTK(std::string const &file)
Read in the wall information from a restart file.
Definition scene.cpp:709
void RemoveWall(Wall *w_ptr)
Remove the given wall from this scene.
Definition scene.cpp:262
bool InScene(const Shape *const s_ptr)
Check if the given shape is in this scene.
Definition scene.cpp:324
VecXT< Shape * > local_shape_list
A list of pointers to all shapes that have been generated locally and not yet synced with other sub-d...
Definition scene.hpp:145
void Init(Simulation *const sim)
Initialize this scene with pointers to its owning simulation object.
Definition scene.cpp:17
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
void ReadRestartParticlesVTK(std::string const &file)
Read in the particle information from a restart file.
Definition scene.cpp:538
void AutoReadRestart(std::string const &path, int mech_cyc, int shape_info_case=0, std::string filecase="vtk")
Restart the simulation using output files.
Definition scene.cpp:452
void SetBondModel(int mat_type_1, int mat_type_2, ContactModel *const cnt_model)
Set the bond model between two materials.
Definition scene.cpp:368
void RemoveShape(Shape *s_ptr)
Remove the given shape from this scene.
Definition scene.cpp:228
Particle * FindParticle(int id)
Find the particle with the given ID in this scene.
Definition scene.cpp:1205
std::unordered_map< int, Shape * > const & GetShapeMap()
Get the shape map in the scene.
Definition scene.cpp:1075
Wall * InsertWall(const Wall *const w_ptr)
Insert a single wall into this scene.
Definition scene.cpp:194
Scene()
Default constructor for the scene class.
Definition scene.cpp:15
VecXT< Particle * > particle_proxy_list
A list of pointers to all proxy particles that belong to other domains, but may come into contact wit...
Definition scene.hpp:113
void RemoveParticle(Particle *p_ptr)
Remove the given particle from this scene.
Definition scene.cpp:238
VecXT< Particle * > const & GetParticles()
Get the particles in the scene.
Definition scene.cpp:1077
VecXT< ContactPW * > GetContactPWs()
Get all particle-wall contacts in this scene.
Definition scene.cpp:1108
void ReadRestartWallsJSON(std::string const &file)
Read in the wall information from a restart file.
Definition scene.cpp:930
void ReadRestartContactsVTK(std::string const &file)
Read in the contact model information from a restart file.
Definition scene.cpp:851
void ClearWall()
Clear all walls from this scene.
Definition scene.cpp:1170
VecXT< Wall * > wall_list
A list of pointers to all walls assumed to exist in this scene. No MPI transfer is performed on wall ...
Definition scene.hpp:71
MiniMap< int, ContactModel * > contact_model_map
A map from integer IDs to pointers to contact models defined in this scene.
Definition scene.hpp:77
Particle * InsertParticleLocal(const Particle *const p_ptr)
Insert a single particle into this scene. The particle will be forced inserted no mather which sub-do...
Definition scene.cpp:48
This class represents different types of shapes and performs various calculations on them.
Definition shape.hpp:15
Class for managing a DEM simulation.
Definition simulation.hpp:21
A class representing a wall object in a physics simulation.
Definition wall.hpp:32
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31
std::array< double, 3 > Vec3d
Definition utils_macros.hpp:18