AcouSTO  version 2.0

◆ read_modgeom()

int read_modgeom ( )
22  {
23  char varname[MAX_PATH]; // temp var to read dynamic geometry &configuration
24  int ltmp;
25  double dtmp; /* INIT MODGEOM */
26  int i;
27  const char* geoname; // name of geometry
28  const char* geotype; // type of geometry
29 
30  config_setting_t* geomcont;
31 
32  /* pointers to known geometryarrays */
33  struct sphere_geom *sphere;
34  struct cylinder_geom *cylinder;
35  struct nodes_geom *nodesgeom;
36  struct plate_geom *plategeom;
37  struct gmsh_geom *gmshgeom;
38 
39 
40  CONFIG_GET_INT(config, "modgeom.active", modgeominfo->active);
41  CONFIG_GET_STRING(config, "modgeom.nodes_file", fileinfo->nodes_file);
42  CONFIG_GET_STRING(config, "modgeom.mics_file", fileinfo->mics_file);
43  CONFIG_GET_INT(config, "modgeom.nelmb", modgeominfo->nelmb);
44  CONFIG_GET_INT(config, "modgeom.ncntr", modgeominfo->ncntr);
45 
46  CONFIG_GET_INT(config, "modgeom.nchief", modgeominfo->nchief);
47  if(modgeominfo->nchief > 0 ){
48  CONFIG_GET_STRING(config, "modgeom.chief_file", fileinfo->chief_file);
49  }
50 
51  read_mics();
52 
53  CONFIG_GET_FLOAT(config, "modgeom.translation.x", modgeominfo->translation.x);
54  CONFIG_GET_FLOAT(config, "modgeom.translation.y", modgeominfo->translation.y);
55  CONFIG_GET_FLOAT(config, "modgeom.translation.z", modgeominfo->translation.z);
56 
57  CONFIG_GET_FLOAT(config, "modgeom.rotation.phi", modgeominfo->rotation.x);
58  CONFIG_GET_FLOAT(config, "modgeom.rotation.theta", modgeominfo->rotation.y);
59  CONFIG_GET_FLOAT(config, "modgeom.rotation.psi", modgeominfo->rotation.z);
60 
61  CONFIG_GET_FLOAT(config, "modgeom.scale.x", modgeominfo->scale.x);
62  CONFIG_GET_FLOAT(config, "modgeom.scale.y", modgeominfo->scale.y);
63  CONFIG_GET_FLOAT(config, "modgeom.scale.z", modgeominfo->scale.z);
64 
65  // Reading geometries
66  geomcont = config_lookup(&config, "modgeom.geoms");
67  geometries = malloc(sizeof(struct geometry)*config_setting_length(geomcont)); // allocating space
68 
69  ngeometries = config_setting_length(geomcont); // number of geometries
70  logger(LOG_INFO, "n geometries=%d\n", ngeometries);
71 
72  // for each geometry, read type and parse the proper structure
73  for (i = 0; i < config_setting_length(geomcont); i++) {
74  sprintf(varname, "modgeom.%s", config_setting_get_string_elem(geomcont, i));
75  geoname = config_setting_get_string_elem(geomcont, i); //config_lookup_string(&config,varname);
76  logger(LOG_DEBUG, " reading geometry[%s]\n", geoname);
77  sprintf(varname, "%s.type", geoname);
78 
79 // if (NULL == geotype) {
80  if (NULL == CONFIG_LOOKUP(config,varname)) {
81  logger(LOG_ERROR, "you must provide a valid geometry type");
82  exit(1);
83  }
84  CONFIG_GET_STRING(config, varname, geotype);
85  if (0 == strcmp(geotype, "sphere")) { // SPHERE
86  sphere = malloc(sizeof(struct sphere_geom));
87  if(-1 == read_sphere(i,geoname,sphere)) return -1;
88  } else if (0 == strcmp(geotype, "cylinder")) { // CYLINDER
89  cylinder = malloc(sizeof(struct cylinder_geom));
90  if(-1 == read_cylinder(i,geoname,cylinder)) return -1;
91  } else if (0 == strcmp(geotype, "nodes")) { // EXTERNAL NODES FILE
92  logger(LOG_DEBUG, "Nodes\n");
93  nodesgeom = malloc(sizeof(struct nodes_geom));
94  if(-1 == read_nodes(i,geoname,nodesgeom)) return -1;
95  } else if (0 == strcmp(geotype, "gmsh")) { // EXTERNAL GMSH FILE
96  logger(LOG_DEBUG, "Gmsh\n");
97  gmshgeom = malloc(sizeof(struct gmsh_geom));
98  if(-1 == read_gmsh(i,geoname,gmshgeom)) return -1;
99  } else if (0 == strcmp(geotype, "plate")) { // PLATE
100  logger(LOG_DEBUG, "Plate\n");
101  plategeom = malloc(sizeof(struct plate_geom));
102  if(-1 == read_plate(i,geoname,plategeom)) return -1;
103  }
104 
105  // translation and rotation are valid for each geometry (if they exist)
106  sprintf(varname, "%s.translation.x", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].translation.x);
107  sprintf(varname, "%s.translation.y", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].translation.y);
108  sprintf(varname, "%s.translation.z", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].translation.z);
109  sprintf(varname, "%s.rotation.x", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].rotation.x);
110  sprintf(varname, "%s.rotation.y", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].rotation.y);
111  sprintf(varname, "%s.rotation.z", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].rotation.z);
112  sprintf(varname, "%s.scale.x", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].scale.x);
113  sprintf(varname, "%s.scale.y", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].scale.y);
114  sprintf(varname, "%s.scale.z", geoname); CONFIG_GET_FLOAT(config, varname, geometries[i].scale.z);
115  logger(LOG_DEBUG, " - nodes = %d\n", geometries[i].nnodb);
116  logger(LOG_DEBUG, " - elements = %d\n", geometries[i].nelmb);
117  logger(LOG_DEBUG, " - ctr.points = %d\n", geometries[i].ncntr);
118  logger(LOG_DEBUG, " - translation = (%f,%f,%f)\n", geometries[i].translation.x, geometries[i].translation.y, geometries[i].translation.z);
119  logger(LOG_DEBUG, " - rotation = (%f,%f,%f)\n", geometries[i].rotation.x, geometries[i].rotation.y, geometries[i].rotation.z);
120  logger(LOG_DEBUG, " - scale = (%f,%f,%f)\n", geometries[i].scale.x, geometries[i].scale.y, geometries[i].scale.z);
121  }
122 
123  // calculating number of nodes and elements
124  modgeominfo->nnodb = 0;
125  modgeominfo->nelmb = 0;
126  modgeominfo->ncntr = 0;
127  for (i = 0; i < config_setting_length(geomcont); i++) {
128  if (geometries[i].type == SPHERE) {
129  sphere = (struct sphere_geom*) geometries[i].ptrgeom;
130  } else if (geometries[i].type == CYLINDER) {
131  cylinder = (struct cylinder_geom*) geometries[i].ptrgeom;
132  } else if (geometries[i].type == NODES) {
133  nodesgeom = (struct nodes_geom*) geometries[i].ptrgeom;
134  } else if (geometries[i].type == GMSH) {
135  gmshgeom = (struct gmsh_geom*) geometries[i].ptrgeom;
136  } else if (geometries[i].type == PLATE) {
137  plategeom = (struct plate_geom*) geometries[i].ptrgeom;
138  }
142  logger(LOG_DEBUG, "modgeominfo.nnodb=%d\n", modgeominfo->nnodb);
143  logger(LOG_DEBUG, "modgeominfo.ncntr=%d\n", modgeominfo->ncntr);
144  logger(LOG_DEBUG, "modgeominfo.nelmb=%d\n", modgeominfo->nelmb);
145  }
146 
147  // Checks row/column-blocks dimensions against number of equations
148  // and modifies if neeeded
150  logger(LOG_WARN, "Row-block size (%d) greater than ncntr(%d) \n",
152  if (modgeominfo->ncntr > (2 * size)) {
154  (int) (modgeominfo->ncntr / (2 * size));
155  } else {
156  runinfo->row_block_size = 1;
157  }
158  logger(LOG_WARN, "Row-block size changed to -> %d \n",
160  }
162  logger(LOG_WARN, "Columns-block size (%d) greater than ncntr(%d) \n", runinfo->col_block_size, modgeominfo->ncntr);
163  if (modgeominfo->ncntr > (2 * size)) {
164  runinfo->col_block_size = (int) (modgeominfo->ncntr / (2 * size));
165  } else {
166  runinfo->col_block_size = 1;
167  }
168  logger(LOG_WARN, "Columns-block size changed to -> %d \n", runinfo->col_block_size);
169  }
171  logger(LOG_WARN, "Mics-block size (%d) greater than nmics(%d)\n", runinfo->mics_block_size, modgeominfo->nmics);
172  if (modgeominfo->nmics > (2 * size)) {
173  runinfo->mics_block_size = (int) (modgeominfo->nmics / (2 * size));
174  } else {
176  }
177  logger(LOG_WARN, "Mics-block size changed to -> %d\n", runinfo->mics_block_size);
178  }
179 
180 
181  return 0;
182 }
#define CONFIG_GET_INT(config, name, var)
Definition: config.h:47
Sphere.
Definition: structs.h:198
int ngeometries
Definition: globals.h:64
struct geometry * geometries
Definition: globals.h:66
int read_gmsh(int igeom, const char *geoname, struct gmsh_geom *gmshgeom)
Definition: gmsh.c:40
struct run_info * runinfo
Definition: globals.h:34
#define GMSH
Definition: config.h:58
struct vector translation
Definition: structs.h:307
#define CYLINDER
Definition: config.h:55
int ncntr
Definition: structs.h:175
#define CONFIG_GET_STRING(config, name, var)
Definition: config.h:48
int ncntr
Definition: structs.h:299
#define CONFIG_LOOKUP(config, name)
Definition: config.h:49
int cylinder(struct geometry *geom)
Definition: geom_cylinder.c:31
#define NODES
Definition: config.h:56
struct vector scale
Definition: structs.h:309
BOOL active
Definition: structs.h:282
int nchief
Definition: structs.h:301
int mics_block_size
Definition: structs.h:124
int size
Definition: globals.h:81
#define LOG_INFO
Definition: logger.h:26
struct vector translation
Definition: structs.h:181
int nelmb
Definition: structs.h:295
int nnodb
Definition: structs.h:293
int read_mics()
Definition: mics.c:22
struct file_info * fileinfo
Definition: globals.h:32
int read_sphere(int igeom, const char *geoname, struct sphere_geom *sphere)
Definition: sphere.c:22
struct vector scale
Definition: structs.h:185
#define LOG_ERROR
Definition: logger.h:24
int nelmb
Definition: structs.h:179
const char * chief_file
Definition: structs.h:405
Plate.
Definition: structs.h:226
struct config_t config
Definition: config.h:61
const char * nodes_file
Definition: structs.h:403
int nmics
Definition: structs.h:304
DOUBLE z
Definition: structs.h:35
struct vector rotation
Definition: structs.h:183
#define LOG_DEBUG
Definition: logger.h:27
#define LOG_WARN
Definition: logger.h:25
#define malloc(size)
Definition: allocation.h:38
int read_plate(int igeom, const char *geoname, struct plate_geom *plategeom)
Definition: plate.c:22
External geometry stored in .msh file using GMSH v2.0 format.
Definition: structs.h:250
#define PLATE
Definition: config.h:57
#define SPHERE
Definition: config.h:54
DOUBLE x
Definition: structs.h:31
int col_block_size
Definition: structs.h:121
int nnodb
Definition: structs.h:177
int sphere(struct geometry *geom)
Definition: geom_sphere.c:30
const char * mics_file
Definition: structs.h:407
int read_cylinder(int igeom, const char *geoname, struct cylinder_geom *cylinder)
Definition: cylinder.c:22
Cylinder.
Definition: structs.h:210
Geometry info structure.
Definition: structs.h:161
#define MAX_PATH
Definition: constants.h:29
int read_nodes(int igeom, const char *geoname, struct nodes_geom *nodesgeom)
Definition: nodes.c:22
#define CONFIG_GET_FLOAT(config, name, var)
Definition: config.h:44
int row_block_size
Definition: structs.h:119
void logger(int level, char *msg,...)
Definition: logger.c:56
struct modgeom_info * modgeominfo
Definition: globals.h:38
External geometry stored in file using acousto native format.
Definition: structs.h:241
DOUBLE y
Definition: structs.h:33
struct vector rotation
Definition: structs.h:308