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_PARTICLEINSERTION_H_ 6 : #define _MOLECULARDYNAMICS_COUPLING_PARTICLEINSERTION_H_ 7 : 8 : #include "coupling/BoundaryForceController.h" 9 : #include <cstdlib> 10 : #include <iostream> 11 : 12 : namespace coupling { 13 : template <class LinkedCell, unsigned int dim> class ParticleInsertion; 14 : } 15 : 16 : /** @brief interface for particle insertion/removal on coupling cell basis. 17 : * @author Philipp Neumann 18 : * @tparam LinkedCell the LinkedCell class is given by the implementation of 19 : * linked cells in the molecular dynamics simulation 20 : * @tparam dim refers to the spacial dimension of the simulation, can be 1, 2, 21 : * or 3 22 : */ 23 : template <class LinkedCell, unsigned int dim> class coupling::ParticleInsertion { 24 : public: 25 : /** this state is returned by the insertDeleteMass() function. To tell the 26 : * program, which action happened through the application of the function*/ 27 : enum Action { 28 : NoAction = 0, ///< No action was taken / Nothing changed 29 : Insertion = 1, ///< A molecule was inserted 30 : Deletion = 2 ///< A molecule was deleted 31 : }; 32 : 33 : /** 34 : * @brief adds or removes particles to the coupling cell, simulates a mass 35 : * flow. 36 : * @param cell the coupling cell to insert or delete mass 37 : * @param couplingCellPosition position of the cell given as a vector 38 : * @param couplingCellSize size of the coupling cell given as a vector 39 : * @param meanVelocity the mean velocity in the cell as a vector 40 : * @param temperature the current temperature in the cell 41 : * @param boundaryForceController an instance of the boundaryForceController 42 : * for the simulation 43 : * @returns the type of coupling::ParticleInsertion::Action that was applied 44 : */ 45 : virtual typename coupling::ParticleInsertion<LinkedCell, dim>::Action 46 : insertDeleteMass(coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell, const tarch::la::Vector<dim, double>& couplingCellPosition, 47 : const tarch::la::Vector<dim, double>& couplingCellSize, const tarch::la::Vector<dim, double>& meanVelocity, const double& temperature, 48 : const coupling::BoundaryForceController<LinkedCell, dim>& boundaryForceController) = 0; 49 : 50 : /** returns true, if the particle insertion requires information on the 51 : * potential energy landscape. The USHER algorithm requires it. Other 52 : * algorithms may not require it; the trivial 53 : * NoParticleInsertion-implementation which does not do anything obviously 54 : * does not require a valid potential energy landscape. 55 : * @brief returns true, if a potential energy landscape is needed for the 56 : * insertion/removal. 57 : * @returns a bool that indicates if a potential energy landscape is 58 : * neccessary (true) or not (false) */ 59 : virtual bool requiresPotentialEnergyLandscape() = 0; 60 : 61 : /** @brief a simple constructor 62 : * @param insertDeleteMassAtTimestep interval of time steps for the 63 : * insertion/removal of particles*/ 64 4 : ParticleInsertion(unsigned int insertDeleteMassEveryTimestep) : _insertDeleteMassEveryTimestep(insertDeleteMassEveryTimestep) { 65 0 : if (_insertDeleteMassEveryTimestep == 0) { 66 0 : std::cout << "ERROR ParticleInsertion::ParticleInsertion(..): " 67 : "_insertDeleteMassEveryTimestep=0!" 68 0 : << std::endl; 69 0 : exit(EXIT_FAILURE); 70 : } 71 0 : } 72 : 73 : /** @brief a simple destructor*/ 74 0 : virtual ~ParticleInsertion() {} 75 : 76 : /** @brief returns true if mass needs to be inserted or removed in a time step 77 : * t 78 : * @param t time step to check for the insertion/removal of mass 79 : * @returns a bool that indicates if mass insertion/deletion shall be applied 80 : * in this time step (true) or not (false) */ 81 0 : bool insertDeleteMassAtTimestep(unsigned int t) const { return (t % _insertDeleteMassEveryTimestep == 0); } 82 : 83 : private: 84 : /** interval of time steps for the insertion/removal of particles */ 85 : const unsigned int _insertDeleteMassEveryTimestep; 86 : }; 87 : #endif // _MOLECULARDYNAMICS_COUPLING_PARTICLEINSERTION_H_