MaMiCo 1.2
Loading...
Searching...
No Matches
VTKMoleculePlotter.h
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
13namespace coupling {
14namespace cellmappings {
15template <class LinkedCell, unsigned int dim> class VTKMoleculePlotter;
16}
17} // namespace coupling
18
25template <class LinkedCell, unsigned int dim> class coupling::cellmappings::VTKMoleculePlotter {
26public:
34 VTKMoleculePlotter(std::stringstream& moleculeVelocities, std::stringstream& moleculePositions, std::stringstream& moleculePotentials,
35 const std::string& appendFloatZeros, coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface)
36 : _mdSolverInterface(mdSolverInterface), _moleculeVelocities(moleculeVelocities), _moleculePositions(moleculePositions),
37 _moleculePotentials(moleculePotentials), _appendFloatZeros(appendFloatZeros), _particleCounter(0) {}
38
41
44 void beginCellIteration() { _particleCounter = 0; }
45
49
53 void handleCell(LinkedCell& cell) {
54 coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
55 it->begin();
56 while (it->continueIteration()) {
57 const coupling::interface::Molecule<dim>& wrapper(it->getConst());
58 const tarch::la::Vector<dim, double> position = wrapper.getPosition();
59 const tarch::la::Vector<dim, double> velocity = wrapper.getVelocity();
60 // std::cout << "Touch molecule " << position << std::endl;
61 for (unsigned int d = 0; d < dim; d++) {
62 _moleculePositions << position[d] << " ";
63 _moleculeVelocities << velocity[d] << " ";
64 }
65 _moleculePositions << _appendFloatZeros << std::endl;
66 _moleculeVelocities << _appendFloatZeros << std::endl;
67 _moleculePotentials << wrapper.getPotentialEnergy() << std::endl;
68
69 _particleCounter++;
70 it->next();
71 }
72 delete it;
73 }
74
78 const unsigned int& getParticleCounter() const { return _particleCounter; }
79
80private:
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_
This class writes molecule data to streams for .vtk file.
Definition VTKMoleculePlotter.h:25
VTKMoleculePlotter(std::stringstream &moleculeVelocities, std::stringstream &moleculePositions, std::stringstream &moleculePotentials, const std::string &appendFloatZeros, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition VTKMoleculePlotter.h:34
const unsigned int & getParticleCounter() const
Definition VTKMoleculePlotter.h:78
~VTKMoleculePlotter()
Definition VTKMoleculePlotter.h:40
void handleCell(LinkedCell &cell)
Definition VTKMoleculePlotter.h:53
void beginCellIteration()
Definition VTKMoleculePlotter.h:44
void endCellIteration()
Definition VTKMoleculePlotter.h:48
interface to the MD simulation
Definition MDSolverInterface.h:25
some iterator scheme for traversing the molecules within a linked cell.
Definition MoleculeIterator.h:24
virtual bool continueIteration() const =0
virtual const coupling::interface::Molecule< dim > & getConst()=0
interface to access a single molecule in the MD simulation.
Definition Molecule.h:23
virtual double getPotentialEnergy() const =0
virtual tarch::la::Vector< dim, double > getVelocity() const =0
virtual tarch::la::Vector< dim, double > getPosition() const =0
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15