MaMiCo 1.2
Loading...
Searching...
No Matches
DifferenceTransferStrategy.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_TRANSFERSTRATEGIES_DIFFERENCETRANSFERSTRATEGY_H_
6#define _MOLECULARDYNAMICS_COUPLING_TRANSFERSTRATEGIES_DIFFERENCETRANSFERSTRATEGY_H_
7
8#include "coupling/cell-mappings/ComputeMassMapping.h"
9#include "coupling/cell-mappings/ComputeMomentumMapping.h"
10#include "coupling/transferstrategies/TransferStrategy.h"
11#include "tarch/la/Vector.h"
12
13namespace coupling {
14namespace transferstrategies {
15template <class LinkedCell, unsigned int dim> class DifferenceTransferStrategy;
16}
17} // namespace coupling
18
28template <class LinkedCell, unsigned int dim>
30public:
34 DifferenceTransferStrategy(coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface, unsigned int numberMDsteps)
35 : coupling::transferstrategies::TransferStrategy<LinkedCell, dim>(mdSolverInterface), _numberMDsteps(numberMDsteps), _zero(0.0),
36 _massMapping(mdSolverInterface), _momentumMapping(mdSolverInterface) {}
37
40
50
60
66 I02 index) override {
67 // compute difference between macroscopic and microscopic mass and momentum
68 // values; this value is set in the microscopic data buffer of the
69 // coupling cell.
70 const double diffMass = cell.getMicroscopicMass() - cell.getMacroscopicMass();
72 cell.setMicroscopicMass(diffMass);
73 cell.setMicroscopicMomentum(diffMomentum);
74 // reset coupling cell buffers
75 cell.setMacroscopicMass(0.0);
77 }
78
84 // average quantities
85 const double mass = cell.getMacroscopicMass() / ((double)_numberMDsteps);
86 const tarch::la::Vector<dim, double> momentum = cell.getMacroscopicMomentum() * (1.0 / ((double)_numberMDsteps));
87 cell.setMacroscopicMass(mass);
88 cell.setMacroscopicMomentum(momentum);
89 }
90
103
104private:
106 const unsigned int _numberMDsteps;
114};
115#endif // _MOLECULARDYNAMICS_COUPLING_TRANSFERSTRATEGIES_DIFFERENCETRANSFERSTRATEGY_H_
This class computes the mass over certain linked cells.
Definition ComputeMassMapping.h:23
This class computes the momentum over certain linked cells.
Definition ComputeMomentumMapping.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 addMacroscopicMomentum(const tarch::la::Vector< dim, double > &momentum)
Definition CouplingCell.h:85
const tarch::la::Vector< dim, double > & getMicroscopicMomentum() const
Definition CouplingCell.h:51
const tarch::la::Vector< dim, double > & getMacroscopicMomentum() const
Definition CouplingCell.h:64
void addMacroscopicMass(const double &mass)
Definition CouplingCell.h:82
void setMicroscopicMass(const double &mass)
Definition CouplingCell.h:42
const double & getMicroscopicMass() const
Definition CouplingCell.h:45
void setMacroscopicMomentum(const tarch::la::Vector< dim, double > &momentum)
Definition CouplingCell.h:61
const double & getMacroscopicMass() const
Definition CouplingCell.h:58
void setMacroscopicMass(const double &mass)
Definition CouplingCell.h:55
void setMicroscopicMomentum(const tarch::la::Vector< dim, double > &momentum)
Definition CouplingCell.h:48
interface to the MD simulation
Definition MDSolverInterface.h:25
Definition DifferenceTransferStrategy.h:29
void processInnerCouplingCellAfterMDTimestep(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 index) override
compute current mass and momentum and add it to averaged buffer value
Definition DifferenceTransferStrategy.h:95
DifferenceTransferStrategy(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, unsigned int numberMDsteps)
a simple constructor
Definition DifferenceTransferStrategy.h:34
const unsigned int _numberMDsteps
Definition DifferenceTransferStrategy.h:106
coupling::cellmappings::ComputeMomentumMapping< LinkedCell, dim > _momentumMapping
Definition DifferenceTransferStrategy.h:113
const tarch::la::Vector< dim, double > _zero
Definition DifferenceTransferStrategy.h:109
coupling::cellmappings::ComputeMassMapping< LinkedCell, dim > _massMapping
Definition DifferenceTransferStrategy.h:111
virtual ~DifferenceTransferStrategy()
a dummy destructor
Definition DifferenceTransferStrategy.h:39
void processInnerCouplingCellAfterReceivingMacroscopicSolverData(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 index) override
difference between microscopic and macroscopic values is evaluated and stored in the macroscopic quan...
Definition DifferenceTransferStrategy.h:65
void processOuterCouplingCellBeforeReceivingMacroscopicSolverData(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 index) override
the microscopicMass and -Momentum are reseted to zero
Definition DifferenceTransferStrategy.h:54
void processInnerCouplingCellBeforeReceivingMacroscopicSolverData(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 index) override
Definition DifferenceTransferStrategy.h:44
void processInnerCouplingCellBeforeSendingMDSolverData(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 index) override
the quantities (mass & momentum) are averaged (divided by the amount of md time steps)
Definition DifferenceTransferStrategy.h:83
Definition TransferStrategy.h:25
TransferStrategy(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple destructor
Definition TransferStrategy.h:29
Definition Vector.h:24
the namespace is used for transferstrategies
Definition AveragingTransferStrategy.h:18
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15