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:
31 NieVelocityImposition(coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface, const unsigned int& outermostLayer,
32 const unsigned int& innermostLayer)
33 : coupling::MomentumInsertion<LinkedCell, dim>(mdSolverInterface), _outermostLayer(outermostLayer), _innermostLayer(innermostLayer) {}
34
37
40 unsigned int getTimeIntervalPerMomentumInsertion() const override { return 1; }
41
47 // nop if this is not an imposition cell
48 if (!isInsideImpositionLayer(idx)) {
49 return;
50 }
51 // set continuum velocity
53
56 cell.iterateConstCells(computeForceAndVelocity);
57 const tarch::la::Vector<dim, double> avgVel(computeForceAndVelocity.getAvgVelocity());
58 const tarch::la::Vector<dim, double> avgF(computeForceAndVelocity.getAvgForce());
59
60 coupling::cellmappings::NieVelocityImpositionMapping<LinkedCell, dim> velocityImposition(continuumVelocity, avgVel, avgF,
62 cell.iterateCells(velocityImposition);
63 }
64
65private:
78 bool isInsideImpositionLayer(I01 globalCellIndex) const {
79 bool inner = true;
80 tarch::la::Vector<dim, unsigned int> globalIndexUnsigned{globalCellIndex.get()};
81 for (unsigned int d = 0; d < dim; d++)
82 inner = inner && (globalIndexUnsigned[d] > _innermostLayer && globalIndexUnsigned[d] < 1 + I09::numberCellsInDomain[d] - _innermostLayer);
83 bool outer = false;
84 for (unsigned int d = 0; d < dim; d++)
85 outer = outer || (globalIndexUnsigned[d] < _outermostLayer || globalIndexUnsigned[d] > 1 + I09::numberCellsInDomain[d] - _outermostLayer);
86 return !inner && !outer;
87 }
88
90 const unsigned int _outermostLayer;
92 const unsigned int _innermostLayer;
93};
94
95#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:47
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:36
NieVelocityImposition(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const unsigned int &outermostLayer, const unsigned int &innermostLayer)
a simple constructor
Definition NieVelocityImposition.h:31
const unsigned int _innermostLayer
the index of the innermost cell layer
Definition NieVelocityImposition.h:92
bool isInsideImpositionLayer(I01 globalCellIndex) const
based on the cell index, the function tells if the cell is inside the imposition layer
Definition NieVelocityImposition.h:78
void insertMomentum(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, I02 idx) const override
inserts momentum to a cell
Definition NieVelocityImposition.h:46
const unsigned int _outermostLayer
the index of the outermost cell layer
Definition NieVelocityImposition.h:90
unsigned int getTimeIntervalPerMomentumInsertion() const override
momentum shall be inserted in every md time step, so this returns 1
Definition NieVelocityImposition.h:40
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:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15