AcouSTO  version 2.0

◆ read_mics()

int read_mics ( )
22  {
23  int j;
24  int ltmp;
25  unsigned long nelcount =0;
26  int eltype;
27  int ntmp;
28  int netmp;
29  char line[MAX_PATH];
30  FILE* fmics;
31 
32  fmics = fopen(fileinfo->mics_file, "r");
33  havemicsmesh=0;
34  if (NULL == fmics) {
37  }
38  fgets(line, 100, fmics);
39  if(0 == strcmp("$MeshFormat\n", line)){
40  havemicsmesh = 1;
41  logger(LOG_INFO,"Mics file appears to be a GMSH FILE\n");
42  logger(LOG_INFO," Proceed with reading of number of mics and mics elements\n");
43  nelcount = 0;
44  while (fgets(line, 100, fmics) != NULL) {
45  if (0 == strcmp("$Nodes\n", line)) {
46  fgets(line, 100, fmics);
47  sscanf(line, "%d\n", &ntmp);
48  modgeominfo->nmics = ntmp;
49  logger(LOG_INFO, "MICS GMSH FILE -> number of microphones %d\n", modgeominfo->nmics);
50  }
51  if (0 == strcmp("$Elements\n", line)) {
52  fgets(line, 100, fmics);
53  sscanf(line, "%d\n", &netmp);
54  for (j = 0; j < netmp; j++) {
55  fgets(line, 100, fmics);
56  sscanf(line, "%d %d\n", &ntmp, &eltype);
57  if (2 == eltype || 3 == eltype || 4 == eltype) {
58  nelcount++;
59  }
60  }
61  modgeominfo->nemics = nelcount;
63  "MICS GMSH FILE -> number of read triangular, quadrilateral and tetrahedra elements %d\n",
64  nelcount);
65  }
66  }
67  fclose(fmics);
68  }else{
69  logger(LOG_INFO,"Mics file appears to be in AcouSTO native format\n");
70  logger(LOG_INFO," Number of mics is read from config file\n");
71  CONFIG_GET_INT(config, "modgeom.nmics", modgeominfo->nmics);
72  }
73 
74 
75  if (modgeominfo->nmics < size) {
78  }
79 
80 
81  return 0;
82 
83 
84 }
#define MSG_GEOM_FILE_NOTFOUND
Definition: messages.h:38
#define CONFIG_GET_INT(config, name, var)
Definition: config.h:47
int nemics
Definition: structs.h:305
int size
Definition: globals.h:81
#define LOG_INFO
Definition: logger.h:26
struct file_info * fileinfo
Definition: globals.h:32
#define LOG_ERROR
Definition: logger.h:24
#define ACOUSTO_ERROR_GEOMETRY
Definition: constants.h:25
struct config_t config
Definition: config.h:61
int nmics
Definition: structs.h:304
#define LOG_WARN
Definition: logger.h:25
#define MSG_CFG_NOTENOUGHMICS
Definition: messages.h:33
const char * mics_file
Definition: structs.h:407
#define MAX_PATH
Definition: constants.h:29
void logger(int level, char *msg,...)
Definition: logger.c:56
struct modgeom_info * modgeominfo
Definition: globals.h:38
int havemicsmesh
Definition: globals.h:72