Matrix calculateDemagTensor_old(long double lx, long double ly, long double lz, int nx, int ny, int nz, int ex, int ey, int ez, int repeat_x, int repeat_y, int repeat_z) { LOG_DEBUG<< "Generating."; Matrix N(Shape(6, ex, ey, ez)); N.fill(0.0); Matrix::wo_accessor N_acc(N); const int dx_len = repeat_x*nx-1; const int dy_len = repeat_y*ny-1; const int dz_len = repeat_z*nz-1; int cnt = 0, percent = 0; for (int dz=0; dz<=+dz_len; dz+=1) { for (int dy=0; dy<=+dy_len; dy+=1) { for (int dx=0; dx<=+dx_len; dx+=1) { computeEntry(N_acc, dx, dy, dz, lx, ly, lz, ex, ey, ez); } cnt += 1; if (100.0 * cnt / ((dy_len+1)*(dz_len+1)) > percent) { LOG_INFO << " " << percent << "%"; percent += 5; } } } LOG_INFO << "Done."; return N; }
void SymmetricMatrixVectorConvolution_Simple::execute(const VectorMatrix &rhs, VectorMatrix &res) { Matrix::ro_accessor N_acc(lhs); VectorMatrix::const_accessor M_acc(rhs); VectorMatrix:: accessor H_acc(res); // H(r) = int N(r-r')*M(r') dr' // Hx = Nxx*Mx + Nxy*My + Nxz*Mz // Hy = Nyx*Mx + Nyy*My + Nyz*Mz // Hz = Nxz*Mx + Nyz*My + Nzz*Mz for (int z=0; z<dim_z; ++z) for (int y=0; y<dim_y; ++y) for (int x=0; x<dim_x; ++x) { Vector3d H(0.0, 0.0, 0.0); for (int o=0; o<dim_z; ++o) for (int n=0; n<dim_y; ++n) for (int m=0; m<dim_x; ++m) { // (X,Y,Z): position in demag tensor field matrix const int X = (x-m+exp_x) % exp_x; const int Y = (y-n+exp_y) % exp_y; const int Z = (z-o+exp_z) % exp_z; const double Nxx = N_acc.at(0,X,Y,Z); const double Nxy = N_acc.at(1,X,Y,Z); const double Nxz = N_acc.at(2,X,Y,Z); const double Nyy = N_acc.at(3,X,Y,Z); const double Nyz = N_acc.at(4,X,Y,Z); const double Nzz = N_acc.at(5,X,Y,Z); const Vector3d &M = M_acc.get(m, n, o); H.x += Nxx*M.x + Nxy*M.y + Nxz*M.z; H.y += Nxy*M.x + Nyy*M.y + Nyz*M.z; H.z += Nxz*M.x + Nyz*M.y + Nzz*M.z; } H_acc.set(x,y,z,H); } }