Skip to content

Commit

Permalink
- function pointers are now declared as extern in interaction.h (main…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
myurkin committed Jan 26, 2021
1 parent ba7a24f commit 3f9b7b0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
27 changes: 27 additions & 0 deletions src/interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@
#include <float.h> // for DBL_EPSILON
#include <stdlib.h>

// 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
Expand Down
29 changes: 5 additions & 24 deletions src/interaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 0 additions & 3 deletions src/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3f9b7b0

Please sign in to comment.