MaMiCo 1.2
Loading...
Searching...
No Matches
ComputeKineticEnergyMapping.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_COMPUTEKINETICENERGYMAPPING_H_
6#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEKINETICENERGYMAPPING_H_
7
8#include "coupling/interface/MDSolverInterface.h"
9#include "coupling/interface/Molecule.h"
10#include <iostream>
11#include <list>
12
13namespace coupling {
14namespace cellmappings {
15template <class LinkedCell, unsigned int dim> class ComputeKineticEnergyMapping;
16}
17} // namespace coupling
18
25template <class LinkedCell, unsigned int dim> class coupling::cellmappings::ComputeKineticEnergyMapping {
26public:
31 : _mdSolverInterface(mdSolverInterface), _kineticEnergy(0.0) {}
32
35
38 void beginCellIteration() { _kineticEnergy = 0.0; }
39
43 void endCellIteration() { _kineticEnergy = 0.5 * _mdSolverInterface->getMoleculeMass() * _kineticEnergy; }
44
48 void handleCell(LinkedCell& cell) {
49
50 coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
51 it->begin();
52 while (it->continueIteration()) {
53 const coupling::interface::Molecule<dim>& wrapper(it->getConst());
54 _kineticEnergy += tarch::la::dot(wrapper.getVelocity(), wrapper.getVelocity());
55
56 it->next();
57 }
58 delete it;
59 }
60
64 double getKineticEnergy() const { return _kineticEnergy; }
65
66private:
68 double _kineticEnergy;
69};
70#endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEKINETICENERGYMAPPING_H_
This class computes the kinetic energy. inside a linked cell.
Definition ComputeKineticEnergyMapping.h:25
void handleCell(LinkedCell &cell)
Definition ComputeKineticEnergyMapping.h:48
void endCellIteration()
Definition ComputeKineticEnergyMapping.h:43
ComputeKineticEnergyMapping(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition ComputeKineticEnergyMapping.h:30
~ComputeKineticEnergyMapping()
Definition ComputeKineticEnergyMapping.h:34
void beginCellIteration()
Definition ComputeKineticEnergyMapping.h:38
double getKineticEnergy() const
Definition ComputeKineticEnergyMapping.h:64
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 tarch::la::Vector< dim, double > getVelocity() const =0
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15