LCOV - code coverage report
Current view: top level - coupling/cell-mappings - ComputeMassMapping.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 17 11.8 %
Date: 2025-06-25 11:26:37 Functions: 0 2 0.0 %

          Line data    Source code
       1             : // Copyright (C) 2015 Technische Universitaet Muenchen
       2             : // This file is part of the Mamico project. For conditions of distribution
       3             : // and use, please see the copyright notice in Mamico's main folder, or at
       4             : // www5.in.tum.de/mamico
       5             : #ifndef _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMASSMAPPING_H_
       6             : #define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMASSMAPPING_H_
       7             : 
       8             : #include "coupling/interface/MDSolverInterface.h"
       9             : #include <iostream>
      10             : 
      11             : namespace coupling {
      12             : namespace cellmappings {
      13             : template <class LinkedCell, unsigned int dim> class ComputeMassMapping;
      14             : }
      15             : } // namespace coupling
      16             : 
      17             : /**
      18             :  *      @brief This class computes the mass over certain linked cells.
      19             :  *      @tparam LinkedCell cell type
      20             :  *      @tparam dim Number of dimensions; it can be 1, 2 or 3
      21             :  *  @author Philipp Neumann
      22             :  */
      23             : template <class LinkedCell, unsigned int dim> class coupling::cellmappings::ComputeMassMapping {
      24             : public:
      25             :   /** Constructor
      26             :    *    @param mdSolverInterface
      27             :    */
      28           8 :   ComputeMassMapping(coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface)
      29           8 :       : _mdSolverInterface(mdSolverInterface), _mass(0.0), _particleCounter(0) {}
      30             : 
      31             :   /** Destructor */
      32           0 :   ~ComputeMassMapping() {}
      33             : 
      34             :   /** sets the mass and the particlee counter to zero, before the iteration
      35             :    * process begins.
      36             :    */
      37           0 :   void beginCellIteration() {
      38           0 :     _mass = 0.0;
      39           0 :     _particleCounter = 0;
      40             :   }
      41             : 
      42             :   /** computes the mass in a linked cell, by multiplying the number of particles
      43             :    * inside the cell with the particel mass(which is assuemd to be constant).
      44             :    */
      45           0 :   void endCellIteration() { _mass = _mdSolverInterface->getMoleculeMass() * _particleCounter; }
      46             : 
      47             :   /** counts the molecules inside a linked cell.
      48             :    *    @param cell
      49             :    */
      50           0 :   void handleCell(LinkedCell& cell) {
      51           0 :     coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
      52           0 :     it->begin();
      53           0 :     while (it->continueIteration()) {
      54           0 :       _particleCounter++;
      55           0 :       it->next();
      56             :     }
      57           0 :     delete it;
      58           0 :   }
      59             : 
      60             :   /** returns the mass inside a linked cell
      61             :    *    @return _mass
      62             :    */
      63           0 :   double getMass() const { return _mass; }
      64             :   /** returns the number of particles inside a linked cell
      65             :    *    @return _particleCounter
      66             :    */
      67           0 :   unsigned int getNumberOfParticles() const { return _particleCounter; }
      68             : 
      69             : private:
      70             :   coupling::interface::MDSolverInterface<LinkedCell, dim>* const _mdSolverInterface;
      71             :   double _mass;
      72             :   unsigned int _particleCounter;
      73             : };
      74             : #endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMASSMAPPING_H_

Generated by: LCOV version 1.14