Skip to content

Commit 8065d78

Browse files
committed
Update generate, coordinates storing.
1 parent 485ec35 commit 8065d78

File tree

6 files changed

+44
-27350
lines changed

6 files changed

+44
-27350
lines changed

fidimag/atomistic/demag.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from fidimag.atomistic.energy import Energy
77
import fidimag.extensions.fmm as fmm
88
import time
9-
9+
import sys
1010

1111

1212
class Demag(Energy):
@@ -47,7 +47,7 @@ def __init__(self, calc_every=0, name='Demag'):
4747

4848
def setup(self, mesh, spin, mu_s, mu_s_inv):
4949
super(Demag, self).setup(mesh, spin, mu_s, mu_s_inv)
50-
50+
5151
# Ryan Pepper 04/04/2019
5252
# We *do not* need to scale by mesh.unit_length**3 here!
5353
# This is because in the base energy class, dx, dy and dz
@@ -102,7 +102,7 @@ def compute_energy(self):
102102
return energy / self.scale
103103

104104

105-
class DemagFMM(Energy):
105+
class DemagFMM(Energy):
106106
def __init__(self, order, ncrit, theta, name="DemagFMM"):
107107
self.name = name
108108
assert order > 0, "Order must be 1 or higher"
@@ -116,14 +116,16 @@ def __init__(self, order, ncrit, theta, name="DemagFMM"):
116116
def setup(self, mesh, spin, mu_s, mu_s_inv):
117117
super(DemagFMM, self).setup(mesh, spin, mu_s, mu_s_inv)
118118
self.n = mesh.n
119-
print(mesh.coordinates)
120119
self.m_temp = spin.copy()
121120
self.m_temp[0::3] *= self.mu_s
122121
self.m_temp[1::3] *= self.mu_s
123122
self.m_temp[2::3] *= self.mu_s
123+
self.coords = mesh.coordinates * mesh.unit_length
124+
print(np.min(self.coords[:, 0]))
125+
print(np.max(self.coords[:, 0]))
124126
self.fmm = fmm.FMM(self.n, self.ncrit, self.theta,
125127
self.order,
126-
mesh.coordinates * mesh.unit_length,
128+
self.coords,
127129
self.m_temp)
128130

129131
def compute_field(self, t=0, spin=None):
@@ -134,6 +136,6 @@ def compute_field(self, t=0, spin=None):
134136

135137
self.field[:] = 0.0
136138
#self.fmm.set(self.m_temp)
137-
self.fmm.compute_field(self.theta, self.field)
139+
self.fmm.compute_field(self.field)
138140
self.field *= 1e-7
139141
return self.field

fidimag/atomistic/fmmlib/calculate.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void interact_dehnen(size_t A, size_t B, std::vector<Cell> &cells, std::vector<P
144144
}
145145
}
146146

147+
147148
void interact_dehnen_lazy(const size_t A, const size_t B,
148149
const std::vector<Cell> &cells,
149150
const std::vector<Particle> &particles,
@@ -155,6 +156,7 @@ void interact_dehnen_lazy(const size_t A, const size_t B,
155156
const double dy = cells[A].y - cells[B].y;
156157
const double dz = cells[A].z - cells[B].z;
157158
const double R = sqrt(dx*dx + dy*dy + dz*dz);
159+
// std::cout << "cells["<<A<<"].rmax = " << cells[A].rmax << "cells["<<B<<"].rmax = " << cells[B].rmax << std::endl;
158160

159161
if (R*theta > (cells[A].rmax + cells[B].rmax)) {
160162
//if (cells[A].nleaf < ncrit && cells[B].nleaf < ncrit) {
@@ -305,7 +307,6 @@ void evaluate_approx_lazy(std::vector<Particle> &particles, std::vector<Cell> &c
305307
#pragma omp barrier
306308
evaluate_L2P(particles, cells, F, ncrit, order);
307309
}
308-
309310
}
310311

311312

@@ -315,15 +316,17 @@ void build_interaction_lists(std::vector<std::pair<size_t, size_t>> &M2L_list,
315316
std::vector<Particle> &particles,
316317
double theta,
317318
size_t order,
318-
size_t ncrit
319-
) {
319+
size_t ncrit) {
320+
321+
322+
interact_dehnen_lazy(0, 0, cells, particles, theta, order, ncrit, M2L_list, P2P_list);
323+
324+
std::cout << "M2L_list.size() = " << M2L_list.size() << std::endl;
325+
std::cout << "P2P_list.size() = " << P2P_list.size() << std::endl;
320326

321327
std::sort(M2L_list.begin(), M2L_list.end(),
322328
[](std::pair<size_t, size_t> &left, std::pair<size_t, size_t> &right) {
323329
return left.first < right.first;
324330
}
325331
);
326-
327-
std::cout << "M2L_list size = " << M2L_list.size() << std::endl;
328-
std::cout << "P2P_list size = " << P2P_list.size() << std::endl;
329-
}
332+
}

0 commit comments

Comments
 (0)