OpenMPCD
StarPolymers.cpp
2 
4 
5 #include <boost/filesystem.hpp>
6 
7 namespace OpenMPCD
8 {
9 namespace CUDA
10 {
11 namespace MPCSolute
12 {
13 namespace Instrumentation
14 {
15 
16 template<typename PositionCoordinate, typename VelocityCoordinate>
19  starPolymers_,
20  const Configuration::Setting& settings_)
21  : starPolymers(starPolymers_), settings(settings_)
22 {
23  resetSnapshotFile();
24 }
25 
26 template<typename PositionCoordinate, typename VelocityCoordinate>
28 {
29  if(!snapshotFilePath.empty())
30  boost::filesystem::remove(snapshotFilePath);
31 }
32 
33 template<typename PositionCoordinate, typename VelocityCoordinate>
35 {
36  starPolymers->writeStateToSnapshot(snapshotFile.get());
37 }
38 
39 template<typename PositionCoordinate, typename VelocityCoordinate>
41  const std::string& rundir) const
42 {
43  const std::string basedir = rundir + "/StarPolymers";
45 
46  if(settings.has("initialState"))
47  {
49  settings.read<std::string>("initialState"),
50  basedir + "/initialState.vtf");
51  }
52 
53  snapshotFile.reset();
54  boost::filesystem::copy(snapshotFilePath, basedir + "/snapshots.vtf");
55  resetSnapshotFile();
56 }
57 
58 template<typename PositionCoordinate, typename VelocityCoordinate>
59 void
61 const
62 {
63  if(!snapshotFilePath.empty())
64  boost::filesystem::remove(snapshotFilePath);
65 
66  {
67  const boost::filesystem::path tmp =
68  boost::filesystem::temp_directory_path() /
69  boost::filesystem::unique_path();
70  snapshotFilePath = tmp.string();
71  }
72  snapshotFile.reset(new VTFSnapshotFile(snapshotFilePath));
73  starPolymers->writeStructureToSnapshot(snapshotFile.get());
74 }
75 
76 } //namespace Instrumentation
77 } //namespace MPCSolute
78 } //namespace CUDA
79 } //namespace OpenMPCD
80 
81 template class
StarPolymers.hpp
OpenMPCD::CUDA::MPCSolute::Instrumentation::StarPolymers::~StarPolymers
virtual ~StarPolymers()
The destructor.
Definition: StarPolymers.cpp:27
OpenMPCD::FilesystemUtilities::ensureDirectory
static void ensureDirectory(const std::string &path)
Ensures that the given directory exists, creating it and its parents if necessary.
Definition: FilesystemUtilities.cpp:9
FilesystemUtilities.hpp
OpenMPCD::CUDA::MPCSolute::Instrumentation::StarPolymers::measureSpecific
virtual void measureSpecific()
Performs measurements specific to the solute type.
Definition: StarPolymers.cpp:34
OpenMPCD::CUDA::MPCSolute::Instrumentation::StarPolymers::StarPolymers
StarPolymers(MPCSolute::StarPolymers< PositionCoordinate, VelocityCoordinate > *const starPolymers_, const Configuration::Setting &settings_)
The constructor.
Definition: StarPolymers.cpp:17
OpenMPCD::ImplementationDetails::Configuration::copy
void copy(const libconfig::Config &from, libconfig::Config *const to)
Copies a libconfig::Config instance.
Definition: copy.hpp:28
OpenMPCD::CUDA::MPCSolute::Instrumentation::StarPolymers::saveSpecific
virtual void saveSpecific(const std::string &rundir) const
Saves measurements specific to the solute type.
Definition: StarPolymers.cpp:40
OpenMPCD::Configuration::Setting
Represents a setting in the configuration.
Definition: Configuration.hpp:36
OpenMPCD::VTFSnapshotFile
Representation of a simulation snapshot file in the VTF format.
Definition: VTFSnapshotFile.hpp:49
OpenMPCD::CUDA::MPCSolute::Instrumentation::StarPolymers
Instrumentation for OpenMPCD::CUDA::MPCSolute::StarPolymers.
Definition: Instrumentation/StarPolymers.hpp:33
OpenMPCD::CUDA::MPCSolute::StarPolymers
Class representing star polymers.
Definition: StarPolymers.hpp:123