MaMiCo 1.2
Loading...
Searching...
No Matches
SetMomentumMapping.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_SETMOMENTUMMAPPING_H_
6#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETMOMENTUMMAPPING_H_
7
8#include "coupling/interface/MDSolverInterface.h"
9#include "coupling/interface/Molecule.h"
10#include <iostream>
11
12namespace coupling {
13namespace cellmappings {
14template <class LinkedCell, unsigned int dim> class SetMomentumMapping;
15}
16} // namespace coupling
17
24template <class LinkedCell, unsigned int dim> class coupling::cellmappings::SetMomentumMapping {
25public:
34 SetMomentumMapping(const tarch::la::Vector<dim, double>& oldMomentum, const tarch::la::Vector<dim, double>& newMomentum, const unsigned int& numberParticles,
36 : _mdSolverInterface(mdSolverInterface), _oldVelocity(getVelocity(numberParticles, oldMomentum)),
37 _newVelocity(getVelocity(numberParticles, newMomentum)) {}
38
41
45
49
54 void handleCell(LinkedCell& cell) {
55 coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
56 it->begin();
57 while (it->continueIteration()) {
60 velocity = velocity - _oldVelocity + _newVelocity;
61 wrapper.setVelocity(velocity);
62
63 it->next();
64 }
65 delete it;
66 }
67
68private:
74 tarch::la::Vector<dim, double> getVelocity(const unsigned int& numberParticles, const tarch::la::Vector<dim, double>& momentum) const {
75 if (numberParticles != 0) {
76 return (1.0 / (numberParticles * _mdSolverInterface->getMoleculeMass())) * momentum;
77 } else {
79 }
80 }
81
85};
86#endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETMOMENTUMMAPPING_H_
This class sets a certain momentum over several linked cells.
Definition SetMomentumMapping.h:24
void beginCellIteration()
Definition SetMomentumMapping.h:44
SetMomentumMapping(const tarch::la::Vector< dim, double > &oldMomentum, const tarch::la::Vector< dim, double > &newMomentum, const unsigned int &numberParticles, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition SetMomentumMapping.h:34
void handleCell(LinkedCell &cell)
Definition SetMomentumMapping.h:54
~SetMomentumMapping()
Definition SetMomentumMapping.h:40
void endCellIteration()
Definition SetMomentumMapping.h:48
tarch::la::Vector< dim, double > getVelocity(const unsigned int &numberParticles, const tarch::la::Vector< dim, double > &momentum) const
Definition SetMomentumMapping.h:74
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 void setVelocity(const tarch::la::Vector< dim, double > &velocity)=0
virtual tarch::la::Vector< dim, double > getVelocity() const =0
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15