42 |
|
* |
43 |
|
* Created by Charles F. Vardeman II on 17 Feb 2006. |
44 |
|
* @author Charles F. Vardeman II |
45 |
< |
* @version $Id: shapedLattice.cpp,v 1.4 2006-05-17 21:51:42 tim Exp $ |
45 |
> |
* @version $Id: shapedLattice.cpp,v 1.5 2006-10-14 20:21:26 gezelter Exp $ |
46 |
|
* |
47 |
|
*/ |
48 |
|
|
53 |
|
#include "lattice/LatticeFactory.hpp" |
54 |
|
|
55 |
|
namespace oopse{ |
56 |
< |
shapedLattice::shapedLattice(RealType latticeConstant, |
56 |
> |
shapedLattice::shapedLattice(RealType latticeConstant, |
57 |
|
std::string latticeType) { |
58 |
< |
latticeConstant_ = latticeConstant; |
59 |
< |
latticeType_ = latticeType; |
60 |
< |
registerLattice(); |
61 |
< |
simpleLattice_ = LatticeFactory::getInstance()->createLattice(latticeType); |
62 |
< |
if (simpleLattice_ == NULL){ |
63 |
< |
std::cerr << "shapedLattice:: Error creating lattice" << std::endl; |
64 |
< |
exit(1); |
65 |
< |
} |
58 |
> |
latticeConstant_ = latticeConstant; |
59 |
> |
latticeType_ = latticeType; |
60 |
> |
registerLattice(); |
61 |
> |
simpleLattice_ = LatticeFactory::getInstance()->createLattice(latticeType); |
62 |
> |
if (simpleLattice_ == NULL){ |
63 |
> |
std::cerr << "shapedLattice:: Error creating lattice" << std::endl; |
64 |
> |
exit(1); |
65 |
> |
} |
66 |
|
|
67 |
< |
//Set the lattice constant |
67 |
> |
//Set the lattice constant |
68 |
|
std::vector<RealType> lc; |
69 |
|
lc.push_back(latticeConstant_); |
70 |
< |
simpleLattice_->setLatticeConstant(lc); |
71 |
< |
} |
72 |
< |
|
73 |
< |
|
74 |
< |
|
70 |
> |
simpleLattice_->setLatticeConstant(lc); |
71 |
> |
sitesComputed_ = false; |
72 |
> |
} |
73 |
> |
|
74 |
|
void shapedLattice::setGridDimension(Vector3d dimension){ |
75 |
|
dimension_ = dimension; |
76 |
< |
// Find number of unit cells in each direction |
77 |
< |
beginNx_ = -(int) ceil(0.5*dimension_[0]/latticeConstant_) ; |
78 |
< |
beginNy_ = -(int) ceil(0.5*dimension_[1]/latticeConstant_) ; |
79 |
< |
beginNz_ = -(int) ceil(0.5*dimension_[2]/latticeConstant_) ; |
76 |
> |
// Find number of unit cells in each direction |
77 |
> |
beginNx_ = -(int) ceil(0.5*dimension_[0]/latticeConstant_) ; |
78 |
> |
beginNy_ = -(int) ceil(0.5*dimension_[1]/latticeConstant_) ; |
79 |
> |
beginNz_ = -(int) ceil(0.5*dimension_[2]/latticeConstant_) ; |
80 |
|
endNx_ = (int) ceil(0.5*dimension_[0]/latticeConstant_); |
81 |
< |
endNy_ = (int) ceil(0.5*dimension_[1]/latticeConstant_); |
82 |
< |
endNz_ = (int) ceil(0.5*dimension_[2]/latticeConstant_); |
81 |
> |
endNy_ = (int) ceil(0.5*dimension_[1]/latticeConstant_); |
82 |
> |
endNz_ = (int) ceil(0.5*dimension_[2]/latticeConstant_); |
83 |
> |
sitesComputed_ = false; |
84 |
|
} |
85 |
|
|
86 |
< |
|
87 |
< |
|
88 |
< |
std::vector<Vector3d> shapedLattice::getPoints(){ |
89 |
< |
std::vector<Vector3d> latticePos; |
90 |
< |
|
91 |
< |
|
92 |
< |
std::vector<Vector3d> pointsOrt = simpleLattice_->getLatticePointsOrt(); |
93 |
< |
int numMolPerCell = simpleLattice_->getNumSitesPerCell(); |
94 |
< |
for(int i = beginNx_; i < endNx_; i++) { |
95 |
< |
for(int j = beginNy_; j < endNy_; j++) { |
96 |
< |
for(int k = beginNz_; k < endNz_; k++) { |
97 |
< |
//get the position of the cell sites |
98 |
< |
simpleLattice_->getLatticePointsPos(latticePos, i, j, k); |
99 |
< |
|
100 |
< |
for(int l = 0; l < numMolPerCell; l++) { |
101 |
< |
|
102 |
< |
|
103 |
< |
if (isInterior(latticePos[l])){ |
104 |
< |
Vector3d myPoint = latticePos[l]; |
105 |
< |
Vector3d myOrt = pointsOrt[l]; |
106 |
< |
coords_.push_back(myPoint); |
107 |
< |
coordsOrt_.push_back(myOrt); |
108 |
< |
} |
86 |
> |
void shapedLattice::findSites(){ |
87 |
> |
|
88 |
> |
sites_.clear(); |
89 |
> |
orientations_.clear(); |
90 |
> |
|
91 |
> |
std::vector<Vector3d> latticePos; |
92 |
> |
std::vector<Vector3d> pointsOrt = simpleLattice_->getLatticePointsOrt(); |
93 |
> |
int numMolPerCell = simpleLattice_->getNumSitesPerCell(); |
94 |
> |
|
95 |
> |
for(int i = beginNx_; i < endNx_; i++) { |
96 |
> |
for(int j = beginNy_; j < endNy_; j++) { |
97 |
> |
for(int k = beginNz_; k < endNz_; k++) { |
98 |
> |
//get the position of the cell sites |
99 |
> |
simpleLattice_->getLatticePointsPos(latticePos, i, j, k); |
100 |
> |
for(int l = 0; l < numMolPerCell; l++) { |
101 |
> |
if (isInterior(latticePos[l])){ |
102 |
> |
Vector3d myPoint = latticePos[l]; |
103 |
> |
Vector3d myOrt = pointsOrt[l]; |
104 |
> |
sites_.push_back(myPoint); |
105 |
> |
orientations_.push_back(myOrt); |
106 |
|
} |
107 |
|
} |
108 |
|
} |
109 |
|
} |
110 |
< |
|
111 |
< |
return coords_; |
112 |
< |
|
113 |
< |
} |
110 |
> |
} |
111 |
> |
sitesComputed_ = true; |
112 |
> |
} |
113 |
> |
|
114 |
> |
std::vector<Vector3d> shapedLattice::getSites() { |
115 |
> |
if (!sitesComputed_) { |
116 |
> |
findSites(); |
117 |
> |
} |
118 |
> |
return sites_; |
119 |
> |
} |
120 |
> |
|
121 |
> |
std::vector<Vector3d> shapedLattice::getOrientations() { |
122 |
> |
if (!sitesComputed_) { |
123 |
> |
findSites(); |
124 |
> |
} |
125 |
> |
return orientations_; |
126 |
> |
} |
127 |
|
} |