File: | aflr3_Interface.c |
Warning: | line 1087, column 7 Value stored to 'ibody' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | // |
2 | // Written by Dr. Ryan Durscher AFRL/RQVC |
3 | // Place clearance statement here. |
4 | // |
5 | // AFLR3 interface functions - Modified from functions provided with |
6 | // AFLR3_LIB source (aflr3.c) written by David L. Marcum |
7 | |
8 | |
9 | #ifdef WIN32 |
10 | #define strcasecmp stricmp |
11 | #define strncasecmp _strnicmp |
12 | #define strtok_r strtok_s |
13 | #endif |
14 | |
15 | #include <math.h> |
16 | |
17 | #include "aimUtil.h" |
18 | #include "meshUtils.h" // Collection of helper functions for meshing |
19 | #include "miscUtils.h" |
20 | #include "egads.h" |
21 | |
22 | #define _ENABLE_BL_ |
23 | |
24 | #include <AFLR3_LIB.h> // AFLR3_API Library include |
25 | #include <aflr4/AFLR4_LIB.h> // Bring in AFLR4 API library |
26 | #include <egads_aflr4/EGADS_AFLR4_LIB_INC.h> |
27 | |
28 | // UG_IO Library (file I/O) include |
29 | // UG_CPP Library (c++ code) include |
30 | |
31 | #include <ug_io/UG_IO_LIB_INC.h> |
32 | #include <ug_cpp/UG_CPP_LIB_INC.h> |
33 | |
34 | // UG_GQ Library (grid quality) include |
35 | // This is optional and not required for implementation. |
36 | |
37 | #include <ug_gq/UG_GQ_LIB_INC.h> |
38 | |
39 | // Includes for version functions |
40 | // This is optional and not required for implementation. |
41 | |
42 | #include <otb/OTB_LIB_INC.h> |
43 | #include <rec3/REC3_LIB_INC.h> |
44 | #include <ug3/UG3_LIB_INC.h> |
45 | #include <dftr3/DFTR3_LIB_INC.h> |
46 | #include <ice3/ICE3_LIB_INC.h> |
47 | |
48 | #ifdef _ENABLE_BL_ |
49 | #include <aflr2c/AFLR2_LIB.h> |
50 | #include <anbl3/ANBL3_LIB.h> |
51 | |
52 | /* |
53 | #include "bl1/BL1_LIB_INC.h" |
54 | #include "dgeom/DGEOM_LIB_INC.h" |
55 | #include "egen/EGEN_LIB_INC.h" |
56 | #include "qtb/QTB_LIB_INC.h" |
57 | #include "rec2/REC2_LIB_INC.h" |
58 | #include "ug2/UG2_LIB_INC.h" |
59 | #include "dftr2/DFTR2_LIB_INC.h" |
60 | #include "ice2/ICE2_LIB_INC.h" |
61 | */ |
62 | #endif |
63 | |
64 | #include "aflr3_Interface.h" |
65 | |
66 | |
67 | int aflr3_to_MeshStruct( INT_ Number_of_Nodes, |
68 | INT_ Number_of_Surf_Trias, |
69 | INT_ Number_of_Surf_Quads, |
70 | INT_ Number_of_Vol_Tets, |
71 | INT_ Number_of_Vol_Pents_5, |
72 | INT_ Number_of_Vol_Pents_6, |
73 | INT_ Number_of_Vol_Hexs, |
74 | INT_1D *Surf_ID_Flag, |
75 | INT_3D *Surf_Tria_Connectivity, |
76 | INT_4D *Surf_Quad_Connectivity, |
77 | INT_4D *Vol_Tet_Connectivity, |
78 | INT_5D *Vol_Pent_5_Connectivity, |
79 | INT_6D *Vol_Pent_6_Connectivity, |
80 | INT_8D *Vol_Hex_Connectivity, |
81 | DOUBLE_3D *Coordinates, |
82 | meshStruct *genUnstrMesh) { |
83 | |
84 | int status; // Function return status |
85 | |
86 | int i, j, elementIndex; // Indexing variable |
87 | |
88 | int numPoint; |
89 | int defaultVolID = 1; // Defailt volume ID |
90 | |
91 | meshAnalysisTypeEnum analysisType; |
92 | |
93 | analysisType = genUnstrMesh->analysisType; |
94 | |
95 | // Cleanup existing node and elements |
96 | (void) destroy_meshNodes(genUnstrMesh); |
97 | |
98 | (void) destroy_meshElements(genUnstrMesh); |
99 | |
100 | (void) destroy_meshQuickRefStruct(&genUnstrMesh->meshQuickRef); |
101 | genUnstrMesh->meshType = VolumeMesh; |
102 | |
103 | //printf ("Transferring mesh to general unstructured structure\n"); |
104 | |
105 | // Numbers |
106 | genUnstrMesh->numNode = Number_of_Nodes; |
107 | genUnstrMesh->numElement = Number_of_Surf_Trias + |
108 | Number_of_Surf_Quads + |
109 | Number_of_Vol_Tets + |
110 | Number_of_Vol_Pents_5 + |
111 | Number_of_Vol_Pents_6 + |
112 | Number_of_Vol_Hexs; |
113 | |
114 | genUnstrMesh->meshQuickRef.useStartIndex = (int) true1; |
115 | |
116 | genUnstrMesh->meshQuickRef.numTriangle = Number_of_Surf_Trias; |
117 | genUnstrMesh->meshQuickRef.numQuadrilateral = Number_of_Surf_Quads; |
118 | |
119 | genUnstrMesh->meshQuickRef.numTetrahedral = Number_of_Vol_Tets; |
120 | genUnstrMesh->meshQuickRef.numPyramid = Number_of_Vol_Pents_5; |
121 | genUnstrMesh->meshQuickRef.numPrism = Number_of_Vol_Pents_6; |
122 | genUnstrMesh->meshQuickRef.numHexahedral = Number_of_Vol_Hexs; |
123 | |
124 | // Allocation |
125 | |
126 | // Nodes - allocate |
127 | genUnstrMesh->node = (meshNodeStruct *) |
128 | EG_alloc(genUnstrMesh->numNode*sizeof(meshNodeStruct)); |
129 | if (genUnstrMesh->node == NULL((void*)0)) { |
130 | #if !defined(_MSC_VER) || (_MSC_VER >= 1800) |
131 | /*@-formatcode@*/ |
132 | printf("Failed to allocate %d meshNodeStruct (%zu bytes)\n", |
133 | genUnstrMesh->numNode, genUnstrMesh->numNode*sizeof(meshNodeStruct)); |
134 | /*@+formatcode@*/ |
135 | #endif |
136 | return EGADS_MALLOC-4; |
137 | } |
138 | |
139 | // Elements - allocate |
140 | genUnstrMesh->element = (meshElementStruct *) |
141 | EG_alloc(genUnstrMesh->numElement*sizeof(meshElementStruct)); |
142 | if (genUnstrMesh->element == NULL((void*)0)) { |
143 | #if !defined(_MSC_VER) || (_MSC_VER >= 1800) |
144 | /*@-formatcode@*/ |
145 | printf("Failed to allocate %d meshElementStruct (%zu bytes)\n", |
146 | genUnstrMesh->numElement, |
147 | genUnstrMesh->numElement*sizeof(meshElementStruct)); |
148 | /*@+formatcode@*/ |
149 | #endif |
150 | EG_free(genUnstrMesh->node); |
151 | genUnstrMesh->node = NULL((void*)0); |
152 | return EGADS_MALLOC-4; |
153 | } |
154 | |
155 | // Initialize |
156 | for (i = 0; i < genUnstrMesh->numNode; i++) { |
157 | status = initiate_meshNodeStruct(&genUnstrMesh->node[i], analysisType); |
158 | if (status != CAPS_SUCCESS0) goto cleanup; |
159 | } |
160 | |
161 | for (i = 0; i < genUnstrMesh->numElement; i++ ) { |
162 | status = initiate_meshElementStruct(&genUnstrMesh->element[i], |
163 | analysisType); |
164 | if (status != CAPS_SUCCESS0) goto cleanup; |
165 | } |
166 | |
167 | // Nodes - set |
168 | for (i = 0; i < genUnstrMesh->numNode; i++) { |
169 | |
170 | // Copy node data |
171 | genUnstrMesh->node[i].nodeID = i+1; |
172 | |
173 | genUnstrMesh->node[i].xyz[0] = Coordinates[i+1][0]; |
174 | genUnstrMesh->node[i].xyz[1] = Coordinates[i+1][1]; |
175 | genUnstrMesh->node[i].xyz[2] = Coordinates[i+1][2]; |
176 | } |
177 | |
178 | |
179 | // Start of element index |
180 | elementIndex = 0; |
181 | |
182 | // Elements-Set triangles |
183 | if (Number_of_Surf_Trias > 0) |
184 | genUnstrMesh->meshQuickRef.startIndexTriangle = elementIndex; |
185 | |
186 | numPoint = 0; |
187 | for (i = 0; i < Number_of_Surf_Trias; i++) { |
188 | |
189 | genUnstrMesh->element[elementIndex].elementType = Triangle; |
190 | genUnstrMesh->element[elementIndex].elementID = elementIndex+1; |
191 | |
192 | genUnstrMesh->element[elementIndex].markerID = Surf_ID_Flag[i+1]; |
193 | |
194 | status = mesh_allocMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
195 | if (status != CAPS_SUCCESS0) goto cleanup; |
196 | |
197 | if (i == 0) { // Only need this once |
198 | numPoint = mesh_numMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
199 | } |
200 | |
201 | for (j = 0; j < numPoint; j++ ) { |
202 | genUnstrMesh->element[elementIndex].connectivity[j] = |
203 | Surf_Tria_Connectivity[i+1][j]; |
204 | } |
205 | |
206 | elementIndex += 1; |
207 | } |
208 | |
209 | // Elements -Set quadrilateral |
210 | if (Number_of_Surf_Quads > 0) |
211 | genUnstrMesh->meshQuickRef.startIndexQuadrilateral = elementIndex; |
212 | |
213 | for (i = 0; i < Number_of_Surf_Quads; i++) { |
214 | |
215 | genUnstrMesh->element[elementIndex].elementType = Quadrilateral; |
216 | genUnstrMesh->element[elementIndex].elementID = elementIndex+1; |
217 | genUnstrMesh->element[elementIndex].markerID = |
218 | Surf_ID_Flag[Number_of_Surf_Trias+i+1]; |
219 | |
220 | status = mesh_allocMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
221 | if (status != CAPS_SUCCESS0) goto cleanup; |
222 | |
223 | if (i == 0) { // Only need this once |
224 | numPoint = mesh_numMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
225 | } |
226 | |
227 | for (j = 0; j < numPoint; j++ ) { |
228 | genUnstrMesh->element[elementIndex].connectivity[j] = |
229 | Surf_Quad_Connectivity[i+1][j]; |
230 | } |
231 | |
232 | elementIndex += 1; |
233 | } |
234 | |
235 | // Elements -Set Tetrahedral |
236 | if (Number_of_Vol_Tets > 0) |
237 | genUnstrMesh->meshQuickRef.startIndexTetrahedral = elementIndex; |
238 | |
239 | for (i = 0; i < Number_of_Vol_Tets; i++) { |
240 | |
241 | genUnstrMesh->element[elementIndex].elementType = Tetrahedral; |
242 | genUnstrMesh->element[elementIndex].elementID = elementIndex+1; |
243 | genUnstrMesh->element[elementIndex].markerID = defaultVolID; |
244 | |
245 | status = mesh_allocMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
246 | if (status != CAPS_SUCCESS0) goto cleanup; |
247 | |
248 | if (i == 0) { // Only need this once |
249 | numPoint = mesh_numMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
250 | } |
251 | |
252 | for (j = 0; j < numPoint; j++ ) { |
253 | genUnstrMesh->element[elementIndex].connectivity[j] = |
254 | Vol_Tet_Connectivity[i+1][j]; |
255 | } |
256 | |
257 | elementIndex += 1; |
258 | } |
259 | |
260 | // Elements -Set Pyramid |
261 | if (Number_of_Vol_Pents_5 > 0) |
262 | genUnstrMesh->meshQuickRef.startIndexPyramid = elementIndex; |
263 | |
264 | for (i = 0; i < Number_of_Vol_Pents_5; i++) { |
265 | |
266 | genUnstrMesh->element[elementIndex].elementType = Pyramid; |
267 | genUnstrMesh->element[elementIndex].elementID = elementIndex+1; |
268 | genUnstrMesh->element[elementIndex].markerID = defaultVolID; |
269 | |
270 | status = mesh_allocMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
271 | if (status != CAPS_SUCCESS0) goto cleanup; |
272 | |
273 | if (i == 0) { // Only need this once |
274 | numPoint = mesh_numMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
275 | } |
276 | |
277 | for (j = 0; j < numPoint; j++ ) { |
278 | genUnstrMesh->element[elementIndex].connectivity[j] = |
279 | Vol_Pent_5_Connectivity[i+1][j]; |
280 | } |
281 | |
282 | elementIndex += 1; |
283 | } |
284 | |
285 | // Elements -Set Prism |
286 | if (Number_of_Vol_Pents_6 > 0) |
287 | genUnstrMesh->meshQuickRef.startIndexPrism = elementIndex; |
288 | |
289 | for (i = 0; i < Number_of_Vol_Pents_6; i++) { |
290 | |
291 | genUnstrMesh->element[elementIndex].elementType = Prism; |
292 | genUnstrMesh->element[elementIndex].elementID = elementIndex+1; |
293 | genUnstrMesh->element[elementIndex].markerID = defaultVolID; |
294 | |
295 | status = mesh_allocMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
296 | if (status != CAPS_SUCCESS0) goto cleanup; |
297 | |
298 | if (i == 0) { // Only need this once |
299 | numPoint = mesh_numMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
300 | } |
301 | |
302 | for (j = 0; j < numPoint; j++ ) { |
303 | genUnstrMesh->element[elementIndex].connectivity[j] = |
304 | Vol_Pent_6_Connectivity[i+1][j]; |
305 | } |
306 | |
307 | elementIndex += 1; |
308 | } |
309 | |
310 | // Elements -Set Hexa |
311 | if (Number_of_Vol_Hexs > 0) |
312 | genUnstrMesh->meshQuickRef.startIndexHexahedral = elementIndex; |
313 | |
314 | for (i = 0; i < Number_of_Vol_Hexs; i++) { |
315 | |
316 | genUnstrMesh->element[elementIndex].elementType = Hexahedral; |
317 | genUnstrMesh->element[elementIndex].elementID = elementIndex+1; |
318 | genUnstrMesh->element[elementIndex].markerID = defaultVolID; |
319 | |
320 | status = mesh_allocMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
321 | if (status != CAPS_SUCCESS0) goto cleanup; |
322 | |
323 | if (i == 0) { // Only need this once |
324 | numPoint = mesh_numMeshElementConnectivity(&genUnstrMesh->element[elementIndex]); |
325 | } |
326 | |
327 | for (j = 0; j < numPoint; j++ ) { |
328 | genUnstrMesh->element[elementIndex].connectivity[j] = |
329 | Vol_Hex_Connectivity[i+1][j]; |
330 | } |
331 | |
332 | elementIndex += 1; |
333 | } |
334 | |
335 | status = CAPS_SUCCESS0; |
336 | |
337 | |
338 | cleanup: |
339 | if (status != CAPS_SUCCESS0) |
340 | printf("Premature exit in aflr3_to_MeshStruct status = %d\n", status); |
341 | |
342 | return status; |
343 | } |
344 | |
345 | |
346 | int aflr3_Volume_Mesh (void *aimInfo, |
347 | capsValue *aimInputs, |
348 | int ibodyOffset, |
349 | meshInputStruct meshInput, |
350 | const char *fileName, |
351 | int boundingBoxIndex, |
352 | int createBL, |
353 | double globalBLSpacing, |
354 | double globalBLThickness, |
355 | double capsMeshLength, |
356 | const mapAttrToIndexStruct *groupMap, |
357 | const mapAttrToIndexStruct *meshMap, |
358 | int numMeshProp, |
359 | meshSizingStruct *meshProp, |
360 | meshStruct *volumeMesh) |
361 | { |
362 | int i, d; // Indexing |
363 | |
364 | int propIndex; |
365 | int bodyIndex, state, np, ibody, nbody; |
366 | |
367 | // Command line variables |
368 | int aflr3_argc = 1; // Number of arguments |
369 | char **aflr3_argv = NULL((void*)0); // String arrays |
370 | char *meshInputString = NULL((void*)0); |
371 | char *rest = NULL((void*)0), *token = NULL((void*)0); |
372 | char aimFile[PATH_MAX4096]; |
373 | |
374 | ego *copy_body_tess=NULL((void*)0), context, body, model=NULL((void*)0); |
375 | ego *faces=NULL((void*)0), *modelFaces=NULL((void*)0); |
376 | int numFace = 0, numModelFace = 0; |
377 | int *faceBodyIndex = NULL((void*)0); |
378 | int *faceGroupIndex = NULL((void*)0); |
379 | |
380 | int transp_intrnl = (int)false0; |
381 | INT_ Input_Surf_Trias = 0; |
382 | int face_ntri, isurf, itri; |
383 | const double *face_xyz, *face_uv; |
384 | const int *face_ptype, *face_pindex, *face_tris, *face_tric; |
385 | |
386 | int itransp = 0; |
387 | int *transpBody = NULL((void*)0); |
388 | |
389 | int iface = 0, nface, meshIndex; |
390 | const char *groupName = NULL((void*)0); |
391 | int nnode_face, *face_node_map = NULL((void*)0); |
392 | |
393 | const char *pstring = NULL((void*)0); |
394 | const int *pints = NULL((void*)0); |
395 | const double *preals = NULL((void*)0); |
396 | int atype, n; |
397 | |
398 | char bodyNumber[42], attrname[128]; |
399 | |
400 | INT_ create_tess_mode = 2; |
401 | INT_ set_node_map = 1; |
402 | |
403 | int aflr4_argc = 1; |
404 | char **aflr4_argv = NULL((void*)0); |
405 | |
406 | UG_Param_Struct *AFLR4_Param_Struct_Ptr = NULL((void*)0); |
407 | |
408 | const char* bcType = NULL((void*)0); |
409 | INT_ nbl, nbldiff; |
410 | INT_ index=0; |
411 | |
412 | // Declare AFLR3 grid generation variables. |
413 | INT_1D *Edge_ID_Flag = NULL((void*)0); |
414 | INT_1D *Surf_Error_Flag= NULL((void*)0); |
415 | INT_1D *Surf_Grid_BC_Flag = NULL((void*)0); |
416 | INT_1D *Surf_ID_Flag = NULL((void*)0); |
417 | INT_1D *Surf_Reconnection_Flag = NULL((void*)0); |
418 | INT_2D *Surf_Edge_Connectivity = NULL((void*)0); |
419 | INT_3D *Surf_Tria_Connectivity = NULL((void*)0); |
420 | INT_4D *Surf_Quad_Connectivity = NULL((void*)0); |
421 | INT_1D *Vol_ID_Flag = NULL((void*)0); |
422 | INT_4D *Vol_Tet_Connectivity = NULL((void*)0); |
423 | INT_5D *Vol_Pent_5_Connectivity = NULL((void*)0); |
424 | INT_6D *Vol_Pent_6_Connectivity = NULL((void*)0); |
425 | INT_8D *Vol_Hex_Connectivity = NULL((void*)0); |
426 | |
427 | DOUBLE_3D *Coordinates = NULL((void*)0); |
428 | DOUBLE_1D *BL_Normal_Spacing = NULL((void*)0); |
429 | DOUBLE_1D *BL_Thickness = NULL((void*)0); |
430 | |
431 | INT_4D *BG_Vol_Tet_Neigbors = NULL((void*)0); |
432 | INT_4D *BG_Vol_Tet_Connectivity = NULL((void*)0); |
433 | |
434 | DOUBLE_3D *BG_Coordinates = NULL((void*)0); |
435 | DOUBLE_1D *BG_Spacing = NULL((void*)0); |
436 | DOUBLE_6D *BG_Metric = NULL((void*)0); |
437 | |
438 | DOUBLE_3D *Source_Coordinates = NULL((void*)0); |
439 | DOUBLE_1D *Source_Spacing = NULL((void*)0); |
440 | DOUBLE_6D *Source_Metric = NULL((void*)0); |
441 | |
442 | INT_ status= 0; |
443 | INT_ Message_Flag = 1; |
444 | INT_ Number_of_BL_Vol_Tets = 0; |
445 | INT_ Number_of_Nodes = 0; |
446 | INT_ Number_of_Surf_Edges = 0; |
447 | INT_ Number_of_Surf_Quads = 0; |
448 | INT_ Number_of_Surf_Trias = 0; |
449 | INT_ Number_of_Vol_Hexs = 0; |
450 | INT_ Number_of_Vol_Pents_5 = 0; |
451 | INT_ Number_of_Vol_Pents_6 = 0; |
452 | INT_ Number_of_Vol_Tets = 0; |
453 | |
454 | INT_ Number_of_BG_Nodes = 0; |
455 | INT_ Number_of_BG_Vol_Tets = 0; |
456 | |
457 | INT_ Number_of_Source_Nodes = 0; |
458 | |
459 | // Declare main program variables. |
460 | |
461 | INT_ idef, noquad = 0; |
462 | INT_ mclosed = 1; |
463 | INT_ glue_trnsp = 1, nfree; |
464 | DOUBLE_2D *u = NULL((void*)0); |
465 | |
466 | // INT_ M_BL_Thickness, M_Initial_Normal_Spacing; |
467 | |
468 | CHAR_UG_MAX Output_Case_Name; |
469 | |
470 | DOUBLE_1D *BG_U_Scalars = NULL((void*)0); |
471 | DOUBLE_6D *BG_U_Metrics = NULL((void*)0); |
472 | |
473 | INT_ * bc_ids_vector = NULL((void*)0); |
474 | DOUBLE_1D *bl_ds_vector = NULL((void*)0); |
475 | DOUBLE_1D *bl_del_vector = NULL((void*)0); |
476 | |
477 | void *ext_cad_data = NULL((void*)0); |
478 | egads_struct *ptr = NULL((void*)0); |
479 | |
480 | // Set and register program parameter functions. |
481 | |
482 | ug_set_prog_param_code (3); |
483 | |
484 | ug_set_prog_param_function1 (ug_initialize_aflr_param); |
485 | ug_set_prog_param_function1 (ug_gq_initialize_param); // optional |
486 | ug_set_prog_param_function2 (aflr3_initialize_param); |
487 | ug_set_prog_param_function2 (aflr3_anbl3_initialize_param); |
488 | ug_set_prog_param_function2 (ice3_initialize_param); |
489 | ug_set_prog_param_function2 (ug3_qchk_initialize_param); // optional |
490 | |
491 | // Register routines for BL mode |
492 | #ifdef _ENABLE_BL_ |
493 | aflr3_anbl3_register_grid_generator (anbl3_grid_generator); |
494 | aflr3_anbl3_register_initialize_param (anbl3_initialize_param); |
495 | aflr3_anbl3_register_be_set_surf_edge_data (anbl3_be_set_surf_edge_data); |
496 | aflr3_anbl3_register_be_get_surf_edge_data (anbl3_be_get_surf_edge_data); |
497 | aflr3_anbl3_register_be_free_data (anbl3_be_free_data); |
498 | #endif |
499 | |
500 | // Register external routines for evaluation of the distribution function, |
501 | // metrics and transformation vectors. |
502 | |
503 | // If external routines are used then they must be registered prior to calling |
504 | // aflr3_grid_generator. The external evaluation routines must be registered |
505 | // using dftr3_register_eval, either dftr3_register_eval_inl or |
506 | // dftr3_register_eval_inl_flags, and possibly dftr3_register_eval_free. |
507 | // Either the full initialization routine must be registered using |
508 | // dftr3_register_eval_inl or the flag intialization routine must be |
509 | // registered using dftr3_register_eval_inl_flag_data. Do not specify both. |
510 | // If your initialization routine allocates and retains memory for subsequent |
511 | // evaluations of the sizing function then a routine that frees that memory at |
512 | // completion of grid generation or when a fatal error occurs must be |
513 | // registered using dftr3_register_eval_free. |
514 | |
515 | dftr3_register_eval (dftr3_test_eval); |
516 | dftr3_register_eval_inl (dftr3_test_eval_inl); |
517 | |
518 | // Register AFLR4-EGADS routines for CAD related setup & cleanup, |
519 | // cad evaluation, cad bounds and generating boundary edge grids. |
520 | |
521 | // these calls are in aflr4_main_register - if that changes then these |
522 | // need to change |
523 | aflr4_register_auto_cad_geom_setup (egads_auto_cad_geom_setup); |
524 | aflr4_register_cad_geom_data_cleanup (egads_cad_geom_data_cleanup); |
525 | aflr4_register_cad_geom_file_read (egads_cad_geom_file_read); |
526 | aflr4_register_cad_geom_file_write (egads_cad_geom_file_write); |
527 | aflr4_register_cad_geom_create_tess (egads_aflr4_create_tess); |
528 | aflr4_register_cad_geom_reset_attr (egads_cad_geom_reset_attr); |
529 | aflr4_register_cad_geom_setup (egads_cad_geom_setup); |
530 | aflr4_register_cad_tess_to_dgeom (egads_aflr4_tess_to_dgeom); |
531 | aflr4_register_set_ext_cad_data (egads_set_ext_cad_data); |
532 | |
533 | dgeom_register_cad_eval_curv_at_uv (egads_eval_curv_at_uv); |
534 | dgeom_register_cad_eval_edge_arclen (egads_eval_edge_arclen); |
535 | dgeom_register_cad_eval_uv_bounds (egads_eval_uv_bounds); |
536 | dgeom_register_cad_eval_uv_at_t (egads_eval_uv_at_t); |
537 | dgeom_register_cad_eval_uv_at_xyz (egads_eval_uv_at_xyz); |
538 | dgeom_register_cad_eval_xyz_at_t (egads_eval_xyz_at_u); |
539 | dgeom_register_cad_eval_xyz_at_uv (egads_eval_xyz_at_uv); |
540 | dgeom_register_discrete_eval_xyz_at_t (surfgen_discrete_eval_xyz_at_t); |
541 | |
542 | |
543 | status = ug_add_new_arg (&aflr3_argv, (char*)"allocate_and_initialize_argv"); |
544 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 544, __func__, 0); goto cleanup; }; |
545 | |
546 | // Set other command options |
547 | if (createBL == (int) true1) { |
548 | status = ug_add_flag_arg ((char*)"mbl=1", &aflr3_argc, &aflr3_argv); |
549 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 549, __func__, 0); goto cleanup; }; |
550 | |
551 | if (aimInputs[BL_Max_Layers-1].nullVal == NotNull) { |
552 | nbl = aimInputs[BL_Max_Layers-1].vals.integer; |
553 | status = ug_add_flag_arg ("nbl", &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 553, __func__, 0); goto cleanup; }; |
554 | status = ug_add_int_arg ( nbl , &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 554, __func__, 0); goto cleanup; }; |
555 | } |
556 | |
557 | if (aimInputs[BL_Max_Layer_Diff-1].nullVal == NotNull) { |
558 | nbldiff = aimInputs[BL_Max_Layer_Diff-1].vals.integer; |
559 | status = ug_add_flag_arg ("nbldiff", &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 559, __func__, 0); goto cleanup; }; |
560 | status = ug_add_int_arg ( nbldiff , &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 560, __func__, 0); goto cleanup; }; |
561 | } |
562 | |
563 | status = ug_add_flag_arg ((char*)"mblelc=1", &aflr3_argc, &aflr3_argv); |
564 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 564, __func__, 0); goto cleanup; }; |
565 | |
566 | } else { |
567 | status = ug_add_flag_arg ((char*)"mbl=0", &aflr3_argc, &aflr3_argv); |
568 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 568, __func__, 0); goto cleanup; }; |
569 | } |
570 | |
571 | status = ug_add_flag_arg ((char*)"mrecm=3" , &aflr3_argc, &aflr3_argv); |
572 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 572, __func__, 0); goto cleanup; }; |
573 | status = ug_add_flag_arg ((char*)"mrecqm=3", &aflr3_argc, &aflr3_argv); |
574 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 574, __func__, 0); goto cleanup; }; |
575 | |
576 | // Parse input string |
577 | if (meshInput.aflr3Input.meshInputString != NULL((void*)0)) { |
578 | |
579 | rest = meshInputString = EG_strdup(meshInput.aflr3Input.meshInputString); |
580 | while ((token = strtok_r(rest, " ", &rest))) { |
581 | status = ug_add_flag_arg (token, &aflr3_argc, &aflr3_argv); |
582 | if (status != 0) { |
583 | printf("Error: Failed to parse input string: %s\n", token); |
584 | if (meshInputString != NULL((void*)0)) |
585 | printf("Complete input string: %s\n", meshInputString); |
586 | goto cleanup; |
587 | } |
588 | } |
589 | } |
590 | |
591 | // Set meshInputs |
592 | if (meshInput.quiet == 1) Message_Flag = 0; |
593 | else Message_Flag = 1; |
594 | |
595 | // find all bodies with all AFLR_GBC TRANSP SRC/INTRNL |
596 | |
597 | AIM_ALLOC(transpBody, volumeMesh->numReferenceMesh, int, aimInfo, status){ if (transpBody != ((void*)0)) { status = -4; aim_status(aimInfo , status, "aflr3_Interface.c", 597, __func__, 1, "AIM_ALLOC: %s != NULL" , "transpBody"); goto cleanup; } size_t memorysize = volumeMesh ->numReferenceMesh; transpBody = (int *) EG_alloc(memorysize *sizeof(int)); if (transpBody == ((void*)0)) { status = -4; aim_status (aimInfo, status, "aflr3_Interface.c", 597, __func__, 3, "AIM_ALLOC: %s size %zu type %s" , "transpBody", memorysize, "int"); goto cleanup; } }; |
598 | for (i = 0; i < volumeMesh->numReferenceMesh; i++) transpBody[i] = 0; |
599 | |
600 | for (bodyIndex = 0; bodyIndex < volumeMesh->numReferenceMesh; bodyIndex++) { |
601 | |
602 | status = EG_statusTessBody(volumeMesh->referenceMesh[bodyIndex].egadsTess, &body, &state, &np); |
603 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 603, __func__, 0); goto cleanup; }; |
604 | |
605 | status = EG_getBodyTopos(body, NULL((void*)0), FACE23, &numFace, &faces); |
606 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 606, __func__, 0); goto cleanup; }; |
607 | AIM_NOTNULL(faces, aimInfo, status){ if (faces == ((void*)0)) { status = -307; aim_status(aimInfo , status, "aflr3_Interface.c", 607, __func__, 1, "%s == NULL!" , "faces"); goto cleanup; } }; |
608 | |
609 | for (iface = 0; iface < numFace; iface++) { |
610 | |
611 | bcType = NULL((void*)0); |
612 | |
613 | // check to see if AFLR_GBC is already set |
614 | status = EG_attributeRet(faces[iface], "AFLR_GBC", &atype, &n, |
615 | &pints, &preals, &pstring); |
616 | if (status == CAPS_SUCCESS0) { |
617 | if (atype != ATTRSTRING3) { |
618 | AIM_ERROR(aimInfo, "AFLR_GBC on Body %d Face %d must be a string!", bodyIndex+1, iface+1){ aim_message(aimInfo, CERROR, 0 , "aflr3_Interface.c", 618, __func__ , "AFLR_GBC on Body %d Face %d must be a string!", bodyIndex+ 1, iface+1); }; |
619 | status = CAPS_BADVALUE-311; |
620 | goto cleanup; |
621 | } |
622 | bcType = pstring; |
623 | } |
624 | |
625 | status = retrieve_CAPSMeshAttr(faces[iface], &groupName); |
626 | if (status == CAPS_SUCCESS0) { |
627 | |
628 | status = get_mapAttrToIndexIndex(meshMap, groupName, &meshIndex); |
629 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 629, __func__, 0); goto cleanup; }; |
630 | |
631 | for (propIndex = 0; propIndex < numMeshProp; propIndex++) { |
632 | if (meshIndex != meshProp[propIndex].attrIndex) continue; |
633 | |
634 | // If bcType specified in meshProp |
635 | if ((meshProp[propIndex].bcType != NULL((void*)0))) { |
636 | bcType = meshProp[propIndex].bcType; |
637 | } |
638 | break; |
639 | } |
640 | } |
641 | |
642 | // HACK to release ESP 1.21 |
643 | if (bcType != NULL((void*)0) && |
644 | strncasecmp(bcType, "TRANSP_INTRNL_UG3_GBC", 20) == 0) { |
645 | transp_intrnl = (int)true1; |
646 | } |
647 | |
648 | // check to see if all faces on a body are TRANSP SRC/INTRNL |
649 | if (bcType != NULL((void*)0) && |
650 | (strncasecmp(bcType, "TRANSP_SRC_UG3_GBC", 18) == 0 || |
651 | strncasecmp(bcType, "TRANSP_INTRNL_UG3_GBC", 20) == 0)) { |
652 | if (transpBody[bodyIndex] == -1) { |
653 | AIM_ERROR(aimInfo, "Body %d has mixture of TRANSP_INTRNL_UG3_GBC/TRANSP_SRC_UG3_GBC and other BCs!"){ aim_message(aimInfo, CERROR, 0 , "aflr3_Interface.c", 653, __func__ , "Body %d has mixture of TRANSP_INTRNL_UG3_GBC/TRANSP_SRC_UG3_GBC and other BCs!" ); }; |
654 | status = CAPS_BADTYPE-306; |
655 | goto cleanup; |
656 | } |
657 | transpBody[bodyIndex] = 1; |
658 | } else { |
659 | if (transpBody[bodyIndex] == 1) { |
660 | AIM_ERROR(aimInfo, "Body %d has mixture of TRANSP_INTRNL_UG3_GBC/TRANSP_SRC_UG3_GBC and other BCs!"){ aim_message(aimInfo, CERROR, 0 , "aflr3_Interface.c", 660, __func__ , "Body %d has mixture of TRANSP_INTRNL_UG3_GBC/TRANSP_SRC_UG3_GBC and other BCs!" ); }; |
661 | status = CAPS_BADTYPE-306; |
662 | goto cleanup; |
663 | } |
664 | transpBody[bodyIndex] = -1; |
665 | } |
666 | } |
667 | AIM_FREE(faces){ EG_free(faces); faces = ((void*)0); }; |
668 | } |
669 | |
670 | for (bodyIndex = 0, nbody = 0; bodyIndex < volumeMesh->numReferenceMesh; bodyIndex++) { |
671 | if (transpBody[bodyIndex] != 1) nbody++; |
672 | } |
673 | |
674 | AIM_ALLOC(copy_body_tess, 2*volumeMesh->numReferenceMesh, ego, aimInfo, status){ if (copy_body_tess != ((void*)0)) { status = -4; aim_status (aimInfo, status, "aflr3_Interface.c", 674, __func__, 1, "AIM_ALLOC: %s != NULL" , "copy_body_tess"); goto cleanup; } size_t memorysize = 2*volumeMesh ->numReferenceMesh; copy_body_tess = (ego *) EG_alloc(memorysize *sizeof(ego)); if (copy_body_tess == ((void*)0)) { status = - 4; aim_status(aimInfo, status, "aflr3_Interface.c", 674, __func__ , 3, "AIM_ALLOC: %s size %zu type %s", "copy_body_tess", memorysize , "ego"); goto cleanup; } }; |
675 | |
676 | // Copy bodies making sure TRANSP bodies are last |
677 | ibody = 0; |
678 | for (itransp = 1; itransp >= -1; itransp -= 2) { |
679 | for (bodyIndex = 0; bodyIndex < volumeMesh->numReferenceMesh; bodyIndex++) { |
680 | if (transpBody[bodyIndex] == itransp) continue; |
681 | |
682 | status = EG_statusTessBody(volumeMesh->referenceMesh[bodyIndex].egadsTess, &body, &state, &np); |
683 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 683, __func__, 0); goto cleanup; }; |
684 | |
685 | status = EG_copyObject(body, NULL((void*)0), ©_body_tess[ibody]); |
686 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 686, __func__, 0); goto cleanup; }; |
687 | |
688 | status = EG_copyObject(volumeMesh->referenceMesh[bodyIndex].egadsTess, copy_body_tess[ibody], |
689 | ©_body_tess[volumeMesh->numReferenceMesh+ibody]); |
690 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 690, __func__, 0); goto cleanup; }; |
691 | |
692 | status = EG_getBodyTopos(copy_body_tess[ibody], NULL((void*)0), FACE23, &numFace, &faces); |
693 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 693, __func__, 0); goto cleanup; }; |
694 | AIM_NOTNULL(faces, aimInfo, status){ if (faces == ((void*)0)) { status = -307; aim_status(aimInfo , status, "aflr3_Interface.c", 694, __func__, 1, "%s == NULL!" , "faces"); goto cleanup; } }; |
695 | |
696 | if (transpBody[bodyIndex] == -1) { |
697 | for (iface = 0; iface < numFace; iface++) { |
698 | status = EG_getTessFace(volumeMesh->referenceMesh[bodyIndex].egadsTess, |
699 | iface+1, &nnode_face, &face_xyz, &face_uv, |
700 | &face_ptype, &face_pindex, &face_ntri, &face_tris, &face_tric); |
701 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 701, __func__, 0); goto cleanup; }; |
702 | |
703 | Input_Surf_Trias += face_ntri; |
704 | } |
705 | } |
706 | |
707 | // Build up an array of all faces in the model |
708 | AIM_REALL(modelFaces, numModelFace+numFace, ego, aimInfo, status){ size_t memorysize = numModelFace+numFace; modelFaces = (ego *) EG_reall(modelFaces, memorysize*sizeof(ego)); if (modelFaces == ((void*)0)) { status = -4; aim_status(aimInfo, status, "aflr3_Interface.c" , 708, __func__, 3, "AIM_REALL: %s size %zu type %s", "modelFaces" , memorysize, "ego"); goto cleanup; } }; |
709 | for (i = 0; i < numFace; i++) modelFaces[numModelFace+i] = faces[i]; |
710 | AIM_REALL(faceBodyIndex, numModelFace+numFace, int, aimInfo, status){ size_t memorysize = numModelFace+numFace; faceBodyIndex = ( int *) EG_reall(faceBodyIndex, memorysize*sizeof(int)); if (faceBodyIndex == ((void*)0)) { status = -4; aim_status(aimInfo, status, "aflr3_Interface.c" , 710, __func__, 3, "AIM_REALL: %s size %zu type %s", "faceBodyIndex" , memorysize, "int"); goto cleanup; } }; |
711 | for (i = 0; i < numFace; i++) faceBodyIndex[numModelFace+i] = bodyIndex; |
712 | |
713 | AIM_REALL(faceGroupIndex, numModelFace+numFace, int, aimInfo, status){ size_t memorysize = numModelFace+numFace; faceGroupIndex = ( int *) EG_reall(faceGroupIndex, memorysize*sizeof(int)); if ( faceGroupIndex == ((void*)0)) { status = -4; aim_status(aimInfo , status, "aflr3_Interface.c", 713, __func__, 3, "AIM_REALL: %s size %zu type %s" , "faceGroupIndex", memorysize, "int"); goto cleanup; } }; |
714 | for (i = 0; i < numFace; i++) { |
715 | status = retrieve_CAPSGroupAttr(faces[i], &groupName); |
716 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 716, __func__, 0); goto cleanup; }; |
717 | |
718 | status = get_mapAttrToIndexIndex(groupMap, groupName, &faceGroupIndex[numModelFace+i]); |
719 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 719, __func__, 0); goto cleanup; }; |
720 | } |
721 | |
722 | AIM_FREE(faces){ EG_free(faces); faces = ((void*)0); }; |
723 | numModelFace += numFace; |
724 | ibody++; |
725 | } |
726 | } |
727 | |
728 | // Map model face ID to property index |
729 | |
730 | bc_ids_vector = (INT_ *) ug_malloc (&status, (numModelFace) * sizeof (INT_)); |
731 | bl_ds_vector = (DOUBLE_1D *) ug_malloc (&status, (numModelFace) * sizeof (DOUBLE_1D)); |
732 | bl_del_vector = (DOUBLE_1D *) ug_malloc (&status, (numModelFace) * sizeof (DOUBLE_1D)); |
733 | |
734 | if (status != 0) { |
735 | AIM_ERROR(aimInfo, "AFLR memory allocation error"){ aim_message(aimInfo, CERROR, 0 , "aflr3_Interface.c", 735, __func__ , "AFLR memory allocation error"); }; |
736 | status = EGADS_MALLOC-4; |
737 | goto cleanup; |
738 | } |
739 | |
740 | AIM_NOTNULL(modelFaces, aimInfo, status){ if (modelFaces == ((void*)0)) { status = -307; aim_status(aimInfo , status, "aflr3_Interface.c", 740, __func__, 1, "%s == NULL!" , "modelFaces"); goto cleanup; } }; |
741 | AIM_NOTNULL(faceBodyIndex, aimInfo, status){ if (faceBodyIndex == ((void*)0)) { status = -307; aim_status (aimInfo, status, "aflr3_Interface.c", 741, __func__, 1, "%s == NULL!" , "faceBodyIndex"); goto cleanup; } }; |
742 | |
743 | for (iface = 0; iface < numModelFace; iface++) { |
744 | |
745 | bc_ids_vector[iface] = iface+1; |
746 | bl_ds_vector[iface] = globalBLSpacing; |
747 | bl_del_vector[iface] = globalBLThickness; |
748 | |
749 | // check to see if AFLR_GBC is already set |
750 | status = EG_attributeRet(modelFaces[iface], "AFLR_GBC", &atype, &n, |
751 | &pints, &preals, &pstring); |
752 | if (status == EGADS_NOTFOUND-1) { |
753 | bcType = (bl_ds_vector[iface] != 0 && bl_del_vector[iface] != 0 && |
754 | faceBodyIndex[iface] != boundingBoxIndex) ? "-STD_UG3_GBC" : "STD_UG3_GBC"; |
755 | |
756 | status = EG_attributeAdd(modelFaces[iface], "AFLR_GBC", ATTRSTRING3, 0, |
757 | NULL((void*)0), NULL((void*)0), bcType); |
758 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 758, __func__, 0); goto cleanup; }; |
759 | } |
760 | |
761 | status = retrieve_CAPSMeshAttr(modelFaces[iface], &groupName); |
762 | if (status == CAPS_SUCCESS0) { |
763 | |
764 | status = get_mapAttrToIndexIndex(meshMap, groupName, &meshIndex); |
765 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 765, __func__, 0); goto cleanup; }; |
766 | |
767 | for (propIndex = 0; propIndex < numMeshProp; propIndex++) { |
768 | if (meshIndex != meshProp[propIndex].attrIndex) continue; |
769 | |
770 | bl_ds_vector[iface] = meshProp[propIndex].boundaryLayerSpacing*capsMeshLength; |
771 | bl_del_vector[iface] = meshProp[propIndex].boundaryLayerThickness*capsMeshLength; |
772 | |
773 | status = EG_attributeRet(modelFaces[iface], "AFLR_GBC", &atype, &n, |
774 | &pints, &preals, &pstring); |
775 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 775, __func__, 0); goto cleanup; }; |
776 | |
777 | bcType = (bl_ds_vector[iface] != 0 && bl_del_vector[iface] != 0 && |
778 | faceBodyIndex[iface] != boundingBoxIndex) ? "-STD_UG3_GBC" : pstring; |
779 | |
780 | // If bcType specified in meshProp |
781 | if ((meshProp[propIndex].bcType != NULL((void*)0))) { |
782 | |
783 | if (strncasecmp(meshProp[propIndex].bcType, "Farfield" , 8) == 0 || |
784 | strncasecmp(meshProp[propIndex].bcType, "Freestream" , 10) == 0 || |
785 | strncasecmp(meshProp[propIndex].bcType, "FARFIELD_UG3_GBC" , 16) == 0) |
786 | bcType = "FARFIELD_UG3_GBC"; |
787 | else if (strncasecmp(meshProp[propIndex].bcType, "Viscous" , 7) == 0 || |
788 | strncasecmp(meshProp[propIndex].bcType, "-STD_UG3_GBC" , 12) == 0 || |
789 | (meshProp[propIndex].boundaryLayerSpacing > 0 && |
790 | meshProp[propIndex].boundaryLayerThickness > 0)) |
791 | bcType = "-STD_UG3_GBC"; |
792 | else if (strncasecmp(meshProp[propIndex].bcType, "Inviscid" , 8) == 0 || |
793 | strncasecmp(meshProp[propIndex].bcType, "STD_UG3_GBC" , 11) == 0) |
794 | bcType = "STD_UG3_GBC"; |
795 | else if (strncasecmp(meshProp[propIndex].bcType, "Symmetry" , 8) == 0 || |
796 | strncasecmp(meshProp[propIndex].bcType, "BL_INT_UG3_GBC" , 14) == 0) |
797 | bcType = "BL_INT_UG3_GBC"; |
798 | else if (strncasecmp(meshProp[propIndex].bcType, "TRANSP_SRC_UG3_GBC" , 18) == 0) |
799 | bcType = "TRANSP_SRC_UG3_GBC"; |
800 | else if (strncasecmp(meshProp[propIndex].bcType, "TRANSP_BL_INT_UG3_GBC", 21) == 0) |
801 | bcType = "TRANSP_BL_INT_UG3_GBC"; |
802 | else if (strncasecmp(meshProp[propIndex].bcType, "TRANSP_UG3_GBC" , 14) == 0) |
803 | bcType = "TRANSP_UG3_GBC"; |
804 | else if (strncasecmp(meshProp[propIndex].bcType, "-TRANSP_UG3_GBC" , 15) == 0) |
805 | bcType = "-TRANSP_UG3_GBC"; |
806 | else if (strncasecmp(meshProp[propIndex].bcType, "TRANSP_INTRNL_UG3_GBC", 20) == 0) |
807 | bcType = "TRANSP_INTRNL_UG3_GBC"; |
808 | else if (strncasecmp(meshProp[propIndex].bcType, "FIXED_BL_INT_UG3_GBC" , 19) == 0) |
809 | bcType = "FIXED_BL_INT_UG3_GBC"; |
810 | } |
811 | |
812 | // Set face BC flag on the copy of the body |
813 | if (bcType != pstring) { |
814 | status = EG_attributeAdd(modelFaces[iface], "AFLR_GBC", ATTRSTRING3, 0, |
815 | NULL((void*)0), NULL((void*)0), bcType); |
816 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 816, __func__, 0); goto cleanup; }; |
817 | } |
818 | |
819 | break; |
820 | } |
821 | } |
822 | } |
823 | |
824 | // create the model |
825 | |
826 | status = EG_getContext(copy_body_tess[0], &context); |
827 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 827, __func__, 0); goto cleanup; }; |
828 | |
829 | status = EG_makeTopology(context, NULL((void*)0), MODEL26, 2*volumeMesh->numReferenceMesh, NULL((void*)0), volumeMesh->numReferenceMesh, |
830 | copy_body_tess, NULL((void*)0), &model); |
831 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 831, __func__, 0); goto cleanup; }; |
832 | |
833 | |
834 | // allocate and initialize a new argument vector |
835 | |
836 | status = ug_add_new_arg (&aflr4_argv, "allocate_and_initialize_argv"); |
837 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 837, __func__, 0); goto cleanup; }; |
838 | |
839 | // setup input parameter structure |
840 | |
841 | status = aflr4_setup_param (Message_Flag, 0, aflr4_argc, aflr4_argv, |
842 | &AFLR4_Param_Struct_Ptr); |
843 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 843, __func__, 0); goto cleanup; }; |
844 | |
845 | (void)ug_set_int_param ("geom_type", 1, AFLR4_Param_Struct_Ptr); |
846 | (void)ug_set_int_param ("mmsg", Message_Flag, AFLR4_Param_Struct_Ptr); |
847 | |
848 | // set CAD geometry data structure |
849 | |
850 | status = aflr4_set_ext_cad_data (&model); |
851 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 851, __func__, 0); goto cleanup; }; |
852 | |
853 | // setup geometry data |
854 | |
855 | status = aflr4_setup_and_grid_gen (0, AFLR4_Param_Struct_Ptr); |
856 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 856, __func__, 0); goto cleanup; }; |
857 | |
858 | // set dgeom from input data |
859 | |
860 | status = aflr4_cad_tess_to_dgeom (); |
861 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 861, __func__, 0); goto cleanup; }; |
862 | |
863 | dgeom_def_get_idef (index, &idef); |
864 | |
865 | |
866 | // add and glue all individual surfaces within composite surface definition |
867 | |
868 | status = dgeom_add_and_glue_comp (glue_trnsp, idef, mclosed, Message_Flag, &nfree); |
869 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 869, __func__, 0); goto cleanup; }; |
870 | |
871 | //------------------------------------------------ GET COPY OF SURFACE MESH DATA |
872 | |
873 | status = aflr4_get_def (idef, noquad, |
874 | &Number_of_Surf_Edges, |
875 | &Number_of_Surf_Trias, |
876 | &Number_of_Nodes, |
877 | &Number_of_Surf_Quads, |
878 | &Surf_Grid_BC_Flag, |
879 | &Edge_ID_Flag, |
880 | &Surf_ID_Flag, |
881 | &Surf_Edge_Connectivity, |
882 | &Surf_Tria_Connectivity, |
883 | &Surf_Quad_Connectivity, |
884 | &u, &Coordinates); |
885 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 885, __func__, 0); goto cleanup; }; |
886 | |
887 | aflr4_free_all (0); |
888 | |
889 | // check that all the inputs |
890 | |
891 | status = ug_check_prog_param(aflr3_argv, aflr3_argc, Message_Flag); |
892 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 892, __func__, 0); goto cleanup; }; |
893 | |
894 | if (createBL == (int)true1) { |
895 | |
896 | status = ug_add_flag_arg ("BC_IDs", &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 896, __func__, 0); goto cleanup; }; |
897 | status = ug_add_int_vector_arg (numModelFace, bc_ids_vector, &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 897, __func__, 0); goto cleanup; }; |
898 | status = ug_add_flag_arg ("BL_DS", &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 898, __func__, 0); goto cleanup; }; |
899 | status = ug_add_double_vector_arg (numModelFace, bl_ds_vector, &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 899, __func__, 0); goto cleanup; }; |
900 | status = ug_add_flag_arg ("BL_DEL", &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 900, __func__, 0); goto cleanup; }; |
901 | status = ug_add_double_vector_arg (numModelFace, bl_del_vector, &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 901, __func__, 0); goto cleanup; }; |
902 | |
903 | } |
904 | |
905 | // Set memory reduction output file format flag parameter, mpfrmt. |
906 | // |
907 | // If mpfrmt=1,2,3,4,5 then the output grid file is created within AFLR3 and |
908 | // only the surface grid is passed back from AFLR3. |
909 | // |
910 | // If mpfrmt=0 then the output grid file is not created within AFLR3 and |
911 | // the complete volume grid is passed back from AFLR3. |
912 | // |
913 | |
914 | // Set write mesh flag - do not write out the mesh internally |
915 | status = ug_add_flag_arg ((char *) "mpfrmt=0", &aflr3_argc, &aflr3_argv); |
916 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 916, __func__, 0); goto cleanup; }; |
917 | |
918 | status = ug_add_flag_arg ((char *) "mmsg", &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 918, __func__, 0); goto cleanup; }; |
919 | status = ug_add_int_arg(Message_Flag, &aflr3_argc, &aflr3_argv); AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 919, __func__, 0); goto cleanup; }; |
920 | |
921 | // note that if mpfrmt is not set to 0 and BL mesh generation is on then only |
922 | // the surface mesh is returned |
923 | |
924 | if (transp_intrnl == (int)true1) { |
925 | // HACK for TRANSP_INTRNL |
926 | |
927 | // This is needed aflr3 will segfault without it |
928 | Surf_Reconnection_Flag = (INT_1D*) ug_malloc (&status, (Number_of_Surf_Trias+Number_of_Surf_Quads+1) * sizeof (INT_1D)); |
929 | if (status != 0) { status = EGADS_MALLOC-4; goto cleanup; } |
930 | for (i = 0; i < Number_of_Surf_Trias+Number_of_Surf_Quads; i++) { |
931 | Surf_Reconnection_Flag[i+1] = 7; // Do not allow swapping on the surface triangles |
932 | } |
933 | |
934 | status = aflr3_grid_generator (aflr3_argc, aflr3_argv, |
935 | &Number_of_BL_Vol_Tets, |
936 | &Number_of_BG_Nodes, |
937 | &Number_of_BG_Vol_Tets, |
938 | &Number_of_Nodes, |
939 | &Number_of_Source_Nodes, |
940 | &Number_of_Surf_Quads, |
941 | &Number_of_Surf_Trias, |
942 | &Number_of_Vol_Hexs, |
943 | &Number_of_Vol_Pents_5, |
944 | &Number_of_Vol_Pents_6, |
945 | &Number_of_Vol_Tets, |
946 | &Surf_Error_Flag, |
947 | &Surf_Grid_BC_Flag, |
948 | &Surf_ID_Flag, |
949 | &Surf_Reconnection_Flag, |
950 | &Surf_Quad_Connectivity, |
951 | &Surf_Tria_Connectivity, |
952 | &Vol_Hex_Connectivity, |
953 | &Vol_Pent_5_Connectivity, |
954 | &Vol_Pent_6_Connectivity, |
955 | &Vol_Tet_Connectivity, |
956 | &BG_Vol_Tet_Neigbors, |
957 | &BG_Vol_Tet_Connectivity, |
958 | &Coordinates, |
959 | &BL_Normal_Spacing, |
960 | &BL_Thickness, |
961 | &BG_Coordinates, |
962 | &BG_Spacing, |
963 | &BG_Metric, |
964 | &Source_Coordinates, |
965 | &Source_Spacing, |
966 | &Source_Metric); |
967 | } else { |
968 | status = aflr3_vol_gen (aflr3_argc, aflr3_argv, Message_Flag, |
969 | &Number_of_Surf_Edges, |
970 | &Number_of_Surf_Trias, |
971 | &Number_of_Surf_Quads, |
972 | &Number_of_BL_Vol_Tets, |
973 | &Number_of_Vol_Tets, |
974 | &Number_of_Vol_Pents_5, |
975 | &Number_of_Vol_Pents_6, |
976 | &Number_of_Vol_Hexs, |
977 | &Number_of_Nodes, |
978 | &Number_of_BG_Vol_Tets, |
979 | &Number_of_BG_Nodes, |
980 | &Number_of_Source_Nodes, |
981 | &Edge_ID_Flag, |
982 | &Surf_Edge_Connectivity, |
983 | &Surf_Grid_BC_Flag, |
984 | &Surf_ID_Flag, |
985 | &Surf_Error_Flag, |
986 | &Surf_Reconnection_Flag, |
987 | &Surf_Tria_Connectivity, |
988 | &Surf_Quad_Connectivity, |
989 | &Vol_ID_Flag, |
990 | &Vol_Tet_Connectivity, |
991 | &Vol_Pent_5_Connectivity, |
992 | &Vol_Pent_6_Connectivity, |
993 | &Vol_Hex_Connectivity, |
994 | &BG_Vol_Tet_Neigbors, |
995 | &BG_Vol_Tet_Connectivity, |
996 | &Coordinates, |
997 | &BL_Normal_Spacing, |
998 | &BL_Thickness, |
999 | &BG_Coordinates, |
1000 | &BG_Spacing, |
1001 | &BG_Metric, |
1002 | &Source_Coordinates, |
1003 | &Source_Spacing, |
1004 | &Source_Metric); |
1005 | } |
1006 | |
1007 | if (status != 0) { |
1008 | FILE *fp; |
1009 | |
1010 | strcpy (Output_Case_Name, "debug"); |
1011 | ug3_write_surf_grid_error_file (Output_Case_Name, |
1012 | status, |
1013 | Number_of_Nodes, |
1014 | Number_of_Surf_Trias, |
1015 | Surf_Error_Flag, |
1016 | Surf_Grid_BC_Flag, |
1017 | Surf_ID_Flag, |
1018 | Surf_Tria_Connectivity, |
1019 | Coordinates); |
1020 | |
1021 | strcpy(aimFile, "aflr3_surf_debug.tec"); |
1022 | |
1023 | fp = fopen(aimFile, "w"); |
1024 | if (fp == NULL((void*)0)) goto cleanup; |
1025 | fprintf(fp, "VARIABLES = X, Y, Z, BC, ID\n"); |
1026 | |
1027 | fprintf(fp, "ZONE N=%d, E=%d, F=FEBLOCK, ET=Triangle\n", |
1028 | Number_of_Nodes, Number_of_Surf_Trias); |
1029 | fprintf(fp, ", VARLOCATION=([1,2,3]=NODAL,[4,5]=CELLCENTERED)\n"); |
1030 | // write nodal coordinates |
1031 | if (Coordinates != NULL((void*)0)) |
1032 | for (d = 0; d < 3; d++) { |
1033 | for (i = 0; i < Number_of_Nodes; i++) { |
1034 | if (i % 5 == 0) fprintf( fp, "\n"); |
1035 | fprintf(fp, "%22.15e ", Coordinates[i+1][d]); |
1036 | } |
1037 | fprintf(fp, "\n"); |
1038 | } |
1039 | |
1040 | if (Surf_Grid_BC_Flag != NULL((void*)0)) |
1041 | for (i = 0; i < Number_of_Surf_Trias; i++) { |
1042 | if (i % 5 == 0) fprintf( fp, "\n"); |
1043 | fprintf(fp, "%d ", Surf_Grid_BC_Flag[i+1]); |
1044 | } |
1045 | |
1046 | if (Surf_ID_Flag != NULL((void*)0)) |
1047 | for (i = 0; i < Number_of_Surf_Trias; i++) { |
1048 | if (i % 5 == 0) fprintf( fp, "\n"); |
1049 | if ((Surf_Error_Flag != NULL((void*)0)) && (Surf_Error_Flag[i+1] < 0)) |
1050 | fprintf(fp, "-1 "); |
1051 | else |
1052 | fprintf(fp, "%d ", Surf_ID_Flag[i+1]); |
1053 | } |
1054 | |
1055 | // cell connectivity |
1056 | if (Surf_Tria_Connectivity != NULL((void*)0)) |
1057 | for (i = 0; i < Number_of_Surf_Trias; i++) |
1058 | fprintf(fp, "%d %d %d\n", Surf_Tria_Connectivity[i+1][0], |
1059 | Surf_Tria_Connectivity[i+1][1], |
1060 | Surf_Tria_Connectivity[i+1][2]); |
1061 | /*@-dependenttrans@*/ |
1062 | fclose(fp); |
1063 | /*@+dependenttrans@*/ |
1064 | AIM_ERROR(aimInfo, "AFLR3 Grid generation error. The input surfaces mesh has been written to: %s", aimFile){ aim_message(aimInfo, CERROR, 0 , "aflr3_Interface.c", 1064, __func__, "AFLR3 Grid generation error. The input surfaces mesh has been written to: %s" , aimFile); }; |
1065 | goto cleanup; |
1066 | } |
1067 | |
1068 | |
1069 | if (transp_intrnl == (int)true1 && |
1070 | Input_Surf_Trias != Number_of_Surf_Trias) { |
1071 | printf("\nInfo: Use of TRANSP_INTRNL_UG3_GBC when the surface mesh is modified precludes mesh sensitivities and data transfer.\n"); |
1072 | printf(" Surface Mesh Number of Triangles: %d\n", Input_Surf_Trias); |
1073 | printf(" Volume Mesh Number of Triangles: %d\n", Number_of_Surf_Trias); |
1074 | printf("\n"); |
1075 | |
1076 | } else if (transp_intrnl == (int)true1) { |
1077 | |
1078 | // TRANSP_INTRNL_UG3_GBC is used, so aflr4_cad_geom_create_tess does not work, |
1079 | // but the surface mesh was preserved |
1080 | |
1081 | AIM_NOTNULL(Surf_ID_Flag, aimInfo, status){ if (Surf_ID_Flag == ((void*)0)) { status = -307; aim_status (aimInfo, status, "aflr3_Interface.c", 1081, __func__, 1, "%s == NULL!" , "Surf_ID_Flag"); goto cleanup; } }; |
1082 | AIM_NOTNULL(Surf_Tria_Connectivity, aimInfo, status){ if (Surf_Tria_Connectivity == ((void*)0)) { status = -307; aim_status (aimInfo, status, "aflr3_Interface.c", 1082, __func__, 1, "%s == NULL!" , "Surf_Tria_Connectivity"); goto cleanup; } }; |
1083 | |
1084 | isurf = 1; |
1085 | itri = 1; |
1086 | |
1087 | ibody = 0; |
Value stored to 'ibody' is never read | |
1088 | for (bodyIndex = 0; bodyIndex < volumeMesh->numReferenceMesh; bodyIndex++) { |
1089 | if (transpBody[bodyIndex] == 1) continue; |
1090 | |
1091 | // set the file name to write the egads file |
1092 | snprintf(bodyNumber, 42, AFLR3TESSFILE"aflr3_%d.eto", bodyIndex+ibodyOffset); |
1093 | status = aim_file(aimInfo, bodyNumber, aimFile); |
1094 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1094, __func__, 0); goto cleanup; }; |
1095 | |
1096 | status = EG_statusTessBody(volumeMesh->referenceMesh[bodyIndex].egadsTess, &body, &state, &np); |
1097 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1097, __func__, 0); goto cleanup; }; |
1098 | |
1099 | status = EG_getBodyTopos(body, NULL((void*)0), FACE23, &nface, NULL((void*)0)); |
1100 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1100, __func__, 0); goto cleanup; }; |
1101 | |
1102 | for (iface = 0; iface < nface; iface++, isurf++) { |
1103 | |
1104 | status = EG_getTessFace(volumeMesh->referenceMesh[bodyIndex].egadsTess, |
1105 | iface+1, &nnode_face, &face_xyz, &face_uv, |
1106 | &face_ptype, &face_pindex, &face_ntri, &face_tris, &face_tric); |
1107 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1107, __func__, 0); goto cleanup; }; |
1108 | |
1109 | AIM_ALLOC(face_node_map, nnode_face, int, aimInfo, status){ if (face_node_map != ((void*)0)) { status = -4; aim_status( aimInfo, status, "aflr3_Interface.c", 1109, __func__, 1, "AIM_ALLOC: %s != NULL" , "face_node_map"); goto cleanup; } size_t memorysize = nnode_face ; face_node_map = (int *) EG_alloc(memorysize*sizeof(int)); if (face_node_map == ((void*)0)) { status = -4; aim_status(aimInfo , status, "aflr3_Interface.c", 1109, __func__, 3, "AIM_ALLOC: %s size %zu type %s" , "face_node_map", memorysize, "int"); goto cleanup; } }; |
1110 | |
1111 | for (i = 0; i < face_ntri; i++, itri++) { |
1112 | if (Surf_ID_Flag[itri] != isurf) { |
1113 | AIM_ERROR(aimInfo, "Developer error Surf_ID_Flag missmatch!"){ aim_message(aimInfo, CERROR, 0 , "aflr3_Interface.c", 1113, __func__, "Developer error Surf_ID_Flag missmatch!"); }; |
1114 | status = CAPS_BADTYPE-306; |
1115 | goto cleanup; |
1116 | } |
1117 | |
1118 | for (d = 0; d < 3; d++) |
1119 | face_node_map[face_tris[3*i+d]-1] = Surf_Tria_Connectivity[itri][d]; |
1120 | } |
1121 | |
1122 | // Add the unique indexing of the tessellation |
1123 | snprintf(attrname, 128, "face_node_map_%d",iface+1); |
1124 | status = EG_attributeAdd(volumeMesh->referenceMesh[bodyIndex].egadsTess, attrname, ATTRINT1, |
1125 | nnode_face, face_node_map, NULL((void*)0), NULL((void*)0)); |
1126 | AIM_FREE (face_node_map){ EG_free(face_node_map); face_node_map = ((void*)0); }; |
1127 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1127, __func__, 0); goto cleanup; }; |
1128 | } |
1129 | |
1130 | remove(aimFile); |
1131 | status = EG_saveTess(volumeMesh->referenceMesh[bodyIndex].egadsTess, aimFile); |
1132 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1132, __func__, 0); goto cleanup; }; |
1133 | } |
1134 | |
1135 | } else { |
1136 | |
1137 | // extract surface mesh data from an existing CAD Model with previously |
1138 | // generated Tess Objects and save the data in the DGEOM data structure |
1139 | |
1140 | // re-cerate the model without any TRANSP SRC/INTRNL bodies if necessary |
1141 | if (nbody < volumeMesh->numReferenceMesh) { |
1142 | status = EG_deleteObject(model); |
1143 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1143, __func__, 0); goto cleanup; }; |
1144 | |
1145 | for (bodyIndex = 0, ibody = 0; bodyIndex < volumeMesh->numReferenceMesh; bodyIndex++) { |
1146 | if (transpBody[bodyIndex] == 1) continue; |
1147 | |
1148 | status = EG_statusTessBody(volumeMesh->referenceMesh[bodyIndex].egadsTess, &body, &state, &np); |
1149 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1149, __func__, 0); goto cleanup; }; |
1150 | |
1151 | status = EG_copyObject(body, NULL((void*)0), ©_body_tess[ibody]); |
1152 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1152, __func__, 0); goto cleanup; }; |
1153 | |
1154 | status = EG_copyObject(volumeMesh->referenceMesh[bodyIndex].egadsTess, copy_body_tess[ibody], ©_body_tess[nbody+ibody]); |
1155 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1155, __func__, 0); goto cleanup; }; |
1156 | |
1157 | ibody++; |
1158 | } |
1159 | |
1160 | status = EG_makeTopology(context, NULL((void*)0), MODEL26, 2*nbody, NULL((void*)0), nbody, |
1161 | copy_body_tess, NULL((void*)0), &model); |
1162 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1162, __func__, 0); goto cleanup; }; |
1163 | } |
1164 | |
1165 | status = aflr4_set_ext_cad_data (&model); |
1166 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1166, __func__, 0); goto cleanup; }; |
1167 | |
1168 | status = aflr4_setup_and_grid_gen (0, AFLR4_Param_Struct_Ptr); |
1169 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1169, __func__, 0); goto cleanup; }; |
1170 | |
1171 | // set dgeom from input data |
1172 | |
1173 | status = aflr4_cad_tess_to_dgeom (); |
1174 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1174, __func__, 0); goto cleanup; }; |
1175 | |
1176 | // save the surface mesh from AFLR3 |
1177 | |
1178 | status = aflr4_input_to_dgeom (Number_of_Surf_Edges, Number_of_Surf_Trias, Number_of_Surf_Quads, |
1179 | Edge_ID_Flag, Surf_Edge_Connectivity, Surf_ID_Flag, Surf_Tria_Connectivity, Surf_Quad_Connectivity, Coordinates); |
1180 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1180, __func__, 0); goto cleanup; }; |
1181 | |
1182 | // create tess object from input surface mesh |
1183 | |
1184 | status = aflr4_cad_geom_create_tess (Message_Flag, create_tess_mode, set_node_map); |
1185 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1185, __func__, 0); goto cleanup; }; |
1186 | |
1187 | ext_cad_data = dgeom_get_ext_cad_data (); |
1188 | ptr = (egads_struct *) ext_cad_data; |
1189 | |
1190 | iface = 1; |
1191 | |
1192 | for (bodyIndex = 0, ibody = 0; bodyIndex < volumeMesh->numReferenceMesh; bodyIndex++) { |
1193 | if (transpBody[bodyIndex] == 1) continue; |
1194 | |
1195 | // set the file name to write the egads file |
1196 | snprintf(bodyNumber, 42, AFLR3TESSFILE"aflr3_%d.eto", bodyIndex+ibodyOffset); |
1197 | status = aim_file(aimInfo, bodyNumber, aimFile); |
1198 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1198, __func__, 0); goto cleanup; }; |
1199 | |
1200 | status = EG_getBodyTopos(ptr->bodies[ibody], NULL((void*)0), FACE23, &nface, NULL((void*)0)); |
1201 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1201, __func__, 0); goto cleanup; }; |
1202 | |
1203 | for (i = 0; i < nface; i++, iface++) { |
1204 | |
1205 | status = egads_face_node_map_get (iface, &nnode_face, &face_node_map); |
1206 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1206, __func__, 0); goto cleanup; }; |
1207 | |
1208 | // Add the unique indexing of the tessellation |
1209 | snprintf(attrname, 128, "face_node_map_%d",i+1); |
1210 | status = EG_attributeAdd(ptr->tess[ibody], attrname, ATTRINT1, |
1211 | nnode_face, face_node_map+1, NULL((void*)0), NULL((void*)0)); // face_node_map is index on [i+1] |
1212 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1212, __func__, 0); goto cleanup; }; |
1213 | |
1214 | ug_free (face_node_map); |
1215 | face_node_map = NULL((void*)0); |
1216 | } |
1217 | |
1218 | remove(aimFile); |
1219 | status = EG_saveTess(ptr->tess[ibody], aimFile); |
1220 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1220, __func__, 0); goto cleanup; }; |
1221 | ibody++; |
1222 | } |
1223 | } |
1224 | |
1225 | // map the face index to the capsGroup index |
1226 | AIM_NOTNULL(Surf_ID_Flag, aimInfo, status){ if (Surf_ID_Flag == ((void*)0)) { status = -307; aim_status (aimInfo, status, "aflr3_Interface.c", 1226, __func__, 1, "%s == NULL!" , "Surf_ID_Flag"); goto cleanup; } }; |
1227 | AIM_NOTNULL(faceGroupIndex, aimInfo, status){ if (faceGroupIndex == ((void*)0)) { status = -307; aim_status (aimInfo, status, "aflr3_Interface.c", 1227, __func__, 1, "%s == NULL!" , "faceGroupIndex"); goto cleanup; } }; |
1228 | |
1229 | for (i = 0; i < Number_of_Surf_Trias + Number_of_Surf_Quads; i++) { |
1230 | Surf_ID_Flag[i+1] = faceGroupIndex[Surf_ID_Flag[i+1]-1]; |
1231 | } |
1232 | |
1233 | // Write the mesh to disk |
1234 | |
1235 | snprintf(aimFile, PATH_MAX4096, "%s.lb8.ugrid", fileName); |
1236 | |
1237 | status = ug_io_write_grid_file(aimFile, |
1238 | Message_Flag, |
1239 | Number_of_BL_Vol_Tets, |
1240 | Number_of_Nodes, |
1241 | Number_of_Surf_Quads, |
1242 | Number_of_Surf_Trias, |
1243 | Number_of_Vol_Hexs, |
1244 | Number_of_Vol_Pents_5, |
1245 | Number_of_Vol_Pents_6, |
1246 | Number_of_Vol_Tets, |
1247 | Surf_Grid_BC_Flag, |
1248 | Surf_ID_Flag, |
1249 | Surf_Reconnection_Flag, |
1250 | Surf_Quad_Connectivity, |
1251 | Surf_Tria_Connectivity, |
1252 | Vol_Hex_Connectivity, |
1253 | Vol_ID_Flag, |
1254 | Vol_Pent_5_Connectivity, |
1255 | Vol_Pent_6_Connectivity, |
1256 | Vol_Tet_Connectivity, |
1257 | Coordinates, |
1258 | BL_Normal_Spacing, |
1259 | BL_Thickness); |
1260 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1260, __func__, 0); goto cleanup; }; |
1261 | |
1262 | status = aflr3_to_MeshStruct(Number_of_Nodes, |
1263 | Number_of_Surf_Trias, |
1264 | Number_of_Surf_Quads, |
1265 | Number_of_Vol_Tets, |
1266 | Number_of_Vol_Pents_5, |
1267 | Number_of_Vol_Pents_6, |
1268 | Number_of_Vol_Hexs, |
1269 | Surf_ID_Flag, |
1270 | Surf_Tria_Connectivity, |
1271 | Surf_Quad_Connectivity, |
1272 | Vol_Tet_Connectivity, |
1273 | Vol_Pent_5_Connectivity, |
1274 | Vol_Pent_6_Connectivity, |
1275 | Vol_Hex_Connectivity, |
1276 | Coordinates, |
1277 | volumeMesh); |
1278 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "aflr3_Interface.c" , 1278, __func__, 0); goto cleanup; }; |
1279 | |
1280 | // Remove the temporary grid created by AFLR |
1281 | remove(".tmp.b8.ugrid"); |
1282 | |
1283 | status = CAPS_SUCCESS0; |
1284 | cleanup: |
1285 | |
1286 | ug_free (face_node_map); |
1287 | face_node_map = NULL((void*)0); |
1288 | |
1289 | // Free program arguements |
1290 | ug_free_argv(aflr3_argv); aflr3_argv = NULL((void*)0); |
1291 | ug_free_argv(aflr4_argv); aflr4_argv = NULL((void*)0); |
1292 | ug_free_param (AFLR4_Param_Struct_Ptr); AFLR4_Param_Struct_Ptr = NULL((void*)0); |
1293 | |
1294 | // Free grid generation and parameter array space in structures. |
1295 | // Note that aflr3_grid_generator frees all background data. |
1296 | ug_io_free_grid(Surf_Grid_BC_Flag, |
1297 | Surf_ID_Flag, |
1298 | Surf_Reconnection_Flag, |
1299 | Surf_Quad_Connectivity, |
1300 | Surf_Tria_Connectivity, |
1301 | Vol_Hex_Connectivity, |
1302 | Vol_ID_Flag, |
1303 | Vol_Pent_5_Connectivity, |
1304 | Vol_Pent_6_Connectivity, |
1305 | Vol_Tet_Connectivity, |
1306 | Coordinates, |
1307 | BL_Normal_Spacing, |
1308 | BL_Thickness); |
1309 | Surf_Grid_BC_Flag = NULL((void*)0); |
1310 | Surf_ID_Flag = NULL((void*)0); |
1311 | Surf_Reconnection_Flag = NULL((void*)0); |
1312 | Surf_Quad_Connectivity = NULL((void*)0); |
1313 | Surf_Tria_Connectivity = NULL((void*)0); |
1314 | Vol_Hex_Connectivity = NULL((void*)0); |
1315 | Vol_ID_Flag = NULL((void*)0); |
1316 | Vol_Pent_5_Connectivity = NULL((void*)0); |
1317 | Vol_Pent_6_Connectivity = NULL((void*)0); |
1318 | Vol_Tet_Connectivity = NULL((void*)0); |
1319 | Coordinates = NULL((void*)0); |
1320 | BL_Normal_Spacing = NULL((void*)0); |
1321 | BL_Thickness = NULL((void*)0); |
1322 | |
1323 | ug_free(Surf_Error_Flag); |
1324 | Surf_Error_Flag= NULL((void*)0); |
1325 | |
1326 | ug_free (BG_Vol_Tet_Neigbors); |
1327 | ug_free (BG_Vol_Tet_Connectivity); |
1328 | ug_free (BG_Coordinates); |
1329 | ug_free (BG_Spacing); |
1330 | ug_free (BG_Metric); |
1331 | |
1332 | BG_Vol_Tet_Neigbors = NULL((void*)0); |
1333 | BG_Vol_Tet_Connectivity = NULL((void*)0); |
1334 | BG_Coordinates = NULL((void*)0); |
1335 | BG_Spacing = NULL((void*)0); |
1336 | BG_Metric = NULL((void*)0); |
1337 | |
1338 | ug_free(BG_U_Scalars); |
1339 | ug_free(BG_U_Metrics); |
1340 | |
1341 | BG_U_Scalars = NULL((void*)0); |
1342 | BG_U_Metrics = NULL((void*)0); |
1343 | |
1344 | ug_free (Edge_ID_Flag); |
1345 | ug_free (Surf_ID_Flag); |
1346 | ug_free (Surf_Edge_Connectivity); |
1347 | ug_free (u); |
1348 | |
1349 | Edge_ID_Flag = NULL((void*)0); |
1350 | Surf_ID_Flag = NULL((void*)0); |
1351 | Surf_Edge_Connectivity = NULL((void*)0); |
1352 | u = NULL((void*)0); |
1353 | |
1354 | ug_io_free_node(Source_Coordinates, Source_Spacing, Source_Metric); |
1355 | |
1356 | Source_Coordinates = NULL((void*)0); |
1357 | Source_Spacing = NULL((void*)0); |
1358 | Source_Metric = NULL((void*)0); |
1359 | |
1360 | ug_free (bc_ids_vector); |
1361 | ug_free (bl_ds_vector); |
1362 | ug_free (bl_del_vector); |
1363 | |
1364 | /*@-mustfreefresh@*/ |
1365 | bc_ids_vector = NULL((void*)0); |
1366 | bl_ds_vector = NULL((void*)0); |
1367 | bl_del_vector = NULL((void*)0); |
1368 | /*@+mustfreefresh@*/ |
1369 | |
1370 | if (ptr != NULL((void*)0)) { |
1371 | EG_free (ptr->bodies); |
1372 | EG_deleteObject (ptr->model); |
1373 | } |
1374 | |
1375 | // cleanup aflr4 structures |
1376 | aflr4_free_all(0); |
1377 | egads_face_node_map_free(); |
1378 | |
1379 | // Shut off memory and file status monitors and close output file. |
1380 | // This is required for implementation! |
1381 | ug_shutdown (); |
1382 | |
1383 | AIM_FREE(meshInputString){ EG_free(meshInputString); meshInputString = ((void*)0); }; |
1384 | AIM_FREE(copy_body_tess){ EG_free(copy_body_tess); copy_body_tess = ((void*)0); }; |
1385 | AIM_FREE(modelFaces){ EG_free(modelFaces); modelFaces = ((void*)0); }; |
1386 | AIM_FREE(faceBodyIndex){ EG_free(faceBodyIndex); faceBodyIndex = ((void*)0); }; |
1387 | AIM_FREE(faceGroupIndex){ EG_free(faceGroupIndex); faceGroupIndex = ((void*)0); }; |
1388 | AIM_FREE(transpBody){ EG_free(transpBody); transpBody = ((void*)0); }; |
1389 | |
1390 | return status; |
1391 | } |