Simpatico  v1.10
ddMd/configIos/ConfigIo.h
1 #ifndef DDMD_CONFIG_IO_H
2 #define DDMD_CONFIG_IO_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/param/ParamComposite.h> // base class
12 
13 #include <ddMd/storage/AtomStorage.h> // member
14 #ifdef SIMP_BOND
15 #include <ddMd/storage/BondStorage.h> // inline function
16 #endif
17 #ifdef SIMP_ANGLE
18 #include <ddMd/storage/AngleStorage.h> // inline function
19 #endif
20 #ifdef SIMP_DIHEDRAL
21 #include <ddMd/storage/DihedralStorage.h> // inline function
22 #endif
23 #include <simp/boundary/Boundary.h> // typedef
24 #include <util/containers/DArray.h> // member
25 
26 #include <ddMd/chemistry/MaskPolicy.h>
27 
28 namespace DdMd
29 {
30 
31  class Simulation;
32  class Domain;
33  class Buffer;
34  template <int N> class GroupStorage;
35  template <int N> class GroupDistributor;
36  template <int N> class GroupCollector;
37 
38  using namespace Util;
39  using namespace Simp;
40 
49  class ConfigIo : public ParamComposite
50  {
51 
52  public:
53 
57  ConfigIo();
58 
64  ConfigIo(Simulation& simulation);
65 
69  virtual ~ConfigIo();
70 
76  void associate(Domain& domain, Boundary& boundary,
77  AtomStorage& atomStorage,
78  #ifdef SIMP_BOND
79  BondStorage& bondStorage,
80  #endif
81  #ifdef SIMP_ANGLE
82  AngleStorage& angleStorage,
83  #endif
84  #ifdef SIMP_DIHEDRAL
85  DihedralStorage& dihedralStorage,
86  #endif
87  Buffer& buffer);
88 
89 
129  virtual void readConfig(std::ifstream& file, MaskPolicy maskPolicy) = 0;
130 
160  virtual void writeConfig(std::ofstream& file) = 0;
161 
162  protected:
163 
167  void setAtomMasks();
168 
172  Domain& domain();
173 
177  Boundary& boundary();
178 
182  AtomStorage& atomStorage();
183 
187  AtomDistributor& atomDistributor();
188 
192  AtomCollector& atomCollector();
193 
194  #ifdef SIMP_BOND
195 
198  BondStorage& bondStorage();
199 
203  GroupDistributor<2>& bondDistributor();
204 
208  GroupCollector<2>& bondCollector();
209  #endif
210 
211  #ifdef SIMP_ANGLE
212 
215  AngleStorage& angleStorage();
216 
220  GroupDistributor<3>& angleDistributor();
221 
225  GroupCollector<3>& angleCollector();
226  #endif
227 
228  #ifdef SIMP_DIHEDRAL
229 
232  DihedralStorage& dihedralStorage();
233 
237  GroupDistributor<4>& dihedralDistributor();
238 
242  GroupCollector<4>& dihedralCollector();
243  #endif
244 
245  private:
246 
247  // Pointers to associated objects.
248  Domain* domainPtr_;
249  Boundary* boundaryPtr_;
250  AtomStorage* atomStoragePtr_;
251  #ifdef SIMP_BOND
252  BondStorage* bondStoragePtr_;
253  #endif
254  #ifdef SIMP_ANGLE
255  AngleStorage* angleStoragePtr_;
256  #endif
257  #ifdef SIMP_DIHEDRAL
258  DihedralStorage* dihedralStoragePtr_;
259  #endif
260 
264  template <int N>
265  int readGroups(std::ifstream& file,
266  const char* sectionLabel, const char* nGroupLabel,
267  GroupDistributor<N>& distributor);
268 
272  template <int N>
273  int writeGroups(std::ofstream& file,
274  const char* sectionLabel, const char* nGroupLabel,
275  GroupStorage<N>& storage, GroupCollector<N>& collector);
276 
277  };
278 
279  // Inline method definitions
280 
282  { return *domainPtr_; }
283 
285  { return *boundaryPtr_; }
286 
288  { return *atomStoragePtr_; }
289 
291  { return atomStoragePtr_->distributor(); }
292 
294  { return atomStoragePtr_->collector(); }
295 
296  #ifdef SIMP_BOND
298  {
299  assert(bondStoragePtr_);
300  return *bondStoragePtr_;
301  }
302 
304  { return bondStorage().distributor(); }
305 
307  { return bondStorage().collector(); }
308  #endif
309 
310  #ifdef SIMP_ANGLE
312  {
313  assert(angleStoragePtr_);
314  return *angleStoragePtr_;
315  }
316 
318  { return angleStorage().distributor(); }
319 
321  { return angleStorage().collector(); }
322  #endif
323 
324  #ifdef SIMP_DIHEDRAL
326  {
327  assert(dihedralStoragePtr_);
328  return *dihedralStoragePtr_;
329  }
330 
332  { return dihedralStorage().distributor(); }
333 
335  { return dihedralStorage().collector(); }
336  #endif
337 
338 }
339 #endif
GroupDistributor< 2 > & bondDistributor()
Get the bondDistributor by reference.
GroupCollector< 4 > & dihedralCollector()
Get the dihedral collector by reference.
AtomStorage & atomStorage()
Get AtomStorage by reference.
BondStorage & bondStorage()
Get BondStorage by reference.
Domain & domain()
Get the Domain by reference.
An orthorhombic periodic unit cell.
AtomCollector & atomCollector()
Get the AtomCollector by reference.
GroupDistributor< 3 > & angleDistributor()
Get the angle distributor by reference.
Parallel domain decomposition (DD) MD simulation.
Classes used by all simpatico molecular simulations.
Main object for a domain-decomposition MD simulation.
Class for collecting Atoms from processors to master processor.
Definition: AtomCollector.h:57
AtomDistributor & atomDistributor()
Get the AtomDistributor by reference.
Class for collecting Groups from processors to master processor.
Utility classes for scientific computation.
Definition: accumulators.mod:1
GroupDistributor< 4 > & dihedralDistributor()
Get the dihedral distributor by reference.
MaskPolicy
Enumeration of policies for suppressing ("masking") some pair interactions.
Boundary & boundary()
Get Boundary by reference.
A container for all the Group<N> objects on this processor.
A container for all the atoms and ghost atoms on this processor.
GroupCollector< 2 > & bondCollector()
Get the bond collector by reference.
Buffer for interprocessor communication.
Definition: Buffer.h:217
Decomposition of the system into domains associated with processors.
Definition: Domain.h:31
Abstract reader/writer for configuration files.
Container for Group<3> (angle) objects.
Definition: AngleStorage.h:25
AngleStorage & angleStorage()
Get AngleStorage by reference.
GroupCollector< 3 > & angleCollector()
Get the angle collector by reference.
Container for Group<4> (dihedral) objects.
DihedralStorage & dihedralStorage()
Get DihedralStorage by reference.
An object that can read multiple parameters from file.
Container for for Group<2> (bond) objects.
Definition: BondStorage.h:25
Class for distributing Atoms among processors.
Class template for distributing Group<N> objects among processors.