Skip to content

Commit 8307070

Browse files
committed
Tweak some of the setup
1 parent f25964a commit 8307070

File tree

5 files changed

+58
-90
lines changed

5 files changed

+58
-90
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ build: $(LIBRARY)
4343
CC=${CC} CXX=${CXX} CPPFLAGS="${CPPFLAGS}" ${PYTHON} setup.py build_ext --inplace
4444

4545

46-
47-
4846
clean:
4947
rm -rf ${EXTENSIONS_DIR}/*
5048
touch ${EXTENSIONS_DIR}/__init__.py
5149
rm -rf build
5250
rm -rf $(OBJECTS) $(TARGET) *.dSYM
51+
find fidimag/ "*.cpp" -exec echo {} \;
52+
5353

5454
docker:
5555
docker build -t fidimag -f ./docker/travis/Dockerfile .

native/Makefile

Lines changed: 0 additions & 32 deletions
This file was deleted.

native/include/c_demagcoef.h

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* This file demag_oommf.h is taken from the OOMMF project (oommf/app/oxs/ext/demagcoef.h
22
downloaded from http://math.nist.gov/oommf/dist/oommf12a5rc_20120928.tar.gz)
3-
with slightly modifications (change OC_REALWIDE to double)
3+
with slightly modifications (change OC_REALWIDE to double)
44
and distributed under this license shown below. */
55

6-
/* License
6+
/* License
77
88
OOMMF - Object Oriented MicroMagnetic Framework
99
@@ -130,49 +130,10 @@ double DemagNyzAsymptotic(double x, double y, double z,
130130
double dx,double dy,double dz);
131131

132132

133-
134133
////////////////////////////////////////////////////////////////////////////
135134
// Routines to do accurate summation
136135

137-
static int AS_Compare(const void* px,const void* py)
138-
{
139-
// Comparison based on absolute values
140-
double x=fabs(*((const double *)px));
141-
double y=fabs(*((const double *)py));
142-
if(x<y) return 1;
143-
if(x>y) return -1;
144-
return 0;
145-
}
146-
147-
148-
static double
149-
AccurateSum(int n,double *arr)
150-
{
151-
// Order by decreasing magnitude
152-
qsort(arr,n,sizeof(double),AS_Compare);
153-
154-
// Add up using doubly compensated summation. If necessary, mark
155-
// variables these "volatile" to protect against problems arising
156-
// from extra precision. Also, don't expect the compiler to respect
157-
// order with respect to parentheses at high levels of optimization,
158-
// i.e., write "u=x; u-=(y-corr)" as opposed to "u=x-(y-corr)".
159-
160-
double sum,corr,y,u,t,v,z,x,tmp;
161-
162-
sum=arr[0]; corr=0;
163-
for(int i=1;i<n;i++) {
164-
x=arr[i];
165-
y=corr+x;
166-
tmp=y-corr;
167-
u=x-tmp;
168-
t=y+sum;
169-
tmp=t-sum;
170-
v=y-tmp;
171-
z=u+v;
172-
sum=t+z;
173-
tmp=sum-t;
174-
corr=z-tmp;
175-
}
176-
return sum;
177-
}
178136

137+
int AS_Compare(const void* px,const void* py);
138+
139+
double AccurateSum(int n,double *arr);

native/src/c_demag_oommf.cpp

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/* This file demag_oommf.c is taken from the OOMMF project (oommf/app/oxs/ext/demagcoef.cc
1+
/* This file demag_oommf.c is taken from the OOMMF project (oommf/app/oxs/ext/demagcoef.cc
22
downloaded from http://math.nist.gov/oommf/dist/oommf12a5rc_20120928.tar.gz)
3-
with slightly modifications (change OC_REALWIDE to double)
3+
with slightly modifications (change OC_REALWIDE to double)
44
and distributed under this license shown below. */
55

6-
/* License
6+
/* License
77
88
OOMMF - Object Oriented MicroMagnetic Framework
99
@@ -46,6 +46,46 @@ to copyright protection within the United States.
4646
#include "c_demagcoef.h"
4747

4848

49+
int AS_Compare(const void* px,const void* py) {
50+
// Comparison based on absolute values
51+
double x=fabs(*((const double *)px));
52+
double y=fabs(*((const double *)py));
53+
if(x<y) return 1;
54+
if(x>y) return -1;
55+
return 0;
56+
}
57+
58+
59+
double AccurateSum(int n,double *arr) {
60+
// Order by decreasing magnitude
61+
qsort(arr,n,sizeof(double), AS_Compare);
62+
63+
// Add up using doubly compensated summation. If necessary, mark
64+
// variables these "volatile" to protect against problems arising
65+
// from extra precision. Also, don't expect the compiler to respect
66+
// order with respect to parentheses at high levels of optimization,
67+
// i.e., write "u=x; u-=(y-corr)" as opposed to "u=x-(y-corr)".
68+
69+
double sum,corr,y,u,t,v,z,x,tmp;
70+
71+
sum=arr[0]; corr=0;
72+
for(int i=1;i<n;i++) {
73+
x=arr[i];
74+
y=corr+x;
75+
tmp=y-corr;
76+
u=x-tmp;
77+
t=y+sum;
78+
tmp=t-sum;
79+
v=y-tmp;
80+
z=u+v;
81+
sum=t+z;
82+
tmp=sum-t;
83+
corr=z-tmp;
84+
}
85+
return sum;
86+
}
87+
88+
4989
/* FILE: demagcoef.cc -*-Mode: c++-*-
5090
*
5191
* Demag coefficients.
@@ -122,7 +162,7 @@ to copyright protection within the United States.
122162

123163

124164
////////////////////////////////////////////////////////////////////////////
125-
// Routines to calculate kernel coefficients
165+
// Routines to calculate kernel coefficientsAS_
126166
// See Newell et al. for details. The code below follows the
127167
// naming conventions in that paper.
128168

@@ -131,7 +171,7 @@ double SelfDemagNx(double x,double y,double z)
131171
// Note: egcs-2.91.57 on Linux/x86 with -O1 mangles this
132172
// function (produces NaN's) unless we manually group terms.
133173

134-
if(x<=0.0 || y<=0.0 || z<=0.0)
174+
if(x<=0.0 || y<=0.0 || z<=0.0)
135175
return 0.0;
136176
if (x==y && y==z)
137177
return 1./3.; // Special case: cube
@@ -285,16 +325,16 @@ Newell_g(double x,double y,double z)
285325
// handle if t=y/x (for example) as x -> 0.
286326

287327
double result_sign=1.0;
288-
if(x<0.0)
289-
result_sign *= -1.0;
290-
if(y<0.0)
328+
if(x<0.0)
329+
result_sign *= -1.0;
330+
if(y<0.0)
291331
result_sign *= -1.0;
292332
x=fabs(x); y=fabs(y); z=fabs(z); // This function is even in z and
293333
/// odd in x and y. The fabs()'s simplify special case handling.
294334

295335
double xsq=x*x,ysq=y*y,zsq=z*z;
296336
double R=xsq+ysq+zsq;
297-
if(R<=0.0)
337+
if(R<=0.0)
298338
return 0.0;
299339
else
300340
R=sqrt(R);
@@ -424,7 +464,7 @@ double DemagNxxAsymptotic(double x, double y, double z,
424464
term5 *= 0.25;
425465
}
426466

427-
double term7 = 0.0;
467+
double term7 = 0.0;
428468
{
429469
double b1 = 32*dx4 - 40*dx2dy2 - 40*dx2dz2 + 12*dy4 + 10*dy2dz2 + 12*dz4;
430470
double b2 = -240*dx4 + 580*dx2dy2 + 20*dx2dz2 - 202*dy4 - 75*dy2dz2 + 22*dz4;

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
lib_paths = [LIB_DIR, os.path.join(MODULE_DIR, 'native')]
2222
com_inc = [numpy.get_include(), INCLUDE_DIR, os.path.join(MODULE_DIR, 'native', 'include')]
2323
com_libs = ['fidimag']
24-
com_args = ['-fopenmp']
25-
24+
com_args = []
2625

2726
if 'SUNDIALS_INC' in os.environ:
2827
com_inc.append(os.environ['SUNDIALS_INC'])

0 commit comments

Comments
 (0)