@@ -87,7 +87,7 @@ class PYBIND11_EXPORT ForceComposite : public MolecularForceCompute
8787
8888#ifdef ENABLE_MPI
8989 // ! Get ghost particle fields requested by this pair potential
90- virtual CommFlags getRequestedCommFlags (uint64_t timestep);
90+ CommFlags getRequestedCommFlags (uint64_t timestep) override ;
9191#endif
9292
9393 // / Update the constituent particles of a composite particle using the position, velocity
@@ -199,6 +199,56 @@ class PYBIND11_EXPORT ForceComposite : public MolecularForceCompute
199199 return m_n_free_particles_global;
200200 }
201201
202+ // / Get constituent particle types per type id
203+ const GPUArray<unsigned int >& getBodyTypes () const
204+ {
205+ return m_body_types;
206+ }
207+
208+ // / Get constituent particle offsets per type id
209+ const GPUArray<Scalar3>& getBodyOffsets () const
210+ {
211+ return m_body_pos;
212+ }
213+
214+ // / Get constituent particle orientations per type id
215+ const GPUArray<Scalar4>& getBodyOrientations () const
216+ {
217+ return m_body_orientation;
218+ }
219+
220+ // / Get length of body per type id
221+ const GPUArray<unsigned int >& getBodyLengths () const
222+ {
223+ return m_body_len;
224+ }
225+
226+ // / Get body parameter indexer
227+ const Index2D& getBodyIndexer ()
228+ {
229+ return m_body_idx;
230+ }
231+
232+ // ! Get rigid centers
233+ GPUVector<unsigned int >& getRigidCenters ()
234+ {
235+ checkParticlesSorted ();
236+ return m_rigid_center;
237+ }
238+
239+ // ! Get lookup centers
240+ GPUVector<unsigned int >& getLookupCenters ()
241+ {
242+ checkParticlesSorted ();
243+ return m_lookup_center;
244+ }
245+
246+ // ! Get number of local rigid bodies
247+ const unsigned int getNLocal () const
248+ {
249+ return m_n_rigid;
250+ }
251+
202252 protected:
203253 bool m_bodies_changed; // !< True if constituent particles have changed
204254 bool m_particles_added_removed; // !< True if particles have been added or removed
@@ -216,6 +266,10 @@ class PYBIND11_EXPORT ForceComposite : public MolecularForceCompute
216266 std::vector<Scalar> m_d_max; // !< Maximum body diameter per constituent particle type
217267 std::vector<bool > m_d_max_changed; // !< True if maximum body diameter changed (per type)
218268
269+ unsigned int m_n_rigid; // !< Number of rigid bodies on the local rank.
270+ GPUVector<unsigned int > m_rigid_center; // !< Local particle indices of all central particles
271+ GPUVector<unsigned int > m_lookup_center; // !< Lookup particle index -> central particle index
272+
219273#ifdef ENABLE_MPI
220274 // / The system's communicator.
221275 std::shared_ptr<Communicator> m_comm;
@@ -227,11 +281,26 @@ class PYBIND11_EXPORT ForceComposite : public MolecularForceCompute
227281 m_particles_added_removed = true ;
228282 }
229283
284+ // ! Helper function to check if particles have been sorted and rebuild indices if necessary
285+ void checkParticlesSorted () override
286+ {
287+ if (m_rebuild_molecules)
288+ // identify center particles for use in GPU kernel
289+ findRigidCenters ();
290+
291+ // Must be called second since the method sets m_rebuild_molecules
292+ // to false if it is true.
293+ MolecularForceCompute::checkParticlesSorted ();
294+ }
295+
296+ // ! Helper kernel to sort rigid bodies by their center particles
297+ virtual void findRigidCenters ();
298+
230299 // / Return the requested minimum ghost layer width for a body's central particle.
231300 virtual Scalar requestBodyGhostLayerWidth (unsigned int type, Scalar* h_r_ghost);
232301
233302 // ! Compute the forces and torques on the central particle
234- virtual void computeForces (uint64_t timestep);
303+ void computeForces (uint64_t timestep) override ;
235304 };
236305
237306 } // end namespace md
0 commit comments