Task: CustomCVForce avoids breaking up molecules (openmm/openmm#3711)

org: openmm
repo: openmm
pr_number: 3711
issue_title: CustomCVForce avoids breaking up molecules
issue_body: This might or might not be the fix for https://github.com/openmm/openmm-ml/issues/36.  Each Force object reports what atoms it creates bonds between, so all the atoms in a molecule are translated together when applying periodic boundary conditions.  CustomCVForce did not propagate the bond specifications from the Forces it contained.

This only applied to output when calling `getState()` with `enforcePeriodicBox=true`.  There's a different mechanism used to identify molecules when internally translating positions to preserve accuracy.  That mechanism was handled correctly, so it never broke up molecules during normal integration.  It only happened when returning output from `getState()`.

cc @dominicrufa
resolved_issues: title: CustomCVForce avoids breaking up molecules
body: ### Issue Description

**Problem:**  
When using `CustomCVForce` in simulations with periodic boundary conditions, molecules may be incorrectly split across boundaries when retrieving the system state via the `getState()` method with `enforcePeriodicBox=true`. This occurs because `CustomCVForce` does not propagate bond information from the forces it contains, which is necessary to ensure that all atoms within a molecule are translated together during boundary enforcement. Although this issue does not affect the accuracy of position translations during integration, it results in incorrect output for the system state under certain conditions.

**Expected Behavior:**  
When `getState()` is called with `enforcePeriodicBox=true`, molecules should remain intact and their constituent atoms should be translated together across periodic boundaries. This behavior should align with the correct handling of molecule integrity during normal integration.

## IMPORTANT INSTRUCTIONS

1. If you edit a python file, you MUST run 'make PythonInstall' inside the build directory
2. If you edit a c++ file, you MUST run 'make -j4 && make install" inside the build directory

Reference solution:
fix_patch: diff --git a/openmmapi/include/openmm/internal/CustomCVForceImpl.h b/openmmapi/include/openmm/internal/CustomCVForceImpl.h
index c0372114d6..01e69a8b45 100644
--- a/openmmapi/include/openmm/internal/CustomCVForceImpl.h
+++ b/openmmapi/include/openmm/internal/CustomCVForceImpl.h
@@ -9,7 +9,7 @@
  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
  *                                                                            *
- * Portions copyright (c) 2008-2017 Stanford University and the Authors.      *
+ * Portions copyright (c) 2008-2022 Stanford University and the Authors.      *
  * Authors: Peter Eastman                                                     *
  * Contributors:                                                              *
  *                                                                            *
@@ -62,6 +62,7 @@ class OPENMM_EXPORT CustomCVForceImpl : public ForceImpl {
     double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups);
     std::map<std::string, double> getDefaultParameters();
     std::vector<std::string> getKernelNames();
+    std::vector<std::pair<int, int> > getBondedParticles() const;
     void getCollectiveVariableValues(ContextImpl& context, std::vector<double>& values);
     Context& getInnerContext();
     void updateParametersInContext(ContextImpl& context);
diff --git a/openmmapi/src/CustomCVForceImpl.cpp b/openmmapi/src/CustomCVForceImpl.cpp
index 31c6930830..d980c0625d 100644
--- a/openmmapi/src/CustomCVForceImpl.cpp
+++ b/openmmapi/src/CustomCVForceImpl.cpp
@@ -6,7 +6,7 @@
  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
  *                                                                            *
- * Portions copyright (c) 2008-2017 Stanford University and the Authors.      *
+ * Portions copyright (c) 2008-2022 Stanford University and the Authors.      *
  * Authors: Peter Eastman                                                     *
  * Contributors:                                                              *
  *                                                                            *
@@ -91,6 +91,16 @@ vector<string> CustomCVForceImpl::getKernelNames() {
     return names;
 }
 
+vector<pair<int, int> > CustomCVForceImpl::getBondedParticles() const {
+    vector<pair<int, int> > bonds;
+    const ContextImpl& innerContextImpl = getContextImpl(*innerContext);
+    for (auto& impl : innerContextImpl.getForceImpls()) {
+        for (auto& bond : impl->getBondedParticles())
+            bonds.push_back(bond);
+    }
+    return bonds;
+}
+
 map<string, double> CustomCVForceImpl::getDefaultParameters() {
     map<string, double> parameters;
     parameters.insert(innerContext->getParameters().begin(), innerContext->getParameters().end());