Dispatches a subscribed force through a non-owning type-erased view. More...
#include <ForceManager.h>
Public Member Functions | |
| template<typename ForceType > | |
| ForceView (ForceType *inputForce) | |
| Constructs a view over a concrete force object. | |
| bool | supportsPBC (const PBC pbc) const |
| Reports whether the viewed force supports a periodic-boundary mode. | |
| void | initialize (const int numAtoms, const std::vector< double > &boxDimensions) |
| Initializes the viewed force for an atom count and periodic box. | |
| void | clear (const bool calcEnergy=true, const bool calcVirial=true) |
| Clears forces and requested output through the concrete interface. | |
| void | calcForce (const float4 *xyzq, const bool calcEnergy, const bool calcVirial) |
| Computes the viewed force for a device coordinate-charge array. | |
| void | setBoxDimensions (const std::vector< double > &boxDimensions) |
| Updates the viewed force's box dimensions. | |
| std::shared_ptr< Force< long long int > > | getForce (void) |
| Returns the viewed force's fixed-point force storage. | |
| std::shared_ptr< CudaEnergyVirial > | getEnergyVirial (void) const |
| Returns the viewed force's energy and virial storage. | |
| bool | contributesVirial (void) const |
| Reports whether the viewed force contributes a virial. | |
| bool | requiresVirialCalculation (void) const |
Dispatches a subscribed force through a non-owning type-erased view.
ForceManager uses this helper to invoke a force implementation without requiring a common virtual base class. The view stores a raw pointer to the supplied object together with function pointers generated from ForceType. It does not own the force.
A force accepted by this view must provide:
static constexpr bool contributesVirial;initialize(int, const std::vector<double> &);clear();calcForce(const float4 *, const bool, const bool);setBoxDimensions(const std::vector<double> &);getForce() returning std::shared_ptr<Force<long long int>>; andgetEnergyVirial() returning std::shared_ptr<CudaEnergyVirial>.A force may additionally provide supportsPBC(PBC) returning a value convertible to bool. When the operation is absent, the view treats the forces as compatible with every valid PBC value.
Optional static constexpr bool computesVirial = true declares that calcForce() supplies the complete virial tensor. Such a force participates in aggregation but skips manager-side force conversion and reconstruction. The absent trait defaults to false, preserving existing force behavior.
Optional clear(const bool calcEnergy, const bool calcVirial) clears the forces and only requested energy/virial outputs. Without it, the original clear() is used.
ForceManager preserves the pointee lifetime while a force is subscribed by retaining a shared owner in its parallel subscription state.
ForceView does not validate or extend the pointee lifetime. Destroying or moving the pointee while the view remains in use leaves the view invalid.
|
inline |
Constructs a view over a concrete force object.
The constructor captures ForceType's compile-time virial trait and creates dispatch functions for the required force interface. No data is copied from the force and no ownership is acquired.
| ForceType | Concrete subscribed-force implementation satisfying the interface documented for ForceView. |
| [in] | inputForce | Borrowed non-null pointer to the force. The pointee must remain alive and at the same address for every subsequent operation on this view. |
inputForce is non-null. ForceType satisfies the required subscribed-force interface.
|
inline |
Computes the viewed force for a device coordinate-charge array.
| [in] | xyzq | Borrowed device pointer to at least numAtoms float4 records in [x, y, z, charge] order. Coordinates are in angstroms and charge is in elementary-charge units. The pointer must remain valid until the viewed force has completed its CUDA work. |
| [in] | calcEnergy | Whether to update the viewed force's energy state. |
| [in] | calcVirial | Whether to update the viewed force's virial state. |
ForceType::calcForce().
|
inline |
Clears forces and requested output through the concrete interface.
If selective clearing is supported, false flags preserve stale output. Otherwise this calls the original unconditional ForceType::clear(). Default arguments retain unconditional standalone clearing.
|
inline |
Reports whether the viewed force contributes a virial.
ForceType::contributesVirial captured when the view was constructed.
|
inline |
Returns the viewed force's energy and virial storage.
CudaEnergyVirial object returned by ForceType::getEnergyVirial().
|
inline |
Returns the viewed force's fixed-point force storage.
Force<long long int> object returned by ForceType::getForce(). Its device array uses structure-of-arrays component layout with the object's reported stride.
|
inline |
Initializes the viewed force for an atom count and periodic box.
| [in] | numAtoms | Number of atoms represented by subsequent coordinate and force arrays. |
| [in] | boxDimensions | Three box lengths in [x, y, z] order, in angstroms. |
ForceType::initialize().
|
inline |
Reports whether the manager must construct this force's virial.
|
inline |
Updates the viewed force's box dimensions.
| [in] | boxDimensions | Three box lengths in [x, y, z] order, in angstroms. |
ForceType::setBoxDimensions().
|
inline |
Reports whether the viewed force supports a periodic-boundary mode.
| [in] | pbc | Periodic-boundary mode proposed by ForceManager. |
ForceType::supportsPBC(pbc) when that expression is well-formed and convertible to bool; otherwise true.ForceManager separately validates that pbc is a named PBC enumerator.