MaMiCo 1.2
Loading...
Searching...
No Matches
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
13namespace coupling {
14namespace cellmappings {
15template <class LinkedCell, unsigned int dim> class DeleteParticleMapping;
16}
17} // namespace coupling
18
25template <class LinkedCell, unsigned int dim> class coupling::cellmappings::DeleteParticleMapping {
26public:
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
37
40 void beginCellIteration() { _particleCounter = 0; }
41
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
89private:
91 const unsigned int _particle;
92 unsigned int _particleCounter;
93 coupling::datastructures::Molecule<dim> _deletedMoleculeCopy;
94};
95#endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_DELETEPARTICLEMAPPING_H_
This class deletes a certain particle from a coupling cell.
Definition DeleteParticleMapping.h:25
coupling::datastructures::Molecule< dim > getDeletedMolecule() const
Definition DeleteParticleMapping.h:87
void handleCell(LinkedCell &cell)
Definition DeleteParticleMapping.h:51
void beginCellIteration()
Definition DeleteParticleMapping.h:40
void endCellIteration()
Definition DeleteParticleMapping.h:44
DeleteParticleMapping(const unsigned int &particle, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition DeleteParticleMapping.h:31
~DeleteParticleMapping()
Definition DeleteParticleMapping.h:36
molecule representation for coupling component. Dericed from the class coupling::interface::Molecule
Definition Molecule.h:24
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 const coupling::interface::Molecule< dim > & getConst()=0
interface to access a single molecule in the MD simulation.
Definition Molecule.h:23
virtual double getPotentialEnergy() const =0
virtual tarch::la::Vector< dim, double > getVelocity() const =0
virtual tarch::la::Vector< dim, double > getForce() const =0
virtual tarch::la::Vector< dim, double > getPosition() const =0
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15
Definition Configuration.h:11