ESyS-Particle  2.2
LsmMpiPy.h
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2013 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 #ifndef ESYS_LSM_LSMMPIPY_H
14 #define ESYS_LSM_LSMMPIPY_H
15 
16 // --- boost includes ---
17 #include <boost/python.hpp>
18 #include <boost/shared_ptr.hpp>
19 
20 // --- STL includes ---
21 #include <string>
22 #include <vector>
23 #include <map>
24 
25 // --- Project includes ---
26 #include "Parallel/LatticeMaster.h"
29 
30 using std::string;
31 
32 namespace esys
33 {
34  namespace lsm
35  {
36  void exportLsm();
37 
50  class NRotBondPrmsPy;
52  class NRotShortBondPrmsPy;
53  class NRotElasticPrmsPy;
57  class LinearDashpotPrmsPy;
58  class NRotFrictionPrmsPy;
59  class RotBondPrmsPy;
60  class RotThermBondPrmsPy;
61  class BrittleBeamPrmsPy;
62  class FrictionPrmsPy;
63  class RotFrictionPrmsPy;
65  class RotElasticPrmsPy;
67  class VWFrictionPrmsPy;
68  class DampingPrmsPy;
69  class LocalDampingPrmsPy;
71  class ABCDampingPrmsPy;
75  class CheckPointPrmsPy;
82  class RunnablePy;
83  class Vec3Py;
84  class BoundingBoxPy;
85  class GravityPrmsPy;
86  class BuoyancyPrmsPy;
87  class MaxTriggerPrmsPy;
88 
89 
90  void checkMpiDimensions(int numProcesses, const std::vector<int> &mpiDimVector);
91 
92  void checkMpiDimensionsPy(int numProcesses, const boost::python::list &mpiDimList);
93 
94  void checkParticleType(const std::string &particleType);
95 
99  class LsmMpiPy
100  {
101  public:
107 
108 
109 
110  LsmMpiPy(
111  int numWorkerProcesses,
112  const boost::python::list &mpiDimList
113  );
114 
115  virtual ~LsmMpiPy();
116 
117  int getNumWorkerProcesses() const;
118 
119  void initVerletModel(
120  const std::string &particleType,
121  double gridSpacing,
122  double verletDist
123  );
124 
125  double getTimeStepSize() const;
126 
127  void setTimeStepSize(double dt);
128 
129  void setTimingFileName(const std::string &fileNamePrefix);
130  void setSlaveTimingFileName(const std::string &fileNamePrefix);
131 
132  std::string getParticleType() const;
133  std::string getLsmVersion() const;
134  void readGeometry(const std::string &fileName);
135 
136  int getNumParticles();
137 
138  int getTimeStep() const;
139 
140  void createParticles(boost::python::object &iterable);
141 
142  void createParticle(boost::python::object &particle);
143 
144  void createConnections(boost::python::object &iterable);
145 
146  // --- interaction creation functions ---
148  void createNRotBondInteractGrp(const NRotBondPrmsPy &bondPrms);
152  void createRotBondInteractGrp(const RotBondPrmsPy &bondPrms);
154  void createBrittleBeamInteractGrp(const BrittleBeamPrmsPy &bondPrms);
155  void createFrictionInteractGrp(const FrictionPrmsPy &prms);
160  void createDamping(const DampingPrmsPy &prms);
161  void createLocalDamping(const LocalDampingPrmsPy &prms);
163  void createABCDamping(const ABCDampingPrmsPy &prms);
164  void createGravity(const GravityPrmsPy&);
165  void createBuoyancy(const BuoyancyPrmsPy&);
170  void createLinearDashpotIG(const LinearDashpotPrmsPy &prms);
171 
172 
173  // --- remove interactions ---
174  void removeInteractionGrp(const std::string&);
175 
176  // --- tagged interaction creation functions ---
177  void createRotFrictionInteractGrpTag(const RotFrictionPrmsPy &prms,int,int,int,int);
178  void createNRotFrictionInteractGrpTag(const NRotFrictionPrmsPy &prms,int,int,int,int);
179  void createLinearDashpotInteractGrpTag(const LinearDashpotPrmsPy &prms,int,int,int,int);
180  void createRotElasticInteractGrpTag(const RotElasticPrmsPy &prms,int,int,int,int);
181  void createElasticInteractGrpTag(const NRotElasticPrmsPy &prms,int,int,int,int);
182 
183 
184  void createExclusion(
185  const std::string &interactionName1,
186  const std::string &interactionName2
187  );
188 
189 
190  // --- particle property setting functions ---
191  void setParticleVel(int,const Vec3Py&);
192  void setParticleAngVel(int,const Vec3Py&);
193  void setParticleDensity(int,int,double);
194  void setTaggedParticleVel(int,const Vec3Py&);
195  void setVelocityOfWall(const std::string&,const Vec3Py&);
196  void tagParticleNearestTo(int,int,const Vec3Py&);
197  void setParticleNonDynamic(int);
198  void setParticleNonRot(int);
199  void setParticleNonTrans(int);
200 
201  // ---- checkpointing -----------
203  void createCheckPointerThroughMaster(const RestartCheckPointPrmsPy &prms); // write through master
204  void createSnapShots(const CheckPointPrmsPy &prms);
205  void loadCheckPoint(const std::string&);
206 
207  // ------------------------------
208  int getNumTimeSteps() const;
209 
210  void setNumTimeSteps(int numTimeSteps);
211 
212  // --- Mesh functions ---
213 
214  void readMeshWithTag(const std::string &fileName, const std::string &meshName, int tag);
215  void readMesh(const std::string &fileName, const std::string &meshName);
216  void createTriMesh(
217  const std::string &meshName,
218  const boost::python::object &nodeSequence,
219  const boost::python::object &triSequence
220  );
221  void translateMesh(const std::string&,const Vec3Py&);
222  void readMesh2D(const std::string &fileName, const std::string &meshName, int tag);
223 
225 
230 
231  void moveSingleMeshNodeBy(const std::string& meshname, int id, const Vec3Py& d);
232 
233  void addPreTimeStepRunnable(RunnablePy &runnable);
234 
235  void addPostTimeStepRunnable(RunnablePy &runnable);
236 
237  void force2dComputations(bool do2d);
238 
239  void setBBoxSpatialDomain(const BoundingBoxPy &domain);
240 
242  const BoundingBoxPy &domain,
243  const boost::python::list &circDimList
244  );
245 
246  void setSpatialDomain(const Vec3Py &minPt, const Vec3Py &maxPt);
247 
248  int findClosestParticle(const Vec3Py &pt);
249 
250  Vec3Py getParticlePosn(int particleId);
251 
252  // --- move particles ---
253  void moveTaggedParticlesTo(int tag, const Vec3Py &pt);
254  void moveTaggedParticlesBy(int tag, const Vec3Py &displacement);
255  void moveSingleParticleTo(int particleId, const Vec3Py &pt);
256 
257  // --- wall related functions ---
258  void createWall(const string &name, const Vec3Py &posn, const Vec3Py &normal);
259  void createNRotBondedWall(const NRotBondedWallPrmsPy &prms);
262  void moveWallBy(const string&, const Vec3Py &disp);
263  void setWallNormal(const string&, const Vec3Py &wn);
264  void applyForceToWall(const string&, const Vec3Py&);
265  Vec3Py getWallPosition(const std::string&);
266  Vec3Py getWallForce(const std::string&);
267 
268 
269  void runTimeStep();
270  void run();
271 
272  // Exit the simulation after running a series of single steps
273  // of the time-integration method.
274  void exit();
275 
276  void SetVerbosityPy(bool);
277 
278  // --- field saving functions ---
281  );
282 
288 
292 
293  void addTaggedScalarParticleDistributionSaver(const string&,const string&,const string&,int,int,int,int,int,int,double,double,int);
297 
298  // --- fields with trigger ---
301 
302  void visitNodeRefs2d(const std::string &meshName, boost::python::object pyObject);
303 
304  void visitRefStressPairs2d(const std::string &meshName, boost::python::object pyObject);
305 
306  void visitRefForcePairs(const std::string &meshName, boost::python::object pyObject);
307 
309  const boost::python::list &idList,
310  boost::python::object &pyObject
311  );
312 
313  void visitParticles(
314  boost::python::object &pyObject
315  );
316 
317  boost::python::list getParticleList();
318 
319  boost::python::list getParticleWithIdList(
320  const boost::python::list &idList
321  );
322 
323  void createBonds(
324  const std::string &groupName,
325  const ParticleIdPairVector &idPairVector
326  );
327 
328  void updateInteractions();
329 
331  const std::string &groupName
332  );
333  void setVerbosityPy(bool verbose);
334 
335 
336  protected:
337  typedef std::map<std::string, std::string> InteractionNameTypeMap;
338 
340  const InteractionNameTypeMap &getNameTypeMap() const;
341 
342  const CLatticeMaster &getLatticeMaster() const;
343 
345 
346  private:
347  class Impl;
348  typedef boost::shared_ptr<Impl> ImplPtr;
350  };
351 
352  void setVerbosityPy(bool verbose);
353  }
354 }
355 #endif
356