File: LsmMpiPy.h

package info (click to toggle)
esys-particle 2.3.5%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,132 kB
  • sloc: cpp: 81,480; python: 5,872; makefile: 1,259; sh: 313; perl: 225
file content (378 lines) | stat: -rw-r--r-- 14,588 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2003-2017 by The University of Queensland //
// Centre for Geoscience Computing                         //
// http://earth.uq.edu.au/centre-geoscience-computing      //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.apache.org/licenses/LICENSE-2.0              //
//                                                         //
/////////////////////////////////////////////////////////////

#ifndef ESYS_LSM_LSMMPIPY_H
#define ESYS_LSM_LSMMPIPY_H

// --- boost includes ---
#include <boost/python.hpp>
#include <boost/shared_ptr.hpp>

// --- STL includes ---
#include <string>
#include <vector>
#include <map>

// --- Project includes ---
#include "Parallel/LatticeMaster.h"
#include "Python/esys/lsm/InteractionGroupPy.h"
#include "Python/esys/lsm/BondInteractionGroupPy.h"

using std::string;

namespace esys
{
  namespace lsm
  {
    void exportLsm();

    class ParticleScalarFieldSaverPrmsPy;
    class ParticleVectorFieldSaverPrmsPy; 
    class TaggedParticleScalarFieldSaverPrmsPy;
    class TaggedParticleVectorFieldSaverPrmsPy;
    class InteractionScalarFieldSaverPrmsPy;
    class CheckedInteractionScalarFieldSaverPrmsPy;
    class TaggedInteractionScalarFieldSaverPrmsPy;
    class InteractionVectorFieldSaverPrmsPy;
    class CheckedInteractionVectorFieldSaverPrmsPy;
    class WallVectorFieldSaverPrmsPy;
    class TriangleScalarFieldSaverPrmsPy;
    class TriangleVectorFieldSaverPrmsPy;
    class NRotBondPrmsPy;
    class CappedNRotBondPrmsPy;
    class NRotShortBondPrmsPy;
    class NRotElasticPrmsPy;
    class HertzianElasticPrmsPy;
    class HertzianViscoElasticFrictionPrmsPy;
    class HertzianViscoElasticPrmsPy;
    class HertzMindlinPrmsPy;
    class HertzMindlinViscoPrmsPy;
    class LinearDashpotPrmsPy;
    class NRotFrictionPrmsPy;
    class RotBondPrmsPy;
    class RotThermBondPrmsPy;
    class BrittleBeamPrmsPy;
    class FrictionPrmsPy;
    class RotFrictionPrmsPy;
    class RotThermFrictionPrmsPy;
    class RotElasticPrmsPy;
    class RotThermElasticPrmsPy;
    class VWFrictionPrmsPy;
    class DampingPrmsPy;
    class LocalDampingPrmsPy;
    class RotLocalDampingPrmsPy;
    class ABCDampingPrmsPy;
    class NRotBondedWallPrmsPy;
    class NRotSoftBondedWallPrmsPy;
    class NRotElasticWallPrmsPy;
    class NRotElasticSphereBodyPrmsPy;
    class CheckPointPrmsPy;
    class RestartCheckPointPrmsPy;
    class NRotElasticTriMeshPrmsPy;
    class NRotElasticMesh2DPrmsPy;
    class NRotElasticLinMeshPrmsPy;
    class NRotBondedTriMeshPrmsPy;
    class NRotBondedLinMeshPrmsPy;
    class RunnablePy;
    class Vec3Py;
    class BoundingBoxPy;
    class GravityPrmsPy;
    class BuoyancyPrmsPy;
    class MaxTriggerPrmsPy;


    void checkMpiDimensions(int numProcesses, const std::vector<int> &mpiDimVector);

    void checkMpiDimensionsPy(int numProcesses, const boost::python::list &mpiDimList);

    void checkParticleType(const std::string &particleType);

    /*!
      \brief Wrapper to make LatticeMaster methods available in Python
    */
    class LsmMpiPy
    {
    public:     
      typedef CLatticeMaster::ParticleIdPair ParticleIdPair;
      typedef CLatticeMaster::ParticleIdPairVector ParticleIdPairVector;
      typedef CLatticeMaster::MeshNodeDataVector MeshNodeDataVector;
      typedef CLatticeMaster::MeshTriDataVector  MeshTriDataVector;
      typedef CLatticeMaster::TriMeshDataPair    TriMeshDataPair;

      

      LsmMpiPy(
        int numWorkerProcesses,
        const boost::python::list &mpiDimList
      );

      virtual ~LsmMpiPy();
      
      int getNumWorkerProcesses() const;

      void initVerletModel(
        const std::string &particleType,
        double gridSpacing,
        double verletDist
      );

      double getTimeStepSize() const;

      void setTimeStepSize(double dt);

      void setTimingFileName(const std::string &fileNamePrefix);
      void setSlaveTimingFileName(const std::string &fileNamePrefix);

      std::string getParticleType() const;
      std::string getLsmVersion() const;
      void readGeometry(const std::string &fileName);

      int getNumParticles();

      int getTimeStep() const;

      void createParticles(boost::python::object &iterable);

      void createParticle(boost::python::object &particle);

      void createConnections(boost::python::object &iterable);

      // --- interaction creation functions ---
      void createNRotElasticInteractGrp(const NRotElasticPrmsPy &prms);
      void createNRotBondInteractGrp(const NRotBondPrmsPy &bondPrms);
      void createCappedNRotBondInteractGrp(const CappedNRotBondPrmsPy &bondPrms);
      void createNRotShortBondInteractGrp(const NRotShortBondPrmsPy &bondPrms);
      void createNRotFrictionInteractGrp(const NRotFrictionPrmsPy &prms);
      void createRotBondInteractGrp(const RotBondPrmsPy &bondPrms);
      BondInteractionGroupPy createRotThermBondInteractGrp(const RotThermBondPrmsPy &bondPrms);
      void createBrittleBeamInteractGrp(const BrittleBeamPrmsPy &bondPrms);
      void createFrictionInteractGrp(const FrictionPrmsPy &prms);
      void createRotFrictionInteractGrp(const RotFrictionPrmsPy &prms);
      void createRotThermFrictionInteractGrp(const RotThermFrictionPrmsPy &prms);
      void createRotElasticInteractGrp(const RotElasticPrmsPy &prms);
      void createRotThermElasticInteractGrp(const RotThermElasticPrmsPy &prms);
      void createDamping(const DampingPrmsPy &prms);
      void createLocalDamping(const LocalDampingPrmsPy &prms);
      void createRotLocalDamping(const RotLocalDampingPrmsPy &prms);
      void createABCDamping(const ABCDampingPrmsPy &prms);
      void createGravity(const GravityPrmsPy&);
      void createBuoyancy(const BuoyancyPrmsPy&);
      void createVWFrictionIG(const VWFrictionPrmsPy&);
      void createHertzianElasticIG(const HertzianElasticPrmsPy &prms);
      void createHertzianViscoElasticFrictionIG(const HertzianViscoElasticFrictionPrmsPy &prms);
      void createHertzianViscoElasticIG(const HertzianViscoElasticPrmsPy &prms);
      void createHertzMindlinIG(const HertzMindlinPrmsPy &prms);
      void createHertzMindlinViscoIG(const HertzMindlinViscoPrmsPy &prms);
      void createLinearDashpotIG(const LinearDashpotPrmsPy &prms);

      
      // --- remove interactions ---
      void removeInteractionGrp(const std::string&);

      // --- tagged interaction creation functions ---
      void createRotFrictionInteractGrpTag(const RotFrictionPrmsPy &prms,int,int,int,int);
      void createFrictionInteractGrpTag(const FrictionPrmsPy &prms,int,int,int,int);
      void createNRotFrictionInteractGrpTag(const NRotFrictionPrmsPy &prms,int,int,int,int);
      void createLinearDashpotInteractGrpTag(const LinearDashpotPrmsPy &prms,int,int,int,int);
      void createRotElasticInteractGrpTag(const RotElasticPrmsPy &prms,int,int,int,int);
      void createElasticInteractGrpTag(const NRotElasticPrmsPy &prms,int,int,int,int);


      void createExclusion(
        const std::string &interactionName1,
        const std::string &interactionName2
      );


      // --- particle property setting functions ---
      void setParticleVel(int,const Vec3Py&);
      void setParticleAngVel(int,const Vec3Py&);
      void setParticleDensity(int,int,double);
      void setTaggedParticleVel(int,const Vec3Py&);
      void setVelocityOfWall(const std::string&,const Vec3Py&);
      void tagParticleNearestTo(int,int,const Vec3Py&);
      void setParticleNonDynamic(int);
      void setParticleNonRot(int);
      void setParticleNonTrans(int);
      
      // ---- checkpointing -----------
      void createCheckPointer(const RestartCheckPointPrmsPy &prms);
      void createCheckPointerThroughMaster(const RestartCheckPointPrmsPy &prms); // write through master
      void createSnapShots(const CheckPointPrmsPy &prms);
      void loadCheckPoint(const std::string&);

      // ------------------------------
      int getNumTimeSteps() const;

      void setNumTimeSteps(int numTimeSteps);

      // --- Mesh functions ---

      void readMeshWithTag(const std::string &fileName, const std::string &meshName, int tag);
      void readMesh(const std::string &fileName, const std::string &meshName);
      void createTriMesh(
        const std::string &meshName,
        const boost::python::object &nodeSequence,
        const boost::python::object &triSequence
      );
      void translateMesh(const std::string&,const Vec3Py&);
      void readMesh2D(const std::string &fileName, const std::string &meshName, int tag);

      void createNRotElasticTriMeshInteractGrp(const NRotElasticTriMeshPrmsPy &prms);

      void createNRotBondedTriMeshInteractGrp(const NRotBondedTriMeshPrmsPy &prms);
      void createNRotElasticMesh2DInteractGrp(const NRotElasticMesh2DPrmsPy &prms);
      void createNRotElasticLinMeshInteractGrp(const NRotElasticLinMeshPrmsPy &prms);
      void createNRotBondedLinMeshInteractGrp(const NRotBondedLinMeshPrmsPy &prms);

      void moveSingleMeshNodeBy(const std::string& meshname, int id, const Vec3Py& d);

      void addPreTimeStepRunnable(RunnablePy &runnable);

      void addPostTimeStepRunnable(RunnablePy &runnable);

      void force2dComputations(bool do2d);

      void setBBoxSpatialDomain(const BoundingBoxPy &domain);

      void setBBoxSpatialDomainWithCirc(
        const BoundingBoxPy &domain,
        const boost::python::list &circDimList
      );

      void setSpatialDomain(const Vec3Py &minPt, const Vec3Py &maxPt);

      void getInitMinMaxPt(Vec3Py &initMinPt, Vec3Py &initMaxPt);

      void getCurMinMaxPt(Vec3Py &curMinPt, Vec3Py &curMaxPt);

      int findClosestParticle(const Vec3Py &pt);

      Vec3Py getParticlePosn(int particleId);

      // --- move particles ---
      void moveTaggedParticlesTo(int tag, const Vec3Py &pt);
      void moveTaggedParticlesBy(int tag, const Vec3Py &displacement);
      void moveSingleParticleTo(int particleId, const Vec3Py &pt);

      // --- wall related functions ---
      void createWall(const string &name, const Vec3Py &posn, const Vec3Py &normal);
      void createSphereBody(const string &name, const Vec3Py &posn, const double &radius);
      void createNRotBondedWall(const NRotBondedWallPrmsPy &prms);
      void createNRotElasticWall(const NRotElasticWallPrmsPy &prms);
      void createNRotElasticSphereBody(const NRotElasticSphereBodyPrmsPy &prms);
      void createNRotSoftBondedWall(const NRotSoftBondedWallPrmsPy &prms);
      void createNRotElasticWallTagged(const NRotElasticWallPrmsPy &prms, int tag, int mask);
      void moveWallBy(const string&, const Vec3Py &disp);
      void moveSphereBodyBy(const string&, const Vec3Py &disp);
      void setWallNormal(const string&, const Vec3Py &wn);
      void applyForceToWall(const string&, const Vec3Py&);
      Vec3Py getWallPosition(const std::string&);
      Vec3Py getWallForce(const std::string&);
      Vec3Py getSphereBodyPosition(const std::string&);
      Vec3Py getSphereBodyForce(const std::string&);


      void runTimeStep();
      void run();

      // Exit the simulation after running a series of single steps
      // of the time-integration method.
      void exit();

      // --- console related functions ---
      void SetVerbosityPy(bool);
      void SetVerbosityLevelPy(int);	
      void SetConsoleFilenamePy(const std::string&);
      void SetConsoleBufferedPy(unsigned int);

      // --- field saving functions ---
      void createParticleScalarFieldSaver(
        const ParticleScalarFieldSaverPrmsPy &prms
      );

      void createParticleVectorFieldSaver(const ParticleVectorFieldSaverPrmsPy&);
      void createInteractionScalarFieldSaver(const InteractionScalarFieldSaverPrmsPy &prms);
      void createCheckedInteractionScalarFieldSaver(const CheckedInteractionScalarFieldSaverPrmsPy &prms);
      void createInteractionVectorFieldSaver(const InteractionVectorFieldSaverPrmsPy&);
      void createCheckedInteractionVectorFieldSaver(const CheckedInteractionVectorFieldSaverPrmsPy &prms);

      void createTaggedParticleScalarFieldSaver(const TaggedParticleScalarFieldSaverPrmsPy&);
      void createTaggedParticleVectorFieldSaver(const TaggedParticleVectorFieldSaverPrmsPy&);
      void createTaggedInteractionScalarFieldSaver(const TaggedInteractionScalarFieldSaverPrmsPy&);

      void addTaggedScalarParticleDistributionSaver(const string&,const string&,const string&,int,int,int,int,int,int,double,double,int);
      void addVectorTriangleSaveField(const TriangleVectorFieldSaverPrmsPy&);
      void addScalarTriangleSaveField(const TriangleScalarFieldSaverPrmsPy&);
      void addVectorWallField(const WallVectorFieldSaverPrmsPy &prms);

      // --- fields with trigger ---
      void createParticleVectorFieldSaverWithTrigger(const MaxTriggerPrmsPy&,const ParticleVectorFieldSaverPrmsPy&);
      void createTaggedParticleVectorFieldSaverWithTrigger(const MaxTriggerPrmsPy&,const TaggedParticleVectorFieldSaverPrmsPy&);
     
      void visitNodeRefs2d(const std::string &meshName, boost::python::object pyObject);

      void visitRefStressPairs2d(const std::string &meshName, boost::python::object pyObject);

      void visitRefForcePairs(const std::string &meshName, boost::python::object pyObject);

      void visitParticlesWithId(
        const boost::python::list &idList,
        boost::python::object &pyObject
      );

      void visitParticles(
        boost::python::object &pyObject
      );

      boost::python::list getParticleList();

      boost::python::list getParticleWithIdList(
        const boost::python::list &idList
      );

      void createBonds(
        const std::string          &groupName,
        const ParticleIdPairVector &idPairVector
      );

      void updateInteractions();

      ParticleIdPairVector getBondGroupIdPairs(
        const std::string &groupName
      );
      void setVerbosityPy(int);


    protected:
      typedef std::map<std::string, std::string> InteractionNameTypeMap;

      InteractionNameTypeMap &getNameTypeMap();
      const InteractionNameTypeMap &getNameTypeMap() const;
      
      const CLatticeMaster &getLatticeMaster() const;

      CLatticeMaster &getLatticeMaster();

    private:
      class Impl;
      typedef boost::shared_ptr<Impl> ImplPtr;
      ImplPtr m_implPtr;
    };

    
    void setVerbosityPy(bool);
    void setVerbosityLevelPy(int);
  }
}
#endif