~esys-p-dev/esys-particle/trunk

861 by dion
Release2009: Updated the copyright headers in all files to 2009 version
1
/////////////////////////////////////////////////////////////
2
//                                                         //
1121 by Vince Boros
Copyright, Centre name, Centre address updates
3
// Copyright (c) 2003-2014 by The University of Queensland //
4
// Centre for Geoscience Computing                         //
5
// http://earth.uq.edu.au/centre-geoscience-computing      //
861 by dion
Release2009: Updated the copyright headers in all files to 2009 version
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
//                                                         //
11
/////////////////////////////////////////////////////////////
795 by dion
DW added copyright headers to most c++ files...still a few to go in subdirs.
12
2 by steffen
Initial revision
13
#ifndef __SUBLATTICE_H
14
#define __SUBLATTICE_H
15
16
// -- project includes --
304 by slatham
Rotational dynamics.
17
201 by slatham
Added tagging of "driving plate" particles in GougeBlock3d, and added a setProcessDims(x, y, z) script-function and CLatticeMaster::setProcessDims(dims) method.
18
#include "Parallel/mpibuf.h"
19
#include "Parallel/mpivbuf.h"
20
#include "Parallel/ASubLattice.h"
21
#include "Parallel/LatticeParam.h"
22
261 by slatham
Updated implementation of the recording of timing data for each worker process.
23
#include "Foundation/Timer.h"
201 by slatham
Added tagging of "driving plate" particles in GougeBlock3d, and added a setProcessDims(x, y, z) script-function and CLatticeMaster::setProcessDims(dims) method.
24
516 by slatham
Replaced std::cout statements with console.Debug() and console.Error() statements.
25
#include "Model/TriMesh.h"
531 by steffen
some more work on 2d mesh stuff
26
#include "Model/Mesh2D.h"
376 by steffen
moved geometric part of triangle mesh out of TriMeshIG into own class
27
301 by steffen
started implementing mesh loading
28
// -- interactions --
201 by slatham
Added tagging of "driving plate" particles in GougeBlock3d, and added a setProcessDims(x, y, z) script-function and CLatticeMaster::setProcessDims(dims) method.
29
#include "Model/Interaction.h"
30
#include "Model/EWallInteractionGroup.h"
31
#include "Model/BWallInteractionGroup.h"
256 by steffen
bit & pieces for viscous drag wall - compiles, but untested
32
#include "Model/ViscWallIG.h"
201 by slatham
Added tagging of "driving plate" particles in GougeBlock3d, and added a setProcessDims(x, y, z) script-function and CLatticeMaster::setProcessDims(dims) method.
33
#include "Model/SoftBWallInteractionGroup.h"
34
304 by slatham
Rotational dynamics.
35
#include "Model/RotBondedInteraction.h"
36
#include "Model/RotElasticInteraction.h"
37
#include "Model/RotFricInteraction.h"
38
1128 by Dion Weatherley
Added sphere body functionality.
39
#include "Model/SphereBodyIG.h"
40
#include "Model/ESphereBodyInteractionGroup.h"
41
376 by steffen
moved geometric part of triangle mesh out of TriMeshIG into own class
42
// -- fields --
201 by slatham
Added tagging of "driving plate" particles in GougeBlock3d, and added a setProcessDims(x, y, z) script-function and CLatticeMaster::setProcessDims(dims) method.
43
#include "Fields/FieldSlave.h"
44
#include "Fields/ScalarParticleFieldSlave.h"
45
#include "Fields/VectorParticleFieldSlave.h"
46
#include "Fields/ScalarInteractionFieldSlave.h"
2 by steffen
Initial revision
47
48
//--- TML includes ---
107 by slatham
Restructure of tml subdir (removal of tml/include).
49
#include "tml/comm/comm.h"
50
#include "tml/comm/comm_world.h"
2 by steffen
Initial revision
51
52
//--- MPI includes ---
53
#include <mpi.h>
54
55
//--- STL includes ---
56
#include <vector>
57
#include <map>
58
#include <string>
59
60
using std::vector;
61
using std::map;
62
using std::string;
63
104 by slatham
Restructure of ppa subdir (removal of ppa/include).
64
template <class T> class ParallelParticleArray;
110 by slatham
Restructure of pis subdir (removal of pis/include).
65
class AParallelInteractionStorage;
104 by slatham
Restructure of ppa subdir (removal of ppa/include).
66
2 by steffen
Initial revision
67
/*!
735 by slatham
Added setTimeStepSize method on LatticeMaster and esys.lsm.LsmMpi. Increased size of esys.lsm.doc doco.
68
  \brief Class for a Sublattice.
2 by steffen
Initial revision
69
*/
70
template <typename T>
71
class TSubLattice : public ASubLattice
72
{
73
 protected:
594 by slatham
Further implementation of WavePropagation sim.
74
  typedef ParallelParticleArray<T> ParticleArray;
2 by steffen
Initial revision
75
  // -- particles storage--
594 by slatham
Further implementation of WavePropagation sim.
76
  ParticleArray *m_ppa;
2 by steffen
Initial revision
77
78
  // -- interaction storage --
165 by slatham
Added esys::lsm::BodyForceGroup class for applying gravitational force to particles.
79
  map<string,AParallelInteractionStorage*> m_dpis; //! dynamic interactions
80
  map<string,AParallelInteractionStorage*> m_bpis; //! persistent interactions
81
  
82
  typedef map<string,AInteractionGroup<T>*> NameIGroupMap;
301 by steffen
started implementing mesh loading
83
  NameIGroupMap m_singleParticleInteractions; //! Body/gravitational force interactions
2 by steffen
Initial revision
84
301 by steffen
started implementing mesh loading
85
  // -- special interaction groups --
353 by steffen
changed Damping from DampingGroup to PIS
86
  map<string,AParallelInteractionStorage*> m_damping;
699 by steffen
changed the API for wall interactions so that walls now have names and are
87
  map<string,AWallInteractionGroup<T>*> m_WIG;
1128 by Dion Weatherley
Added sphere body functionality.
88
  map<string,ASphereBodyInteractionGroup<T>*> m_SIG;
705 by steffen
changed the wall/wall interaction setup
89
  map<string,CWall*> m_walls;
1128 by Dion Weatherley
Added sphere body functionality.
90
  map<string,CSphereBody*> m_spheres;
376 by steffen
moved geometric part of triangle mesh out of TriMeshIG into own class
91
  map<string,TriMesh*> m_mesh; 
531 by steffen
some more work on 2d mesh stuff
92
  map<string,Mesh2D*> m_mesh2d;
2 by steffen
Initial revision
93
94
  // -- parameters --
95
  double m_dt; // time step for integration
96
  double m_nrange; // search range for neighbor table
92 by steffen
changed ntable setup
97
  //  double m_rmax; // max. particle radius
73 by steffen
merging circ_bcond_branch with trunk
98
  double m_alpha; // search range padding
2 by steffen
Initial revision
99
100
  int m_last_ns; // timestamp of last neighborsearch
824 by steffen
- applied chunked bond broadcast patch to branch
101
102
  // Temporary storage of connections
103
  map<int, vector<int> > m_temp_conn;
104
2 by steffen
Initial revision
105
  // -- MPI --
507 by steffen
changed mpi stuff to spawn
106
  int m_rank; //!< rank in m_comm
2 by steffen
Initial revision
107
  MPI_Comm m_comm;
507 by steffen
changed mpi stuff to spawn
108
  TML_Comm m_tml_comm;
2 by steffen
Initial revision
109
  MPI_Comm m_worker_comm; //!< MPI communicator between workers (excl. master)
212 by steffen
added applyForceToWall
110
  TML_Comm m_tml_worker_comm; //!< TML version of the communicator between workers (excl. master)
507 by steffen
changed mpi stuff to spawn
111
  //  int m_num_workers;
201 by slatham
Added tagging of "driving plate" particles in GougeBlock3d, and added a setProcessDims(x, y, z) script-function and CLatticeMaster::setProcessDims(dims) method.
112
  /**
113
   * Process partitioning, non-zero entries are taken literally,
114
   * zero entries are computed via MPI_Dims_create.
115
   */
116
  esys::lsm::CLatticeParam::ProcessDims m_dims;
2 by steffen
Initial revision
117
118
  // -- times --
119
  double packtime; 
120
  double unpacktime;
121
  double commtime;
122
  double forcetime;
123
124
  // -- fields --
125
3 by steffen
updated field functions
126
  // -- "new" fields --
127
  map<int,AFieldSlave*> m_field_slaves;
261 by slatham
Updated implementation of the recording of timing data for each worker process.
128
  
129
  MpiWTimers *m_pTimers;
3 by steffen
updated field functions
130
2 by steffen
Initial revision
131
  // -- private functions --
132
  void calcForces();
133
  void zeroForces();
134
  void integrate(double);
941 by vboros
Rotational Thermal Merge
135
  void integrateTherm(double dt);
136
  void zeroHeat();
137
  void thermExpansion();
138
  void calcHeatFrict();
139
  void calcHeatTrans();
140
656 by steffen
- added rotational damping
141
  // functions doing the actual work adding interaction groups
790 by steffen
=added features=
142
  virtual bool doAddPIG(const string&,const string&,CVarMPIBuffer&,bool tagged=false);
656 by steffen
- added rotational damping
143
  virtual bool doAddDamping(const string&,CVarMPIBuffer&);
144
2 by steffen
Initial revision
145
 public:
507 by steffen
changed mpi stuff to spawn
146
  TSubLattice(const esys::lsm::CLatticeParam &prm, int rank, MPI_Comm comm, MPI_Comm worker_comm);
2 by steffen
Initial revision
147
  virtual ~TSubLattice();
148
735 by slatham
Added setTimeStepSize method on LatticeMaster and esys.lsm.LsmMpi. Increased size of esys.lsm.doc doco.
149
  virtual void setTimeStepSize(double dt);
150
2 by steffen
Initial revision
151
  virtual vector<int> getCommCoords() const {return m_ppa->getCommCoords();};
152
  virtual vector<int> getCommDims() const {return m_ppa->getCommDims();};
153
507 by steffen
changed mpi stuff to spawn
154
  virtual void receiveParticles();
824 by steffen
- applied chunked bond broadcast patch to branch
155
  virtual void receiveConnections();
2 by steffen
Initial revision
156
260 by slatham
Added recording of timing data for each worker process.
157
  virtual const MPI_Comm &getWorkerComm() const {return m_worker_comm;}
158
  
2 by steffen
Initial revision
159
  virtual void initNeighborTable(const Vec3&,const Vec3&);
73 by steffen
merging circ_bcond_branch with trunk
160
  virtual void initNeighborTable(const Vec3&,const Vec3&,const vector<bool>&);
705 by steffen
changed the wall/wall interaction setup
161
  virtual void addWall();
162
  virtual void addElasticWIG();
163
  virtual void addBondedWIG();
164
  virtual void addDirBondedWIG();
165
  virtual void addViscWIG();
1110 by Steffen Abe
- added tagged elastic wall interactions. Usage is createInteractionGroupTagged(param, tag, mask) where param are NRotElasticWallPrms.
166
  virtual void addTaggedElasticWIG();
376 by steffen
moved geometric part of triangle mesh out of TriMeshIG into own class
167
  virtual void addTriMesh();
301 by steffen
started implementing mesh loading
168
  virtual void addTriMeshIG();
399 by steffen
more work on bondend trimesh interactions
169
  virtual void addBondedTriMeshIG();
531 by steffen
some more work on 2d mesh stuff
170
  virtual void addMesh2D();
171
  virtual void addMesh2DIG();
172
  virtual void addBondedMesh2DIG();
2 by steffen
Initial revision
173
  virtual void addPairIG();
790 by steffen
=added features=
174
  virtual void addTaggedPairIG();
2 by steffen
Initial revision
175
  virtual void addSingleIG();
176
  virtual void addBondedIG();
786 by steffen
documentation later
177
  virtual void addCappedBondedIG();
778 by steffen
started work on a new interaction type - "short" bonded interactions
178
  virtual void addShortBondedIG();
304 by slatham
Rotational dynamics.
179
  virtual void addRotBondedIG();
941 by vboros
Rotational Thermal Merge
180
  virtual void addRotThermBondedIG();
2 by steffen
Initial revision
181
  virtual void addDamping();
182
  virtual void setExIG();
803 by steffen
- fixed issue in RotBondedInteraction:
183
  virtual void removeIG();
817 by steffen
Added getWallPosition(name) call
184
  virtual void getWallPos();
929 by dion
Added getWallForce() subroutine to return force acting on a wall to Python layer.
185
  virtual void getWallForce();
1128 by Dion Weatherley
Added sphere body functionality.
186
  virtual void addSphereBody();
187
  virtual void addESphereBodyIG();
188
  virtual void getSphereBodyPos();
189
  virtual void getSphereBodyForce();
2 by steffen
Initial revision
190
191
  virtual void oneStep();
941 by vboros
Rotational Thermal Merge
192
  virtual void oneStepTherm();
2 by steffen
Initial revision
193
  virtual void exchangePos();
194
  void setTimeStep(double dt){m_dt=dt;};
156 by slatham
Moved parser PredefinedFunction classes out of LatticeMaster.cpp into ParserLmInitialiser.h and ParserLmInitialiser.cpp
195
260 by slatham
Added recording of timing data for each worker process.
196
  virtual void rebuildParticleArray();
197
  virtual void rebuildInteractions();
2 by steffen
Initial revision
198
  virtual void searchNeighbors();
199
  virtual void updateInteractions();
200
  virtual void checkNeighbors();
201
  void resetDisplacements();
370 by slatham
Added do2dCalculations script function to force particles to remain in the xy plane.
202
  
593 by slatham
Moved esys::lsm::SimpleParticle data files from Model into Geometry, further implementation of WavePropagation sim.
203
  virtual void do2dCalculations(bool do2d);
516 by slatham
Replaced std::cout statements with console.Debug() and console.Error() statements.
204
  virtual int getNumParticles();
2 by steffen
Initial revision
205
594 by slatham
Further implementation of WavePropagation sim.
206
  std::pair<double, int> findParticleNearestTo(const Vec3 &pt);
207
208
  std::pair<int, Vec3> getParticlePosn(int particleId);
209
941 by vboros
Rotational Thermal Merge
210
  AParallelInteractionStorage *findPis(const std::string &groupName);
211
  
212
//  virtual ParticleIdPairVector getBondGroupIdPairs(const std::string &groupName);
213
214
  template <typename TmplPis>
215
  ParticleIdPairVector getBondGroupIdPairs(TmplPis *pBondPis);
216
2 by steffen
Initial revision
217
  virtual void moveParticleTo();
816 by steffen
Added missing mesh functions from trunk_premerge_stable
218
  virtual void moveTaggedParticlesBy();
598 by slatham
Further implementation of WavePropagation sim.
219
  virtual void moveSingleParticleTo(int particleId, const Vec3 &posn);
2 by steffen
Initial revision
220
  virtual void moveWallBy();
1128 by Dion Weatherley
Added sphere body functionality.
221
  virtual void moveSphereBodyBy();
901 by whancock
Added a function setWallNormal() to change a planar walls normal vector in simulation
222
  virtual void setWallNormal();
212 by steffen
added applyForceToWall
223
  virtual void applyForceToWall();
260 by slatham
Added recording of timing data for each worker process.
224
  virtual void setParticleVelocity();
257 by steffen
implementation of viscous drag wall ++untested++
225
  virtual void setVelocityOfWall();
101 by steffen
added a funciton to make a particle non-dynamic
226
  virtual void setParticleNonDynamic();
448 by steffen
added setNonRot function
227
  virtual void setParticleNonRot();
881 by steffen
- changed non-rotational / non-dynamic implementation from infinite mass/inertia
228
  virtual void setParticleNonTrans();
802 by steffen
- added setParticleDensity (only NRot so far)
229
  virtual void setParticleDensity();
840 by dion
Added setTaggedParticleVelocity(..) to dublin branch
230
  virtual void setTaggedParticleVel();
249 by steffen
rougher faults in SplitBlock3D
231
  virtual void tagParticleNearestTo();
335 by steffen
implemented moving trimesh nodes around
232
  virtual void moveSingleNode();
233
  virtual void moveTaggedNodes();
816 by steffen
Added missing mesh functions from trunk_premerge_stable
234
  virtual void translateMeshBy(const std::string &meshName, const Vec3 &translation);
2 by steffen
Initial revision
235
236
  virtual void sendDataToMaster();
237
  virtual void countParticles();
238
239
  virtual void printStruct();
240
  virtual void printData();
241
  virtual void printTimes();
242
243
  //-- "new" field functions --
244
  virtual void addScalarParticleField();
245
  virtual void addVectorParticleField();
62 by steffen
egs_friction_branch merged
246
  virtual void addScalarInteractionField();
1129 by Steffen Abe
Changes to console. console messages are now written to one file per process and can be merged by the python script provided in Tools/MergeLog. Other changes:
247
  virtual void addScalarHistoryInteractionField();
369 by steffen
added vector-valued fields on interactions to saver infrastructure
248
  virtual void addVectorInteractionField();
421 by steffen
saving scalar fields on triangles
249
  virtual void addScalarTriangleField();
413 by steffen
added some parts to save vector data from triangles
250
  virtual void addVectorTriangleField();
3 by steffen
updated field functions
251
  virtual void sendFieldData();
711 by steffen
some more work on wall fields - compiles, but does nothing
252
  virtual void addVectorWallField();
2 by steffen
Initial revision
253
549 by steffen
started adding functions for getting reference IDs and mesh data
254
  // -- checkpointing --
805 by steffen
- beginning of separation checkpointing / snapshots
255
  virtual void saveSnapShotData(std::ostream &oStream);
162 by slatham
Further check-point implementation.
256
  virtual void saveCheckPointData(std::ostream &oStream);
257
  virtual void loadCheckPointData(std::istream &iStream);
258
  
549 by steffen
started adding functions for getting reference IDs and mesh data
259
  // -- timer --
261 by slatham
Updated implementation of the recording of timing data for each worker process.
260
  virtual void setTimer(MpiWTimers &timers) {m_pTimers = &timers;}
549 by steffen
started adding functions for getting reference IDs and mesh data
261
262
  // -- mesh data exchange --
263
  virtual void getMeshNodeRef();
264
  virtual void getMeshFaceRef();
265
  virtual void getMesh2DStress();
941 by vboros
Rotational Thermal Merge
266
  virtual void getTriMeshForce();
596 by slatham
Further implementation of WavePropagation sim.
267
  virtual void getParticleData(const IdVector &particleIdVector);
2 by steffen
Initial revision
268
};
269
516 by slatham
Replaced std::cout statements with console.Debug() and console.Error() statements.
270
#include "Parallel/SubLattice.hpp"
2 by steffen
Initial revision
271
272
#endif