Expand signatures for nblib listed forces calculator
[alexxy/gromacs.git] / api / nblib / listed_forces / calculator.h
index 7017862aa690dcb98a09608e82dc3b9d53df2101..70097bf35a324c4cb0ae8b4c270e11acf1275f0b 100644 (file)
@@ -65,7 +65,7 @@ namespace nblib
 class Box;
 class PbcHolder;
 template<class T>
-class ForceBuffer;
+class ForceBufferProxy;
 
 /*! \internal \brief Object to calculate forces and energies of listed forces
  *
@@ -90,15 +90,22 @@ public:
      * 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
@@ -107,9 +114,6 @@ public:
 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_;
 
@@ -117,13 +121,20 @@ private:
     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