Télécharger toposauv.procedur

Retour à la liste

Numérotation des lignes :

  1. * TOPOSAUV PROCEDUR FD218221 25/12/18 21:15:14 12429
  2.  
  3. ************************************************************************
  4. ** Procedure called by TOPOPTIM for saving some data for restart and
  5. ** user-requested outputs.
  6. **
  7. ** Author:
  8. ** Guenhael Le Quilliec (LaMe - Polytech Tours)
  9. **
  10. ** Version:
  11. ** 4.0 2025/11/17 Made compatible with TOPOPTIM V4.0
  12. ** 3.0 2021/04/15 Made compatible with TOPOPTIM V3.0
  13. ** 2.0 2018/02/09 Always save the last cycle data in case of early
  14. ** stop of the optimization process for safe restart
  15. ** and delete the previous cycle data if it did not need
  16. ** to be saved
  17. ** 1.0 2017/04/18 Initial version
  18. ************************************************************************
  19.  
  20. * TODO sauver X et TOPO dans les tables utilisateur et dans RTABLE
  21.  
  22. DEBP TOPOSAUV tab*'TABLE' ;
  23.  
  24. * Input data
  25. * **********
  26.  
  27. Wtab = tab.'WTABLE' ;
  28. Ltab = Wtab.'LOGIQUE' ;
  29.  
  30. * Initialize restart table if it does not exists
  31. SI (NON (EXIS tab 'RTABLE')) ;
  32. tab.'RTABLE' = TABL ;
  33. FINS ;
  34. Rtab = tab.'RTABLE' ;
  35.  
  36. * Base model
  37. modB = Wtab.'MODELE_B' ;
  38.  
  39. * Current cycle number
  40. cyc = Wtab.'CYCLE' ;
  41.  
  42. * Number of cycles since the last call to TOPOPTIM
  43. nbritr = Wtab.'ITERATION' ;
  44.  
  45. * Fixed zone
  46. LF = Ltab.'ZONE_FIGEE' ;
  47. SI LF ;
  48. uniF = Wtab.'UNIT_F' ;
  49. FINS ;
  50.  
  51. * Update output evolutions
  52. * ************************
  53.  
  54. * Table of evolutions
  55. lstevo = tab.'EVOLUTIONS' ;
  56.  
  57. REPE itr (DIME tab.'EVOLUTIONS_SAUVEES') ;
  58.  
  59. * Value name
  60. varnam = EXTR tab.'EVOLUTIONS_SAUVEES' &itr ;
  61. * Get its value
  62. var = FAUX ;
  63. SI (EXIS Wtab varnam) ;
  64. var = Wtab.varnam ;
  65. SINO ;
  66. SI (EXIS tab varnam) ;
  67. var = tab.varnam ;
  68. FINS ;
  69. FINS ;
  70. * Update its value if it is 'FRACTION_VOLUME' or 'TEMPS_CYCLE'
  71. SI (EGA varnam 'FRACTION_VOLUME') ;
  72. modD = Wtab.'MODELE_D' ;
  73. matD = Wtab.'CARACTERISTIQUES_D' ;
  74. SI (TOPOMODI tab (CHAI 'FRACTION_VOLUME') Wtab.'Y_D_PRECED' modD matD) ;
  75. Wtab.'FRACTION_VOLUME' = (INTG Wtab.'Y_D_PRECED' modD matD) /
  76. Wtab.'VOLUME_TOTAL_D' ;
  77. FINS ;
  78. var = Wtab.'FRACTION_VOLUME' ;
  79. FINS ;
  80. SI (EGA varnam 'TEMPS_CYCLE') ;
  81. var = (TEMP 'HORL') - Wtab.'HORLOGE' ;
  82. Wtab.'TEMPS_CYCLE' = var ;
  83. FINS ;
  84.  
  85. * If value exists
  86. SI (NEG (TYPE var) 'LOGIQUE') ;
  87.  
  88. * Initialize the corresponding evolutions if they do not already exist
  89. SI ((nbritr EGA 1) ET (NON (EXIS lstevo varnam))) ;
  90. lstevo.varnam = EVOL 'MANU' (PROG) (PROG) ;
  91. FINS ;
  92.  
  93. * Update evolution
  94. evo = lstevo.varnam ;
  95. tmp1 = (EXTR evo 'ABSC') ET cyc ;
  96. tmp2 = (EXTR evo 'ORDO') ET var ;
  97. tmp3 = MOT 'BLAN' ;
  98. SI (EXIS Wtab.'EVOLUTIONS_COULEUR'.varnam) ;
  99. tmp3 = Wtab.'EVOLUTIONS_COULEUR'.varnam ;
  100. FINS ;
  101. lstevo.varnam = EVOL 'MANU' 'CYCLE' tmp1 varnam tmp2 'COUL' tmp3 ;
  102.  
  103. SINO ;
  104. MESS (CHAI 'Variable' ' ' varnam
  105. ' inconnue. Son evolution n''a pas ete sauvegardee.') ;
  106. FINS ;
  107.  
  108. FIN itr ;
  109.  
  110. * Save restart data
  111. * *****************
  112.  
  113. * Save in a "restart table", any data that would be needed to
  114. * restart the optimization exactly where it was previously stopped.
  115. * Using this table, the final result should be exactly the same as
  116. * if the user didn't change any input data between the two calls.
  117. * Output fields are defined on B, not on D, as F may evolve between
  118. * tow successive calls to TOPOPTIM.
  119. * Remark: the user is not supposed to change anything in this table.
  120.  
  121. * Reset restart table
  122. tab.'RTABLE' = TABL ;
  123. Rtab = tab.'RTABLE' ;
  124.  
  125. * Restart save
  126. SI tab.'SAUVEGARDE_DE_REPRISE' ;
  127.  
  128. * Save next cycle design variables
  129. Rtab.'X_B' = Wtab.'X_D' ;
  130. SI LF ;
  131. * Combine the X field on D with the unitary field on F
  132. * This creates a 2-zone field merged into a single zone
  133. * field, preserving the original element order using REDU
  134. Rtab.'X_B' = REDU (Wtab.'X_D' ET uniF) modB ;
  135. FINS ;
  136.  
  137. * Save next cycle intermediate densities
  138. Rtab.'S_B' = Wtab.'S_D' ;
  139. SI LF ;
  140. * Combine the X field on D with the unitary field on F
  141. * This creates a 2-zone field merged into a single zone
  142. * field, preserving the original element order using REDU
  143. Rtab.'S_B' = REDU (Wtab.'S_D' ET uniF) modB ;
  144. FINS ;
  145.  
  146. * Save next cycle physical densities
  147. Rtab.'Y_B' = Wtab.'Y_D' ;
  148. SI LF ;
  149. * Combine the Y field on D with the unitary field on F
  150. * This creates a 2-zone field merged into a single zone
  151. * field, preserving the original element order using REDU
  152. Rtab.'Y_B' = REDU (Wtab.'Y_D' ET uniF) modB ;
  153. FINS ;
  154.  
  155. * As any call to MFIL to get the hat filter matrix can be time
  156. * consuming, we always save any existing hat filter matrix to allow
  157. * reusing it without recalculating it.
  158. SI (EXIS Wtab 'FILTRE_CHAPEAU_NORMALISE') ;
  159. Rtab.'FILTRE_CHAPEAU_NORMALISE' = Wtab.'FILTRE_CHAPEAU_NORMALISE' ;
  160. * If FILTRE_CHAPEAU_NORMALISE exists, then FILTRE_CHAPEAU_MODIFIE might also
  161. * exist and should be saved too.
  162. SI (EXIS Wtab 'FILTRE_CHAPEAU_MODIFIE') ;
  163. Rtab.'FILTRE_CHAPEAU_MODIFIE' = Wtab.'FILTRE_CHAPEAU_MODIFIE' ;
  164. FINS ;
  165. * Save their corresponding identification extra data that will
  166. * later be used to know if the hat filter matrices need to be
  167. * updated (i.e., if one of those corresponding parameters has
  168. * changed)
  169. Rtab.'FILTRE_CHAPEAU_ID' = Wtab.'FILTRE_CHAPEAU_ID' ;
  170. FINS ;
  171.  
  172. * Copy loading and mechanism for modification detection
  173. res = Wtab.'RESOLUTION_B' ;
  174. ldg = res.'CHARGEMENT' ;
  175. SI (EGA (TYPE ldg) 'TABLE') ;
  176. Rtab.'CHARGEMENT' = COPI ldg ;
  177. SINO ;
  178. Rtab.'CHARGEMENT' = ldg ;
  179. FINS ;
  180. SI Ltab.'MECANISME' ;
  181. ldg1 = tab.'MECANISME' ;
  182. SI (EGA (TYPE ldg1) 'TABLE') ;
  183. Rtab.'MECANISME' = COPI ldg1 ;
  184. SINO ;
  185. Rtab.'MECANISME' = ldg1 ;
  186. FINS ;
  187. FINS ;
  188.  
  189. * MMA data
  190. SI (EXIS Wtab 'MMA') ;
  191. Rtab.'MMA' = Wtab.'MMA' ;
  192. FINS ;
  193.  
  194. * Projection data
  195. SI Ltab.'PROJECTION_VOLUME_CONSTANT' ;
  196. Rtab.'PROJECTION_SEUIL' = Wtab.'PROJECTION_SEUIL' ;
  197. FINS ;
  198.  
  199. SINO ;
  200.  
  201. * Delete RTABLE from tab ;
  202. OTER tab 'RTABLE' ;
  203.  
  204. FINS ;
  205.  
  206. * Save user requested data
  207. * ************************
  208.  
  209. * If this cycle has to be saved or if it is the final cycle
  210. SI ((EXIS tab.'CYCLES_SAUVES' cyc) OU Ltab.'STOP') ;
  211.  
  212. * Save the design variables (X)
  213. SI tab.'MES_SAUVEGARDES'.'X' ;
  214. * Copy X from Rtab except if it is the first cycle as X in Rtab may
  215. * differe from the actual initial design variables
  216. SI ((EXIS Rtab 'X_B') ET (nbritr > 1)) ;
  217. tab.'X'.cyc = Rtab.'X_B' ;
  218. SINO ;
  219. tab.'X'.cyc = Wtab.'X_D_PRECED' ;
  220. SI LF ;
  221. * Combine the X field on D with the unitary field on F
  222. * This creates a 2-zone field merged into a single zone
  223. * field, preserving the original element order using REDU
  224. tab.'X'.cyc = REDU (Wtab.'X_D_PRECED' ET uniF) modB ;
  225. FINS ;
  226. FINS ;
  227. FINS ;
  228.  
  229. * Save the intermediate densities (S)
  230. SI tab.'MES_SAUVEGARDES'.'X_FILTRE' ;
  231. * Copy S from Rtab except if it is the first cycle as X in Rtab may
  232. * differe from the actual initial design variables
  233. SI ((EXIS Rtab 'S_B') ET (nbritr > 1)) ;
  234. tab.'X_FILTRE'.cyc = Rtab.'S_B' ;
  235. SINO ;
  236. tab.'X_FILTRE'.cyc = Wtab.'S_D_PRECED' ;
  237. SI LF ;
  238. * Combine the X field on D with the unitary field on F
  239. * This creates a 2-zone field merged into a single zone
  240. * field, preserving the original element order using REDU
  241. tab.'X_FILTRE'.cyc = REDU (Wtab.'S_D_PRECED' ET uniF) modB ;
  242. FINS ;
  243. FINS ;
  244. FINS ;
  245.  
  246. * Save the physical densities (Y)
  247. SI tab.'MES_SAUVEGARDES'.'TOPOLOGIE' ;
  248. * Copy Y from Rtab except if it is the first cycle as Y in Rtab may
  249. * differe from the actual initial design variables
  250. SI ((EXIS Rtab 'Y_B') ET (nbritr > 1)) ;
  251. tab.'TOPOLOGIE'.cyc = Rtab.'Y_B' ;
  252. SINO ;
  253. tab.'TOPOLOGIE'.cyc = Wtab.'Y_D_PRECED' ;
  254. SI LF ;
  255. * Combine the Y field on D with the unitary field on F
  256. * This creates a 2-zone field merged into a single zone
  257. * field, preserving the original element order using REDU
  258. tab.'TOPOLOGIE'.cyc = REDU (Wtab.'Y_D_PRECED' ET uniF) modB ;
  259. FINS ;
  260. FINS ;
  261. FINS ;
  262.  
  263. * Save the mesh
  264. SI tab.'MES_SAUVEGARDES'.'MAILLAGE' ;
  265. tab.'MAILLAGE'.cyc = Wtab.'MAILLAGE_A' ;
  266. FINS ;
  267.  
  268. * Save the resolution data
  269. SI tab.'MES_SAUVEGARDES'.'RESOLUTION' ;
  270. tab.'RESOLUTION'.cyc = Wtab.'RESOLUTION_A' ;
  271. FINS ;
  272.  
  273. FINS ;
  274.  
  275. * Save next cycle design variables, intermediate densities and physical densities
  276. * *******************************************************************************
  277.  
  278. * Save X and Y of the next cycle if the current cycle is the final one,
  279. * as the user may want to access them.
  280.  
  281. SI (tab.'MES_SAUVEGARDES'.'X' ET Ltab.'STOP') ;
  282. SI tab.'SAUVEGARDE_DE_REPRISE' ;
  283. tab.'X'.(cyc + 1) = Rtab.'X_B' ;
  284. SINO ;
  285. tab.'X'.(cyc + 1) = Wtab.'X_D' ;
  286. SI LF ;
  287. * Combine the X field on D with the unitary field on F
  288. * This creates a 2-zone field merged into a single zone
  289. * field, preserving the original element order using REDU
  290. tab.'X'.(cyc + 1) = REDU (Wtab.'X_D' ET uniF) modB ;
  291. FINS ;
  292. FINS ;
  293. FINS ;
  294.  
  295. SI (tab.'MES_SAUVEGARDES'.'X_FILTRE' ET Ltab.'STOP') ;
  296. SI tab.'SAUVEGARDE_DE_REPRISE' ;
  297. tab.'X_FILTRE'.(cyc + 1) = Rtab.'S_B' ;
  298. SINO ;
  299. tab.'X_FILTRE'.(cyc + 1) = Wtab.'S_D' ;
  300. SI LF ;
  301. * Combine the X field on D with the unitary field on F
  302. * This creates a 2-zone field merged into a single zone
  303. * field, preserving the original element order using REDU
  304. tab.'X_FILTRE'.(cyc + 1) = REDU (Wtab.'S_D' ET uniF) modB ;
  305. FINS ;
  306. FINS ;
  307. FINS ;
  308.  
  309. SI (tab.'MES_SAUVEGARDES'.'TOPOLOGIE' ET Ltab.'STOP') ;
  310. SI tab.'SAUVEGARDE_DE_REPRISE' ;
  311. tab.'TOPOLOGIE'.(cyc + 1) = Rtab.'Y_B' ;
  312. SINO ;
  313. tab.'TOPOLOGIE'.(cyc + 1) = Wtab.'Y_D' ;
  314. SI LF ;
  315. * Combine the Y field on D with the unitary field on F
  316. * This creates a 2-zone field merged into a single zone
  317. * field, preserving the original element order using REDU
  318. tab.'TOPOLOGIE'.(cyc + 1) = REDU (Wtab.'Y_D' ET uniF) modB ;
  319. FINS ;
  320. FINS ;
  321. FINS ;
  322.  
  323. * And delete them from the previous cycle
  324. * - if it is not 0 as this cycle can't exists and
  325. * - if it is not in CYCLES_SAUVES
  326. oldcyc = cyc - 1 ;
  327. SI ((NEG oldcyc 0) ET (NON (EXIS tab.'CYCLES_SAUVES' oldcyc))) ;
  328. SI (EXIS (tab.'X') oldcyc) ;
  329. OTER (tab.'X') oldcyc ;
  330. FINS ;
  331. SI (EXIS (tab.'X_FILTRE') oldcyc) ;
  332. OTER (tab.'X_FILTRE') oldcyc ;
  333. FINS ;
  334. SI (EXIS (tab.'TOPOLOGIE') oldcyc) ;
  335. OTER (tab.'TOPOLOGIE') oldcyc ;
  336. FINS ;
  337. SI (EXIS (tab.'MAILLAGE') oldcyc) ;
  338. OTER (tab.'MAILLAGE') oldcyc ;
  339. FINS ;
  340. SI (EXIS (tab.'RESOLUTION') oldcyc) ;
  341. OTER (tab.'RESOLUTION') oldcyc ;
  342. FINS ;
  343. FINS ;
  344.  
  345. * Save data in a file
  346. * *******************
  347.  
  348. SI tab.'SAUV' ;
  349. * Save the current cycle data if requested
  350. SI ((EXIS tab.'CYCLES_SAUVES' cyc) OU Ltab.'STOP') ;
  351. * Save design variables
  352. SI tab.'MES_SAUVEGARDES'.'X' ;
  353. SAUV tab.'X'.cyc ;
  354. OUBL tab.'X' cyc ;
  355. FINS ;
  356. * Save intermediate densities
  357. SI tab.'MES_SAUVEGARDES'.'X_FILTRE' ;
  358. SAUV tab.'X_FILTRE'.cyc ;
  359. OUBL tab.'X_FILTRE' cyc ;
  360. FINS ;
  361. * Save physical densities
  362. SI tab.'MES_SAUVEGARDES'.'TOPOLOGIE' ;
  363. SAUV tab.'TOPOLOGIE'.cyc ;
  364. OUBL tab.'TOPOLOGIE' cyc ;
  365. FINS ;
  366. * Save active mesh
  367. SI tab.'MES_SAUVEGARDES'.'MAILLAGE' ;
  368. SAUV tab.'MAILLAGE'.cyc ;
  369. OUBL tab.'MAILLAGE' cyc ;
  370. FINS ;
  371. * Save resolution
  372. SI tab.'MES_SAUVEGARDES'.'RESOLUTION' ;
  373. SAUV tab.'RESOLUTION'.cyc ;
  374. OUBL tab.'RESOLUTION' cyc ;
  375. FINS ;
  376. FINS ;
  377. FINS ;
  378.  
  379. FINP ;
  380.  
  381.  
  382.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales