1
// A class for defining an alternate atomic mass, needed for templating
3
#ifndef FUNDAMENTAL_ATOM_QUANTITY_H
4
#define FUNDAMENTAL_ATOM_QUANTITY_H
8
#include "PerAtomQuantity.h"
12
// forward declarations
15
//--------------------------------------------------------
16
//--------------------------------------------------------
17
// Class FundamentalAtomQuantity
18
// A base class for defining objects that manage
19
// quantities defined at atoms based on lammps data
20
//--------------------------------------------------------
21
//--------------------------------------------------------
23
class FundamentalAtomQuantity : public ShallowAtomQuantity<double> {
28
FundamentalAtomQuantity(ATC_Method * atc,
29
LammpsInterface::FundamentalAtomQuantity atomQuantity,
30
AtomType atomType=INTERNAL);
33
virtual ~FundamentalAtomQuantity() {};
35
/** specialized reset to account for quantities which lammps can change */
36
virtual void lammps_force_reset() {this->force_reset();};
40
/** enumerates the type of atom quantity being considered */
41
LammpsInterface::FundamentalAtomQuantity atomQuantity_;
43
/** converts from Lammps units to ATC units */
44
double unitsConversion_;
46
/** sets lammps data based on the quantity */
47
virtual void set_lammps_to_quantity() const;
49
/** sets the quantity based on a lammps pointer */
50
virtual void set_quantity_to_lammps() const
51
{ShallowAtomQuantity<double>::set_quantity_to_lammps(); if (unitsConversion_!=1.) quantity_ *= unitsConversion_;};
53
/** gets appropriate pointer for lammps data */
54
virtual double * lammps_scalar() const
55
{return lammpsInterface_->atom_scalar(atomQuantity_);};
57
/** gets appropriate pointer for lammps data */
58
virtual double ** lammps_vector() const
59
{return lammpsInterface_->atom_vector(atomQuantity_);};
64
FundamentalAtomQuantity();
68
//--------------------------------------------------------
69
//--------------------------------------------------------
71
//--------------------------------------------------------
72
//--------------------------------------------------------
74
class AtomMass : public FundamentalAtomQuantity {
79
AtomMass(ATC_Method * atc,AtomType atomType = INTERNAL);
82
virtual ~AtomMass() {};
84
/** sets the quantity to a given value */
85
virtual void operator=(const DENS_MAT & target)
86
{throw ATC_Error("Cannot modify type-based atom mass");};
88
/** sets the quantity to a given constant value */
89
virtual void operator=(const double & target)
90
{throw ATC_Error("Cannot modify type-based atom mass");};
92
/** adds the given data to the Lammps quantity */
93
virtual void operator+=(const DENS_MAT & addition)
94
{throw ATC_Error("Cannot modify type-based atom mass");};
96
/** adds the scalar data to the Lammps quantity for AtC atoms */
97
virtual void operator+=(double addition)
98
{throw ATC_Error("Cannot modify type-based atom mass");};
100
/** subtracts the given data from the Lammps quantity */
101
virtual void operator-=(const DENS_MAT & subtraction)
102
{throw ATC_Error("Cannot modify type-based atom mass");};
104
/** subtracts the scalar data from the Lammps quantity for AtC atoms */
105
virtual void operator-=(double subtracts)
106
{throw ATC_Error("Cannot modify type-based atom mass");};
108
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
109
virtual void operator*=(const DENS_MAT & multiplier)
110
{throw ATC_Error("Cannot modify type-based atom mass");};
112
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
113
virtual void operator*=(double multiplier)
114
{throw ATC_Error("Cannot modify type-based atom mass");};
116
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
117
virtual void operator/=(const DENS_MAT & divisor)
118
{throw ATC_Error("Cannot modify type-based atom mass");};
120
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
121
virtual void operator/=(double divisor)
122
{throw ATC_Error("Cannot modify type-based atom mass");};
126
/** sets lammps data based on the quantity */
127
virtual void set_lammps_to_quantity(){};
129
/** sets the quantity based on a lammps pointer */
130
virtual void set_quantity_to_lammps() const;
132
/** gets appropriate pointer for lammps data */
133
virtual double * lammps_scalar() const
136
/** gets appropriate pointer for lammps data */
137
virtual double ** lammps_vector() const
147
//--------------------------------------------------------
148
//--------------------------------------------------------
149
// Class ComputedAtomQuantity
150
// A base class for defining objects that manage
151
// quantities defined at atoms by Lammps computes
152
// The compute associated with the tag must already
154
//--------------------------------------------------------
155
//--------------------------------------------------------
157
class ComputedAtomQuantity : public ShallowAtomQuantity<double> {
162
ComputedAtomQuantity(ATC_Method * atc,
163
const std::string & tag,
164
double unitsConversion = 1.,
165
AtomType atomType=INTERNAL);
168
virtual ~ComputedAtomQuantity() {};
170
/** resets compute, must be this way to accomodate atom sorting between runs */
171
virtual void post_exchange() {this->needReset_ = true;};
173
/** specialized reset to account for forcing lammps to perform the compute */
174
virtual void force_reset();
176
/** specialized reset to account for quantities which lammps can change */
177
virtual void lammps_force_reset() {this->force_reset();};
179
// remove operations that change the lammps data
180
/** returns a non-const version for manipulations and changes, resets dependent quantities */
181
virtual DENS_MAT & set_quantity()
182
{throw ATC_Error("ComputedAtomQuantity::set_quantity - Cannot modify computed per atom quantities"); return quantity_;};
184
/** sets the quantity to a given constant value */
185
virtual void operator=(const DENS_MAT & target)
186
{throw ATC_Error("ComputedAtomQuantity::operator= - Cannot modify computed per atom quantities");};
188
/** adds the given data to the Lammps quantity */
189
virtual void operator+=(const DENS_MAT & addition)
190
{throw ATC_Error("ComputedAtomQuantity::operator+= - Cannot modify computed per atom quantities");};
192
/** adds the scalar data to the Lammps quantity for AtC atoms */
193
virtual void operator+=(double addition)
194
{throw ATC_Error("ComputedAtomQuantity::operator+= - Cannot modify computed per atom quantities");};
196
/** subtracts the given data from the Lammps quantity */
197
virtual void operator-=(const DENS_MAT & subtraction)
198
{throw ATC_Error("ComputedAtomQuantity::operator-= - Cannot modify computed per atom quantities");};
200
/** subtracts the scalar data from the Lammps quantity for AtC atoms */
201
virtual void operator-=(double subtraction)
202
{throw ATC_Error("ComputedAtomQuantity::operator-= - Cannot modify computed per atom quantities");};
204
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
205
virtual void operator*=(const DENS_MAT & multiplier)
206
{throw ATC_Error("ComputedAtomQuantity::operator*= - Cannot modify computed per atom quantities");};
208
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
209
virtual void operator*=(double multiplier)
210
{throw ATC_Error("ComputedAtomQuantity::operator*= - Cannot modify computed per atom quantities");};
212
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
213
virtual void operator/=(const DENS_MAT & divisor)
214
{throw ATC_Error("ComputedAtomQuantity::operator/= - Cannot modify computed per atom quantities");};
216
/** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
217
virtual void operator/=(double divisor)
218
{throw ATC_Error("ComputedAtomQuantity::operator/= - Cannot modify computed per atom quantities");};
222
/** pointer to Lammps compute, meant as rapid indexing only (do not use!) */
223
COMPUTE_POINTER computePointer_;
225
/** tag for Lammps compute */
226
std::string computeTag_;
228
/** units conversion from LAMMPS to ATC units */
229
double unitsConversion_;
231
/** sets the quantity based on a lammps pointer */
232
virtual void set_quantity_to_lammps() const
233
{ShallowAtomQuantity<double>::set_quantity_to_lammps(); if (unitsConversion_!=1.) quantity_ *= unitsConversion_;};
235
/** gets appropriate data for lammps pointer */
236
virtual double * lammps_scalar() const {return lammpsInterface_->compute_vector_peratom(computePointer_);};
238
/** gets appropriate data for lammps pointer */
239
virtual double ** lammps_vector() const {return lammpsInterface_->compute_array_peratom(computePointer_);};
241
// not needed if no MPI
242
/** sets lammps data based on the quantity */
243
virtual void set_lammps_to_quantity()
244
{throw ATC_Error("ComputedAtomQuantity::set_lammps_to_quantity - Cannot modify a compute's LAMMPS data");};
249
ComputedAtomQuantity();