Skip to content

Commit 7e42a94

Browse files
committed
Move micro C++ files to native directory and resolve duplicate function names
1 parent ca06d0f commit 7e42a94

File tree

12 files changed

+84
-9144
lines changed

12 files changed

+84
-9144
lines changed

fidimag/common/lib/helper_cython.cpp

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

fidimag/micro/lib/anis.cpp

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

native/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.PHONY : clean
2+
3+
FFTW_INC=../local/include
4+
FFTW_LIB=../local/lib
5+
6+
SUNDIALS_INC=../local/include
7+
SUNDIALS_LIB=../local/lib
8+
9+
CPPFLAGS = -fPIC -g -Iinclude/ \
10+
-I${FFTW_INC} -L${FFTW_LIB} \
11+
-I${SUNDIALS_INC} -L${SUNDIALS_LIB} \
12+
-lm \
13+
-lfftw3_omp -lfftw3 \
14+
-lsundials_cvodes -lsundials_nvecserial -lsundials_nvecopenmp \
15+
-lblas -llapack \
16+
-fopenmp
17+
18+
LDFLAGS = -shared
19+
20+
SOURCES = $(shell echo src/*.cpp)
21+
22+
OBJECTS = $(SOURCES:.cpp=.o)
23+
24+
TARGET = libfidimag.so
25+
26+
all: $(TARGET)
27+
28+
clean:
29+
rm -rf $(OBJECTS) $(TARGET) *.dSYM
30+
31+
$(TARGET) : $(OBJECTS)
32+
$(CXX) $(CPPFLAGS) $(OBJECTS) -o $@ $(LDFLAGS)

fidimag/micro/lib/baryakhtar/baryakhtar_clib.h renamed to native/include/m_baryakhtar_clib.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#define WIDE_PI 3.1415926535897932384626433832795L
66
#define MU0 1.25663706143591728850e-6
77

8-
inline double cross_x(double a0, double a1, double a2, double b0, double b1, double b2) { return a1*b2 - a2*b1; }
9-
inline double cross_y(double a0, double a1, double a2, double b0, double b1, double b2) { return a2*b0 - a0*b2; }
10-
inline double cross_z(double a0, double a1, double a2, double b0, double b1, double b2) { return a0*b1 - a1*b0; }
11-
128
void compute_laplace_m(double *m, double *field, double *Ms, double dx, double dy, double dz,
139
int nx, int ny, int nz);
1410

fidimag/micro/lib/micro_clib.h renamed to native/include/m_clib.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
#include<math.h>
2-
32
#include<omp.h>
43

54
#define WIDE_PI 3.1415926535897932384626433832795L
65
#define MU0 1.25663706143591728850e-6
76
#define MU0_INV 795774.71545947669074
87

9-
inline double cross_x(double a0, double a1, double a2,
10-
double b0, double b1, double b2) { return a1*b2 - a2*b1; }
11-
inline double cross_y(double a0, double a1, double a2,
12-
double b0, double b1, double b2) { return a2*b0 - a0*b2; }
13-
inline double cross_z(double a0, double a1, double a2,
14-
double b0, double b1, double b2) { return a0*b1 - a1*b0; }
8+
double cross_x(double a0, double a1, double a2, double b0, double b1, double b2);
9+
double cross_y(double a0, double a1, double a2, double b0, double b1, double b2);
10+
double cross_z(double a0, double a1, double a2, double b0, double b1, double b2);
1511

1612
void compute_exch_field_micro(double * m, double * field, double * energy, double * Ms_inv,
1713
double A, double dx, double dy, double dz, int n, int *ngbs);

native/src/m_anis.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "m_clib.h"
2+
3+
void compute_uniaxial_anis(double * m, double * field, double * energy, double * Ms_inv,
4+
double * Ku, double * axis, int nx, int ny, int nz) {
5+
6+
int n = nx * ny * nz;
7+
8+
#pragma omp parallel for
9+
for (int i = 0; i < n; i++) {
10+
int j = 3 * i;
11+
12+
if (Ms_inv[i] == 0.0){
13+
field[j] = 0;
14+
field[j + 1] = 0;
15+
field[j + 2] = 0;
16+
energy[i] = 0;
17+
continue;
18+
}
19+
20+
double m_u = m[j] * axis[j] + m[j + 1] * axis[j + 1] + m[j + 2] * axis[j + 2];
21+
22+
field[j] = 2 * Ku[i] * m_u * Ms_inv[i] * MU0_INV * axis[j];
23+
field[j + 1] = 2 * Ku[i] * m_u * Ms_inv[i] * MU0_INV * axis[j + 1];
24+
field[j + 2] = 2 * Ku[i] * m_u * Ms_inv[i] * MU0_INV * axis[j + 2];
25+
26+
energy[i] = Ku[i] * (1 - m_u * m_u);
27+
}
28+
}
29+

fidimag/micro/lib/baryakhtar/llg.cpp renamed to native/src/m_baryakhtar_llg.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include "baryakhtar_clib.h"
1+
#include "m_clib.h"
2+
#include "m_baryakhtar_clib.h"
3+
24

35
void llg_rhs_baryakhtar(double *dm_dt, double *m, double *h, double *delta_h,
46
double *alpha, double beta, int *pins,

fidimag/micro/lib/baryakhtar/util.cpp renamed to native/src/m_baryakhtar_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "baryakhtar_clib.h"
1+
#include "m_baryakhtar_clib.h"
22

33
void compute_laplace_m(double *m, double *field, double *Ms, double dx,
44
double dy, double dz, int nx, int ny, int nz) {

fidimag/micro/lib/dmi.cpp renamed to native/src/m_dmi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "micro_clib.h"
1+
#include "m_clib.h"
22
#include <stdlib.h>
33
#include <stdio.h>
44
#include <math.h>

0 commit comments

Comments
 (0)