~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to lib/atc/FundamentalAtomicQuantity.h

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2013-11-20 22:41:36 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131120224136-tzx7leh606fqnckm
Tags: 0~20131119.git7162cf0-1
* [e65b919] Imported Upstream version 0~20131119.git7162cf0
* [f7bddd4] Fix some problems, introduced by upstream recently.
* [3616dfc] Use wrap-and-sort script.
* [7e92030] Ignore quilt dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// A class for defining an alternate atomic mass, needed for templating
 
2
 
 
3
#ifndef FUNDAMENTAL_ATOM_QUANTITY_H
 
4
#define FUNDAMENTAL_ATOM_QUANTITY_H
 
5
 
 
6
#include <string>
 
7
 
 
8
#include "PerAtomQuantity.h"
 
9
 
 
10
namespace ATC {
 
11
 
 
12
  // forward declarations
 
13
  class ATC_Method;
 
14
 
 
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
  //--------------------------------------------------------
 
22
 
 
23
  class FundamentalAtomQuantity : public ShallowAtomQuantity<double> {
 
24
 
 
25
  public:
 
26
 
 
27
    // constructor
 
28
    FundamentalAtomQuantity(ATC_Method * atc,
 
29
                            LammpsInterface::FundamentalAtomQuantity atomQuantity,
 
30
                            AtomType atomType=INTERNAL);
 
31
 
 
32
    // destructor
 
33
    virtual ~FundamentalAtomQuantity() {};
 
34
 
 
35
    /** specialized reset to account for quantities which lammps can change */
 
36
    virtual void lammps_force_reset() {this->force_reset();};
 
37
 
 
38
  protected:
 
39
 
 
40
    /** enumerates the type of atom quantity being considered */
 
41
    LammpsInterface::FundamentalAtomQuantity atomQuantity_;
 
42
 
 
43
    /** converts from Lammps units to ATC units */
 
44
    double unitsConversion_;
 
45
 
 
46
    /** sets lammps data based on the quantity */
 
47
    virtual void set_lammps_to_quantity() const;
 
48
 
 
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_;};
 
52
 
 
53
    /** gets appropriate pointer for lammps data */
 
54
    virtual double * lammps_scalar() const
 
55
      {return lammpsInterface_->atom_scalar(atomQuantity_);};
 
56
 
 
57
    /** gets appropriate pointer for lammps data */
 
58
    virtual double ** lammps_vector() const
 
59
      {return lammpsInterface_->atom_vector(atomQuantity_);};
 
60
 
 
61
  private:
 
62
 
 
63
    // do not define
 
64
    FundamentalAtomQuantity();
 
65
 
 
66
  };
 
67
 
 
68
  //--------------------------------------------------------
 
69
  //--------------------------------------------------------
 
70
  //  Class AtomMass
 
71
  //--------------------------------------------------------
 
72
  //--------------------------------------------------------
 
73
 
 
74
  class AtomMass : public FundamentalAtomQuantity {
 
75
 
 
76
  public:
 
77
 
 
78
    // constructor
 
79
    AtomMass(ATC_Method * atc,AtomType atomType = INTERNAL);
 
80
 
 
81
    // destructor
 
82
    virtual ~AtomMass() {};
 
83
 
 
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");};
 
87
 
 
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");};
 
91
 
 
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");};
 
95
 
 
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");};
 
99
 
 
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");};
 
103
 
 
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");};
 
107
 
 
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");};
 
111
 
 
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");};
 
115
 
 
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");};
 
119
 
 
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");};
 
123
 
 
124
  protected:
 
125
 
 
126
    /** sets lammps data based on the quantity */
 
127
    virtual void set_lammps_to_quantity(){};
 
128
 
 
129
    /** sets the quantity based on a lammps pointer */
 
130
    virtual void set_quantity_to_lammps() const;
 
131
 
 
132
    /** gets appropriate pointer for lammps data */
 
133
    virtual double * lammps_scalar() const
 
134
      {return NULL;};
 
135
 
 
136
    /** gets appropriate pointer for lammps data */
 
137
    virtual double ** lammps_vector() const
 
138
      {return NULL;};
 
139
 
 
140
  private:
 
141
 
 
142
    // do not define
 
143
    AtomMass();
 
144
 
 
145
  };
 
146
 
 
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
 
153
  //    be initialized.
 
154
  //--------------------------------------------------------
 
155
  //--------------------------------------------------------
 
156
  
 
157
  class ComputedAtomQuantity : public ShallowAtomQuantity<double> {
 
158
 
 
159
  public:
 
160
 
 
161
    // constructor
 
162
    ComputedAtomQuantity(ATC_Method * atc,
 
163
                         const std::string & tag,
 
164
                         double unitsConversion = 1.,
 
165
                         AtomType atomType=INTERNAL);
 
166
 
 
167
    // destructor
 
168
    virtual ~ComputedAtomQuantity() {};
 
169
 
 
170
    /** resets compute, must be this way to accomodate atom sorting between runs */
 
171
    virtual void post_exchange() {this->needReset_ = true;};
 
172
 
 
173
    /** specialized reset to account for forcing lammps to perform the compute */
 
174
    virtual void force_reset();
 
175
 
 
176
    /** specialized reset to account for quantities which lammps can change */
 
177
    virtual void lammps_force_reset() {this->force_reset();};
 
178
 
 
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_;};
 
183
 
 
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");};
 
187
 
 
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");};
 
191
 
 
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");};
 
195
 
 
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");};
 
199
 
 
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");};
 
203
 
 
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");};
 
207
 
 
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");};
 
211
 
 
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");};
 
215
 
 
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");};
 
219
 
 
220
  protected:
 
221
 
 
222
    /** pointer to Lammps compute, meant as rapid indexing only (do not use!) */
 
223
    COMPUTE_POINTER computePointer_;  
 
224
 
 
225
    /** tag for Lammps compute */
 
226
    std::string computeTag_;
 
227
 
 
228
    /** units conversion from LAMMPS to ATC units */
 
229
    double unitsConversion_;
 
230
 
 
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_;};
 
234
 
 
235
    /** gets appropriate data for lammps pointer */
 
236
    virtual double * lammps_scalar() const {return lammpsInterface_->compute_vector_peratom(computePointer_);};
 
237
 
 
238
    /** gets appropriate data for lammps pointer */
 
239
    virtual double ** lammps_vector() const {return lammpsInterface_->compute_array_peratom(computePointer_);};
 
240
 
 
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");};
 
245
 
 
246
  private:
 
247
 
 
248
    // do not define
 
249
    ComputedAtomQuantity();
 
250
 
 
251
  };
 
252
 
 
253
}
 
254
#endif