File: | zaeroGraphical.c |
Warning: | line 63, column 3 Value stored to 'status' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #include <string.h> |
2 | |
3 | #include "aimUtil.h" |
4 | #include "miscUtils.h" |
5 | #include "jsonUtils.h" |
6 | #include "zaeroUtils.h" |
7 | #include "zaeroCards.h" |
8 | #include "zaeroGraphical.h" |
9 | |
10 | |
11 | int zaero_textFileGenerationAero(void *aimInfo, |
12 | FILE *fp, |
13 | const char *jsonDict, |
14 | const zaeroProblemStruct *zaeroProblem, |
15 | const feaFileTypeEnum formatType, |
16 | int *setID) |
17 | { |
18 | int status; |
19 | |
20 | int numFilenames, numForms; |
21 | char **filenames = NULL((void*)0), **forms = NULL((void*)0); |
22 | |
23 | // make sure jsonDict is json string |
24 | if (!json_isDict(jsonDict)) { |
25 | printf("\tError: Output Aero tuple value is expected to be a JSON dictionary string\n"); |
26 | return CAPS_BADVALUE-311; |
27 | } |
28 | |
29 | status = json_getStringDynamicArray(jsonDict, "filename", &numFilenames, &filenames); |
30 | if (status != CAPS_SUCCESS0) { |
31 | // TODO: is it required? |
32 | } |
33 | |
34 | status = json_getStringDynamicArray(jsonDict, "form", &numForms, &forms); |
35 | if (status != CAPS_SUCCESS0) { |
36 | // TODO: is it required? |
37 | } |
38 | |
39 | if (!zaero_allEqual(Integer, &numFilenames, &numForms, NULL((void*)0))) { |
40 | printf("Error in Output Aero input, not all values have same length.\n"); |
41 | return CAPS_BADVALUE-311; |
42 | } |
43 | |
44 | for (int i = 0; i < numFilenames; i++) { |
45 | |
46 | (*setID)++; |
47 | |
48 | status = zaero_card_pltaero( |
49 | aimInfo, |
50 | fp, |
51 | (*setID), // setid |
52 | "YES", // femgrid, TODO: hardcoded |
53 | 0, // offset, TODO: hardcoded |
54 | forms[i], // form |
55 | filenames[i], // filenm |
56 | "NO", // cell, TODO: hardcoded |
57 | "NO", // vct, TODO: hardcoded |
58 | formatType |
59 | ); |
60 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 60, __func__, 0); goto cleanup; }; |
61 | } |
62 | |
63 | status = CAPS_SUCCESS0; |
Value stored to 'status' is never read | |
64 | cleanup: |
65 | string_freeArray(numFilenames, &filenames); |
66 | string_freeArray(numForms, &forms); |
67 | |
68 | return CAPS_SUCCESS0; |
69 | } |
70 | |
71 | int zaero_textFileGenerationFlutter(void *aimInfo, |
72 | FILE *fp, |
73 | const char *jsonDict, |
74 | const zaeroProblemStruct *zaeroProblem, |
75 | const feaFileTypeEnum formatType, |
76 | int *setID) |
77 | { |
78 | int status; |
79 | |
80 | int flutterID; |
81 | int numAnalysis, numModes, numFilenames, numAeronames, numForms; |
82 | int *modes; |
83 | char **analysis = NULL((void*)0), **filenames = NULL((void*)0), **aeronames, **forms = NULL((void*)0); |
84 | zaeroSubcaseStruct *subcase; |
85 | |
86 | // make sure jsonDict is json string |
87 | if (!json_isDict(jsonDict)) { |
88 | AIM_ERROR(aimInfo, "Output Flutter tuple value is expected to be a JSON dictionary string\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 88, __func__ , "Output Flutter tuple value is expected to be a JSON dictionary string\n" ); }; |
89 | return CAPS_BADVALUE-311; |
90 | } |
91 | |
92 | status = json_getStringDynamicArray(jsonDict, "analysis", &numAnalysis, &analysis); |
93 | if (status != CAPS_SUCCESS0) { |
94 | // TODO: is it required? |
95 | } |
96 | |
97 | status = json_getIntegerDynamicArray(jsonDict, "mode", &numModes, &modes); |
98 | if (status != CAPS_SUCCESS0) { |
99 | // TODO: is it required? |
100 | } |
101 | |
102 | status = json_getStringDynamicArray(jsonDict, "filename", &numFilenames, &filenames); |
103 | if (status != CAPS_SUCCESS0) { |
104 | // TODO: is it required? |
105 | } |
106 | |
107 | status = json_getStringDynamicArray(jsonDict, "form", &numForms, &forms); |
108 | if (status != CAPS_SUCCESS0) { |
109 | numForms = numAnalysis; |
110 | zaero_setBlankStringArray(numForms, &forms); |
111 | } |
112 | |
113 | status = json_getStringDynamicArray(jsonDict, "aeroname", &numAeronames, &aeronames); |
114 | if (status != CAPS_SUCCESS0) { |
115 | numAeronames = numAnalysis; |
116 | zaero_setBlankStringArray(numAeronames, &aeronames); |
117 | } |
118 | |
119 | if (!zaero_allEqual(Integer, &numFilenames, &numAeronames, &numForms, &numAnalysis, NULL((void*)0))) { |
120 | AIM_ERROR(aimInfo, "Error in Output Flutter input, not all values have same length.\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 120, __func__ , "Error in Output Flutter input, not all values have same length.\n" ); }; |
121 | return CAPS_BADVALUE-311; |
122 | } |
123 | |
124 | for (int i = 0; i < numFilenames; i++) { |
125 | |
126 | (*setID)++; |
127 | status = zaero_findSubcaseByName(aimInfo, analysis[i], zaeroProblem, &subcase); |
128 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 128, __func__, 0); goto cleanup; }; |
129 | flutterID = subcase->analysisID; |
130 | // TODO: assert(subcase->analysisType == AerolasticFlutter); |
131 | |
132 | status = zaero_card_pltflut( |
133 | aimInfo, |
134 | fp, |
135 | (*setID), // setid |
136 | flutterID, // idflut |
137 | modes[i], // mode |
138 | 1, // ntime, TODO: hardcoded |
139 | 1.0, // maxdisp, TODO: hardcoded |
140 | forms[i], // form |
141 | filenames[i], // filenm |
142 | aeronames[i], // aeronm |
143 | formatType |
144 | ); |
145 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 145, __func__, 0); goto cleanup; }; |
146 | } |
147 | |
148 | status = CAPS_SUCCESS0; |
149 | cleanup: |
150 | string_freeArray(numAnalysis, &analysis); |
151 | string_freeArray(numFilenames, &filenames); |
152 | string_freeArray(numAeronames, &aeronames); |
153 | string_freeArray(numForms, &forms); |
154 | AIM_FREE(modes){ EG_free(modes); modes = ((void*)0); }; |
155 | |
156 | return CAPS_SUCCESS0; |
157 | } |
158 | |
159 | int zaero_textFileGenerationMode(void *aimInfo, |
160 | FILE *fp, |
161 | const char *jsonDict, |
162 | const zaeroProblemStruct *zaeroProblem, |
163 | const feaFileTypeEnum formatType, |
164 | int *setID) |
165 | { |
166 | int status; |
167 | |
168 | int numModes, numFilenames, numForms, numAeronames; |
169 | int *modes = NULL((void*)0); |
170 | char **filenames = NULL((void*)0), **forms = NULL((void*)0), **aeronames; |
171 | |
172 | // make sure jsonDict is json string |
173 | if (!json_isDict(jsonDict)) { |
174 | AIM_ERROR(aimInfo, "Output Mode tuple value is expected to be a JSON dictionary string\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 174, __func__ , "Output Mode tuple value is expected to be a JSON dictionary string\n" ); }; |
175 | return CAPS_BADVALUE-311; |
176 | } |
177 | |
178 | status = json_getIntegerDynamicArray(jsonDict, "mode", &numModes, &modes); |
179 | if (status != CAPS_SUCCESS0) { |
180 | // TODO: is it required? |
181 | } |
182 | |
183 | status = json_getStringDynamicArray(jsonDict, "filename", &numFilenames, &filenames); |
184 | if (status != CAPS_SUCCESS0) { |
185 | // TODO: is it required? |
186 | } |
187 | |
188 | status = json_getStringDynamicArray(jsonDict, "form", &numForms, &forms); |
189 | if (status != CAPS_SUCCESS0) { |
190 | numForms = numModes; |
191 | zaero_setBlankStringArray(numForms, &forms); |
192 | } |
193 | |
194 | status = json_getStringDynamicArray(jsonDict, "aeroname", &numAeronames, &aeronames); |
195 | if (status != CAPS_SUCCESS0) { |
196 | numAeronames = numModes; |
197 | zaero_setBlankStringArray(numAeronames, &aeronames); |
198 | } |
199 | |
200 | if (!zaero_allEqual(Integer, &numFilenames, &numForms, &numModes, &numAeronames, NULL((void*)0))) { |
201 | AIM_ERROR(aimInfo, "Error in Output Mode input, not all values have same length.\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 201, __func__ , "Error in Output Mode input, not all values have same length.\n" ); }; |
202 | return CAPS_BADVALUE-311; |
203 | } |
204 | |
205 | for (int i = 0; i < numFilenames; i++) { |
206 | |
207 | (*setID)++; |
208 | |
209 | status = zaero_card_pltmode( |
210 | aimInfo, |
211 | fp, |
212 | (*setID), // setid |
213 | "SYM", // sym, TODO: hardcoded |
214 | modes[i], // mode |
215 | 1.0, // maxdisp, TODO: hardcoded |
216 | forms[i], // form |
217 | filenames[i], // filenm |
218 | aeronames[i], // aeronm |
219 | formatType |
220 | ); |
221 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 221, __func__, 0); goto cleanup; }; |
222 | } |
223 | |
224 | cleanup: |
225 | string_freeArray(numFilenames, &filenames); |
226 | string_freeArray(numAeronames, &aeronames); |
227 | string_freeArray(numForms, &forms); |
228 | AIM_FREE(modes){ EG_free(modes); modes = ((void*)0); }; |
229 | |
230 | return status; |
231 | } |
232 | |
233 | int zaero_textFileGenerationTrim(void *aimInfo, |
234 | FILE *fp, |
235 | const char *jsonDict, |
236 | const zaeroProblemStruct *zaeroProblem, |
237 | const feaFileTypeEnum formatType, |
238 | int *setID) |
239 | { |
240 | int status; |
241 | |
242 | int trimID; |
243 | int numAnalysis, numFlexs, numTypes, numFilenames, numForms, numScales, numAeronames; |
244 | double *scales = NULL((void*)0); |
245 | char **analysis, **filenames = NULL((void*)0), **flexs = NULL((void*)0), **types = NULL((void*)0), |
246 | **forms = NULL((void*)0), **aeronames = NULL((void*)0); |
247 | zaeroSubcaseStruct *subcase; |
248 | |
249 | // make sure jsonDict is json string |
250 | if (!json_isDict(jsonDict)) { |
251 | AIM_ERROR(aimInfo, "Output Trim tuple value is expected to be a JSON dictionary string\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 251, __func__ , "Output Trim tuple value is expected to be a JSON dictionary string\n" ); }; |
252 | return CAPS_BADVALUE-311; |
253 | } |
254 | |
255 | status = json_getStringDynamicArray(jsonDict, "analysis", &numAnalysis, &analysis); |
256 | if (status != CAPS_SUCCESS0) { |
257 | // TODO: is it required? |
258 | } |
259 | |
260 | status = json_getStringDynamicArray(jsonDict, "flex", &numFlexs, &flexs); |
261 | if (status != CAPS_SUCCESS0) { |
262 | numFlexs = numAnalysis; |
263 | zaero_setBlankStringArray(numFlexs, &flexs); |
264 | } |
265 | |
266 | status = json_getStringDynamicArray(jsonDict, "type", &numTypes, &types); |
267 | if (status != CAPS_SUCCESS0) { |
268 | AIM_ERROR(aimInfo, "Output Trim \"type\" value is required\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 268, __func__ , "Output Trim \"type\" value is required\n"); }; |
269 | return status; |
270 | } |
271 | |
272 | status = json_getStringDynamicArray(jsonDict, "form", &numForms, &forms); |
273 | if (status != CAPS_SUCCESS0) { |
274 | numForms = numAnalysis; |
275 | zaero_setBlankStringArray(numForms, &forms); |
276 | } |
277 | |
278 | status = json_getStringDynamicArray(jsonDict, "filename", &numFilenames, &filenames); |
279 | if (status != CAPS_SUCCESS0) { |
280 | AIM_ERROR(aimInfo, "Output Trim \"filename\" value is required\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 280, __func__ , "Output Trim \"filename\" value is required\n"); }; |
281 | return status; |
282 | } |
283 | |
284 | status = json_getDoubleDynamicArray(jsonDict, "scale", &numScales, &scales); |
285 | if (status != CAPS_SUCCESS0) { |
286 | numScales = numAnalysis; |
287 | zaero_setBlankRealArray(numScales, &scales); |
288 | } |
289 | |
290 | status = json_getStringDynamicArray(jsonDict, "aeroname", &numAeronames, &aeronames); |
291 | if (status != CAPS_SUCCESS0) { |
292 | numAeronames = numAnalysis; |
293 | zaero_setBlankStringArray(numAeronames, &aeronames); |
294 | } |
295 | |
296 | if (!zaero_allEqual(Integer, &numAnalysis, &numScales, &numFilenames, |
297 | &numForms, &numFlexs, &numTypes, &numAeronames, NULL((void*)0))) { |
298 | AIM_ERROR(aimInfo, "Error in Output Trim input, not all values have same length.\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 298, __func__ , "Error in Output Trim input, not all values have same length.\n" ); }; |
299 | return CAPS_BADVALUE-311; |
300 | } |
301 | |
302 | for (int i = 0; i < numFilenames; i++) { |
303 | |
304 | (*setID)++; |
305 | status = zaero_findSubcaseByName(aimInfo, analysis[i], zaeroProblem, &subcase); |
306 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 306, __func__, 0); goto cleanup; }; |
307 | trimID = subcase->analysisID; |
308 | // TODO: assert(subcase->analysisType == AerolasticFlutter); |
309 | |
310 | status = zaero_card_plttrim( |
311 | aimInfo, |
312 | fp, |
313 | (*setID), // setid |
314 | trimID, // idtrim |
315 | flexs[i], // flex |
316 | types[i], // type |
317 | forms[i], // form |
318 | filenames[i], // filenm |
319 | scales[i], // scale |
320 | aeronames[i], // aeronm |
321 | formatType |
322 | ); |
323 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 323, __func__, 0); goto cleanup; }; |
324 | |
325 | } |
326 | |
327 | status = CAPS_SUCCESS0; |
328 | cleanup: |
329 | string_freeArray(numFlexs, &flexs); |
330 | string_freeArray(numTypes, &types); |
331 | string_freeArray(numForms, &forms); |
332 | string_freeArray(numFilenames, &filenames); |
333 | string_freeArray(numAeronames, &aeronames); |
334 | AIM_FREE(scales){ EG_free(scales); scales = ((void*)0); }; |
335 | // if (aeronames != NULL) EG_free(aeronames); // blank strings are NULL pointers |
336 | |
337 | return status; |
338 | } |
339 | |
340 | int zaero_textFileGenerationVG(void *aimInfo, |
341 | FILE *fp, |
342 | const char *jsonDict, |
343 | const zaeroProblemStruct *zaeroProblem, |
344 | const feaFileTypeEnum formatType, |
345 | int *setID) |
346 | { |
347 | int status; |
348 | |
349 | int flutterID; |
350 | int numAnalysis, numFilenames, numForms, numXAxis; |
351 | char **analysis = NULL((void*)0), **filenames = NULL((void*)0), **forms = NULL((void*)0), **xAxis = NULL((void*)0); |
352 | zaeroSubcaseStruct *subcase; |
353 | |
354 | // make sure jsonDict is json string |
355 | if (!json_isDict(jsonDict)) { |
356 | AIM_ERROR(aimInfo, "Output VG tuple value is expected "{ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 357, __func__ , "Output VG tuple value is expected " "to be a JSON dictionary string\n" ); } |
357 | "to be a JSON dictionary string\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 357, __func__ , "Output VG tuple value is expected " "to be a JSON dictionary string\n" ); }; |
358 | return CAPS_BADVALUE-311; |
359 | } |
360 | |
361 | status = json_getStringDynamicArray(jsonDict, "analysis", &numAnalysis, &analysis); |
362 | if (status != CAPS_SUCCESS0) { |
363 | // TODO: is it required? |
364 | } |
365 | |
366 | status = json_getStringDynamicArray(jsonDict, "filename", &numFilenames, &filenames); |
367 | if (status != CAPS_SUCCESS0) { |
368 | // TODO: is it required? |
369 | } |
370 | |
371 | status = json_getStringDynamicArray(jsonDict, "form", &numForms, &forms); |
372 | if (status != CAPS_SUCCESS0) { |
373 | numForms = numAnalysis; |
374 | zaero_setBlankStringArray(numForms, &forms); |
375 | } |
376 | |
377 | status = json_getStringDynamicArray(jsonDict, "xAxis", &numXAxis, &xAxis); |
378 | if (status != CAPS_SUCCESS0) { |
379 | // TODO: is it required? |
380 | } |
381 | |
382 | if (!zaero_allEqual(Integer, &numFilenames, &numForms, |
383 | &numAnalysis, &numXAxis, NULL((void*)0))) { |
384 | AIM_ERROR(aimInfo, "Error in Output VG input, not all values have same length.\n"){ aim_message(aimInfo, CERROR, 0 , "zaeroGraphical.c", 384, __func__ , "Error in Output VG input, not all values have same length.\n" ); }; |
385 | return CAPS_BADVALUE-311; |
386 | } |
387 | |
388 | for (int i = 0; i < numFilenames; i++) { |
389 | |
390 | (*setID)++; |
391 | status = zaero_findSubcaseByName(aimInfo, analysis[i], zaeroProblem, &subcase); |
392 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 392, __func__, 0); goto cleanup; }; |
393 | flutterID = subcase->analysisID; |
394 | // TODO: assert(subcase->analysisType == AerolasticFlutter); |
395 | |
396 | status = zaero_card_pltvg( |
397 | aimInfo, |
398 | fp, |
399 | (*setID), // setid |
400 | flutterID, // idflut |
401 | -1, // nmode (blank), TODO: hardcoded |
402 | xAxis[i], // ntime |
403 | forms[i], // form |
404 | filenames[i], // filenm |
405 | -1.0, // refrho (blank), TODO: hardcoded |
406 | formatType |
407 | ); |
408 | AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "zaeroGraphical.c" , 408, __func__, 0); goto cleanup; }; |
409 | } |
410 | |
411 | status = CAPS_SUCCESS0; |
412 | cleanup: |
413 | string_freeArray(numAnalysis, &analysis); |
414 | string_freeArray(numFilenames, &filenames); |
415 | string_freeArray(numXAxis, &xAxis); |
416 | string_freeArray(numForms, &forms); |
417 | |
418 | return status; |
419 | } |