1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
|
// A class for defining atomic quantities for interscale operations
#ifndef PER_PAIR_QUANTITY_H
#define PER_PAIR_QUANTITY_H
// ATC_Method headers
#include "LammpsInterface.h"
#include "DependencyManager.h"
#include "PerAtomQuantity.h"
#include <map>
#include <utility>
#include <string>
namespace ATC {
/** mapping of atomic pairs to pair index value */
typedef std::map< std::pair< int,int >,int > PAIR_MAP;
typedef std::map< std::pair< int,int >,int >::const_iterator PAIR_MAP_ITERATOR;
typedef std::pair< std::pair< int,int >,int > ATOM_PAIR;
/**
* @class PairMap
* @brief Base class maps of pair indices to a single index
*/
class PairMap : public DependencyManager {
public:
PairMap(LammpsInterface * lammpsInterface, int groupbit);
virtual ~PairMap(void);
virtual void reset(void) const = 0;
void quantity() {};
void set_quantity() { throw ATC_Error("inappropriate access to pair map");}
// lammps communication
virtual void post_exchange() {this->force_reset();};
virtual void rest_nlocal() {this->force_reset();};
// iterator interface
int size(void) const {
if (this->need_reset()) reset();
return nPairs_+nBonds_;
}
int num_bonds(void) const { return nBonds_; }
virtual ATOM_PAIR start() const = 0; // const reset / non-const call propagte reset
virtual ATOM_PAIR next() const = 0;
//ATOM_PAIR& operator++ () {return next();} // prefix ++: no parameter, returns a reference
ATOM_PAIR operator++ (int) const {return next();} // postfix ++: dummy parameter, returns a value
virtual bool finished() const = 0;
protected:
LammpsInterface * lammpsInterface_;
int groupbit_;
mutable int nPairs_;
mutable int nBonds_;
private:
PairMap();// do not define
};
class PairMapNeighbor : public PairMap {
public:
PairMapNeighbor(LammpsInterface * lammpsInterface, int groupbit);
virtual ~PairMapNeighbor(void) {};
virtual void reset(void) const;
virtual ATOM_PAIR start(void) const {
if (this->need_reset()) reset();
iterator_ = pairMap_.begin(); return *iterator_;}
virtual ATOM_PAIR next(void) const {
iterator_++; return *iterator_;}
virtual bool finished() const {
return (iterator_==pairMap_.end());}
protected:
mutable PAIR_MAP pairMap_;
private:
mutable PAIR_MAP_ITERATOR iterator_;
PairMapNeighbor();// do not define
};
class PairMapBond : public PairMap {
public:
PairMapBond(LammpsInterface * lammpsInterface, int groupbit);
virtual ~PairMapBond(void) {};
virtual bool need_reset(void) const { return true;}
virtual void reset(void) const {nBonds_ = lammpsInterface_->bond_list_length(); };
ATOM_PAIR start() const {
reset();
// if (needs_reset()) propagate_reset()
index_ = 0; return atom_pair(index_);}
ATOM_PAIR next() const {return atom_pair(++index_);}
bool finished() const { return index_==nBonds_; }
ATOM_PAIR atom_pair(int n) const {
if ( !(n<nBonds_) ) {
std::pair<int,int> pair_ij(-1,-1); // this is the "end" value
ATOM_PAIR p(pair_ij,n);
return p;
}
int * bond = (lammpsInterface_->bond_list())[n];
std::pair<int,int> pair_ij(bond[0],bond[1]);
ATOM_PAIR p(pair_ij,n);
return p;
}
private:
mutable int index_;
PairMapBond();// do not define
};
class PairMapBoth : public PairMapNeighbor {
public:
PairMapBoth(LammpsInterface * lammpsInterface, int groupbit);
virtual ~PairMapBoth(void) {};
virtual bool need_reset(void) const {
nBonds_ = lammpsInterface_->bond_list_length();
return PairMapNeighbor::need_reset();
}
virtual void reset(void) const {
nBonds_ = lammpsInterface_->bond_list_length();
PairMapNeighbor::reset();
}
virtual ATOM_PAIR start(void) const {
if (need_reset()) reset();
index_ = 0;
iterator_ = pairMap_.begin();
return atom_pair(index_); // start with bonds
}
virtual ATOM_PAIR next(void) const {
++index_;
if (index_ < nBonds_) { return atom_pair(index_);}
else { if (index_>nBonds_) iterator_++; return *iterator_; }
}
ATOM_PAIR atom_pair(int n) const {
int * bond = (lammpsInterface_->bond_list())[n];
std::pair<int,int> pair_ij(bond[0],bond[1]);
ATOM_PAIR p(pair_ij,n);
return p;
}
virtual bool finished() const {
return (iterator_==pairMap_.end());}
private:
mutable int index_;
mutable PAIR_MAP_ITERATOR iterator_;
PairMapBoth();// do not define
};
/**
* @class DensePerPairQuantity
* @brief Base class for objects that manage pair/bond quantities
*/
class DensePerPairMatrix : public MatrixDependencyManager<DenseMatrix, double> {
public:
// constructor
DensePerPairMatrix(LammpsInterface * lammpsInterface,
const PairMap & pairMap,
int nCols = 1);
// destructor
virtual ~DensePerPairMatrix(){};
/** access to a constant dense matrix of the quantity */
virtual const DenseMatrix<double> & quantity() const
{this->reset(); return MatrixDependencyManager<DenseMatrix, double>::quantity();};
/** access to a non-constant dens matrix of the quantity */
virtual DenseMatrix<double> & set_quantity()
{this->reset(); return MatrixDependencyManager<DenseMatrix, double>::set_quantity();}
/** number of columns in quantity */
INDEX nCols() const {return nCols_;};
/** resets data, if necessary */
virtual void reset() const = 0;
protected:
/** pointer to access Lammps data */
LammpsInterface * lammpsInterface_;
/** reference to pair map */
const PairMap & pairMap_;
/** number of columns of the per atom quantity -static */
int nCols_;
private:
DensePerPairMatrix(); // do not define
};
/**
* @class PairVirial
* @brief f_ab (x) x_ab where (ab) -> p
*/
class PairVirial : public DensePerPairMatrix {
public:
// constructor
PairVirial(LammpsInterface * lammpsInterface,
const PairMap & pairMap, int nCols);
// destructor
virtual ~PairVirial(){};
/** resets data, if necessary */
virtual void reset() const = 0;
private:
PairVirial(void); // do not define
};
/**
* @class PairVirial
* @brief f_ab (x) x_ab where (ab) -> p
*/
class PairVirialEulerian : public PairVirial {
public:
// constructor
PairVirialEulerian(LammpsInterface * lammpsInterface,
const PairMap & pairMap);
// destructor
virtual ~PairVirialEulerian(){};
/** resets data, if necessary */
virtual void reset() const;
private:
PairVirialEulerian(void); // do not define
};
class PairVirialLagrangian : public PairVirial {
public:
// constructor
PairVirialLagrangian(LammpsInterface * lammpsInterface,
const PairMap & pairMap,
double ** xRef);
// const PerAtomQuantity<double> * x0);
// destructor
virtual ~PairVirialLagrangian(){};
/** resets data, if necessary */
virtual void reset() const;
protected:
double ** xRef_; // note difficult to make a ** const
// const PerAtomQuantity<double> * xRef_;
private:
PairVirialLagrangian(void); // do not define
};
/**`
* @class PairPotentialHeatFlux
* @brief f_ab v_b where (ab) -> p
*/
class PairPotentialHeatFlux : public DensePerPairMatrix {
public:
// constructor
PairPotentialHeatFlux(LammpsInterface * lammpsInterface,
const PairMap & pairMap);
// destructor
virtual ~PairPotentialHeatFlux(){};
/** resets data, if necessary */
virtual void reset() const =0;
private:
PairPotentialHeatFlux(void); // do not define
};
class PairPotentialHeatFluxEulerian : public PairPotentialHeatFlux {
public:
// constructor
PairPotentialHeatFluxEulerian(LammpsInterface * lammpsInterface,
const PairMap & pairMap);
// destructor
virtual ~PairPotentialHeatFluxEulerian(){};
/** resets data, if necessary */
virtual void reset() const;
private:
PairPotentialHeatFluxEulerian(void); // do not define
};
class PairPotentialHeatFluxLagrangian : public PairPotentialHeatFlux {
public:
// constructor
PairPotentialHeatFluxLagrangian(LammpsInterface * lammpsInterface,
const PairMap & pairMap, double ** xRef);
// destructor
virtual ~PairPotentialHeatFluxLagrangian(){};
/** resets data, if necessary */
virtual void reset() const;
protected:
double ** xRef_; // note difficult to make a ** const
//const PerAtomQuantity<double> * x0_;
private:
PairPotentialHeatFluxLagrangian(void); // do not define
};
/**
* @class SparsePerPairMatrix
* @brief Base class for objects that manage pair/bond quantities
*/
class SparsePerPairMatrix : public MatrixDependencyManager<SparseMatrix, double> {
public:
// constructor
SparsePerPairMatrix(LammpsInterface * lammpsInterface,
const PairMap & pairMap);
// destructor
virtual ~SparsePerPairMatrix(){};
/** access to a constant dense matrix of the quantity */
virtual const SparseMatrix<double> & quantity() const
{reset(); return MatrixDependencyManager<SparseMatrix, double>::quantity();};
/** access to a non-constant dens matrix of the quantity */
virtual SparseMatrix<double> & set_quantity()
{reset(); return MatrixDependencyManager<SparseMatrix, double>::set_quantity();}
/** resets data, if necessary */
virtual void reset() const = 0;
protected:
/** pointer to access Lammps data */
LammpsInterface * lammpsInterface_;
/** reference to pair map */
const PairMap & pairMap_;
private:
SparsePerPairMatrix(); // do not define
};
/**
* @class BondMatrix
* @brief Hardy's B_Iab wher (ab) -> p
*/
class BondMatrix : public SparsePerPairMatrix {
public:
// constructor
BondMatrix(LammpsInterface * lammpsInterface,
const PairMap & pairMap, double ** x_, const class FE_Mesh * feMesh);
// destructor
virtual ~BondMatrix(){};
/** resets data, if necessary */
virtual void reset() const = 0;
protected:
double ** x_;
const class FE_Mesh * feMesh_;
private:
BondMatrix(void); // do not define
};
/**
* @class BondMatrixKernel
* @brief Hardy's B_Iab wher (ab) -> p
*/
class BondMatrixKernel : public BondMatrix {
public:
// constructor
BondMatrixKernel(LammpsInterface * lammpsInterface,
const PairMap & pairMap,
double ** x,
const class FE_Mesh * feMesh,
const class KernelFunction * kernelFunction);
// destructor
virtual ~BondMatrixKernel(){};
/** resets data, if necessary */
virtual void reset() const;
protected:
const class KernelFunction * kernelFunction_;
private:
BondMatrixKernel(void); // do not define
};
/**
* @class BondMatrixPartitionOfUnity
* @brief Hardy's B_Iab wher (ab) -> p
*/
class BondMatrixPartitionOfUnity : public BondMatrix {
public:
// constructor
BondMatrixPartitionOfUnity(LammpsInterface * lammpsInterface,
const PairMap & pairMap,
double ** x,
const class FE_Mesh * feMesh,
const DIAG_MAN * invVol);
// destructor
virtual ~BondMatrixPartitionOfUnity(){};
/** resets data, if necessary */
virtual void reset() const;
protected:
const DIAG_MAN * invVols_;
static const int lineNgauss_ = 10;
double lineXg_[lineNgauss_], lineWg_[lineNgauss_];
private:
BondMatrixPartitionOfUnity(void); // do not define
};
}
#endif
|