ls1-MarDyn
ls1-MarDyn molecular dynamics code
VirialProfile.h
1//
2// Created by Kruegener on 1/15/2019.
3//
4
5#ifndef MARDYN_VIRIAL_H
6#define MARDYN_VIRIAL_H
7
8#include "ProfileBase.h"
9#include "plugins/SpatialProfile.h"
10
11/* @brief VirialProfile is writing a special 1D output in Y dimension and does therefore
12 * not call the normal writeMatrix function. The output is always the same, regardless
13 * of cartesian or cylindrical sampling. For this output, pressures in x,y,z and the pressure differential in
14 * y-direction are computed in each layer and output as one line. There is therefore no spatial resolution
15 * inside the layer.
16 * Each line is: y-value, PD, PX, PY, PZ
17 *
18 * VirialProfile also depends on a DensityProfile, which is triggered automatically
19*/
20class VirialProfile : public ProfileBase {
21public:
22 VirialProfile(DensityProfile* densProf) :
23 _densityProfile{densProf}, _local3dProfile(), _global3dProfile() {};
24
25 ~~VirialProfile() = default;
26
27 void record(Molecule& mol, unsigned long uID) final {
28 for (unsigned short d = 0; d < 3; d++) {
29 _local3dProfile[uID][d] += mol.Vi(d);
30 }
31 }
32
33 void collectAppend(DomainDecompBase* domainDecomp, unsigned long uID) final {
34 for (unsigned short d = 0; d < 3; d++) {
35 domainDecomp->collCommAppendDouble(_local3dProfile[uID][d]);
36 }
37 }
38
39 void collectRetrieve(DomainDecompBase* domainDecomp, unsigned long uID) final {
40 for (unsigned short d = 0; d < 3; d++) {
41 _global3dProfile[uID][d] = domainDecomp->collCommGetDouble();
42 }
43 }
44
50 void output(string prefix, long unsigned accumulatedDatasets) final;
51
52 void reset(unsigned long uID) final {
53 for (unsigned d = 0; d < 3; d++) {
54 _local3dProfile[uID][d] = 0.0;
55 _global3dProfile[uID][d] = 0.0;
56 }
57 }
58
59 int comms() final { return 3; }
60
61private:
62 DensityProfile* _densityProfile;
63
64 // Local 3D Profile
65 std::map<unsigned, std::array<double, 3>> _local3dProfile;
66 // Global 3D Profile
67 std::map<unsigned, std::array<double, 3>> _global3dProfile;
68
69 // Only needed because its abstract, all output handled by output()
70 void writeDataEntry(unsigned long uID, ofstream& outfile) const final {};
71
72};
73
74
75#endif //MARDYN_VIRIAL_H
Outputs the number density of molecules per bin specified by Sampling grid in KartesianProfile.
Definition: DensityProfile.h:14
handle boundary region and multiple processes
Definition: DomainDecompBase.h:51
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
Base class for all Profile outputs used by KartesianProfile.
Definition: ProfileBase.h:34
Definition: VirialProfile.h:20
void collectAppend(DomainDecompBase *domainDecomp, unsigned long uID) final
Append all necessary communication per bin to the DomainDecomposition. Append from e....
Definition: VirialProfile.h:33
void collectRetrieve(DomainDecompBase *domainDecomp, unsigned long uID) final
Get global values after AllReduceSum per bin. Write to e.g. _globalProfile.
Definition: VirialProfile.h:39
void output(string prefix, long unsigned accumulatedDatasets) final
Definition: VirialProfile.cpp:8
void reset(unsigned long uID) final
Used to reset all array contents for a specific uID in order to start the next recording timeframe.
Definition: VirialProfile.h:52
int comms() final
1D profiles like a number density profile should return 1 here. 3D profiles that have 3 entries per b...
Definition: VirialProfile.h:59
void record(Molecule &mol, unsigned long uID) final
The recording step defines what kind of data needs to be recorded for a single molecule with a corres...
Definition: VirialProfile.h:27