Line data Source code
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_ZHOUBOUNDARYFORCECONTROLLER_H_ 6 : #define _MOLECULARDYNAMICS_COUPLING_ZHOUBOUNDARYFORCECONTROLLER_H_ 7 : 8 : #include "coupling/BoundaryForceController.h" 9 : #include "coupling/cell-mappings/ZhouBoundaryForce.h" 10 : 11 : namespace coupling { 12 : template <class LinkedCell, unsigned int dim> class ZhouBoundaryForceController; 13 : } 14 : 15 : /** For details on the forcing, check out the descriptions in 16 : * cell-mappings/ZhouBoundaryForce. 17 : * @brief applies the boundary force from Zhou et al. in boundary cell. 18 : * @tparam LinkedCell the LinkedCell class is given by the implementation of 19 : * linked cells in the molecular dynamics simulation 20 : * @tparam dim the integer dim refers to the spacial dimension of the 21 : * simulation, can be 1, 2, or 3 22 : * @author Philipp Neumann 23 : */ 24 : template <class LinkedCell, unsigned int dim> class coupling::ZhouBoundaryForceController : public coupling::BoundaryForceController<LinkedCell, dim> { 25 : public: 26 : /** @brief A simple constructor 27 : * @param density the mean density for the setup 28 : * @param temperature the mean temperature for the setup 29 : * @param boundary a vector of booleans indicating at which boundaries the 30 : * force shall be applied 31 : * @param mdSolverInterface a reference to the interface of the MD solver*/ 32 0 : ZhouBoundaryForceController(const double& density, const double& temperature, const tarch::la::Vector<2 * dim, bool>& boundary, 33 : coupling::interface::MDSolverInterface<LinkedCell, dim>* const mdSolverInterface) 34 0 : : coupling::BoundaryForceController<LinkedCell, dim>(mdSolverInterface), _density(density), _temperature(temperature), _boundary(boundary), 35 0 : _zhouBoundaryForce(density, temperature, mdSolverInterface->getMoleculeEpsilon(), mdSolverInterface->getMoleculeSigma(), boundary, 36 0 : mdSolverInterface->getGlobalMDDomainOffset(), mdSolverInterface->getGlobalMDDomainSize(), mdSolverInterface) {} 37 : 38 : /** @brief Destructor*/ 39 0 : virtual ~ZhouBoundaryForceController() {} 40 : 41 : /** iterates over all linked cells of the given coupling cell and applies 42 : * the cellmapping for the Zhou boundary force 43 : * @brief applies the Zhou boundary force on a boundary cell 44 : * @param cell the macroscopic boundary cell to apply the boundary force 45 : */ 46 0 : virtual void applyBoundaryForce(coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell) { cell.iterateCells(_zhouBoundaryForce); } 47 : 48 : /** @brief calculates the potential energy for a given position 49 : * @param position the position for which the potential energy will be 50 : * calculated 51 : * @returns the potential energy at the given position */ 52 0 : virtual double getPotentialEnergy(const tarch::la::Vector<dim, double>& position) const { return _zhouBoundaryForce.getPotentialEnergy(position); } 53 : 54 : /** @brief calculates the boundary force for the given particle position 55 : * @param position particle position for the force calculation 56 : * @returns the boundary force at the given position */ 57 0 : virtual tarch::la::Vector<dim, double> getForce(const tarch::la::Vector<dim, double>& position) const { 58 0 : return _zhouBoundaryForce.getBoundaryForces(position); 59 : } 60 : 61 : private: 62 : const double _density; ///< the mean density 63 : const double _temperature; ///< the mean temperature 64 : /** A boolean vector which indicates where to apply the boundary force. 65 : * Per dimension it has two enteries. They refer to the boundaries in the 66 : * following order: left (small x), right (high x), front (small y), back 67 : * (high y), bottom (small z), top (high z). 68 : * @brief indicates at which boundaries to apply the force */ 69 : const tarch::la::Vector<2 * dim, bool> _boundary; 70 : coupling::cellmappings::ZhouBoundaryForce<LinkedCell, dim> _zhouBoundaryForce; ///< the cell mapping for the application of the force 71 : }; 72 : #endif // _MOLECULARDYNAMICS_COUPLING_ZHOUBOUNDARYFORCECONTROLLER_H_