MaMiCo 1.2
Loading...
Searching...
No Matches
SetGivenVelocity4MomentumInsertion.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_SETGIVENVELOCITY4MOMENTUMINSERTION_H_
6#define _MOLECULARDYNAMICS_COUPLING_SETGIVENVELOCITY4MOMENTUMINSERTION_H_
7
8#include "coupling/MomentumInsertion.h"
9#include "coupling/cell-mappings/ComputeMassMapping.h"
10#include "coupling/cell-mappings/ComputeMomentumMapping.h"
11#include "coupling/cell-mappings/SetMomentumMapping.h"
12#include "coupling/interface/MDSolverInterface.h"
13
14namespace coupling {
15template <class LinkedCell, unsigned int dim> class SetGivenVelocity4MomentumInsertion;
16}
17
25template <class LinkedCell, unsigned int dim> class coupling::SetGivenVelocity4MomentumInsertion : public coupling::MomentumInsertion<LinkedCell, dim> {
26public:
31
34
38 unsigned int getTimeIntervalPerMomentumInsertion() const override { return 1; }
39
49
50 // old and new momentum
51 tarch::la::Vector<dim, double> oldMomentum(0.0);
52 tarch::la::Vector<dim, double> newMomentum(0.0);
53 unsigned int particleCounter = 0;
54
55 cell.iterateConstCells(massMapping);
56 cell.iterateConstCells(momentumMapping);
57 // set old momentum
58 oldMomentum = momentumMapping.getMomentum();
59 // set new momentum (only number of particles is missing)
60 newMomentum = massMapping.getMass() * cell.getMicroscopicMomentum();
61 particleCounter = massMapping.getNumberOfParticles();
62
63 // set new momentum (based on velocity stored in microscopic
64 // momentum-buffer)
65 coupling::cellmappings::SetMomentumMapping<LinkedCell, dim> setMomentumMapping(oldMomentum, newMomentum, particleCounter,
67 cell.iterateCells(setMomentumMapping);
68 }
69};
70#endif // _MOLECULARDYNAMICS_COUPLING_SETGIVENVELOCITY4MOMENTUMINSERTION_H_
used to manipulate the momentum/ velocity of the molecules contained in a coupling cell.
Definition MomentumInsertion.h:23
coupling::interface::MDSolverInterface< LinkedCell, dim > *const _mdSolverInterface
Definition MomentumInsertion.h:47
MomentumInsertion(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
Definition MomentumInsertion.h:27
Definition SetGivenVelocity4MomentumInsertion.h:25
unsigned int getTimeIntervalPerMomentumInsertion() const override
returns 1, since momentum insertions will be applied in every md timestep
Definition SetGivenVelocity4MomentumInsertion.h:38
SetGivenVelocity4MomentumInsertion(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
Definition SetGivenVelocity4MomentumInsertion.h:29
void insertMomentum(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 idx) const override
updates the momentum based on the microscopic momentum
Definition SetGivenVelocity4MomentumInsertion.h:46
virtual ~SetGivenVelocity4MomentumInsertion()
a simple destructor
Definition SetGivenVelocity4MomentumInsertion.h:33
This class computes the mass over certain linked cells.
Definition ComputeMassMapping.h:23
unsigned int getNumberOfParticles() const
Definition ComputeMassMapping.h:67
double getMass() const
Definition ComputeMassMapping.h:63
This class computes the momentum over certain linked cells.
Definition ComputeMomentumMapping.h:24
tarch::la::Vector< dim, double > getMomentum() const
Definition ComputeMomentumMapping.h:76
This class sets a certain momentum over several linked cells.
Definition SetMomentumMapping.h:24
defines the cell type with cell-averaged quantities. Derived from the class coupling::datastructures:...
Definition CouplingCellWithLinkedCells.h:26
void iterateConstCells(A &a) const
Definition CouplingCellWithLinkedCells.h:90
void iterateCells(A &a)
Definition CouplingCellWithLinkedCells.h:74
const tarch::la::Vector< dim, double > & getMicroscopicMomentum() const
Definition CouplingCell.h:51
interface to the MD simulation
Definition MDSolverInterface.h:25
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15