AcouSTO  version 2.0

◆ pre_mic_coef()

void pre_mic_coef ( COMPLEX  cfreq,
int  icounter 
)

Evaluates solution at microphones. Coefficients are calculated. This function is called when pre_calculate_coefs == 0.

Parameters
[in]cfreqCOMPLEX frequency
[in]icounterfrequency index
337  {
338  int i,icntr;
339  int iphiu;
340  int nphiu;
341  int nphib;
342 
343  int mpi_ncntr,mpi_nelmu;
344 
345  int locRows,locCols,locCRows;
346  int gRows,gCols,gCRows;
347  int ielmb,ielmu;
348  int j;
349  int descpsiu[9];
350  int descgpsiu[9];
351  int mm,nn;
352  int ione = 1;
353  int izero = 0;
354  int info;
355  struct vector g;
356  struct vector un;
357  DOUBLE gdotn;
358 
359 
360  COMPLEX cexpo;
361  DOUBLE bb,cc,dd,theta,thetad;
362  COMPLEX rho_s;
363 
364  Vec psincvec;
365  Vec phincvec;
366 
367  COMPLEX phiscval = COMPLEX_ZERO; // Cauchy Data
368  COMPLEX phincval = COMPLEX_ZERO;
369  COMPLEX phitcval = COMPLEX_ZERO;
370 
371  COMPLEX psincval = COMPLEX_ZERO;
372  COMPLEX psiscval = COMPLEX_ZERO;
373  COMPLEX psitcval = COMPLEX_ZERO;
374 
375  COMPLEX phincmval = COMPLEX_ZERO; // Potential at microphones
376  COMPLEX phiscmval = COMPLEX_ZERO;
377  COMPLEX phitmval = COMPLEX_ZERO;
378 
379  COMPLEX prescmval = COMPLEX_ZERO;
380  COMPLEX pretmval = COMPLEX_ZERO;
381 
382  int is;
383  struct panel4* mpi_elements;
384  struct vector* mpi_cntr;
385  int kode;
386  DOUBLE source,doublet,ratelet;
387 
388  COMPLEX lambda;
389  COMPLEX gamma;
390  COMPLEX func;
391  COMPLEX gamma_over_lambda;
392  COMPLEX lambda_over_gamma;
393 
394 #ifdef _ACOUSTO_DEBUG
395  int imics;
396  char fname[MAX_PATH];
397  FILE* f;
398 #endif
399 
400 // char fname2[25];
401 // FILE* f2;
402 // sprintf(fname2,"coemicdump_dipaolo.%d%d",runinfo->myrow,runinfo->mycol);
403 // f2 = fopen(fname2,"w");
404 
405  mpi_cntr = geometry->mics;
406  mpi_elements = geometry->elements;
407  mpi_ncntr = modgeominfo->ncntr + modgeominfo->nchief;
408  mpi_nelmu = modgeominfo->ncntr;
409  nphiu = modgeominfo->ncntr;
410 
411  gRows = modgeominfo->nmics;
412 // gCols = modgeominfo->nelmb;
413  gCols = modgeominfo->ncntr;
414  gCRows = nphiu;
415 
416  locRows = numroc_(&gRows ,&runinfo->mics_block_size,&runinfo->myrow,&izero,&runinfo->nprows);
417  locCols = numroc_(&gCols ,&runinfo->col_block_size,&runinfo->mycol,&izero,&runinfo->npcols);
418  locCRows = numroc_(&gCRows ,&runinfo->row_block_size,&runinfo->myrow,&izero,&runinfo->nprows);
419 
420  nphib = modgeominfo->nelmb;
421 
422  if(0==icounter){
423  CREATE_VEC(solution->vecPhium ,locRows);
424  CREATE_VEC(solution->vecPrescm,locRows);
425  CREATE_VEC(solution->vecPretm ,locRows);
426  }
427  VecZeroEntries(solution->vecPhium ,locRows);
428  VecZeroEntries(solution->vecPrescm ,locRows);
429  VecZeroEntries(solution->vecPretm ,locRows);
430 
431  psincvec = calloc(nphiu,sizeof(COMPLEX)); // allocating vector
432  phincvec = calloc(nphiu,sizeof(COMPLEX)); // allocating vector
433 
434  // Gathering psiu on node 0 and broadcasting
435  // Collecting solution on node zero and broadcasting to everyone
436  mm = gCRows;// * runinfo->nprows;
437  nn = runinfo->npcols;
438  descinit_(descpsiu , &gCRows ,&ione, &runinfo->row_block_size ,&ione,&izero,&izero,&runinfo->ctxt,&gCRows ,&info);
439  descinit_(descgpsiu , &mm ,&ione, &gCRows ,&ione,&izero,&izero,&runinfo->ctxt,&gCRows ,&info);
440  pzgemr2d_(&gCRows,&ione,solution->vecPsinc,&ione, &ione,descpsiu, psincvec,&ione,&ione,descgpsiu,&runinfo->ctxt);
441  pzgemr2d_(&gCRows,&ione,solution->vecPhinc,&ione, &ione,descpsiu, phincvec,&ione,&ione,descgpsiu,&runinfo->ctxt);
442 
443  MPI_Bcast(psincvec,gCRows,MPI_ACOUSTO_COMPLEX,0,MPI_COMM_WORLD);
444  MPI_Bcast(phincvec,gCRows,MPI_ACOUSTO_COMPLEX,0,MPI_COMM_WORLD);
445 
446  rho_s = cfreq*modsolinfo->rho;
447 
448 
449  /* Since we are splitting also on columns Pressure on microphones must be summed on the columns
450  * of the grid.
451  * e.g.:
452  * for pressure on microphones in row 0 of the process grid (PRE00, PRE01, PRE02)
453  * the actual pressure on the microphones is the sum on the colums (PRE00+PRE01+PRE02)
454  *
455  * This is due to the choice of splitting the body elements along the column of the process
456  * grid and to the fact that the evaluation of pressure is simply additive.
457  *
458  * This also applies to potential at microphones
459  *
460  * 0 1 2
461  * --------------------------------
462  * | | | |
463  * 0 | PRE00 | PRE01 | PRE02 |
464  * | | | |
465  * --------------------------------
466  * | | | |
467  * 1 | PRE11 | PRE11 | PRE12 |
468  * | | | |
469  * --------------------------------
470  *
471  **/
472 
473 
474  for(i=0;i<locRows;i++){
475  phiscmval = COMPLEX_ZERO;
477 
478  for(j=0;j<locCols;j++){
479  // getting local indices
481 
482  for(is=0;is<runinfo->nsymm;is++){
483 
484  ielmu = iphiu;
485  ielmb = ielmu + is*mpi_nelmu;
486 
487  /* Coefficients at microphones */
488  kode = 0; // singular panels flag not applicable here
489  delaya(&thetad,ielmb,&mpi_elements[ielmb],mpi_cntr[icntr]); // evaluating acoustic delay
490  intgba(1, 0, kode, &mpi_cntr[icntr], &mpi_elements[ielmb], &source, &doublet, &ratelet); // integrating
491 
492  bb = source;
493  cc = doublet;
494  dd = ratelet/runinfo->vsound;
495  theta = thetad/runinfo->vsound;
496 
497  cexpo = CEXP(-cfreq*theta);
498 
499  psincval = psincvec[iphiu]; // Psi_incident on surface
500  phincval = phincvec[iphiu]; // Phi_incident on surface
501 
502  vec_copy(&un,mpi_elements[ielmb].n);
503  lambda = bc.lambda[ielmu];
504  gamma = bc.gamma[ielmu];
505  func = bc.func[ielmu];
506  gamma_over_lambda = gamma/lambda;
507  lambda_over_gamma = lambda/gamma;
508  g.x = bc.g.x;
509  g.y = bc.g.y;
510  g.z = bc.g.z;
511  gdotn = vec_dot(g,un);
512 
513  if (1 == modsolinfo->dirneu){ // Dirichlet-type formulation
514 
515  if(1 == modsolinfo->knw){ // Phi scatttering on surface
516  psitcval = solution->sol[iphiu];
517  psiscval = solution->sol[iphiu] - psincval; // Form A
518  phitcval = (func+gdotn)/gamma - lambda_over_gamma * psitcval;
519  phiscmval += bb*cexpo*psitcval + (cc + cfreq*dd)*phitcval*cexpo;
520  }else if (2 == modsolinfo->knw){
521  psiscval = solution->sol[iphiu];
522  psitcval = psiscval + psincval; // Form B
523  phitcval = (func+gdotn)/gamma - lambda_over_gamma * psitcval;
524  phiscval = phitcval - phincval;
525  phiscmval += bb*cexpo*psiscval + (cc + cfreq*dd)*phiscval*cexpo;
526  }
527 
528  }else if (2 == modsolinfo->dirneu){
529 
530  if(1 == modsolinfo->knw){ // Phi scatttering on surface
531  phitcval = solution->sol[iphiu];
532  phiscval = solution->sol[iphiu] - phincval; // Form A
533  }else if (2 == modsolinfo->knw){
534  phiscval = solution->sol[iphiu];
535  phitcval = phiscval + phincval; // Form B
536  }
537 
538  if(1 == modsolinfo->knw){
539  phiscmval += bb*cexpo*((func+gdotn)/lambda - gamma_over_lambda * phitcval) + (cc + cfreq*dd)*phitcval*cexpo;
540  }else if (2 == modsolinfo->knw){
541  phiscmval += bb*cexpo*((func+gdotn)/lambda - gamma_over_lambda * phincval - gamma_over_lambda*phiscval - psincval) + (cc+cfreq*dd)*phiscval*cexpo;
542  }
543  }
544 
545  } // END OF SYMMETRY LOOP
546 
547  }
548 
549  phincmval = solution->vecPhincm[i];
550  phitmval = phincmval + phiscmval;
551 
552 // prescmval = -rho_s * phiscmval;
553 // pretmval = -rho_s * phitmval;
554 
555  prescmval = phiscmval;
556  pretmval = phitmval;
557 
558  solution->vecPhium [i] = phiscmval;
559  solution->vecPrescm[i] = prescmval;
560  solution->vecPretm [i] = pretmval;
561 
562  } // END OF LOOP ON LocRows
563 
564  Czgsum2d(runinfo->ctxt,"R"," ",locRows,1,solution->vecPhium ,locRows,-1,-1);
565  Czgsum2d(runinfo->ctxt,"R"," ",locRows,1,solution->vecPrescm ,locRows,-1,-1);
566  Czgsum2d(runinfo->ctxt,"R"," ",locRows,1,solution->vecPretm ,locRows,-1,-1);
567 
568 // fclose(f2);
569 
570  // summing on process columns
571 
572 #ifdef _ACOUSTO_DEBUG
573  sprintf(fname,"pre.%d%d",runinfo->myrow,runinfo->mycol);
574  f = fopen(fname,"w");
575  for(i=0;i<locRows;i++){
577  fprintf(f," %d %f %f %f %f %f %f\n",imics,
581  );
582  }
583  fclose(f);
584 #endif
585 
586  /* Printing pressures */
587 
588  if(modsolinfo->printout){
589  print_premic_on_master(cfreq);
590  }
591 
592  VecDestroy(psincvec);
593  VecDestroy(phincvec);
594 
595 }
struct run_info * runinfo
Definition: globals.h:34
#define Vec
Definition: types.h:63
int npcols
Definition: structs.h:113
#define VecDestroy(v)
Definition: allocation.h:111
int ncntr
Definition: structs.h:299
DOUBLE vsound
Definition: structs.h:102
#define CREAL(x)
Definition: functions.h:49
void delaya(DOUBLE *theta, int ielmb, struct panel4 *element, struct vector xc)
Definition: integrals.c:268
void Czgsum2d(int ctxt, char *scope, char *top, int m, int n, COMPLEX *A, int llda, int recr, int recc)
#define MPI_ACOUSTO_COMPLEX
Definition: types.h:56
Vec vecPsinc
Definition: structs.h:580
int myrow
Definition: structs.h:115
void vec_copy(struct vector *vdest, const struct vector vsrc)
Definition: math.c:158
int nprows
Definition: structs.h:111
vector struct to hold triplets.
Definition: structs.h:29
#define CIMAG(x)
Definition: functions.h:50
COMPLEX * lambda
Definition: structs.h:623
int nchief
Definition: structs.h:301
COMPLEX * sol
Definition: structs.h:607
int mics_block_size
Definition: structs.h:124
void pzgemr2d_(int *m, int *n, COMPLEX *A, int *ia, int *ja, int *desca, COMPLEX *B, int *ib, int *jb, int *descb, int *ictxt)
Copies a (m x n) submatrix of A from element (ia,ja) on a submatrix of B from element (ib...
struct bc_struct bc
Definition: globals.h:54
int nelmb
Definition: structs.h:295
#define CEXP(x)
Definition: functions.h:48
Vec vecPhinc
Definition: structs.h:578
#define COMPLEX_ZERO
Definition: constants.h:44
int ctxt
Definition: structs.h:109
int knw
Definition: structs.h:446
Definition of a quadrilateral panel.
Definition: structs.h:44
DOUBLE rho
Definition: structs.h:476
void descinit_(int *desc, int *m, int *n, int *mb, int *nb, int *ia, int *ja, int *ictxt, int *llda, int *info)
struct solution_struct * solution
Definition: globals.h:52
#define COMPLEX
Definition: types.h:48
Vec vecPhincm
Definition: structs.h:582
BOOL printout
Definition: structs.h:486
struct modsol_info * modsolinfo
Definition: globals.h:44
int nmics
Definition: structs.h:304
DOUBLE z
Definition: structs.h:35
struct vector g
Definition: structs.h:626
DOUBLE vec_dot(struct vector v1, struct vector v2)
Definition: math.c:34
COMPLEX * gamma
Definition: structs.h:624
Vec vecPhium
Definition: structs.h:586
int mycol
Definition: structs.h:117
int nsymm
Definition: structs.h:97
Vec vecPrescm
Definition: structs.h:588
double DOUBLE
Definition: types.h:44
int numroc_(int *m, int *mb, int *p, int *ia, int *npr)
DOUBLE x
Definition: structs.h:31
#define CREATE_VEC(v, lsize)
Definition: allocation.h:90
int col_block_size
Definition: structs.h:121
COMPLEX * func
Definition: structs.h:625
void intgba(int kcrce, int kelem, int kode, struct vector *xcntr, struct panel4 *element, DOUBLE *source, DOUBLE *doublet, DOUBLE *ratelet)
Definition: integrals.c:40
Geometry info structure.
Definition: structs.h:161
void print_premic_on_master(COMPLEX cfreq)
Definition: pre_mic.c:604
Vec vecPretm
Definition: structs.h:590
#define MAX_PATH
Definition: constants.h:29
int row_block_size
Definition: structs.h:119
#define calloc(n, size)
Definition: allocation.h:37
struct modgeom_info * modgeominfo
Definition: globals.h:38
void sc_l2g(int il, int p, int n, int np, int nb, int *i)
Definition: matutils.c:116
#define VecZeroEntries(V, n)
Definition: allocation.h:99
DOUBLE y
Definition: structs.h:33
int dirneu
Definition: structs.h:444