From 3f9b7b0fc9eddf3bbcbd1160b8e306f773787cff Mon Sep 17 00:00:00 2001 From: Maxim Yurkin Date: Tue, 26 Jan 2021 10:20:55 +0700 Subject: [PATCH] - function pointers are now declared as extern in interaction.h (main definition is now in interactio.c). - removed duplicate declaration of Xmatrix in vars.c/h This fixes #284 - compilation errors with gcc version 10 and higher. --- src/interaction.c | 27 +++++++++++++++++++++++++++ src/interaction.h | 29 +++++------------------------ src/vars.c | 6 ------ src/vars.h | 3 --- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/interaction.c b/src/interaction.c index 647187cb..8735a3d3 100644 --- a/src/interaction.c +++ b/src/interaction.c @@ -24,6 +24,33 @@ #include // for DBL_EPSILON #include +// GLOBAL VARIABLES + +// function pointers, defined as extern in interaction.h +/* Calculates interaction term between two dipoles; given integer distance vector {i,j,k} (in units of d). The acting + * dipole is placed in the origin, while the field is calculated at position given as argument. All six components of + * the symmetric matrix are computed at once. The elements in result are: [G11, G12, G13, G22, G23, G33] + */ +void (*InterTerm_int)(const int i,const int j,const int k,doublecomplex result[static restrict 6]); +// same as above, but distance is passed as a double vector (in um) +void (*InterTerm_real)(const double qvec[static restrict 3],doublecomplex result[static restrict 6]); +/* Calculates reflection term between two dipoles; given integer distance vector {i,j,k} (in units of d). k is the _sum_ + * of dipole indices along z with respect to the center of bottom dipoles of the particle. Bottom is considered for the + * current processor (position) and the whole particle (position_full) in FFT and SPARSE modes respectively. The latter + * behavior is determined by ZsumShift. + * The acting dipole is placed in the origin, while the field is calculated at position given as argument. + * Six components of the matrix are computed at once: [GR11, GR12, GR13, GR22, GR23, GR33]. + * The matrix is not symmetric, but satisfies: GR21=GR12, GR31=-GR13, GR32=-GR23. However the large matrix GR, which + * acts on the total vector of dipole polarizations is still complex-symmetric, since GR[i,j]=GR^T[j,i] (interchange of + * i and j changes only the sign of x and y components, but not z, which leads to sign change of 13,31,23,32 components) + */ +void (*ReflTerm_int)(const int i,const int j,const int k,doublecomplex result[static restrict 6]); +/* same as above, but distance is passed as a double vector (in um) and its z-component is the sum of heights of + * source and probe points above the surface. So qvec_in is the actual distance between probe point and the image of the + * source point. + */ +void (*ReflTerm_real)(const double qvec[static restrict 3],doublecomplex result[static restrict 6]); + // SEMI-GLOBAL VARIABLES // defined and initialized in make_particle.c diff --git a/src/interaction.h b/src/interaction.h index c59fa5d3..f0396c8e 100644 --- a/src/interaction.h +++ b/src/interaction.h @@ -17,30 +17,11 @@ #include "cmplx.h" -/* Calculates interaction term between two dipoles; given integer distance vector {i,j,k} (in units of d). The acting - * dipole is placed in the origin, while the field is calculated at position given as argument. All six components of - * the symmetric matrix are computed at once. The elements in result are: [G11, G12, G13, G22, G23, G33] - */ -void (*InterTerm_int)(const int i,const int j,const int k,doublecomplex result[static restrict 6]); -// same as above, but distance is passed as a double vector (in um) -void (*InterTerm_real)(const double qvec[static restrict 3],doublecomplex result[static restrict 6]); - -/* Calculates reflection term between two dipoles; given integer distance vector {i,j,k} (in units of d). k is the _sum_ - * of dipole indices along z with respect to the center of bottom dipoles of the particle. Bottom is considered for the - * current processor (position) and the whole particle (position_full) in FFT and SPARSE modes respectively. The latter - * behavior is determined by ZsumShift. - * The acting dipole is placed in the origin, while the field is calculated at position given as argument. - * Six components of the matrix are computed at once: [GR11, GR12, GR13, GR22, GR23, GR33]. - * The matrix is not symmetric, but satisfies: GR21=GR12, GR31=-GR13, GR32=-GR23. However the large matrix GR, which - * acts on the total vector of dipole polarizations is still complex-symmetric, since GR[i,j]=GR^T[j,i] (interchange of - * i and j changes only the sign of x and y components, but not z, which leads to sign change of 13,31,23,32 components) - */ -void (*ReflTerm_int)(const int i,const int j,const int k,doublecomplex result[static restrict 6]); -/* same as above, but distance is passed as a double vector (in um) and its z-component is the sum of heights of - * source and probe points above the surface. So qvec_in is the actual distance between probe point and the image of the - * source point. - */ -void (*ReflTerm_real)(const double qvec[static restrict 3],doublecomplex result[static restrict 6]); +// following function pointers are explained in interaction.c +extern void (*InterTerm_int)(const int i,const int j,const int k,doublecomplex result[static restrict 6]); +extern void (*InterTerm_real)(const double qvec[static restrict 3],doublecomplex result[static restrict 6]); +extern void (*ReflTerm_int)(const int i,const int j,const int k,doublecomplex result[static restrict 6]); +extern void (*ReflTerm_real)(const double qvec[static restrict 3],doublecomplex result[static restrict 6]); void InitInteraction(void); void FreeInteraction(void); diff --git a/src/vars.c b/src/vars.c index 0649c804..7d54d7bb 100644 --- a/src/vars.c +++ b/src/vars.c @@ -139,12 +139,6 @@ double prIncRefl[3],prIncTran[3]; // position of the dipoles; in the very end of make_particle() z-components are adjusted to be relative to the local_z0 unsigned short * restrict position; - -/* holds input vector (on expanded grid) to matvec. Also used as buffer in certain algorithms, that do not call MatVec - * (this should be strictly ensured !!!) - */ -doublecomplex * restrict Xmatrix; - // auxiliary grids and their partition over processors size_t gridX,gridY,gridZ; /* sizes of the 'matrix' X, size_t - to remove type conversions we assume that 'int' is enough for it, but this declaration is to avoid type casting in calculations */ diff --git a/src/vars.h b/src/vars.h index 12780f2b..a7fcc267 100644 --- a/src/vars.h +++ b/src/vars.h @@ -89,9 +89,6 @@ extern double inc_scale,hsub,prIncRefl[3],prIncTran[3]; #ifndef SPARSE // These variables are exclusive to the FFT mode extern unsigned short * restrict position; - -extern doublecomplex * restrict Xmatrix; - // auxiliary grids and their partition over processors extern size_t gridX,gridY,gridZ; extern size_t gridYZ;