MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
cell-mappings
DeleteParticleMapping.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_DELETEPARTICLEMAPPING_H_
6
#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_DELETEPARTICLEMAPPING_H_
7
8
#include "coupling/datastructures/Molecule.h"
9
#include "coupling/interface/MDSolverInterface.h"
10
#include "coupling/interface/Molecule.h"
11
#include <iostream>
12
13
namespace
coupling
{
14
namespace
cellmappings {
15
template
<
class
LinkedCell,
unsigned
int
dim>
class
DeleteParticleMapping
;
16
}
17
}
// namespace coupling
18
25
template
<
class
LinkedCell,
unsigned
int
dim>
class
coupling::cellmappings::DeleteParticleMapping
{
26
public
:
31
DeleteParticleMapping
(
const
unsigned
int
& particle,
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
mdSolverInterface)
32
: _mdSolverInterface(mdSolverInterface), _particle(particle), _particleCounter(0),
33
_deletedMoleculeCopy(
tarch
::la::Vector<dim, double>(0.0),
tarch
::la::Vector<dim, double>(0.0),
tarch
::la::Vector<dim, double>(0.0), 0.0) {}
34
36
~DeleteParticleMapping
() {}
37
40
void
beginCellIteration
() { _particleCounter = 0; }
41
44
void
endCellIteration
() {}
45
51
void
handleCell
(LinkedCell& cell) {
52
// return, if we already deleted the respective particle
53
if
(_particleCounter > _particle) {
54
return
;
55
}
56
57
// otherwise: loop over particles
58
coupling::interface::MoleculeIterator<LinkedCell, dim>
* it = _mdSolverInterface->getMoleculeIterator(cell);
59
it->
begin
();
60
while
(it->
continueIteration
()) {
61
// if we reached the respective particle, delete it
62
if
(_particleCounter == _particle) {
63
const
coupling::interface::Molecule<dim>
& myMolecule(it->
getConst
());
64
65
// save copy of particle
66
const
tarch::la::Vector<dim, double>
position = myMolecule.
getPosition
();
67
const
tarch::la::Vector<dim, double>
velocity = myMolecule.
getVelocity
();
68
const
tarch::la::Vector<dim, double>
force = myMolecule.
getForce
();
69
const
double
potentialEnergy = myMolecule.
getPotentialEnergy
();
70
_deletedMoleculeCopy =
coupling::datastructures::Molecule<dim>
(position, velocity, force, potentialEnergy);
71
72
// delete molecule from MD simulation
73
_mdSolverInterface->deleteMoleculeFromMDSimulation(myMolecule, cell);
74
_particleCounter++;
75
break
;
76
}
77
_particleCounter++;
78
79
it->
next
();
80
}
81
delete
it;
82
}
83
87
coupling::datastructures::Molecule<dim>
getDeletedMolecule
()
const
{
return
_deletedMoleculeCopy; }
88
89
private
:
90
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
_mdSolverInterface;
91
const
unsigned
int
_particle;
92
unsigned
int
_particleCounter;
93
coupling::datastructures::Molecule<dim>
_deletedMoleculeCopy;
94
};
95
#endif
// _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_DELETEPARTICLEMAPPING_H_
coupling::cellmappings::DeleteParticleMapping
This class deletes a certain particle from a coupling cell.
Definition
DeleteParticleMapping.h:25
coupling::cellmappings::DeleteParticleMapping::getDeletedMolecule
coupling::datastructures::Molecule< dim > getDeletedMolecule() const
Definition
DeleteParticleMapping.h:87
coupling::cellmappings::DeleteParticleMapping::handleCell
void handleCell(LinkedCell &cell)
Definition
DeleteParticleMapping.h:51
coupling::cellmappings::DeleteParticleMapping::beginCellIteration
void beginCellIteration()
Definition
DeleteParticleMapping.h:40
coupling::cellmappings::DeleteParticleMapping::endCellIteration
void endCellIteration()
Definition
DeleteParticleMapping.h:44
coupling::cellmappings::DeleteParticleMapping::DeleteParticleMapping
DeleteParticleMapping(const unsigned int &particle, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition
DeleteParticleMapping.h:31
coupling::cellmappings::DeleteParticleMapping::~DeleteParticleMapping
~DeleteParticleMapping()
Definition
DeleteParticleMapping.h:36
coupling::datastructures::Molecule
molecule representation for coupling component. Dericed from the class coupling::interface::Molecule
Definition
Molecule.h:24
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::getPotentialEnergy
virtual double getPotentialEnergy() const =0
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
coupling::interface::Molecule::getPosition
virtual tarch::la::Vector< dim, double > getPosition() const =0
tarch::la::Vector
Definition
Vector.h:25
coupling
everything necessary for coupling operations, is defined in here
Definition
AdditiveMomentumInsertion.h:15
tarch
Definition
Configuration.h:11
Generated by
1.17.0