MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
cell-mappings
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
11
namespace
coupling
{
12
namespace
cellmappings {
13
template
<
class
LinkedCell,
unsigned
int
dim>
class
ComputeAvgForceAndVelocity
;
14
}
15
}
// namespace coupling
16
26
template
<
class
LinkedCell,
unsigned
int
dim>
class
coupling::cellmappings::ComputeAvgForceAndVelocity
{
27
public
:
31
ComputeAvgForceAndVelocity
(
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
mdSolverInterface)
32
: _mdSolverInterface(mdSolverInterface), _force(0.0), _velocity(0.0), _particleCounter(0) {}
33
35
~ComputeAvgForceAndVelocity
() {}
36
40
void
beginCellIteration
() {
41
_particleCounter = 0;
42
_force =
tarch::la::Vector<dim, double>
(0.0);
43
_velocity =
tarch::la::Vector<dim, double>
(0.0);
44
}
45
50
void
endCellIteration
() {
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
()) {
65
coupling::interface::Molecule<dim>
& wrapper(it->
get
());
66
_particleCounter++;
67
_force = _force + wrapper.
getForce
();
68
_velocity = _velocity + wrapper.
getVelocity
();
69
it->
next
();
70
}
71
delete
it;
72
}
73
77
tarch::la::Vector<dim, double>
getAvgForce
()
const
{
return
_force; }
78
82
tarch::la::Vector<dim, double>
getAvgVelocity
()
const
{
return
_velocity; }
83
84
private
:
85
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
_mdSolverInterface;
86
tarch::la::Vector<dim, double>
_force;
87
tarch::la::Vector<dim, double>
_velocity;
88
unsigned
int
_particleCounter;
89
};
90
#endif
// _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEAVGFORCEANDVELOCITY_H_
coupling::cellmappings::ComputeAvgForceAndVelocity
This class sums up all force/velocity vectors and counts molecules inside a linked cell.
Definition
ComputeAvgForceAndVelocity.h:26
coupling::cellmappings::ComputeAvgForceAndVelocity::~ComputeAvgForceAndVelocity
~ComputeAvgForceAndVelocity()
Definition
ComputeAvgForceAndVelocity.h:35
coupling::cellmappings::ComputeAvgForceAndVelocity::getAvgVelocity
tarch::la::Vector< dim, double > getAvgVelocity() const
Definition
ComputeAvgForceAndVelocity.h:82
coupling::cellmappings::ComputeAvgForceAndVelocity::beginCellIteration
void beginCellIteration()
Definition
ComputeAvgForceAndVelocity.h:40
coupling::cellmappings::ComputeAvgForceAndVelocity::getAvgForce
tarch::la::Vector< dim, double > getAvgForce() const
Definition
ComputeAvgForceAndVelocity.h:77
coupling::cellmappings::ComputeAvgForceAndVelocity::handleCell
void handleCell(LinkedCell &cell)
Definition
ComputeAvgForceAndVelocity.h:61
coupling::cellmappings::ComputeAvgForceAndVelocity::endCellIteration
void endCellIteration()
Definition
ComputeAvgForceAndVelocity.h:50
coupling::cellmappings::ComputeAvgForceAndVelocity::ComputeAvgForceAndVelocity
ComputeAvgForceAndVelocity(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition
ComputeAvgForceAndVelocity.h:31
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::getVelocity
virtual tarch::la::Vector< dim, double > getVelocity() const =0
coupling::interface::Molecule::getForce
virtual tarch::la::Vector< dim, double > getForce() 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