MaMiCo 1.2
Loading...
Searching...
No Matches
AdditiveMomentumInsertion.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_ADDITIVEMOMENTUMINSERTION_H_
6#define _MOLECULARDYNAMICS_COUPLING_ADDITIVEMOMENTUMINSERTION_H_
7
8#include "coupling/MomentumInsertion.h"
9#include "coupling/cell-mappings/ComputeMassMapping.h"
10#include "coupling/cell-mappings/SetMomentumMapping.h"
11#include "coupling/datastructures/CouplingCell.h"
12#include "tarch/la/Vector.h"
13
15namespace coupling {
16template <class LinkedCell, unsigned int dim> class AdditiveMomentumInsertion;
17}
18
30template <class LinkedCell, unsigned int dim> class coupling::AdditiveMomentumInsertion : public coupling::MomentumInsertion<LinkedCell, dim> {
31public:
37 AdditiveMomentumInsertion(coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface, unsigned int numberMDTimestepsPerCouplingCycle)
38 : coupling::MomentumInsertion<LinkedCell, dim>(mdSolverInterface), _numberMDTimestepsPerCouplingCycle(numberMDTimestepsPerCouplingCycle) {}
39
42
46 unsigned int getTimeIntervalPerMomentumInsertion() const override { return 1; }
47
56 const unsigned int timeIntervalMomentumInsertion = getTimeIntervalPerMomentumInsertion();
57 // determine fraction of momentum that is to be inserted in this frame
58 double fraction = 1.0 / ((_numberMDTimestepsPerCouplingCycle / timeIntervalMomentumInsertion) +
59 (_numberMDTimestepsPerCouplingCycle % timeIntervalMomentumInsertion != 0));
61 tarch::la::Vector<dim, double> zeroMomentum(0.0);
62
63 // if there is some momentum to be transferred, do so
64 if (tarch::la::dot(momentum, momentum) != 0.0) {
66 cell.iterateConstCells(computeMassMapping);
67 unsigned int numberParticles = computeMassMapping.getNumberOfParticles();
68 coupling::cellmappings::SetMomentumMapping<LinkedCell, dim> setMomentumMapping(zeroMomentum, momentum, numberParticles,
70 cell.iterateCells(setMomentumMapping);
71 }
72 }
73
74private:
78};
79#endif // _MOLECULARDYNAMICS_COUPLING_ADDITIVEMOMENTUMINSERTION_H_
used to manipulate the momentum/velocity of the molecules contained in a coupling cell.
Definition AdditiveMomentumInsertion.h:30
const unsigned int _numberMDTimestepsPerCouplingCycle
Definition AdditiveMomentumInsertion.h:75
unsigned int getTimeIntervalPerMomentumInsertion() const override
returns the interval of time steps for momentum insertion
Definition AdditiveMomentumInsertion.h:46
void insertMomentum(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 idx) const override
inserts momentum to the cell
Definition AdditiveMomentumInsertion.h:55
AdditiveMomentumInsertion(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, unsigned int numberMDTimestepsPerCouplingCycle)
A simple constructor.
Definition AdditiveMomentumInsertion.h:37
~AdditiveMomentumInsertion()
A simple destructor.
Definition AdditiveMomentumInsertion.h:41
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
This class computes the mass over certain linked cells.
Definition ComputeMassMapping.h:23
unsigned int getNumberOfParticles() const
Definition ComputeMassMapping.h:67
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