MaMiCo 1.2
Loading...
Searching...
No Matches
VelocityGradientRelaxation.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_VELOCITYGRADIENTRELAXATION_H_
6#define _MOLECULARDYNAMICS_COUPLING_VELOCITYGRADIENTRELAXATION_H_
7
8#include "coupling/MomentumInsertion.h"
9#include "coupling/cell-mappings/ComputeMomentumMapping.h"
10#include "coupling/cell-mappings/VelocityGradientRelaxationMapping.h"
11#include "coupling/interface/MDSolverInterface.h"
12
13namespace coupling {
14template <class LinkedCell, unsigned int dim> class VelocityGradientRelaxation;
15template <class LinkedCell, unsigned int dim> class VelocityGradientRelaxationTopOnly;
16} // namespace coupling
17
37template <class LinkedCell, unsigned int dim> class coupling::VelocityGradientRelaxation : public coupling::MomentumInsertion<LinkedCell, dim> {
38public:
48 : coupling::MomentumInsertion<LinkedCell, dim>(mdSolverInterface), _couplingCells(couplingCells), _relaxationParam(relaxationParam) {}
49
51
55 unsigned int getTimeIntervalPerMomentumInsertion() const override { return 1; }
56
66 tarch::la::Vector<dim, double> oldVelocity(0.0);
67 cell.iterateConstCells(momentumMapping);
68 // set current average velocity within this cell
69 oldVelocity = momentumMapping.getMeanVelocity();
70 // set new momentum (based on velocity stored in microscopic
71 // momentum-buffer)
74 cell.iterateCells(velocityGradientRelaxation);
75 }
76
77 void setInnerImposition(bool enable) override {
78 throw std::runtime_error(std::string("coupling::AdditiveMomentumInsertion::setInnerImposition not implemented"));
79 }
80
81protected:
88 const double _relaxationParam;
89};
90
110template <class LinkedCell, unsigned int dim> class coupling::VelocityGradientRelaxationTopOnly : public coupling::VelocityGradientRelaxation<LinkedCell, dim> {
111public:
115 : coupling::VelocityGradientRelaxation<LinkedCell, dim>(relaxationParam, mdSolverInterface, couplingCells) {}
116
119
129 tarch::la::Vector<dim, double> oldVelocity(0.0);
130 cell.iterateConstCells(momentumMapping);
131 // set current average velocity within this cell
132 oldVelocity = momentumMapping.getMeanVelocity();
133
134 // set new momentum (based on velocity stored in microscopic
135 // momentum-buffer)
139 cell.iterateCells(velocityGradientRelaxation);
140 }
141};
142#endif // _MOLECULARDYNAMICS_COUPLING_VELOCITYGRADIENTRELAXATION_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:50
MomentumInsertion(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
Definition MomentumInsertion.h:27
carries out velocity relaxation (similar to the SetMomentumMapping procedure).
Definition VelocityGradientRelaxation.h:110
virtual ~VelocityGradientRelaxationTopOnly()
a dummy destructor
Definition VelocityGradientRelaxation.h:118
VelocityGradientRelaxationTopOnly(double relaxationParam, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > *const couplingCells)
a simple constructor
Definition VelocityGradientRelaxation.h:113
void insertMomentum(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 idx) const override
insertes the momentum to the cells according to the params and velocity gradient relaxation method
Definition VelocityGradientRelaxation.h:127
carries out velocity relaxation (similar to the SetMomentumMapping procedure).
Definition VelocityGradientRelaxation.h:37
void insertMomentum(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 idx) const override
insertes the momentum to the cells according to the params and velocity gradient relaxation method
Definition VelocityGradientRelaxation.h:64
const coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > *const _couplingCells
Definition VelocityGradientRelaxation.h:83
unsigned int getTimeIntervalPerMomentumInsertion() const override
returns the time step interval for the momentum insertion, always one for this method
Definition VelocityGradientRelaxation.h:55
const double _relaxationParam
Definition VelocityGradientRelaxation.h:88
VelocityGradientRelaxation(double relaxationParam, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > *const couplingCells)
a simple constructor
Definition VelocityGradientRelaxation.h:46
void setInnerImposition(bool enable) override
Definition VelocityGradientRelaxation.h:77
virtual ~VelocityGradientRelaxation()
a dummy destructor
Definition VelocityGradientRelaxation.h:50
This class computes the momentum over certain linked cells.
Definition ComputeMomentumMapping.h:24
tarch::la::Vector< dim, double > getMeanVelocity() const
Definition ComputeMomentumMapping.h:81
This class relaxes velocities of molecules towards an interpolated avergaged velocity value.
Definition VelocityGradientRelaxationMapping.h:38
This is the same as the class coupling::cellmappings::VelocityGradientRelaxationMapping,...
Definition VelocityGradientRelaxationMapping.h:406
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
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