8 #include "LammpsConfigIo.h"    10 #include <ddMd/simulation/Simulation.h>                     11 #include <ddMd/communicate/Domain.h>       13 #include <ddMd/storage/AtomStorage.h>                   15 #include <ddMd/storage/BondStorage.h>                   18 #include <ddMd/storage/AngleStorage.h>                   21 #include <ddMd/storage/DihedralStorage.h>                   24 #include <ddMd/communicate/GroupCollector.tpp>     25 #include <ddMd/communicate/GroupDistributor.tpp>     27 #include <ddMd/communicate/Buffer.h>     28 #include <ddMd/chemistry/Atom.h>    29 #include <ddMd/chemistry/Bond.h>    30 #include <ddMd/chemistry/MaskPolicy.h>    31 #include <util/space/Vector.h>    33 #include <util/format/Int.h>    34 #include <util/format/Dbl.h>    74    void LammpsConfigIo::readGroups(std::ifstream& file, 
    75                   const char* sectionLabel, 
int nGroup,
    79          file >> 
Label(sectionLabel);
    83          for (i = 0; i < nGroup; ++i) {
    84             groupPtr = distributor.
newPtr();
    89             for (j = 0; j < N; ++j) {
   110          UTIL_THROW(
"Atom storage is not empty (has local atoms)");
   113          UTIL_THROW(
"Atom storage is not empty (has ghost atoms)");
   116          UTIL_THROW(
"Atom storage is set for Cartesian coordinates");
   118       if (
domain().isMaster() && !file.is_open()) {  
   119             UTIL_THROW(
"Error: File is not open on master"); 
   133       if (
domain().isMaster()) {  
   137          std::getline(file, line);
   140          file >> nAtom >> 
Label(
"atoms");
   141          file >> nBond >> Label(
"bonds");
   142          file >> nAngle >> Label(
"angles");
   143          file >> nDihedral >> Label(
"dihedrals");
   144          file >> nImproper >> Label(
"impropers");
   147          file >> nAtomType >> Label(
"atom") >> Label(
"types");
   148          file >> nBondType >> Label(
"bond") >> Label(
"types");
   149          file >> nAngleType >> Label(
"angle") >> Label(
"types");
   150          file >> nDihedralType >> Label(
"dihedral") >> Label(
"types");
   151          file >> nImproperType >> Label(
"improper") >> Label(
"types");
   153          if (nAtomType > nAtomType_) {
   154             UTIL_THROW(
"nAtomType > simulation().nAtomType()");
   157          if (nBondType > nBondType_) {
   158             UTIL_THROW(
"nAtomType > simulation().nBondType()");
   162          if (nAngleType > nAngleType_) {
   163             UTIL_THROW(
"nAngleype > simulation().nAngleType()");
   167          if (nDihedralType > nDihedralType_) {
   168             UTIL_THROW(
"nDihedralType > simulation().nDihedralType()");
   177       if (
domain().isMaster()) {  
   178          file >> min[0] >> max[0] >> 
Label(
"xlo") >> 
Label(
"xhi");
   179          file >> min[1] >> max[1] >> Label(
"ylo") >> Label(
"yhi");
   180          file >> min[2] >> max[2] >> Label(
"zlo") >> Label(
"zhi");
   191       if (
domain().isMaster()) {  
   192          file >> 
Label(
"Masses");
   193          for (
int i = 0; i < nAtomType; ++i) {
   194             file >> atomTypeId >> mass;
   203       if (
domain().isMaster()) {  
   204          file >> 
Label(
"Atoms");
   219          for (
int i = 0; i < nAtom; ++i) {
   224             file >> 
id >> moleculeId >> typeId;
   225             if (id <= 0 || id > totalAtomCapacity) {
   228             atomPtr->
setId(
id-1);
   251       if (
domain().isMaster()) {
   252          if (nAtomAll != nAtom) {
   253             UTIL_THROW(
"nAtomAll != nAtom after distribution");
   257       bool hasGhosts = 
false;
   263          if (maskPolicy == MaskBonded) {
   289    void LammpsConfigIo::writeGroups(std::ofstream& file, 
   290                   const char* sectionLabel,
   297       nGroup = storage.
nTotal();
   298       if (
domain().isMaster()) { 
   301          std::vector<IoGroup <N> > groups;
   304          groups.reserve(nGroup);
   306          groups.insert(groups.end(), nGroup, ioGroup);
   308          groupPtr = collector.
nextPtr();
   314             groups[id].group = *groupPtr;
   315             groupPtr = collector.
nextPtr();
   319             UTIL_THROW(
"Inconsistency in total number of groups");
   324          file << sectionLabel << std::endl;
   327          for (
id = 0; 
id < nGroup; ++id) {
   328             if (
id != groups[
id].
id) {
   329                UTIL_THROW(
"Incorrect group id in ordered output");
   331             k = groups[id].id + 1;
   333             k = groups[id].group.typeId() + 1;
   335             for (j = 0; j < N; ++j) {
   336                k = groups[id].group.atomId(j) + 1;
   353       if (
domain().isMaster() && !file.is_open()) {  
   354             UTIL_THROW(
"Error: File is not open on master"); 
   378       if (nDihedralType_) {
   385       if (
domain().isMaster()) {
   388          file << 
"LAMMPS data file" << endl;
   407          if (nDihedralType_) {
   413          file << nAtom << 
" atoms     "      << endl;
   414          file << nBond << 
" bonds     " << endl;
   415          file << nAngle << 
" angles    " << endl;
   416          file << nDihedral << 
" dihedrals " << endl;
   417          file << nImproper << 
" impropers" << endl;
   421          file << nAtomType_     << 
" atom types" << endl;
   422          file << nBondType_     << 
" bond types" << endl;
   423          file << nAngleType_    << 
" angle types" << endl;
   424          file << nDihedralType_ << 
" dihedral types" << endl;
   425          file << nImproperType_ << 
" improper types" << endl;
   430          file << 
Dbl(0.0) << 
Dbl(lengths[0]) << 
"  xlo xhi" << endl;
   431          file << 
Dbl(0.0) << 
Dbl(lengths[1]) << 
"  ylo yhi" << endl;
   432          file << 
Dbl(0.0) << 
Dbl(lengths[2]) << 
"  zlo zhi" << endl;
   437          file << 
"Masses" << endl;
   439          for (
int iType = 0; iType < nAtomType_; ++iType) {
   440             file << iType+1 << 
" " << 1.0 << endl;
   444          atoms_.reserve(nAtom);
   446          atoms_.insert(atoms_.end(), nAtom, atom);
   459             atoms_[id].typeId = atomPtr->
typeId();
   465             atoms_[id].position = r;
   470             UTIL_THROW(
"Inconsistency in number of atoms");
   477          file << 
"Atoms" << endl;
   480          for (
id = 0; 
id < nAtom; ++id) {
   481             if (
id != atoms_[
id].
id) {
   482                UTIL_THROW(
"Incorrect atom id in ordered output");
   484             file << 
id+1 << 
" " << 
"1 " << atoms_[id].typeId + 1 
   485                  << 
" " << atoms_[id].position;
   487                file << 
" " << shift;
   527       if (nDihedralType_) {
 void computeNTotal(MPI::Intracomm &communicator)
Compute and store the number of distinct groups on all processors. 
 
void setup()
Setup master processor for receiving. 
 
GroupDistributor< 2 > & bondDistributor()
Get the bondDistributor by reference. 
 
int typeId() const 
Get atom type index. 
 
const int Dimension
Dimensionality of space. 
 
GroupCollector< 4 > & dihedralCollector()
Get the dihedral collector by reference. 
 
A Vector is a Cartesian vector. 
 
AtomStorage & atomStorage()
Get AtomStorage by reference. 
 
Atom * newAtomPtr()
Returns pointer an address available for a new Atom. 
 
int nAtomTotal() const 
Get total number of atoms on all processors. 
 
void add()
Add a group to the cache for sending, send if necessary. 
 
Group< N > * nextPtr()
Return a pointer to the next available atom, or null. 
 
BondStorage & bondStorage()
Get BondStorage by reference. 
 
void setTypeId(int Id)
Set the atom type index. 
 
void setOrthorhombic(const Vector &lengths)
Set unit cell dimensions for orthorhombic boundary. 
 
void setId(int Id)
Set unique global id for this Atom. 
 
const Vector & lengths() const 
Get Vector of unit cell lengths by const reference. 
 
Domain & domain()
Get the Domain by reference. 
 
Vector & position()
Get position Vector by reference. 
 
AtomCollector & atomCollector()
Get the AtomCollector by reference. 
 
void send()
Send all atoms to the master. 
 
GroupDistributor< 3 > & angleDistributor()
Get the angle distributor by reference. 
 
virtual void writeConfig(std::ofstream &file)
Write configuration file. 
 
Wrapper for a double precision number, for formatted ostream output. 
 
int nBondType()
Get maximum number of bond types. 
 
A point particle in an MD simulation. 
 
Parallel domain decomposition (DD) MD simulation. 
 
Main object for a domain-decomposition MD simulation. 
 
int id() const 
Get unique global index for this atom. 
 
int capacity() const 
Return capacity for groups on this processor. 
 
virtual void readConfig(std::ifstream &file, MaskPolicy maskPolicy)
Read configuration file. 
 
int nDihedralType()
Get maximum number of dihedral types. 
 
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number. 
 
void setTypeId(int typeId)
Set the group type id for this group. 
 
AtomDistributor & atomDistributor()
Get the AtomDistributor by reference. 
 
void bcast(MPI::Intracomm &comm, T &data, int root)
Broadcast a single T value. 
 
int addAtom()
Process the active atom for sending. 
 
Class for collecting Groups from processors to master processor. 
 
LammpsConfigIo()
Default constructor. 
 
Utility classes for scientific computation. 
 
void setAtomMasks()
Set Mask data on all atoms. 
 
Atom * nextPtr()
Return a pointer to the next available atom, or null. 
 
GroupDistributor< 4 > & dihedralDistributor()
Get the dihedral distributor by reference. 
 
MaskPolicy
Enumeration of policies for suppressing ("masking") some pair interactions. 
 
virtual bool isValid(AtomStorage &atomStorage, MPI::Intracomm &communicator, bool hasGhosts)
Return true if the container is valid, or throw an Exception. 
 
Group< N > * newPtr()
Returns pointer an address available for a new Group<N>. 
 
Boundary & boundary()
Get Boundary by reference. 
 
void receive()
Receive all atoms sent by master processor. 
 
A container for all the Group<N> objects on this processor. 
 
void send()
Send all atoms that have not be sent previously. 
 
void transformGenToCart(const Vector &Rg, Vector &Rc) const 
Transform Vector of generalized coordinates to Cartesian Vector. 
 
GroupCollector< 2 > & bondCollector()
Get the bond collector by reference. 
 
void computeNAtomTotal(MPI::Intracomm &communicator)
Compute the total number of local atoms on all processors. 
 
int totalAtomCapacity() const 
Return maximum number of atoms on all processors. 
 
void setup()
Initialization before the loop over atoms on master processor. 
 
A label string in a file format. 
 
int nTotal() const 
Return total number of distinct groups on all processors. 
 
int validate()
Validate distribution of atoms after completion. 
 
Abstract reader/writer for configuration files. 
 
void send()
Send all groups on this processor to the master processor. 
 
void setup()
Initialize Buffer for sending. 
 
bool isCartesian() const 
Are atom coordinates Cartesian (true) or generalized (false)? 
 
This file contains templates for global functions send<T>, recv<T> and bcast<T>. 
 
void receive()
Receive all atoms sent by master processor. 
 
Vector & subtract(const Vector &v1, const Vector &v2)
Subtract vector v2 from v1. 
 
AngleStorage & angleStorage()
Get AngleStorage by reference. 
 
An IntVector is an integer Cartesian vector. 
 
int nAtomType()
Get maximum number of atom types. 
 
A group of covalently interacting atoms. 
 
void setup()
Setup master processor for receiving. 
 
GroupCollector< 3 > & angleCollector()
Get the angle collector by reference. 
 
void setAtomId(int i, int atomId)
Set the id for a specific atom. 
 
int nAngleType()
Get maximum number of angle types. 
 
DihedralStorage & dihedralStorage()
Get DihedralStorage by reference. 
 
int id() const 
Get the global id for this group. 
 
void send()
Send all atoms that have not be sent previously. 
 
void setId(int id)
Set the global id for this group. 
 
void transformCartToGen(const Vector &Rc, Vector &Rg) const 
Transform Cartesian Vector to scaled / generalized coordinates. 
 
Class template for distributing Group<N> objects among processors.