MaMiCo 1.2
Loading...
Searching...
No Matches
NieVelocityImposition.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_NIEVELOCITYIMPOSITION_H_
6#define _MOLECULARDYNAMICS_COUPLING_NIEVELOCITYIMPOSITION_H_
7
8#include "coupling/MomentumInsertion.h"
9#include "coupling/cell-mappings/ComputeAvgForceAndVelocity.h"
10#include "coupling/cell-mappings/NieVelocityImpositionMapping.h"
11#include "coupling/interface/MDSolverInterface.h"
12
13namespace coupling {
14template <class LinkedCell, unsigned int dim> class NieVelocityImposition;
15}
16
25template <class LinkedCell, unsigned int dim> class coupling::NieVelocityImposition : public coupling::MomentumInsertion<LinkedCell, dim> {
26public:
32 NieVelocityImposition(coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface, const unsigned int& outermostLayer,
33 const unsigned int& innermostLayer, const tarch::la::Vector<2 * dim, bool> impositionEnabled)
34 : coupling::MomentumInsertion<LinkedCell, dim>(mdSolverInterface), _outermostLayer(outermostLayer), _innermostLayer(innermostLayer),
35 _impositionEnabled(impositionEnabled), _enableInnerImposition(false) {}
36
39
42 unsigned int getTimeIntervalPerMomentumInsertion() const override { return 1; }
43
49 // nop if this is not an imposition cell
50 if (!isInsideImpositionLayer(idx)) {
51 return;
52 }
53 // set continuum velocity
55
58 cell.iterateConstCells(computeForceAndVelocity);
59 const tarch::la::Vector<dim, double> avgVel(computeForceAndVelocity.getAvgVelocity());
60 const tarch::la::Vector<dim, double> avgF(computeForceAndVelocity.getAvgForce());
61
62 coupling::cellmappings::NieVelocityImpositionMapping<LinkedCell, dim> velocityImposition(continuumVelocity, avgVel, avgF,
64 cell.iterateCells(velocityImposition);
65 }
66
67 void setInnerImposition(bool enable) override { _enableInnerImposition = enable; }
68
69private:
83 bool isInsideImpositionLayer(I01 globalCellIndex) const {
84 bool inner = true;
85 bool outer = false;
86 tarch::la::Vector<dim, unsigned int> globalIndexUnsigned{globalCellIndex.get()};
87 for (unsigned int d = 0; d < dim; d++) {
88 if (_impositionEnabled[d * 2]) { // negative direction
89 inner = inner && (globalIndexUnsigned[d] > _innermostLayer);
90 outer = outer || (globalIndexUnsigned[d] < _outermostLayer);
91 }
92 if (_impositionEnabled[d * 2 + 1]) { // positive direction
93 inner = inner && (globalIndexUnsigned[d] < 1 + I09::numberCellsInDomain[d] - _innermostLayer);
94 outer = outer || (globalIndexUnsigned[d] > 1 + I09::numberCellsInDomain[d] - _outermostLayer);
95 }
96 }
97 return (_enableInnerImposition || !inner) && !outer;
98 }
99
101 const unsigned int _outermostLayer;
103 const unsigned int _innermostLayer;
104 const tarch::la::Vector<2 * dim, bool> _impositionEnabled;
105 bool _enableInnerImposition;
106};
107
108#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
Velocity imposition scheme following the respective paper by Nie et al., J. Fluid....
Definition NieVelocityImposition.h:25
virtual ~NieVelocityImposition()
a simple destructor
Definition NieVelocityImposition.h:38
const unsigned int _innermostLayer
the index of the innermost cell layer
Definition NieVelocityImposition.h:103
bool isInsideImpositionLayer(I01 globalCellIndex) const
based on the cell index, the function tells if the cell is inside the imposition layer
Definition NieVelocityImposition.h:83
NieVelocityImposition(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const unsigned int &outermostLayer, const unsigned int &innermostLayer, const tarch::la::Vector< 2 *dim, bool > impositionEnabled)
a simple constructor
Definition NieVelocityImposition.h:32
void insertMomentum(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 idx) const override
inserts momentum to a cell
Definition NieVelocityImposition.h:48
void setInnerImposition(bool enable) override
Definition NieVelocityImposition.h:67
const unsigned int _outermostLayer
the index of the outermost cell layer
Definition NieVelocityImposition.h:101
unsigned int getTimeIntervalPerMomentumInsertion() const override
momentum shall be inserted in every md time step, so this returns 1
Definition NieVelocityImposition.h:42
This class sums up all force/velocity vectors and counts molecules inside a linked cell.
Definition ComputeAvgForceAndVelocity.h:26
tarch::la::Vector< dim, double > getAvgVelocity() const
Definition ComputeAvgForceAndVelocity.h:82
tarch::la::Vector< dim, double > getAvgForce() const
Definition ComputeAvgForceAndVelocity.h:77
This class employs an acceleration based on velocity gradients (in time) using the forcing term of th...
Definition NieVelocityImpositionMapping.h:34
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
static tarch::la::Vector< dim, unsigned int > numberCellsInDomain
Definition CellIndex.h:264
value_T get() const
Definition CellIndex.h:138
interface to the MD simulation
Definition MDSolverInterface.h:25
Definition Vector.h:25
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15