#include <stdio.h>
#include <stdlib.h>

void cbem_lap_ex_int_ud(int i); /* For every triangle i, compute and add the influence contribution to all collocation points in h and g */


void cbem_lap_assem(void)
{

/* ===purpose=== */

/**********************************************************************************************************************************/
/********************************  COLLOCATION BEM for 3D LAPLACE EQUATION: SINGULAR FORMULATION  *********************************/
/***************************************  3-NODED TRIANGULAR ELEMENT: ANALYTIC INTEGRATION  ***************************************/
/***********************************************  PIECEWISE CONSTANT APPROXIMATION  ***********************************************/
/********************************************  Assemble h and g influence matrices  ***********************************************/
/**********************************************************************************************************************************/

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

 
   extern int nbelt;     /* nbelt == Total number of boundary elements */
                         /* For Piecewise constant approximation, nbelt is also equal to the number of collocation points on the surface */
   extern double *h, *g; /* h == Coefficient matrix acting on the vector of boundary potentials <==> potential influence matrix */
                         /* g == Coefficient matrix acting on the vector of boundary fluxes <==> flux influence matrix */

   int k,snbelt;



   snbelt = nbelt*nbelt;
   if ( (h = (double *)calloc(snbelt,sizeof(double))) == NULL ) /* If h is not successfully allocated */
   {printf("cbem_lap_assem: Allocate array \"h\" failed\n"); exit(1);}
    
   if ( (g = (double *)calloc(snbelt,sizeof(double))) == NULL ) /* If g is not successfully allocated */
   {printf("cbem_lap_assem: Allocate array \"g\" failed\n"); exit(1);}
   
/* Assemble h and g influence matrices */
   for (k=0; k<nbelt; k++) /* Loop over all boundary elements */
      cbem_lap_ex_int_ud(k); /* For every triangle k, compute and add the influence contribution to all collocation points in h and g */

}
