9 #include <util/param/Parameter.h> 74 if (atomType.hasCharge_) {
75 in >> atomType.charge_;
87 out << atomType.name_;
88 out.setf(std::ios::scientific);
91 out << atomType.mass_;
93 if (atomType.hasCharge_) {
95 out << atomType.charge_;
108 void send<McMd::AtomType>(MPI::Comm& comm,
McMd::AtomType& data,
int dest,
int tag)
110 std::string
name = data.name();
111 send<std::string>(comm,
name, dest, tag);
113 double mass = data.mass();
114 send<double>(comm,
mass, dest, tag);
120 double charge = data.charge();
121 send<double>(comm,
charge, dest, tag);
127 void recv<McMd::AtomType>(MPI::Comm& comm,
McMd::AtomType& data,
int source,
int tag)
130 recv<std::string>(comm,
name, source, tag);
134 recv<double>(comm,
mass, source, tag);
139 recv<bool>(comm,
hasCharge, source, tag);
140 data.setHasCharge(hasCharge);
143 recv<double>(comm,
charge, source, tag);
144 data.setCharge(charge);
158 int rank = comm.Get_rank();
163 hasCharge = data.hasCharge();
165 charge = data.charge();
169 bcast<std::string>(comm,
name, root);
170 bcast<double>(comm,
mass, root);
174 bcast<double>(comm,
charge, root);
181 data.setHasCharge(hasCharge);
183 data.setCharge(charge);
196 #endif // ifdef UTIL_MPI void setId(int Id)
Set the type index.
void setMass(double mass)
Set the mass.
void setHasCharge(bool hasCharge)
Set the boolean "hasCharge" property.
virtual ~AtomType()
Destructor.
void setName(std::string name)
Set the name string.
friend std::ostream & operator<<(std::ostream &out, const AtomType &atomType)
ostream inserter (<<) for an AtomType.
Descriptor for a type of Atom.
Utility classes for scientific computation.
int id() const
Get the index.
static const int Precision
Precision for io of floating point data field.
static const int Width
Width of output field for a scalar variable.
double mass() const
Get the mass.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
double charge() const
Get the electrical charge value.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
const std::string & name() const
Get the name string.
bool hasCharge() const
Does this type have a charge value?
friend std::istream & operator>>(std::istream &in, AtomType &atomType)
istream extractor (>>) for an AtomType.
void setCharge(double charge)
Set the charge value.