LCOV - code coverage report
Current view: top level - simplemd/molecule-mappings - ConvertForcesFixedToFloatMapping.h Coverage Total Hit
Test: coverage.info Lines: 100.0 % 5 5
Test Date: 2026-08-21 15:14:06 Functions: - 0 0

            Line data    Source code
       1              : #ifndef _MOLECULARDYNAMICS_MOLECULEMAPPINGS_CONVERTFORCES_MAPPING_H_
       2              : #define _MOLECULARDYNAMICS_MOLECULEMAPPINGS_CONVERTFORCES_MAPPING_H_
       3              : 
       4              : #include "tarch/utils/Utils.h"
       5              : 
       6              : namespace simplemd {
       7              : namespace moleculemappings {
       8              : class ConvertForcesFixedToFloatMapping;
       9              : }
      10              : } // namespace simplemd
      11              : 
      12              : /*
      13              :  * fixed-point math for force accumulation
      14              :  * only active in debug mode, useful for verification of simulation results
      15              :  * because results do not depend on order of force summation
      16              :  * this expects forces to contain long int and converts them back into double
      17              :  */
      18              : class simplemd::moleculemappings::ConvertForcesFixedToFloatMapping {
      19              : public:
      20              :   void beginMoleculeIteration() const {}
      21        16500 :   KOKKOS_FUNCTION void handleMolecule(simplemd::Molecule& molecule) const {
      22        16500 :     DEFINE_DECIMAL_FP_LIMITS(6);
      23              : 
      24        16500 :     tarch::la::Vector<MD_DIM, double>& force = molecule.getForce();
      25        66000 :     for (unsigned int d = 0; d < MD_DIM; d++) {
      26        49500 :       force[d] = *(long long*)(&force[d]) * minFP6;
      27              :     }
      28              :   }
      29              :   void endMoleculeIteration() const {}
      30              :   static const bool IsParallel = true;
      31              : };
      32              : 
      33              : #endif // _MOLECULARDYNAMICS_MOLECULEMAPPINGS_CONVERTFORCES_MAPPING_H_
        

Generated by: LCOV version 2.0-1