34 #include "Utils/clusterspecifier.h" 41 #include "Math/point.h" 51 for(
int i = 0; i < su3lat.sites; i++){
52 su3lat.lattice.at(i).setSU3Zero();
53 su3lat.lattice.at(i).mat[1]= lat.at(i);
54 su3lat.lattice.at(i).mat[9]= lat.at(i);
55 su3lat.lattice.at(i).mat[17]= lat.at(i);
60 for(
int i = 0; i < su3lat.sites; i++){
61 su3lat.lattice.at(i).setSU3Zero();
62 su3lat.lattice.at(i).mat[1]= lat.at(i);
63 su3lat.lattice.at(i).mat[9]= lat.at(i);
64 su3lat.lattice.at(i).mat[17]= lat.at(i);
72 for(
int i = 0; i < su3lat.sites; i++)
73 su3lat.lattice.at(i).setSU3Zero();
80 for(
int i = 0; i < su3lat.sites; i++)
81 su3lat.lattice.at(i).setSU3Identity();
88 void Lattice::setToRandom(){
89 for(
int x = 0; x < size[0]; x++){
90 for(
int y = 0; y < size[1]; y++){
91 for(
int z = 0; z < size[2]; z++){
92 for(
int t = 0; t < size[3]; t++){
93 for(
int mu = 0; mu < 4; mu++){
103 void Lattice::setToUnity(){
104 for(
int x = 0; x < size[0]; x++){
105 for(
int y = 0; y < size[1]; y++){
106 for(
int z = 0; z < size[2]; z++){
107 for(
int t = 0; t < size[3]; t++){
108 for(
int mu = 0; mu < 4; mu++){
109 lattice[x][y][z][t][mu].setSU3Identity();
120 SU3 Lattice::shift(
int x,
int y,
int z,
int t,
int mu,
int shiftDir,
int shiftSign){
121 std::vector<int> idx = {x,y,z,t};
122 int mpiShifts = 0, mpiShiftDir = -1, mpiShiftSign;
125 for(
int i = 0; i < 4; i++){
126 if(shiftDir == i) idx[i] += shiftSign;
132 if(idx[i] == size[i]){
139 if(mpiShifts == 0)
return lattice[idx[0]][idx[1]][idx[2]][idx[3]][mu];
146 std::vector<int> sendIdx = {x,y,z,t};
147 for(
int i = 0; i < 4; i++){
148 if(mpiShiftDir == i && idx[i] == -1){
149 sendIdx[i] = size[i]-1;
152 else if(mpiShiftDir == i && idx[i] == size[i]){
160 MPI_Sendrecv(lattice[sendIdx[0]][sendIdx[1]][sendIdx[2]][sendIdx[3]][mu].mat.data(), 18, MPI_DOUBLE,
Parallel::getNeighbor(mpiShiftDir, mpiShiftSign), 0,
162 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
163 return std::move(msg);
174 SU3 Lattice::shift2(
int x,
int y,
int z,
int t,
int mu,
int shiftDir,
int shiftSign,
int shiftDir2,
int shiftSign2){
175 std::vector<int> idx = {x,y,z,t};
176 int mpiShifts = 0, mpiShiftDir = -1, mpiShiftDir2, mpiShiftSign, mpiShiftSign2;
179 for(
int i = 0; i < 4; i++){
180 if(shiftDir == i) idx[i] += shiftSign;
181 if(shiftDir2 == i) idx[i] += shiftSign2;
185 if(mpiShiftDir == -1) mpiShiftDir = i;
186 else mpiShiftDir2 = i;
188 if(idx[i] == size[i]){
190 if(mpiShiftDir == -1) mpiShiftDir = i;
191 else mpiShiftDir2 = i;
196 if(mpiShifts == 0)
return lattice[idx[0]][idx[1]][idx[2]][idx[3]][mu];
203 std::vector<int> sendIdx = {x,y,z,t};
204 for(
int i = 0; i < 4; i++){
205 if(mpiShiftDir == i && idx[i] == -1){
206 sendIdx[i] = size[i]-1;
209 else if(mpiShiftDir == i && idx[i] == size[i]){
217 MPI_Sendrecv(lattice[sendIdx[0]][sendIdx[1]][sendIdx[2]][sendIdx[3]][mu].mat.data(), 18, MPI_DOUBLE,
Parallel::getNeighbor(mpiShiftDir, mpiShiftSign), 0,
219 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
220 return std::move(msg);
226 std::vector<int> sendIdx = {x,y,z,t};
227 for(
int i = 0; i < 4; i++){
228 if(mpiShiftDir == i && idx[i] == -1){
229 sendIdx[i] = size[i]-1;
232 else if(mpiShiftDir == i && idx[i] == size[i]){
236 else if(mpiShiftDir2 == i && idx[i] == -1){
237 sendIdx[i] = size[i]-1;
240 else if(mpiShiftDir2 == i && idx[i] == size[i]){
247 MPI_Sendrecv(lattice[sendIdx[0]][sendIdx[1]][sendIdx[2]][sendIdx[3]][mu].mat.data(), 18, MPI_DOUBLE,
249 msg.mat.data(), 18, MPI_DOUBLE,
Parallel::getSecondNeighbor(mpiShiftDir, abs(mpiShiftSign-1), mpiShiftDir2, abs(mpiShiftSign2-1)), 0,
250 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
251 return std::move(msg);
static SU3 randSU3()
returns random SU3 matrix, by choosing 2 random complex vectors as the first two columns, orthogonalizing them and taking the outer product as a third column
Contains the definition of the Lattice class.
Implementation of a class to perform arithmetics between links.
void setToIdentity(Lattice< SU3 > &su3lat)
sets a lattice object to all identity matrices
Utilities for parallelization.
Basic library to implement SU3 matrix arithmetics and functions.
void setToZero(Lattice< SU3 > &su3lat)
sets a lattice object to all zero matrices
void setLatticeImagIdentityValue(Lattice< SU3 > &su3lat, const Lattice< double > &lat)
sets a lattice object to only diagonal matrices with complex values
static int getSecondNeighbor(int direction1, int sign1, int direction2, int sign2)
return the rank of the neighbor along the two given directions and signs
static int getNeighbor(int direction, int sign)
return the rank of the neighbor along the given direction and sign
Contains the definition of the Random class.