class Box;
class PbcHolder;
template<class T>
-class ForceBuffer;
+class ForceBufferProxy;
/*! \internal \brief Object to calculate forces and energies of listed forces
*
* This function also stores the forces and energies from listed interactions in the internal
* buffer of the ListedForceCalculator object
*
- * \param[in] coordinates to be used for the force calculation
- * \param[out] forces buffer to store the output forces
+ * \param[in] coordinates input coordinates for the force calculation
+ * \param[inout] forces output for adding the forces
+ * \param[inout] shiftForces output for adding shift forces
+ * \param[out] energies output for potential energies
+ * \param[in] usePbc whether or not to consider periodic boundary conditions
*/
- void compute(gmx::ArrayRef<const Vec3> coordinates, gmx::ArrayRef<Vec3> forces, bool usePbc = false);
+ void compute(gmx::ArrayRef<const Vec3> coordinates,
+ gmx::ArrayRef<Vec3> forces,
+ gmx::ArrayRef<Vec3> shiftForces,
+ gmx::ArrayRef<real> energies,
+ bool usePbc = false);
- //! \brief Alternative overload with the energies in an output buffer
+ //! \brief Alternative overload without shift forces
void compute(gmx::ArrayRef<const Vec3> coordinates,
gmx::ArrayRef<Vec3> forces,
- EnergyType& energies,
+ gmx::ArrayRef<real> energies,
bool usePbc = false);
//! \brief default, but moved to separate compilation unit
private:
int numThreads;
- //! the main buffer to hold the final listed forces
- std::vector<gmx::RVec> masterForceBuffer_;
-
//! holds the array of energies computed
EnergyType energyBuffer_;
std::vector<ListedInteractionData> threadedInteractions_;
//! reduction force buffers
- std::vector<std::unique_ptr<ForceBuffer<gmx::RVec>>> threadedForceBuffers_;
+ std::vector<ForceBufferProxy<Vec3>> threadedForceBuffers_;
+
+ //! reduction shift force buffers
+ std::vector<std::vector<Vec3>> threadedShiftForceBuffers_;
//! PBC objects
std::unique_ptr<PbcHolder> pbcHolder_;
//! compute listed forces and energies, overwrites the internal buffers
- void computeForcesAndEnergies(gmx::ArrayRef<const Vec3> x, bool usePbc = false);
+ template<class ShiftForce>
+ void computeForcesAndEnergies(gmx::ArrayRef<const Vec3> x,
+ gmx::ArrayRef<Vec3> forces,
+ [[maybe_unused]] gmx::ArrayRef<ShiftForce> shiftForces,
+ bool usePbc = false);
};
} // namespace nblib