#include <stdlib.h>


void gbem_lap_del(void)
{

/* ===purpose=== */

/**********************************************************************************************************************************/
/**********************************  GALERKIN BEM for 3D LAPLACE EQUATION: SINGULAR FORMULATION  **********************************/
/************************************  3-NODED TRIANGULAR ELEMENT: SEMI-ANALYTIC INTEGRATION  *************************************/
/************************************************  PIECEWISE LINEAR APPROXIMATION  ************************************************/
/******************************  Deallocate remaining global arrays associated with the GALERKIN BEM  *****************************/
/**********************************************************************************************************************************/

/* Developer: Sylvain Nintcheu Fata */
/* Version:   V.1.1                 */
/* Released:  Jun 14, 2012          */


/* Global variables */
   extern int nbnd,nbelt;        /* nbnd == Total number of boundary nodes, nbelt == Total number of boundary elements */
   extern int **belt;            /* belt[i][0:2] == Global indices of boundary nodes on the i-th element */
   extern double **bnd;          /* bnd[i][0:2] = Cartesian coordinates of the i-th boundary node */
   extern double **LocCBasisElt; /* LocCBasisElt[k][0:8] == Local Companion Basis associated with the k-th boundary element */
   extern double **xvElt,*zvElt; /* xvElt[k][0] == Base of the k-th boundary element */
				 /* xvElt[k][1] == Geometric parameter associated with the k-th boundary element */
				 /* zvElt[k] == Height of the k-th boundary element */
   extern double **thetaElt;     /* thetaElt[k][i] == Angle at the i-th vertex of the k-th boundary element */
   extern double *phi, *flx;     /* phi == Vector containing boundary potentials, flx == Vector containing boundary fluxes */

/* Local variables */
   int i;



    for (i=0; i<nbnd; i++) free(bnd[i]); /* Deallocate memory block for all boundary nodes */
    free(bnd);

    for (i=0; i<nbelt; i++) free(belt[i]); /* Deallocate memory block for all boundary elements */
    free(belt);

    for (i=0; i<nbelt; i++) {free(xvElt[i]); free(thetaElt[i]); free(LocCBasisElt[i]);}
    free(xvElt); free(zvElt); free(thetaElt); free(LocCBasisElt);

    free(phi); free(flx); /* Deallocate potential and flux vectors */

}
