# ?_Helmholtz_2D/?_Helmholtz_3D

Computes the solution of 2D/3D Helmholtz problem specified by the parameters.

## Syntax

void d_Helmholtz_2D(double* f, double* bd_ax, double* bd_bx, double* bd_ay, double* bd_by, DFTI_DESCIPTOR* xhandle, int* ipar, double* dpar, int* stat);

void s_Helmholtz_2D (float* f, float* bd_ax, float* bd_bx, float* bd_ay, float* bd_by, DFTI_DESCIPTOR* xhandle, int* ipar, float* spar, int* stat);

void d_Helmholtz_3D(double* f, double* bd_ax, double* bd_bx, double* bd_ay, double* bd_by, double* bd_az, double* bd_bz, DFTI_DESCIPTOR* xhandle, DFTI_DESCIPTOR* yhandle, int* ipar, double* dpar, int* stat);

void s_Helmholtz_3D(float* f, float* bd_ax, float* bd_bx, float* bd_ay, float* bd_by, float* bd_az, float* bd_bz, DFTI_DESCIPTOR* xhandle, DFTI_DESCIPTOR* yhandle, int* ipar, float* spar, int* stat);

## Input Parameters

f | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. Contains the right-hand side of the problem packed in a single vector and modified by the appropriate ?_commit_Helmholtz_2D/?_commit_Helmholtz_3D routine. Note that an attempt to substitute the original right-hand side vector at this point will result in a wrong solution. The size of the vector for the 2D problem is (nx+1)*(ny+1). In this case, value of the right-hand side in the mesh point (i, j) is stored in f[i+j*(nx+1)] . The size of the vector for the 3D problem is (nx+1)*(ny+1)*(nz+1). In this case, value of the right-hand side in the mesh point (i, j, k) is stored in f[i+j*(nx+1)+k*(nx+1)*(ny+1)].
xhandle, yhandle | DESCIPTOR_HANDLE*. Data structures used by the Intel MKL FFT interface (for details, refer to FFT Functions). yhandle is used only by ?_Helmholtz_3D.
ipar | int array of size 128. Contains integer data to be used by Fast Helmholtz Solver (for details, refer to Common Parameters).
dpar | double array of size 5*nx/2+7 in the 2D case or 5*(nx+ny)/2+9 in the 3D case. Contains double-precision data to be used by Fast Helmholtz Solver (for details, refer toCommon Parameters
spar | float array of size 5*nx/2+7 in the 2D case or 5*(nx+ny)/2+9 in the 3D case. Contains single-precision data to be used by Fast Helmholtz Solver (for details, refer to Common Parameters).
bd_ax | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. Contains values of the boundary condition on the leftmost boundary of the domain along x-axis. For ?_Helmholtz_2D, the size of the array is ny+1. In case of the the Dirichlet boundary condition (value of BCtype[0] is 'D'), it contains values of the function G(ax, yj), j=0, ..., ny. In case of the the Neumann boundary condition (value of BCtype[0] is 'N'), it contains values of the function g(ax, yj), j=0, ..., ny. The value corresponding to the index j is placed in bd_ax[j]. For ?_Helmholtz_3D, the size of the array is (ny+1)*(nz+1). In case of the the Dirichlet boundary condition (value of BCtype[0] is 'D'), it contains values of the function G(ax, yj, zk), j=0, ..., ny, k=0, ..., nz. In case of the Neumann boundary condition (value of BCtype[0] is 'N'), it contains the values of the function g(ax, yj, zk), j=0, ..., ny, k=0, ..., nz. The values are packed in the array so that the value corresponding to indices (j, k) is placed in bd_ax[j+k*(ny+1)].
bd_bx | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. Contains values of the boundary condition on the rightmost boundary of the domain along x-axis. For ?_Helmholtz_2D, the size of the array is ny+1. In case of the Dirichlet boundary condition (value of BCtype[1] is 'D'), it contains values of the function G(bx, yj), j=0, ..., ny. In case of the Neumann boundary condition (value of BCtype[1] is 'N'), it contains values of the function g(bx, yj), j=0, ..., ny. The value corresponding to the index j is placed in bd_bx[j]. For ?_Helmholtz_3D, the size of the array is (ny+1)*(nz+1). In case of the Dirichlet boundary condition (value of BCtype[1] is 'D'), it contains values of the function G(bx, yj, zk), j=0, ..., ny, k=0, ..., nz. In case of the Neumann boundary condition (value of BCtype[1] is 'N'), it contains the values of the function g(bx, yj, zk), j=0, ..., ny, k=0, ..., nz. The values are packed in the array so that the value corresponding to indices (j, k) is placed in bd_bx[j+k*(ny+1)].
bd_ay | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. Contains values of the boundary condition on the leftmost boundary of the domain along y-axis. For ?_Helmholtz_2D, the size of the array is nx+1. In case of the Dirichlet boundary condition (value of BCtype[2] is 'D'), it contains values of the function G(xi, ay), i=0, ..., nx. In case of the Neumann boundary condition (value of BCtype[2] is 'N'), it contains values of the function g(xi, ay), i=0, ..., nx. The value corresponding to the index i is placed in bd_ay[i]. For ?_Helmholtz_3D, the size of the array is (nx+1)*(nz+1). In case of the Dirichlet boundary condition (value of BCtype[2] is 'D'), it contains values of the function G(xi,ay, zk), i=0, ..., nx, k=0, ..., nz. In case of the Neumann boundary condition (value of BCtype[2] is 'N'), it contains the values of the function g(xi,ay, zk), i=0, ..., nx, k=0, ..., nz. The values are packed in the array so that the value corresponding to indices (i, k) is placed in bd_ay[i+k*(nx+1)].
bd_by | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. Contains values of the boundary condition on the rightmost boundary of the domain along y-axis. For ?_Helmholtz_2D, the size of the array is nx+1. In case of the Dirichlet boundary condition (value of BCtype[3] is 'D'), it contains values of the function G(xi, by), i=0, ..., nx. In case of the Neumann boundary condition (value of BCtype[3] is 'N'), it contains values of the function g(xi, by), i=0, ..., nx. The value corresponding to the index i is placed in bd_by[i]. For ?_Helmholtz_3D, the size of the array is (nx+1)*(nz+1). In case of the Dirichlet boundary condition (value of BCtype[3] is 'D'), it contains values of the function G(xi,by, zk), i=0, ..., nx, k=0, ..., nz. In case of the Neumann boundary condition (value of BCtype[3] is 'N'), it contains the values of the function g(xi,by, zk), i=0, ..., nx, k=0, ..., nz. The values are packed in the array so that the value corresponding to indices (i, k) is placed in bd_by[i+k*(nx+1)].
bd_az | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. This parameter is needed only for ?_Helmholtz_3D. Contains values of the boundary condition on the leftmost boundary of the domain along z-axis. The size of the array is (nx+1)*(ny+1). In case of the Dirichlet boundary condition (value of BCtype[4] is 'D'), it contains values of the function G(xi, yj,az), i=0, ..., nx, j=0, ..., ny. In case of the Neumann boundary condition (value of BCtype[4] is 'N'), it contains the values of the function g(xi, yj,az), i=0, ..., nx, j=0, ..., ny. The values are packed in the array so that the value corresponding to indices (i, j) is placed in bd_az[i+j*(nx+1)].
bd_bz | double* for d_Helmholtz_2D/d_Helmholtz_3D, float* for s_Helmholtz_2D/s_Helmholtz_3D. This parameter is needed only for ?_Helmholtz_3D. Contains values of the boundary condition on the rightmost boundary of the domain along z-axis. The size of the array is (nx+1)*(ny+1). In case of the Dirichlet boundary condition (value of BCtype[5] is 'D'), it contains values of the function G(xi, yj,bz), i=0, ..., nx, j=0, ..., ny. In case of the Neumann boundary condition (value of BCtype[5] is 'N'), it contains the values of the function g(xi, yj,bz), i=0, ..., nx, j=0, ..., ny. The values are packed in the array so that the value corresponding to indices (i, j) is placed in bd_bz[i+j*(nx+1)].

### Note

To avoid wrong computation results, do not change arrays bd_ax, bd_bx, bd_ay, bd_by, bd_az, bd_bz between a call to the ?_commit_Helmholtz_2D/?_commit_Helmholtz_3D routine and a subsequent call to the appropriate ?_Helmholtz_2D/?_Helmholtz_3D routine.

## Output Parameters

f | On output, contains the approximate solution to the problem packed the same way as the right-hand side of the problem was packed on input.
xhandle, yhandle | Data structures used by the Intel MKL FFT interface.
ipar | Contains integer data to be used by Fast Helmholtz Solver. Modified on output as explained in Common Parameters.
dpar | Contains double-precision data to be used by Fast Helmholtz Solver. Modified on output as explained in Common Parameters
spar | Contains single-precision data to be used by Fast Helmholtz Solver. Modified on output as explained in Common Parameters.
stat | int*. Routine completion status, which is also written to ipar[0]. The status should be 0 to proceed to other PL routines.

## Description

The routines compute the approximate solution of Helmholtz problem defined in the previous calls to the corresponding initialization and commit routines. The solution is computed according to formulas given in Poisson Library Implemented. The f parameter, which initially holds the packed vector of the right-hand side of the problem, is replaced by the computed solution packed in the same way. Values of ax, bx, ay, by, az, bz, nx, ny, nz, and BCtype are passed to each of the routines with the ipar array and defined in the previous call to the appropriate ?_init_Helmholtz_2D/?_init_Helmholtz_3D routine.

## Return Values

stat= 1 | The routine completed without errors and produced some warnings.
stat= 0 | The routine successfully completed the task.
stat= -2 | The routine stopped because division by zero occurred. It usually happens if the data in the dpar or spar array was altered by mistake.
stat= -3 | The routine stopped because the memory was insufficient to complete the computations.
stat= -100 | The routine stopped because an error in the user's data was found or the data in the dpar, spar or ipar array was altered by mistake.
stat= -1000 | The routine stopped because of the Intel MKL FFT or TT interface error.
stat= -10000 | The routine stopped because the initialization failed to complete or the parameter ipar[0] was altered by mistake.
stat= -99999 | The routine failed to complete the task because of a fatal error.

Parent topic: PL Routines for the Cartesian Solver