LatticeLevelIterator::LatticeLevelIterator(const Lattice& l) { int max; max=l.max_k() ? l.max_k() : 1; L=&l; iter=SimpleIndex(l.dim(),max); overflow=false; }
int Site::coordLocal(int direction) { if(direction==lattice_->dim()-1) { return index_/lattice_->jump(direction) - lattice_->halo(); } else if(direction==0) { return index_%lattice_->jump(1) - lattice_->halo(); } else { return (index_%lattice_->jump(direction+1)) / lattice_->jump(direction) - lattice_->halo(); } }
void Site::haloNext() { index_++; //Can only leave boundary by reaching coord(0)=0, so otherwise done if(coordLocal(0)==0) { bool is_in_halo = 0; for(int i=1; i<lattice_->dim(); i++) { if( coordLocal(i)<0 || coordLocal(i)>=lattice_->sizeLocal(i) ) { is_in_halo = 1; break; } } if(!is_in_halo) index_ += lattice_->sizeLocal(0); } }
void Site::next() { index_++; //If coordLocal(0) != sizeLocal(0) then next site reached if( coordLocal(0) != lattice_->sizeLocal(0) ) { return; } else { index_ -= lattice_->sizeLocal(0); for(int i=1; i<lattice_->dim(); i++) { index_ += lattice_->jump(i); //If coordLocal(i) !=sizeLocal(0) then next site reached if( coordLocal(i) != lattice_->sizeLocal(i) ) { return; } index_ -= lattice_->sizeLocal(i) * lattice_->jump(i); } index_ = lattice_->siteLast() + 1; } }
bool Site::setCoord(int* r) { this->first(); //Check site is local if(r[lattice_->dim()-1]<this->coord(lattice_->dim()-1) || r[lattice_->dim()-1]>=this->coord(lattice_->dim()-1)+lattice_->sizeLocal(lattice_->dim()-1) || r[lattice_->dim()-2]<this->coord(lattice_->dim()-2) || r[lattice_->dim()-2]>=this->coord(lattice_->dim()-2)+lattice_->sizeLocal(lattice_->dim()-2) ) { return false; //COUT<<"LATfield::Site::setCoord(int*) - Site desired non-local!"<<endl; } else { int jump=0; for(int i=0; i<lattice_->dim(); i++) { jump+=(r[i]-coord(i))*lattice_->jump(i); } this->indexAdvance(jump); return true; } }
int Site::coord(int direction) ////////sensible a quelle dim est scatter (seul modif a faire ici) { if(direction<lattice_->dim()-2) { return coordLocal(direction); } else if (direction==lattice_->dim()-2) {return coordLocal(direction)+lattice_->coordSkip()[1]; } else {return coordLocal(direction)+lattice_->coordSkip()[0]; } }