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_DATA_STRUCTURES_COUPLINGCELL_H_ 6 : #define _MOLECULARDYNAMICS_COUPLING_DATA_STRUCTURES_COUPLINGCELL_H_ 7 : 8 : #include "tarch/la/Vector.h" 9 : #include <cstdlib> 10 : #include <fstream> 11 : #include <iostream> 12 : #include <string> 13 : 14 : namespace coupling { 15 : namespace datastructures { 16 : 17 : template <unsigned int dim> class CouplingCell; 18 : } // namespace datastructures 19 : } // namespace coupling 20 : 21 : /** describes a quadratic/ cubic coupling cell filled with fluid (no linked 22 : *cells). Base class for the class 23 : *coupling::datastructures::CouplingCellWithLinkedCells 24 : * @brief defines the cell type with cell-averaged quantities only (no 25 : *linked cells). 26 : * @tparam dim Number of dimensions; it can be 1, 2 or 3 27 : * @author Philipp Neumann 28 : */ 29 : template <unsigned int dim> class coupling::datastructures::CouplingCell { 30 : public: 31 : /** Constructor: initialises the coupling cell with zero values. 32 : */ 33 56072 : CouplingCell() 34 56072 : : _microscopicMass(0.0), _microscopicMomentum(0.0), _macroscopicMass(0.0), _macroscopicMomentum(0.0), _potentialEnergy(0.0), _temperature(0.0), 35 112144 : _currentVelocity(0.0) {} 36 : 37 : /** Destructor */ 38 55960 : virtual ~CouplingCell() {} 39 : 40 : /** sets the microscopic mass 41 : * @param mass Mass*/ 42 0 : void setMicroscopicMass(const double& mass) { _microscopicMass = mass; } 43 : /** returns the microscopic mass 44 : * @returns _microscopicMass Mass*/ 45 0 : const double& getMicroscopicMass() const { return _microscopicMass; } 46 : /** sets the microscopic moments 47 : * @param momentum Momentum*/ 48 0 : void setMicroscopicMomentum(const tarch::la::Vector<dim, double>& momentum) { _microscopicMomentum = momentum; } 49 : /** returns the microscopic moments 50 : * @returns _microscopicMomentum Momentum*/ 51 0 : const tarch::la::Vector<dim, double>& getMicroscopicMomentum() const { return _microscopicMomentum; } 52 : 53 : /** sets the microscopic mass 54 : * @param mass Mass*/ 55 36364 : void setMacroscopicMass(const double& mass) { _macroscopicMass = mass; } 56 : /** returns the microscopic mass 57 : * @returns _microscopicMass Mass*/ 58 0 : const double& getMacroscopicMass() const { return _macroscopicMass; } 59 : /** sets the microscopic moments 60 : * @param momentum Momentum*/ 61 0 : void setMacroscopicMomentum(const tarch::la::Vector<dim, double>& momentum) { _macroscopicMomentum = momentum; } 62 : /** returns the microscopic moments 63 : * @returns _microscopicMomentum Momentum*/ 64 0 : const tarch::la::Vector<dim, double>& getMacroscopicMomentum() const { return _macroscopicMomentum; } 65 : 66 : /** returns the mean potential energy over the coupling cell 67 : * @returns _potentialEnergy potential energy*/ 68 0 : const double& getPotentialEnergy() const { return _potentialEnergy; } 69 : /** sets the mean potential energy over the coupling cell 70 : * @param potentialEnergy potential energy*/ 71 0 : void setPotentialEnergy(const double& potentialEnergy) { _potentialEnergy = potentialEnergy; } 72 : 73 : /** adds a certain amount to the microscopic mass 74 : * @param mass Mass to be added to the microscopic mass*/ 75 0 : void addMicroscopicMass(const double& mass) { _microscopicMass += mass; } 76 : /** adds a certain amount to the microscopic moments 77 : * @param momentum Momentum to be added to the microscopic moments*/ 78 : void addMicroscopicMomentum(const tarch::la::Vector<dim, double>& momentum) { _microscopicMomentum += momentum; } 79 : 80 : /** adds a certain amount to the macroscopic mass 81 : * @param mass Mass to be added to the macroscopic mass*/ 82 0 : void addMacroscopicMass(const double& mass) { _macroscopicMass += mass; } 83 : /** adds a certain amount to the macroscopic moments 84 : * @param momentum Momentum to be added to the macroscopic moments*/ 85 0 : void addMacroscopicMomentum(const tarch::la::Vector<dim, double>& momentum) { _macroscopicMomentum += momentum; } 86 : 87 : /** sets current velocity (sampled right before any distributeX(...) call) 88 : * @param velocity velocity*/ 89 0 : void setCurrentVelocity(const tarch::la::Vector<dim, double>& velocity) { _currentVelocity = velocity; } 90 : /** returns current velocity (sampled right before any distributeX(...) call) 91 : * @return _currentVelocity velocity*/ 92 0 : const tarch::la::Vector<dim, double>& getCurrentVelocity() const { return _currentVelocity; } 93 : 94 : /** sets the temperature 95 : * @param temperature temperature*/ 96 0 : void setTemperature(const double& temperature) { _temperature = temperature; } 97 : /** returns the temperature 98 : * @return _temperature temperature*/ 99 0 : const double& getTemperature() const { return _temperature; } 100 : 101 : /** buffers for macroscopic mass that need to be transferred 102 : * from the macroscopic to the microscopic simulation */ 103 : double _microscopicMass; 104 : /** buffers for macroscopic quantities of momentum that need to be transferred 105 : * from the macroscopic to the microscopic simulation */ 106 : tarch::la::Vector<dim, double> _microscopicMomentum; 107 : 108 : /** buffers for macroscopic mass that need to be returned 109 : * from the microscopic to the macroscopic simulation */ 110 : double _macroscopicMass; 111 : /** buffers for macroscopic quantities of momentum that need to be returned 112 : * from the microscopic to the macroscopic simulation */ 113 : tarch::la::Vector<dim, double> _macroscopicMomentum; 114 : 115 : /** holds the mean potential energy within the coupling cell. This value is 116 : * needed as a reference potential energy value for the USHER scheme. 117 : */ 118 : double _potentialEnergy; 119 : 120 : /** temperature within this cell. Needed for the thermostat. */ 121 : double _temperature; 122 : 123 : /** buffer for current mean velocity in the cell. */ 124 : tarch::la::Vector<dim, double> _currentVelocity; 125 : }; 126 : 127 : #endif // _MOLECULARDYNAMICS_COUPLING_DATA_STRUCTURES_COUPLINGCELL_H_