MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
cell-mappings
ComputeMomentumMapping.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_COMPUTEMOMENTUMMAPPING_H_
6
#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMOMENTUMMAPPING_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
ComputeMomentumMapping
;
15
}
16
}
// namespace coupling
17
24
template
<
class
LinkedCell,
unsigned
int
dim>
class
coupling::cellmappings::ComputeMomentumMapping
{
25
public
:
29
ComputeMomentumMapping
(
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
mdSolverInterface)
30
: _mdSolverInterface(mdSolverInterface), _momentum(0.0), _meanVelocity(0.0), _particleCounter(0) {}
31
33
~ComputeMomentumMapping
() {}
34
38
void
beginCellIteration
() {
39
_momentum =
tarch::la::Vector<dim, double>
(0.0);
40
_meanVelocity =
tarch::la::Vector<dim, double>
(0.0);
41
_particleCounter = 0;
42
}
43
49
void
endCellIteration
() {
50
if
(_particleCounter != 0) {
51
_meanVelocity = (1.0 / ((double)_particleCounter)) * _momentum;
52
_momentum = _mdSolverInterface->getMoleculeMass() * _momentum;
53
}
54
}
55
60
void
handleCell
(LinkedCell& cell) {
61
coupling::interface::MoleculeIterator<LinkedCell, dim>
* it = _mdSolverInterface->getMoleculeIterator(cell);
62
it->
begin
();
63
while
(it->
continueIteration
()) {
64
const
coupling::interface::Molecule<dim>
& wrapper(it->
getConst
());
65
_momentum += wrapper.
getVelocity
();
66
_particleCounter++;
67
68
it->
next
();
69
}
70
delete
it;
71
}
72
76
tarch::la::Vector<dim, double>
getMomentum
()
const
{
return
_momentum; }
77
81
tarch::la::Vector<dim, double>
getMeanVelocity
()
const
{
return
_meanVelocity; }
82
83
private
:
84
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
_mdSolverInterface;
85
tarch::la::Vector<dim, double>
_momentum;
86
tarch::la::Vector<dim, double>
_meanVelocity;
87
unsigned
int
_particleCounter;
88
};
89
#endif
// _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMOMENTUMMAPPING_H_
coupling::cellmappings::ComputeMomentumMapping
This class computes the momentum over certain linked cells.
Definition
ComputeMomentumMapping.h:24
coupling::cellmappings::ComputeMomentumMapping::getMeanVelocity
tarch::la::Vector< dim, double > getMeanVelocity() const
Definition
ComputeMomentumMapping.h:81
coupling::cellmappings::ComputeMomentumMapping::~ComputeMomentumMapping
~ComputeMomentumMapping()
Definition
ComputeMomentumMapping.h:33
coupling::cellmappings::ComputeMomentumMapping::handleCell
void handleCell(LinkedCell &cell)
Definition
ComputeMomentumMapping.h:60
coupling::cellmappings::ComputeMomentumMapping::getMomentum
tarch::la::Vector< dim, double > getMomentum() const
Definition
ComputeMomentumMapping.h:76
coupling::cellmappings::ComputeMomentumMapping::endCellIteration
void endCellIteration()
Definition
ComputeMomentumMapping.h:49
coupling::cellmappings::ComputeMomentumMapping::beginCellIteration
void beginCellIteration()
Definition
ComputeMomentumMapping.h:38
coupling::cellmappings::ComputeMomentumMapping::ComputeMomentumMapping
ComputeMomentumMapping(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition
ComputeMomentumMapping.h:29
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::getConst
virtual const coupling::interface::Molecule< dim > & getConst()=0
coupling::interface::Molecule
interface to access a single molecule in the MD simulation.
Definition
Molecule.h:23
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