OpenMPCD
CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base class.
4  */
5 
6 #ifndef OPENMPCD_CUDA_MPCFLUID_INSTRUMENTATION_FOURIERTRANSFORMEDVELOCITY_BASE_HPP
7 #define OPENMPCD_CUDA_MPCFLUID_INSTRUMENTATION_FOURIERTRANSFORMEDVELOCITY_BASE_HPP
8 
10 #include <OpenMPCD/Vector3D.hpp>
11 
12 #include <complex>
13 #include <deque>
14 #include <vector>
15 
16 namespace OpenMPCD
17 {
18 namespace CUDA
19 {
20 
21 class Simulation;
22 
23 namespace MPCFluid
24 {
25 
26 class Base;
27 
28 namespace Instrumentation
29 {
30 /**
31  * Namespace for classes that measure the Fourier-transformed velocities in MPC fluids.
32  *
33  * See @ref velocityInFourierSpace
34  */
35 namespace FourierTransformedVelocity
36 {
37 /**
38  * Base class for measurements of Fourier-transformed velocities in MPC fluids.
39  */
40 class Base
41 {
42  protected:
43  /**
44  * The constructor.
45  * @param[in] sim The simulation instance.
46  * @param[in] devMemMgr The Device memory manager.
47  * @param[in] mpcFluid_ The MPC fluid to measure.
48  * @param[in] numberOfConstituents The number of logical constituents (e.g. pairs, triplets, ...) in the fluid.
49  */
50  Base(
51  const Simulation* const sim, DeviceMemoryManager* devMemMgr,
52  const MPCFluid::Base* const mpcFluid_,
53  const unsigned int numberOfConstituents);
54 
55  private:
56  Base(const Base&); ///< The copy constructor.
57 
58  public:
59  /**
60  * The destructor.
61  */
62  virtual ~Base();
63 
64  public:
65  /**
66  * Performs measurements.
67  */
68  virtual void measure() = 0;
69 
70  /**
71  * Saves the data to the given run directory.
72  * @param[in] rundir The path to the run directory.
73  */
74  virtual void save(const std::string& rundir) const;
75 
76  public:
77  /**
78  * Returns whether the given simulation configured this instrumentation.
79  * @param[in] sim The simulation instance.
80  * @throw NULLPointerException Throws if `sim` is `nullptr`.
81  */
82  static bool isConfigured(const Simulation* const sim);
83 
84  private:
85  /**
86  * Reads the configuration.
87  */
88  void readConfig();
89 
90  /**
91  * Saves the Fourier-transformed velocities to the given directory.
92  * @param[in] datadir The directory to save the data in.
93  */
94  void saveFourierTransformedVelocities(const std::string& datadir) const;
95 
96  /**
97  * Prints the Fourier-transformed velocities to the given stream.
98  * @param[in] k The index for the \f$\vec{k}\f$ vector.
99  * @param[in] stream The stream to print to.
100  * @throw OutOfBoundsException Throws if index is out of bounds.
101  */
102  void saveFourierTransformedVelocities(const unsigned int index, std::ostream& stream) const;
103 
104  protected:
105  const Simulation* const simulation; ///< The simulation instance.
106  DeviceMemoryManager* const deviceMemoryManager; ///< The Device memory manager.
107  const MPCFluid::Base* const mpcFluid; ///< The fluid to measure.
108 
109  MPCParticleVelocityType* realBuffer; ///< Device buffer for temporary results.
110  MPCParticleVelocityType* imagBuffer; ///< Device buffer for temporary results.
111 
112  std::vector<std::vector<MPCParticlePositionType> > k_n;
113  ///< The multiples of \f$ 2*\pi/L_i \f$ for each component \f$ i \f$ of each \f$\vec{k}\f$ vector.
114  std::vector<std::deque<std::pair<FP, Vector3D<std::complex<MPCParticleVelocityType> > > > >
116  /**< The Fourier-transformed velocities measured, along with the
117  corresponding simulation timestamps.*/
118 }; //class Base
119 } //namespace FourierTransformedVelocity
120 } //namespace Instrumentation
121 } //namespace MPCFluid
122 } //namespace CUDA
123 } //namespace OpenMPCD
124 
125 #endif
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::realBuffer
MPCParticleVelocityType * realBuffer
Device buffer for temporary results.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:109
OpenMPCD::CUDA::MPCFluid::Base
Base class for MPC fluids.
Definition: CUDA/MPCFluid/Base.hpp:40
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::isConfigured
static bool isConfigured(const Simulation *const sim)
Returns whether the given simulation configured this instrumentation.
Definition: Base.cpp:36
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::k_n
std::vector< std::vector< MPCParticlePositionType > > k_n
The multiples of for each component of each vector.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:112
OpenMPCD::CUDA::DeviceMemoryManager
Class for managing memory on the CUDA Device.
Definition: DeviceMemoryManager.hpp:21
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::imagBuffer
MPCParticleVelocityType * imagBuffer
Device buffer for temporary results.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:110
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::~Base
virtual ~Base()
The destructor.
Definition: Base.cpp:25
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::deviceMemoryManager
DeviceMemoryManager *const deviceMemoryManager
The Device memory manager.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:106
OpenMPCD::CUDA::Simulation
MPCD simulation with Molecular Dynamics on CUDA-capable GPUs.
Definition: CUDA/Simulation.hpp:48
DeviceMemoryManager.hpp
Vector3D.hpp
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::simulation
const Simulation *const simulation
The simulation instance.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:105
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::save
virtual void save(const std::string &rundir) const
Saves the data to the given run directory.
Definition: Base.cpp:31
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::Base
Base(const Simulation *const sim, DeviceMemoryManager *devMemMgr, const MPCFluid::Base *const mpcFluid_, const unsigned int numberOfConstituents)
The constructor.
Definition: Base.cpp:14
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::fourierTransformedVelocities
std::vector< std::deque< std::pair< FP, Vector3D< std::complex< MPCParticleVelocityType > > > > > fourierTransformedVelocities
The Fourier-transformed velocities measured, along with the corresponding simulation timestamps.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:115
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base
Base class for measurements of Fourier-transformed velocities in MPC fluids.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:40
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::measure
virtual void measure()=0
Performs measurements.
OpenMPCD::MPCParticleVelocityType
FP MPCParticleVelocityType
The data type for the velocities of MPC particles.
Definition: Types.hpp:16
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::mpcFluid
const MPCFluid::Base *const mpcFluid
The fluid to measure.
Definition: CUDA/MPCFluid/Instrumentation/FourierTransformedVelocity/Base.hpp:107