LCOV - code coverage report
Current view: top level - coupling/cell-mappings - VTKMoleculePlotter.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 22 0.0 %
Date: 2025-06-25 11:26:37 Functions: 0 1 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_VTKMOLECULEPLOTTER_H_
       6             : #define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_VTKMOLECULEPLOTTER_H_
       7             : 
       8             : #include "coupling/interface/MDSolverInterface.h"
       9             : #include "coupling/interface/Molecule.h"
      10             : #include <iostream>
      11             : #include <sstream>
      12             : 
      13             : namespace coupling {
      14             : namespace cellmappings {
      15             : template <class LinkedCell, unsigned int dim> class VTKMoleculePlotter;
      16             : }
      17             : } // namespace coupling
      18             : 
      19             : /**
      20             :  *      @brief This class writes molecule data to streams for .vtk file.
      21             :  *      @tparam LinkedCell cell type
      22             :  *      @tparam dim Number of dimensions; it can be 1, 2 or 3
      23             :  *  @author Philipp Neumann
      24             :  */
      25             : template <class LinkedCell, unsigned int dim> class coupling::cellmappings::VTKMoleculePlotter {
      26             : public:
      27             :   /** Constructor
      28             :    *    @param moleculeVelocities
      29             :    *    @param moleculePositions
      30             :    *    @param moleculePotentials
      31             :    *    @param appendFloatZeros
      32             :    *    @param mdSolverInterface
      33             :    */
      34           0 :   VTKMoleculePlotter(std::stringstream& moleculeVelocities, std::stringstream& moleculePositions, std::stringstream& moleculePotentials,
      35             :                      const std::string& appendFloatZeros, coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface)
      36           0 :       : _mdSolverInterface(mdSolverInterface), _moleculeVelocities(moleculeVelocities), _moleculePositions(moleculePositions),
      37           0 :         _moleculePotentials(moleculePotentials), _appendFloatZeros(appendFloatZeros), _particleCounter(0) {}
      38             : 
      39             :   /** Destructor */
      40           0 :   ~VTKMoleculePlotter() {}
      41             : 
      42             :   /** sets the particle counter to zero, before the iteration process begins.
      43             :    */
      44           0 :   void beginCellIteration() { _particleCounter = 0; }
      45             : 
      46             :   /** empty function
      47             :    */
      48             :   void endCellIteration() {}
      49             : 
      50             :   /** writes molecule data to the corresponding stringstreams.
      51             :    *    @param cell
      52             :    */
      53           0 :   void handleCell(LinkedCell& cell) {
      54           0 :     coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
      55           0 :     it->begin();
      56           0 :     while (it->continueIteration()) {
      57           0 :       const coupling::interface::Molecule<dim>& wrapper(it->getConst());
      58           0 :       const tarch::la::Vector<dim, double> position = wrapper.getPosition();
      59           0 :       const tarch::la::Vector<dim, double> velocity = wrapper.getVelocity();
      60             :       // std::cout << "Touch molecule " << position << std::endl;
      61           0 :       for (unsigned int d = 0; d < dim; d++) {
      62           0 :         _moleculePositions << position[d] << " ";
      63           0 :         _moleculeVelocities << velocity[d] << " ";
      64             :       }
      65           0 :       _moleculePositions << _appendFloatZeros << std::endl;
      66           0 :       _moleculeVelocities << _appendFloatZeros << std::endl;
      67           0 :       _moleculePotentials << wrapper.getPotentialEnergy() << std::endl;
      68             : 
      69           0 :       _particleCounter++;
      70           0 :       it->next();
      71             :     }
      72           0 :     delete it;
      73           0 :   }
      74             : 
      75             :   /** returns number if the particles
      76             :    *    @return _particleCounter
      77             :    */
      78             :   const unsigned int& getParticleCounter() const { return _particleCounter; }
      79             : 
      80             : private:
      81             :   coupling::interface::MDSolverInterface<LinkedCell, dim>* const _mdSolverInterface;
      82             :   std::stringstream& _moleculeVelocities;
      83             :   std::stringstream& _moleculePositions;
      84             :   std::stringstream& _moleculePotentials;
      85             :   const std::string& _appendFloatZeros;
      86             :   unsigned int _particleCounter;
      87             : };
      88             : #endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_VTKMOLECULEPLOTTER_H_

Generated by: LCOV version 1.14