MaMiCo 1.2
Loading...
Searching...
No Matches
ComputeAvgForceAndVelocity.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_COMPUTEAVGFORCEANDVELOCITY_H_
6#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEAVGFORCEANDVELOCITY_H_
7
8#include "coupling/interface/MDSolverInterface.h"
9#include <iostream>
10
11namespace coupling {
12namespace cellmappings {
13template <class LinkedCell, unsigned int dim> class ComputeAvgForceAndVelocity;
14}
15} // namespace coupling
16
26template <class LinkedCell, unsigned int dim> class coupling::cellmappings::ComputeAvgForceAndVelocity {
27public:
32 : _mdSolverInterface(mdSolverInterface), _force(0.0), _velocity(0.0), _particleCounter(0) {}
33
36
41 _particleCounter = 0;
43 _velocity = tarch::la::Vector<dim, double>(0.0);
44 }
45
51 if (_particleCounter != 0) {
52 _force = (1.0 / _particleCounter) * _force;
53 _velocity = (1.0 / _particleCounter) * _velocity;
54 }
55 }
56
61 void handleCell(LinkedCell& cell) {
62 coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
63 it->begin();
64 while (it->continueIteration()) {
66 _particleCounter++;
67 _force = _force + wrapper.getForce();
68 _velocity = _velocity + wrapper.getVelocity();
69 it->next();
70 }
71 delete it;
72 }
73
78
82 tarch::la::Vector<dim, double> getAvgVelocity() const { return _velocity; }
83
84private:
88 unsigned int _particleCounter;
89};
90#endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEAVGFORCEANDVELOCITY_H_
This class sums up all force/velocity vectors and counts molecules inside a linked cell.
Definition ComputeAvgForceAndVelocity.h:26
~ComputeAvgForceAndVelocity()
Definition ComputeAvgForceAndVelocity.h:35
tarch::la::Vector< dim, double > getAvgVelocity() const
Definition ComputeAvgForceAndVelocity.h:82
void beginCellIteration()
Definition ComputeAvgForceAndVelocity.h:40
tarch::la::Vector< dim, double > getAvgForce() const
Definition ComputeAvgForceAndVelocity.h:77
void handleCell(LinkedCell &cell)
Definition ComputeAvgForceAndVelocity.h:61
void endCellIteration()
Definition ComputeAvgForceAndVelocity.h:50
ComputeAvgForceAndVelocity(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition ComputeAvgForceAndVelocity.h:31
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 coupling::interface::Molecule< dim > & get()=0
interface to access a single molecule in the MD simulation.
Definition Molecule.h:23
virtual tarch::la::Vector< dim, double > getVelocity() const =0
virtual tarch::la::Vector< dim, double > getForce() const =0
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15