Dispatches a subscribed force through a non-owning type-erased view.
More...
#include <ForceManager.h>
|
| template<typename ForceType > |
| | ForceView (ForceType *inputForce) |
| | Constructs a view over a concrete force object.
|
| |
| void | initialize (const int numAtoms, const std::vector< double > &boxDimensions) |
| | Initializes the viewed force for an atom count and periodic box.
|
| |
| void | clear (void) |
| | Clears the viewed force's accumulated output.
|
| |
| 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.
|
| |
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:
ForceManager preserves the pointee lifetime while a force is subscribed by retaining a shared owner in its parallel subscription state.
- Warning
- A standalone
ForceView does not validate or extend the pointee lifetime. Destroying or moving the pointee while the view remains in use leaves the view invalid.
-
This helper and the object it dispatches provide no internal synchronization for concurrent host access.
◆ ForceView()
template<typename ForceType >
| ForceView::ForceView |
( |
ForceType * |
inputForce | ) |
|
|
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.
- Template Parameters
-
| ForceType | Concrete subscribed-force implementation satisfying the interface documented for ForceView. |
- Parameters
-
| [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. |
- Precondition
inputForce is non-null.
-
ForceType satisfies the required subscribed-force interface.
◆ calcForce()
| void ForceView::calcForce |
( |
const float4 * |
xyzq, |
|
|
const bool |
calcEnergy, |
|
|
const bool |
calcVirial |
|
) |
| |
|
inline |
Computes the viewed force for a device coordinate-charge array.
- Parameters
-
| [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. |
- Precondition
- The borrowed force pointer remains valid.
-
The force has been initialized for the supplied array.
- Note
- CUDA launch and synchronization behavior is defined by
ForceType::calcForce().
◆ clear()
| void ForceView::clear |
( |
void |
| ) |
|
|
inline |
Clears the viewed force's accumulated output.
- Precondition
- The borrowed force pointer remains valid.
- Note
- CUDA stream and synchronization behavior is defined by
ForceType::clear().
◆ contributesVirial()
| bool ForceView::contributesVirial |
( |
void |
| ) |
const |
|
inline |
Reports whether the viewed force contributes a virial.
- Returns
- The value of
ForceType::contributesVirial captured when the view was constructed.
◆ getEnergyVirial()
| std::shared_ptr< CudaEnergyVirial > ForceView::getEnergyVirial |
( |
void |
| ) |
const |
|
inline |
Returns the viewed force's energy and virial storage.
- Returns
- A copied shared owner of the
CudaEnergyVirial object returned by ForceType::getEnergyVirial().
- Precondition
- The borrowed force pointer remains valid.
◆ getForce()
| std::shared_ptr< Force< long long int > > ForceView::getForce |
( |
void |
| ) |
|
|
inline |
Returns the viewed force's fixed-point force storage.
- Returns
- A copied shared owner of the
Force<long long int> object returned by ForceType::getForce(). Its device array uses structure-of-arrays component layout with the object's reported stride.
- Precondition
- The borrowed force pointer remains valid.
◆ initialize()
| void ForceView::initialize |
( |
const int |
numAtoms, |
|
|
const std::vector< double > & |
boxDimensions |
|
) |
| |
|
inline |
Initializes the viewed force for an atom count and periodic box.
- Parameters
-
| [in] | numAtoms | Number of atoms represented by subsequent coordinate and force arrays. |
| [in] | boxDimensions | Three box lengths in [x, y, z] order, in angstroms. |
- Precondition
- The borrowed force pointer remains valid.
- Note
- All validation, allocation, host-to-device transfer, and synchronization behavior is defined by
ForceType::initialize().
◆ setBoxDimensions()
| void ForceView::setBoxDimensions |
( |
const std::vector< double > & |
boxDimensions | ) |
|
|
inline |
Updates the viewed force's box dimensions.
- Parameters
-
| [in] | boxDimensions | Three box lengths in [x, y, z] order, in angstroms. |
- Precondition
- The borrowed force pointer remains valid.
- Note
- Validation, transfer, and synchronization behavior is defined by
ForceType::setBoxDimensions().