MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
cell-mappings
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
12
namespace
coupling
{
13
namespace
cellmappings {
14
template
<
class
LinkedCell,
unsigned
int
dim>
class
SetMomentumMapping
;
15
}
16
}
// namespace coupling
17
24
template
<
class
LinkedCell,
unsigned
int
dim>
class
coupling::cellmappings::SetMomentumMapping
{
25
public
:
34
SetMomentumMapping
(
const
tarch::la::Vector<dim, double>
& oldMomentum,
const
tarch::la::Vector<dim, double>
& newMomentum,
const
unsigned
int
& numberParticles,
35
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
mdSolverInterface)
36
: _mdSolverInterface(mdSolverInterface), _oldVelocity(
getVelocity
(numberParticles, oldMomentum)),
37
_newVelocity(
getVelocity
(numberParticles, newMomentum)) {}
38
40
~SetMomentumMapping
() {}
41
44
void
beginCellIteration
() {}
45
48
void
endCellIteration
() {}
49
54
void
handleCell
(LinkedCell& cell) {
55
coupling::interface::MoleculeIterator<LinkedCell, dim>
* it = _mdSolverInterface->getMoleculeIterator(cell);
56
it->
begin
();
57
while
(it->
continueIteration
()) {
58
coupling::interface::Molecule<dim>
& wrapper(it->
get
());
59
tarch::la::Vector<dim, double>
velocity = wrapper.
getVelocity
();
60
velocity = velocity - _oldVelocity + _newVelocity;
61
wrapper.
setVelocity
(velocity);
62
63
it->
next
();
64
}
65
delete
it;
66
}
67
68
private
:
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
{
78
return
tarch::la::Vector<dim, double>
(0.0);
79
}
80
}
81
82
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
_mdSolverInterface;
83
tarch::la::Vector<dim, double>
_oldVelocity;
84
tarch::la::Vector<dim, double>
_newVelocity;
85
};
86
#endif
// _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETMOMENTUMMAPPING_H_
coupling::cellmappings::SetMomentumMapping
This class sets a certain momentum over several linked cells.
Definition
SetMomentumMapping.h:24
coupling::cellmappings::SetMomentumMapping::beginCellIteration
void beginCellIteration()
Definition
SetMomentumMapping.h:44
coupling::cellmappings::SetMomentumMapping::SetMomentumMapping
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
coupling::cellmappings::SetMomentumMapping::handleCell
void handleCell(LinkedCell &cell)
Definition
SetMomentumMapping.h:54
coupling::cellmappings::SetMomentumMapping::~SetMomentumMapping
~SetMomentumMapping()
Definition
SetMomentumMapping.h:40
coupling::cellmappings::SetMomentumMapping::endCellIteration
void endCellIteration()
Definition
SetMomentumMapping.h:48
coupling::cellmappings::SetMomentumMapping::getVelocity
tarch::la::Vector< dim, double > getVelocity(const unsigned int &numberParticles, const tarch::la::Vector< dim, double > &momentum) const
Definition
SetMomentumMapping.h:74
coupling::interface::MDSolverInterface
interface to the MD simulation
Definition
MDSolverInterface.h:25
coupling::interface::MoleculeIterator
some iterator scheme for traversing the molecules within a linked cell.
Definition
MoleculeIterator.h:24
coupling::interface::MoleculeIterator::continueIteration
virtual bool continueIteration() const =0
coupling::interface::MoleculeIterator::next
virtual void next()=0
coupling::interface::MoleculeIterator::begin
virtual void begin()=0
coupling::interface::MoleculeIterator::get
virtual coupling::interface::Molecule< dim > & get()=0
coupling::interface::Molecule
interface to access a single molecule in the MD simulation.
Definition
Molecule.h:23
coupling::interface::Molecule::setVelocity
virtual void setVelocity(const tarch::la::Vector< dim, double > &velocity)=0
coupling::interface::Molecule::getVelocity
virtual tarch::la::Vector< dim, double > getVelocity() const =0
tarch::la::Vector
Definition
Vector.h:25
coupling
everything necessary for coupling operations, is defined in here
Definition
AdditiveMomentumInsertion.h:15
Generated by
1.17.0