AcouSTO  version 2.0

◆ read_acoustic_files()

int read_acoustic_files ( )

Reads acoustic solution files.

27  {
28 
29  FILE* file_sources = NULL ;
30  FILE* file_planw = NULL;
31  FILE* file_dipoles = NULL ;
32 
33  char line[200];
34  int i;
35  long double d1,d2,d3,d4,d5,d6,d7,d8,d9;
36 
37  int nfreq;
38 
39  int mpi_ncntr;
40  int nphiu;
41 
42  nfreq = modsolinfo->nsig * modsolinfo->nome;
43  mpi_ncntr = modgeominfo->ncntr + modgeominfo->nchief;
44  nphiu = modgeominfo->ncntr;
45 
46 
47  /* open files */
48  if(modsolinfo->nsourc > 0){
49  logger(LOG_DEBUG," reading file %s\n",fileinfo->sources_file);
50  file_sources = fopen(fileinfo->sources_file,"r");
51  if(NULL == file_sources ){
52  perror("Coudln't find SOURCES file ");
53  return 0;
54  }
55  }
56 
57  if(modsolinfo->nplanw > 0){
58  logger(LOG_DEBUG," reading file %s\n",fileinfo->planw_file);
59  file_planw = fopen(fileinfo->planw_file,"r");
60  if(NULL == file_planw){
61  perror("Coudln't find PLAN WAVES file ");
62  return 0;
63  }
64  }
65 
66 
67  if(modsolinfo->ndipoles > 0){
68  logger(LOG_DEBUG," reading file %s\n",fileinfo->dipoles_file);
69  file_dipoles = fopen(fileinfo->dipoles_file,"r");
70  if(NULL == file_dipoles && modsolinfo->ndipoles > 0){
71  perror("Coudln't find DIPOLES file ");
72  return 0;
73  }
74  }
75  /* Reading */
76 
77  /* SOURCES */
78  for(i=0;i<modsolinfo->nsourc;i++){
79  fgets(line,100,file_sources);
80  sscanf(line,ACPOINT_SCANF,&d1,&d2,&d3,&d4,&d5);
81  solution->sources[i].pos.x = d1;
82  solution->sources[i].pos.y = d2;
83  solution->sources[i].pos.z = d3;
84  solution->sources[i].amplitude = d4 + I*d5;
85  _DEBUG_ACOUPOINT("SOURCES",rank,solution->sources[i]);
87  }
88 
89  /* PLANE WAVES */
90  for(i=0;i<modsolinfo->nplanw;i++){
91  fgets(line,100,file_planw);
92  sscanf(line,ACPOINT_SCANF,&d1,&d2,&d3,&d4,&d5);
93  solution->planw[i].pos.x = d1;
94  solution->planw[i].pos.y = d2;
95  solution->planw[i].pos.z = d3;
96  solution->planw[i].amplitude = d4 + I*d5;
97  _DEBUG_ACOUPOINT("PLANW",rank,solution->planw[i]);
99  }
100 
101 
102  /* DIPOLES */
103  for(i=0;i<modsolinfo->ndipoles;i++){
104  fgets(line,100,file_dipoles);
105  sscanf(line,DIPOLE_SCANF,&d1,&d2,&d3,
106  &d4,&d5,&d6,
107  &d7,&d8,
108  &d9);
109  solution->dipoles[i].pos.x = d1;
110  solution->dipoles[i].pos.y = d2;
111  solution->dipoles[i].pos.z = d3;
112  solution->dipoles[i].dir.x = d4;
113  solution->dipoles[i].dir.y = d5;
114  solution->dipoles[i].dir.z = d6;
115  solution->dipoles[i].amplitude = d7 + I*d8;
116  solution->dipoles[i].d = d9;
117  _DEBUG_DIPOLE("DIPOLES",i,solution->dipoles[i]);
119  }
120 
121  if(modsolinfo->nsourc > 0 && NULL != file_sources ) fclose(file_sources);
122  if(modsolinfo->ndipoles> 0 && NULL != file_dipoles ) fclose(file_dipoles);
123  if(modsolinfo->nplanw > 0 && NULL != file_planw ) fclose(file_planw);
124 
125 
126  if(modsolinfo->nsourc > 0 ) logger(LOG_DEBUG,"file %s read\n",fileinfo->sources_file);
127  if(modsolinfo->ndipoles > 0) logger(LOG_DEBUG,"file %s read\n",fileinfo->dipoles_file);
128  if(modsolinfo->nplanw > 0 ) logger(LOG_DEBUG,"file %s read\n",fileinfo->planw_file);
129  return 1;
130 }
int ncntr
Definition: structs.h:299
COMPLEX amplitude
Definition: structs.h:537
#define LOG_ACPOINT(ctx, i, v)
Definition: print.h:66
struct acoustic_point * planw
Definition: structs.h:575
#define DIPOLE_SCANF
Definition: formats.h:62
int ndipoles
Definition: structs.h:503
int nsourc
Definition: structs.h:448
#define _DEBUG_ACOUPOINT(ctx, i, v)
Definition: print.h:55
int nchief
Definition: structs.h:301
DOUBLE d
Definition: structs.h:547
struct dipole * dipoles
Definition: structs.h:563
#define LOG_DIPOLE(ctx, i, v)
Definition: print.h:71
int nsig
Definition: structs.h:456
struct file_info * fileinfo
Definition: globals.h:32
const char * dipoles_file
Definition: structs.h:418
const char * planw_file
Definition: structs.h:415
struct acoustic_point * sources
Definition: structs.h:561
struct solution_struct * solution
Definition: globals.h:52
#define ACPOINT_SCANF
Definition: formats.h:61
struct modsol_info * modsolinfo
Definition: globals.h:44
DOUBLE z
Definition: structs.h:35
#define LOG_DEBUG
Definition: logger.h:27
struct vector dir
Definition: structs.h:542
struct vector pos
Definition: structs.h:535
int rank
Definition: globals.h:79
DOUBLE x
Definition: structs.h:31
COMPLEX amplitude
Definition: structs.h:544
int nome
Definition: structs.h:458
#define _DEBUG_DIPOLE(ctx, i, v)
Definition: print.h:56
struct vector pos
Definition: structs.h:541
int nplanw
Definition: structs.h:454
const char * sources_file
Definition: structs.h:409
void logger(int level, char *msg,...)
Definition: logger.c:56
struct modgeom_info * modgeominfo
Definition: globals.h:38
DOUBLE y
Definition: structs.h:33