Télécharger topoboot.procedur

Retour à la liste

Numérotation des lignes :

  1. * TOPOBOOT PROCEDUR FD218221 25/12/18 21:15:02 12429
  2.  
  3. ************************************************************************
  4. ** Procedure called by TOPOPTIM for preprocessing input data before
  5. ** starting the topology optimization loop.
  6. **
  7. ** Author:
  8. ** Guenhael Le Quilliec (LaMe - Polytech Tours)
  9. **
  10. ** Version:
  11. ** 3.0 2025/12/01 Various updates and improvements for TOPOPTIM V4.0.
  12. ** 2.0 2021/04/22 Made compatible with Cast3M-2020 for linear
  13. ** thermo-mechanical resolution
  14. ** 1.0 2021/04/15 Initial version
  15. ************************************************************************
  16. *
  17. * TOPOBOOT sections:
  18. * ------------------
  19. *
  20. * - Initialization
  21. * - TOPOPTIM version < 4.0 input data verification
  22. * - General options
  23. * - Base (B) resolution model (mod) and material characteristics (mat)
  24. * - Mechanism (mcn)
  25. * - Base (B), frozen (F), design (D) and contact (cnt) meshes (msh)
  26. * - Initialization of active (A) and intersection (I) meshes
  27. * - Design (D) and frozen (F) model and material characteristics
  28. * - Constraints (g & G)
  29. * - Objective (O)
  30. * - Optimizer
  31. * - Design variables (X)
  32. * - Restrictions
  33. * - Filtering of some sensitivities or the intermediate density (S)
  34. * - Binarization by projection of the physical density (Y)
  35. * - Physical density penalization (Z)
  36. * - Convergence
  37. * - Parameters evolving over optimization cycles
  38. * - On-the-fly monitoring
  39. * - Output data
  40. * - Unitary (uni) and volume (V) element fields
  41. * - Default model, characteristics, unitary and volume element fields
  42. * - Design zone (D) various data: zero field, centroids & total volume
  43. * - Restart (R)
  44. * - Initial design variables (X) and physical densities (Y)
  45. *
  46. **********************************************************************
  47.  
  48. DEBP TOPOBOOT tab*'TABLE' ;
  49.  
  50. **********************************************************************
  51. * Initialization *
  52. **********************************************************************
  53.  
  54. * Start timer
  55.  
  56. * Working (W) table (tab)
  57. tab.'WTABLE' = TABL ;
  58. Wtab = tab.'WTABLE' ;
  59.  
  60. * Boolean/Logiocal (L) table (tab)
  61. Wtab.'LOGIQUE' = TABL ;
  62. Ltab = Wtab.'LOGIQUE' ;
  63.  
  64. * Define "Not a Number"
  65. Wtab.'NAN' = LOG -1.0 ;
  66.  
  67. * Define empty variable
  68. Wtab.'VIDE' = VIDE 'MMODEL' ;
  69.  
  70. * Table of pointers used by TOPOMODI
  71. Wtab.'POINTEURS' = TABL ;
  72.  
  73. * Number of the last completed cycle
  74. SI (NON (EXIS tab 'CYCLE')) ;
  75. tab.'CYCLE' = 0 ;
  76. FINS ;
  77. cyc = (ENTI (tab.'CYCLE')) + 1 ;
  78. Wtab.'CYCLE' = cyc ;
  79.  
  80. * Number of the current iteration and its timer
  81. Wtab.'ITERATION' = 0 ;
  82. Wtab.'HORLOGE' = 0.0 ;
  83.  
  84. **********************************************************************
  85. * TOPOPTIM version < 4.0 input data verification *
  86. **********************************************************************
  87.  
  88. * Check old input names for compatibility
  89.  
  90. oldtab = TABL ;
  91. oldtab.'CRITERE' = CHAI 'CONVERGENCE_CRITERE' ;
  92. oldtab.'CYCLES_SAUVEGARDES' = CHAI 'CYCLES_SAUVES' ;
  93. oldtab.'FRACTION_VOLUME' = CHAI 'FRACTION_VOLUME_LIMITE' ;
  94. oldtab.'FACTEUR_D' = CHAI 'OC_D' ;
  95. oldtab.'FACTEUR_P' = CHAI 'PENALISATION_P' ;
  96. oldtab.'FACTEUR_Q' = CHAI 'OC_Q' ;
  97. oldtab.'SEUIL' = CHAI 'SEUIL_ELEMENTS_ACTIFS' ;
  98. oldtab.'TOPOLOGIE_MAX_INC' = CHAI 'X_CHANGE_SEUIL' ;
  99. oldtab.'TOPOLOGIE_MIN' = CHAI 'X_MIN_SEUIL' ;
  100.  
  101. tmp = INDE oldtab ;
  102. REPE itr (DIME tmp) ;
  103. SI (EXIS tab tmp.&itr) ;
  104. ERRE (CHAI 'Attention, depuis TOPOPTIM V4.0, le parametre' ' '
  105. tmp.&itr ' a ete renomme' ' ' oldtab.(tmp.&itr) '.') ;
  106. FINS ;
  107. FIN itr ;
  108.  
  109. * Check old name of hat filter
  110. SI (EXIS tab 'FILTRE') ;
  111. SI (EGA tab.'FILTRE' 'MATRICE') ;
  112. ERRE (CHAI 'Attention, depuis TOPOPTIM V4.0, le filtre MATRICE'
  113. ' a ete renomme CHAPEAU.') ;
  114. FINS ;
  115. FINS ;
  116.  
  117. * Check old index of initial topology
  118. SI (EXIS tab 'TOPOLOGIE') ;
  119. SI (EXIS tab.'TOPOLOGIE' 0) ;
  120. ERRE (CHAI 'Attention, depuis TOPOPTIM V4.0, la topologie'
  121. ' initiale est donnee a l''indice 1.') ;
  122. FINS ;
  123. FINS ;
  124.  
  125. **********************************************************************
  126. * General options *
  127. **********************************************************************
  128.  
  129. * Numerical precision
  130. SI (NON (EXIS tab 'PRECISION')) ;
  131. tab.'PRECISION' = 1.0e-9 ;
  132. FINS ;
  133.  
  134. * Division by zero protection
  135. SI (NON (EXIS tab 'ZERO_DIVISION')) ;
  136. tab.'ZERO_DIVISION' = 0.001 ;
  137. FINS ;
  138.  
  139. * Maximum distance for node fusion
  140. SI (NON (EXIS tab 'ELIM_CRITERE')) ;
  141. tab.'ELIM_CRITERE' = 1.0e-9 ;
  142. FINS ;
  143.  
  144. * User-defined procedure called just before the resolution, which
  145. * can be used to update the loading and any other data
  146. * if they (partly or totally) depend on topology
  147. SI (NON (EXIS tab 'PROCEDURE_TOPOUPDT')) ;
  148. tab.'PROCEDURE_TOPOUPDT' = FAUX ;
  149. FINS ;
  150.  
  151. * Personal procedure that can be used, among others, to
  152. * calculate/modify the sensitivity field and objective value
  153. SI (NON (EXIS tab 'PROCEDURE_TOPOPERS')) ;
  154. tab.'PROCEDURE_TOPOPERS' = FAUX ;
  155. FINS ;
  156.  
  157.  
  158. **********************************************************************
  159. * Base (B) resolution model (mod) and material characteristics (mat) *
  160. **********************************************************************
  161.  
  162. * Table of the resolution (res) data of the base (B) finite element
  163. * model
  164. Ltab.'PASAPAS' = EXIS tab 'RESOLUTION_PASAPAS' ;
  165. SI Ltab.'PASAPAS' ;
  166. resB = tab.'RESOLUTION_PASAPAS' ;
  167. SINO ;
  168. resB = tab.'RESOLUTION_LINEAIRE' ;
  169. FINS ;
  170. Wtab.'RESOLUTION_B' = resB ;
  171.  
  172. * Base (B) mechanical (M), thermal (T), and contact (cnt) models (mod)
  173. modB = resB.'MODELE' ;
  174. LM = EXIS modB 'FORM' 'MECANIQUE' ;
  175. Ltab.'MECANIQUE' = LM ;
  176. SI LM ;
  177. Wtab.'MECANIQUE' = TABL ;
  178. modMB = EXTR modB 'FORM' 'MECANIQUE' ;
  179. Wtab.'MECANIQUE'.'MODELE_B' = modMB ;
  180. FINS ;
  181. LT = EXIS modB 'FORM' 'THERMIQUE' ;
  182. Ltab.'THERMIQUE' = LT ;
  183. SI LT ;
  184. Wtab.'THERMIQUE' = TABL ;
  185. modTB = EXTR modB 'FORM' 'THERMIQUE' ;
  186. Wtab.'THERMIQUE'.'MODELE_B' = modTB ;
  187. FINS ;
  188. Lcnt = EXIS modB 'FORM' 'CONTACT' ;
  189. Ltab.'CONTACT' = Lcnt ;
  190. SI Lcnt ;
  191. Wtab.'CONTACT' = TABL ;
  192. modcntB = EXTR modB 'FORM' 'CONTACT' ;
  193. Wtab.'CONTACT'.'MODELE_B' = modcntB ;
  194. FINS ;
  195.  
  196. * Base (B) mechanical (M), thermal (T), and contact (cnt) material
  197. * characteristics (mat)
  198. matB = resB.'CARACTERISTIQUES' ;
  199. SI LM ;
  200. matMB = REDU matB modMB ;
  201. Wtab.'MECANIQUE'.'CARACTERISTIQUES_B' = matMB ;
  202. FINS ;
  203. SI LT ;
  204. matTB = REDU matB modTB ;
  205. Wtab.'THERMIQUE'.'CARACTERISTIQUES_B' = matTB ;
  206. FINS ;
  207. SI Lcnt ;
  208. matcntB = REDU matB modcntB ;
  209. Wtab.'CONTACT'.'CARACTERISTIQUES_B' = matcntB ;
  210. FINS ;
  211.  
  212.  
  213. **********************************************************************
  214. * Mechanism (mcn) *
  215. **********************************************************************
  216.  
  217. * Compliant mechanism synthesis topology optimization
  218. Lmcn = EXIS tab 'MECANISME' ;
  219. Ltab.'MECANISME' = Lmcn ;
  220.  
  221. * Solve the problem also without springs
  222. SI (NON (EXIS tab 'MECANISME_ZERO_SPRING')) ;
  223. tab.'MECANISME_ZERO_SPRING' = FAUX ;
  224. FINS ;
  225.  
  226. * Verification
  227. * !!!!!!!!!!!!
  228.  
  229. * Check that a mechanical model exists
  230. SI (Lmcn ET (NON LM)) ;
  231. MESS 'Pour effectuer une optimisation de mecanisme deformable,' ;
  232. MESS 'il faut imperativement preciser un modele mecanique.' ;
  233. ERRE 'Veuillez preciser le modele mecanique a utiliser.' ;
  234. FINS ;
  235.  
  236.  
  237. **********************************************************************
  238. * Base (B), frozen (F), design (D) and contact (cnt) meshes (msh) *
  239. **********************************************************************
  240.  
  241. * Base (B) mesh
  242. * *************
  243. * Remark: without contact mesh, only mechanical or thermal
  244. SI LM ;
  245. mshB = EXTR modMB 'MAIL' ;
  246. SINO ;
  247. mshB = EXTR modTB 'MAIL' ;
  248. FINS ;
  249. Wtab.'MAILLAGE_B' = mshB ;
  250.  
  251. * Frozen area (F) mesh
  252. * ********************
  253. SI (NON (EXIS tab 'ZONE_FIGEE')) ;
  254. tab.'ZONE_FIGEE' = VIDE 'MAILLAGE' ;
  255. FINS ;
  256. LF = (NBEL tab.'ZONE_FIGEE') > 0 ;
  257. Ltab.'ZONE_FIGEE' = LF ;
  258. SI LF ;
  259. mshF = tab.'ZONE_FIGEE' ;
  260. mshD = DIFF mshB mshF ;
  261. SINO ;
  262. mshD = mshB ;
  263. FINS ;
  264.  
  265. * Design (D) mesh
  266. * ***************
  267. SI LF ;
  268. mshD = DIFF mshB mshF ;
  269. SINO ;
  270. mshD = mshB ;
  271. FINS ;
  272.  
  273. * Contact (cnt) mesh
  274. * ******************
  275. SI Lcnt ;
  276. Wtab.'CONTACT'.'MAILLAGE_B' = EXTR modcntB 'MAIL' ;
  277. FINS ;
  278.  
  279. * Verification
  280. * !!!!!!!!!!!!
  281.  
  282. * Check that the number of elements of thermal and mechanical meshes
  283. * equals that of the base mesh, otherwise the procedure can't work
  284. SI (LM ET LT) ;
  285. SI (NEG (NBEL (EXTR modMB 'MAIL')) (NBEL (EXTR modTB 'MAIL'))) ;
  286. MESS 'Les modeles thermique et mecanique doivent s''appuyer sur un meme maillage.' ;
  287. ERRE 'Veuillez adapter vos modeles en consequence.' ;
  288. FINS ;
  289. FINS ;
  290.  
  291.  
  292. **********************************************************************
  293. * Initialization of active (A) and intersection (I) meshes *
  294. **********************************************************************
  295.  
  296. * Initialize active (A) & intersection (I) zones with empty meshes
  297. * Remark: this is needed by TOPOACTI at first iteration
  298. Wtab.'MAILLAGE_A' = DIFF (mshD ELEM 1) (mshD ELEM 1) ;
  299. Wtab.'MAILLAGE_I' = Wtab.'MAILLAGE_A' ;
  300.  
  301.  
  302. **********************************************************************
  303. * Design (D) and frozen (F) model and material characteristics *
  304. **********************************************************************
  305.  
  306. SI LF ;
  307. SI LM ;
  308. modMD = REDU modMB mshD ;
  309. modMF = REDU modMB mshF ;
  310. Wtab.'MECANIQUE'.'MODELE_F' = modMF ;
  311. matMD = REDU matMB mshD ;
  312. matMF = REDU matMB mshF ;
  313. Wtab.'MECANIQUE'.'CARACTERISTIQUES_F' = matMF ;
  314. FINS ;
  315. SI LT ;
  316. modTD = REDU modTB mshD ;
  317. modTF = REDU modTB mshF ;
  318. Wtab.'THERMIQUE'.'MODELE_F' = modTF ;
  319. matTD = REDU matTB mshD ;
  320. matTF = REDU matTB mshF ;
  321. Wtab.'THERMIQUE'.'CARACTERISTIQUES_F' = matTF ;
  322. FINS ;
  323. SINO ;
  324. SI LM ;
  325. modMD = modMB ;
  326. matMD = matMB ;
  327. FINS ;
  328. SI LT ;
  329. modTD = modTB ;
  330. matTD = matTB ;
  331. FINS ;
  332. FINS ;
  333. Wtab.'MAILLAGE_D' = mshD ;
  334. SI LM ;
  335. Wtab.'MECANIQUE'.'MODELE_D' = modMD ;
  336. Wtab.'MECANIQUE'.'CARACTERISTIQUES_D' = matMD ;
  337. FINS ;
  338. SI LT ;
  339. Wtab.'THERMIQUE'.'MODELE_D' = modTD ;
  340. Wtab.'THERMIQUE'.'CARACTERISTIQUES_D' = matTD ;
  341. FINS ;
  342.  
  343.  
  344. **********************************************************************
  345. * Constraints (g & G) *
  346. **********************************************************************
  347.  
  348. * List of constraints
  349. Wtab.'LISTE_CONTRAINTES' = MOTS ;
  350.  
  351. * Maximum volume fraction constraint
  352. * Remark: No longer optional since TOPOPTIM V4, as this data now
  353. * indicates not only the maximum volume but also whether a
  354. * maximum volume constraint is desired.
  355. Ltab.'CONTRAINTE_VOLUME' = EXIS tab 'FRACTION_VOLUME_LIMITE' ;
  356. SI Ltab.'CONTRAINTE_VOLUME' ;
  357. Wtab.'LISTE_CONTRAINTES' = Wtab.'LISTE_CONTRAINTES' ET (MOTS 'VOLUME') ;
  358. FINS ;
  359.  
  360. * Maximum von Mises stress constraint
  361. * TODO could be either a scalar or a field?
  362. Ltab.'VERBART' = FAUX ;
  363. Ltab.'CONIGLIO' = FAUX ;
  364. Ltab.'CONTRAINTE_SIGMA_VM' = EXIS tab 'SIGMA_VM_LIMITATION' ;
  365. SI Ltab.'CONTRAINTE_SIGMA_VM' ;
  366. SI (NON (EXIS tab 'SIGMA_VM_LIMITE')) ;
  367. ERRE 'La contrainte de von Mises limite SIGMA_VM_LIMITE doit etre renseignee.' ;
  368. FINS ;
  369. SI (NON (EXIS (MOTS 'VERBART' 'CONIGLIO') tab.'SIGMA_VM_LIMITATION')) ;
  370. ERRE 'Seuls les approches VERBART et CONIGLIO sont disponibles.' ;
  371. FINS ;
  372. SI (EGA tab.'SIGMA_VM_LIMITATION' 'VERBART') ;
  373. Ltab.'VERBART' = VRAI ;
  374. SINO ;
  375. Ltab.'CONIGLIO' = VRAI ;
  376. FINS ;
  377. SINO ;
  378. SI (EXIS tab 'SIGMA_VM_LIMITE') ;
  379. Ltab.'CONTRAINTE_SIGMA_VM' = VRAI ;
  380. Ltab.'VERBART' = VRAI ;
  381. FINS ;
  382. FINS ;
  383. SI Ltab.'CONTRAINTE_SIGMA_VM' ;
  384. Wtab.'LISTE_CONTRAINTES' = Wtab.'LISTE_CONTRAINTES' ET (MOTS 'SIGMA_VM_LIMITE') ;
  385. FINS ;
  386.  
  387. * Aggregation
  388. SI (EXIS tab 'AGREGATION') ;
  389. Wtab.'AGREGATION' = tab.'AGREGATION' ;
  390. SINO ;
  391. Wtab.'AGREGATION' = MOT 'KSL' ;
  392. * SI (Ltab.'VERBART' OU Ltab.'CONIGLIO') ;
  393. * Wtab.'AGREGATION' = MOT 'KSL' ;
  394. * FINS ;
  395. FINS ;
  396. * And its parameter
  397. SI (EXIS tab 'AGREGATION_P') ;
  398. Wtab.'AGREGATION_P' = tab.'AGREGATION_P' ;
  399. SINO ;
  400. SI (EXIS Wtab 'AGREGATION') ;
  401. SI (EGA Wtab.'AGREGATION' 'KSL') ;
  402. Wtab.'AGREGATION_P' = 8.0 ;
  403. FINS ;
  404. FINS ;
  405. FINS ;
  406.  
  407. * Verification
  408. * !!!!!!!!!!!!
  409.  
  410. * Check that a constraint is set
  411. SI (EGA (DIME Wtab.'LISTE_CONTRAINTES') 0);
  412. MESS 'Il manque une contrainte d''optimisation.'
  413. ERRE 'Par exemple, indiquez une valeur pour FRACTION_VOLUME_LIMITE.' ;
  414. FINS ;
  415.  
  416.  
  417. **********************************************************************
  418. * Objective (O) *
  419. **********************************************************************
  420.  
  421. * Type of objective function
  422. * **************************
  423.  
  424. * Remark: mechanism synthesis uses compliance objective function type
  425. SI (NON (EXIS tab 'OBJECTIF')) ;
  426. SI Ltab.'CONTRAINTE_VOLUME' ;
  427. tab.'OBJECTIF' = MOT 'COMPLIANCE' ;
  428. SINO ;
  429. tab.'OBJECTIF' = MOT 'FRACTION_VOLUME' ;
  430. FINS ;
  431. FINS ;
  432.  
  433. Ltab.'OBJECTIF_COMPLIANCE' = EGA tab.'OBJECTIF' 'COMPLIANCE' ;
  434. Ltab.'OBJECTIF_VOLUME' = EGA tab.'OBJECTIF' 'FRACTION_VOLUME' ;
  435.  
  436. * Weights for multi-objective applications
  437. * ****************************************
  438.  
  439. SI (NON (EXIS tab 'POIDS_MECANISME')) ;
  440. tab.'POIDS_MECANISME' = 1.0 ;
  441. FINS ;
  442.  
  443. SI (NON (EXIS tab 'POIDS_ENERGIE_DEFO')) ;
  444. SI Lmcn ;
  445. tab.'POIDS_ENERGIE_DEFO' = 0.0 ;
  446. SINO ;
  447. tab.'POIDS_ENERGIE_DEFO' = 1.0 ;
  448. FINS ;
  449. FINS ;
  450.  
  451. SI (NON (EXIS tab 'POIDS_TEMPERATURE')) ;
  452. SI Lmcn ;
  453. tab.'POIDS_TEMPERATURE' = 0.0 ;
  454. SINO ;
  455. tab.'POIDS_TEMPERATURE' = 1.0 ;
  456. FINS ;
  457. FINS ;
  458.  
  459. * Verification
  460. * !!!!!!!!!!!!
  461.  
  462. SI (NON (EXIS (MOTS 'COMPLIANCE' 'FRACTION_VOLUME') tab.'OBJECTIF')) ;
  463. ERRE (CHAI 'Il n''est pas possible de minimiser l''OBJECTIF :' ' ' tab.'OBJECTIF') ;
  464. FINS ;
  465.  
  466.  
  467. **********************************************************************
  468. * Optimizer *
  469. **********************************************************************
  470.  
  471. * Default optimization algorithm
  472. * ******************************
  473.  
  474. SI (NON (EXIS tab 'OPTIMISEUR')) ;
  475. tab.'OPTIMISEUR' = MOT 'OC' ;
  476. FINS ;
  477.  
  478. * Optimality criterion (OC)
  479. * *************************
  480.  
  481. * Damping factor (D)
  482. SI (NON (EXIS tab 'OC_D')) ;
  483. * Default value of D
  484. tab.'OC_D' = 0.5 ;
  485. FINS ;
  486.  
  487. * Grey Scale Factor (Q)
  488. SI (NON (EXIS tab 'OC_Q')) ;
  489. * Default value of Q
  490. tab.'OC_Q' = 1.0 ;
  491. FINS ;
  492.  
  493. * Initial lower bound for the Lagrangian multiplier
  494. SI (NON (EXIS tab 'OC_L1')) ;
  495. tab.'OC_L1' = 0.0 ;
  496. FINS ;
  497.  
  498. * Initial upper bound for the Lagrangian multiplier
  499. *SI (NON (EXIS tab 'OC_L2')) ;
  500. * tab.'OC_L2' = 1.0e5 ;
  501. *FINS ;
  502.  
  503. * Minimal value for the upper bound
  504. SI (NON (EXIS tab 'OC_L2_MIN')) ;
  505. tab.'OC_L2_MIN' = 1.0e-40 ;
  506. FINS ;
  507.  
  508. * Convergence criterion for the bi-sectioning algorithm
  509. SI (NON (EXIS tab 'OC_CRITERE')) ;
  510. tab.'OC_CRITERE' = 1.0e-8 ;
  511. FINS ;
  512.  
  513. * Maximum number of iterations for the bi-sectioning algorithm
  514. SI (NON (EXIS tab 'OC_MAX_IT')) ;
  515. tab.'OC_MAX_IT' = 100000 ;
  516. FINS ;
  517.  
  518. * Lower bound for B (where B**D is the ratio between the new and the
  519. * previous topology fields)
  520. SI (NON (EXIS tab 'OC_B_MIN')) ;
  521. tab.'OC_B_MIN' = 1.0e-10 ;
  522. FINS ;
  523.  
  524. * Method of Moving Asymptotes (MMA)
  525. * *********************************
  526.  
  527. * Coefficient(s) C of MMA
  528. * TODO à adapter le jour où on proposerra d'appliquer plus d'une contrainte
  529. * TODO cette valeur par défaut est-elle judicieuse en cas de contrainte de
  530. * sur le volume?
  531. SI (NON (EXIS tab 'MMA_C')) ;
  532. tab.'MMA_C' = PROG 1.0e4 ;
  533. SINO ;
  534. SI (EGA (TYPE tab.'MMA_C') 'FLOTTANT') ;
  535. tab.'MMA_C' = PROG tab.'MMA_C' ;
  536. FINS ;
  537. FINS ;
  538.  
  539. * Coefficient to be applied on the objective function so that it remains
  540. * between 1 and 100
  541. SI (NON (EXIS tab 'MMA_COEF_OBJECTIF')) ;
  542. tab.'MMA_COEF_OBJECTIF' = 1.0 ;
  543. SI (EGA tab.'OBJECTIF' 'COMPLIANCE') ;
  544. * tab.'MMA_COEF_OBJECTIF' = Wtab.'NAN' ;
  545. tab.'MMA_COEF_OBJECTIF' = 0.0 ;
  546. FINS ;
  547. SI (EGA tab.'OBJECTIF' 'FRACTION_VOLUME') ;
  548. tab.'MMA_COEF_OBJECTIF' = 100.0 ;
  549. FINS ;
  550. FINS ;
  551.  
  552. * Verification
  553. * !!!!!!!!!!!!
  554.  
  555. * With OC, only maximum volume fraction must be set
  556. SI ((EGA tab.'OPTIMISEUR' 'OC') ET
  557. (((DIME Wtab.'LISTE_CONTRAINTES') > 1) OU
  558. (NON Ltab.'CONTRAINTE_VOLUME')));
  559. ERRE 'Seule une contrainte sur le volume est autorisee avec OC. Tentez d''utiliser l''optimiseur MMA.' ;
  560. FINS ;
  561.  
  562. * Stress constraint is compatible only with MMA and a mechanical model should be defined
  563. SI Ltab.'CONTRAINTE_SIGMA_VM' ;
  564. SI (NEG tab.'OPTIMISEUR' 'MMA') ;
  565. ERRE 'Seul l''optimiseur MMA est compatible avec une contrainte de von Mises maximale.' ;
  566. FINS ;
  567. SI (NON Ltab.'MECANIQUE') ;
  568. ERRE 'Un modele mecanique est indispensable pour imposer une contrainte de von Mises maximale.' ;
  569. FINS ;
  570. FINS ;
  571.  
  572.  
  573. **********************************************************************
  574. * Design variables (X) *
  575. **********************************************************************
  576.  
  577. * Move (absolute value of the increment) threshold of the design
  578. * variable between two cycles
  579. SI (NON (EXIS tab 'X_CHANGE_SEUIL')) ;
  580. tab.'X_CHANGE_SEUIL' = 0.2 ;
  581. FINS ;
  582.  
  583. * Design variable minimum threshold
  584. SI (NON (EXIS tab 'X_MIN_SEUIL')) ;
  585. SI Lmcn ;
  586. tab.'X_MIN_SEUIL' = 0.001 ;
  587. SINO ;
  588. tab.'X_MIN_SEUIL' = 0.0 ;
  589. FINS ;
  590. FINS ;
  591.  
  592.  
  593. **********************************************************************
  594. * Restrictions *
  595. **********************************************************************
  596.  
  597. * Procedure to add a geometric restrictions
  598. Ltab.'RESTRICTIONS' = EXIS tab 'RESTRICTIONS' ;
  599.  
  600.  
  601. **********************************************************************
  602. * Filtering of some sensitivities or the intermediate density (S) *
  603. **********************************************************************
  604.  
  605. * Type of filter
  606. SI (NON (EXIS tab 'FILTRE')) ;
  607. tab.'FILTRE' = MOT 'GIBIANE' ;
  608. FINS ;
  609.  
  610. * Parameters for Helmholtz (PDE) filter
  611. SI (EGA tab.'FILTRE' 'EDP');
  612. * Filter radius
  613. SI (NON (EXIS tab 'FILTRE_EDP_RAYON')) ;
  614. ERRE 'Veuillez preciser un rayon de filtrage.' ;
  615. FINS ;
  616. FINS ;
  617. * Default Helmholtz (PDE) filter identification data
  618. Wtab.'FILTRE_EDP_ID' = TABL ;
  619. Wtab.'FILTRE_EDP_ID'.'MODEL' = VIDE 'MMODEL' ;
  620. Wtab.'FILTRE_EDP_ID'.'ZONE_FIGEE' = VIDE 'MAILLAGE' ;
  621. Wtab.'FILTRE_EDP_ID'.'RAYON' = 0.0 ;
  622.  
  623. * Parameters for hat filter
  624. SI (EGA tab.'FILTRE' 'CHAPEAU');
  625. * Filter radius
  626. SI (NON (EXIS tab 'FILTRE_CHAPEAU_RAYON')) ;
  627. ERRE 'Veuillez preciser un rayon de filtrage.' ;
  628. FINS ;
  629. * Filter exponent
  630. SI (NON (EXIS tab 'FILTRE_CHAPEAU_EXPOSANT')) ;
  631. tab.'FILTRE_CHAPEAU_EXPOSANT' = 1.0 ;
  632. FINS ;
  633. * Filter weight minimum threshold
  634. SI (NON (EXIS tab 'FILTRE_CHAPEAU_CRITERE')) ;
  635. tab.'FILTRE_CHAPEAU_CRITERE' = 0.0 ;
  636. FINS ;
  637. FINS ;
  638. * Default hat filter identification data (compatible with SAUV/REST)
  639. Wtab.'FILTRE_CHAPEAU_ID' = TABL ;
  640. Wtab.'FILTRE_CHAPEAU_ID'.'MODEL' = VIDE 'MMODEL' ;
  641. Wtab.'FILTRE_CHAPEAU_ID'.'ZONE_FIGEE' = VIDE 'MAILLAGE' ;
  642. Wtab.'FILTRE_CHAPEAU_ID'.'RAYON' = 0.0 ;
  643. Wtab.'FILTRE_CHAPEAU_ID'.'EXPOSANT' = 0.0 ;
  644. Wtab.'FILTRE_CHAPEAU_ID'.'CRITERE' = 0.0 ;
  645.  
  646. * Parameters for Gibiane filter type
  647. SI (EGA tab.'FILTRE' 'GIBIANE');
  648. * Filter rate
  649. SI (NON (EXIS tab 'FILTRE_GIBIANE_TAUX')) ;
  650. tab.'FILTRE_GIBIANE_TAUX' = 1 ;
  651. FINS ;
  652. FINS ;
  653.  
  654. * Field to be filtered
  655. Ltab.'FILTRE_SENSIBILITE_OBJECTIF' = FAUX ;
  656. Ltab.'FILTRE_SENSIBILITES_CONTRAINTES' = FAUX ;
  657. Ltab.'FILTRE_DENSITE' = FAUX ;
  658. SI (EXIS tab 'FILTRER') ;
  659. SI (EXIS (MOTS 'DENSITE'
  660. 'SENSIBILITE_OBJECTIF'
  661. 'SENSIBILITES_CONTRAINTES') tab.'FILTRER') ;
  662. SI (EGA tab.'FILTRER' 'DENSITE') ;
  663. Ltab.'FILTRE_DENSITE' = VRAI ;
  664. FINS ;
  665. SI (EGA tab.'FILTRER' 'SENSIBILITE_OBJECTIF') ;
  666. SI (NON Ltab.'CONTRAINTE_VOLUME') ;
  667. ERRE (CHAI 'L''option FILTRER ne peut valoir SENSIBILITE_OBJECTIF'
  668. ' qu''en cas de contrainte sur le volume.') ;
  669. FINS ;
  670. Ltab.'FILTRE_SENSIBILITE_OBJECTIF' = VRAI ;
  671. FINS ;
  672. SI (EGA tab.'FILTRER' 'SENSIBILITES_CONTRAINTES') ;
  673. SI (Ltab.'CONTRAINTE_VOLUME') ;
  674. ERRE (CHAI 'L''option FILTRER ne peut valoir SENSIBILITES_CONTRAINTES'
  675. ' qu''en cas de contrainte sur von Mises.') ;
  676. FINS ;
  677. Ltab.'FILTRE_SENSIBILITES_CONTRAINTES' = VRAI ;
  678. FINS ;
  679. SINO ;
  680. ERRE 'Le champ a filtrer n''est pas reconnu.' ;
  681. FINS ;
  682. SINO ;
  683. SI Ltab.'CONTRAINTE_VOLUME' ;
  684. tab.'FILTRER' = MOT 'SENSIBILITE_OBJECTIF' ;
  685. Ltab.'FILTRE_SENSIBILITE_OBJECTIF' = VRAI ;
  686. SINO ;
  687. tab.'FILTRER' = MOT 'SENSIBILITES_CONTRAINTES' ;
  688. Ltab.'FILTRE_SENSIBILITES_CONTRAINTES' = VRAI ;
  689. FINS ;
  690. FINS ;
  691.  
  692. * Verification
  693. * !!!!!!!!!!!!
  694.  
  695. *SI (Ltab.'FILTRE_DENSITE' ET (NEG tab.'FILTRE' 'CHAPEAU')) ;
  696. ** If the density is filtered then the "modified filter" is needed
  697. ** to get the X derivative. This is possible only with the hat
  698. ** filter.
  699. * ERRE (CHAI 'Seul le filtre de type CHAPEAU permet de filtrer la'
  700. * ' DENSITE. Veuillez adapter les parametres d''entree.') ;
  701. *FINS ;
  702.  
  703.  
  704. **********************************************************************
  705. * Binarization by projection of the physical density (Y) *
  706. **********************************************************************
  707.  
  708. * Physical density projection with a hyperbolic sigmoid function
  709. * **************************************************************
  710.  
  711. * TODO Créer une erreure ou une alerte si OC_Q est actif en même temps que la projection (car ils ont le même but)
  712. * Idem s'il est actif avec MMA?...
  713.  
  714. Ltab.'PROJECTION' = EXIS tab 'PROJECTION_RAIDEUR' ;
  715. Ltab.'PROJECTION_VOLUME_CONSTANT' = FAUX ;
  716.  
  717. SI (NON (EXIS tab 'PROJECTION')) ;
  718. tab.'PROJECTION' = MOT 'GUEST_2004' ;
  719. FINS ;
  720.  
  721. SI (EGA tab.'PROJECTION' 'GUEST_2004') ;
  722. Wtab.'PROJECTION_SEUIL' = 0.0 ;
  723. FINS ;
  724.  
  725. * Constant density threshold projection or constant volume projection
  726. SI ((EGA tab.'PROJECTION' 'SIGMOID_TANH') ET
  727. (NON (EXIS tab 'PROJECTION_SEUIL'))) ;
  728. Wtab.'PROJECTION_SEUIL' = 0.5 ;
  729. Ltab.'PROJECTION_VOLUME_CONSTANT' = VRAI ;
  730. FINS ;
  731. SI (EXIS tab 'PROJECTION_SEUIL') ;
  732. Wtab.'PROJECTION_SEUIL' = tab.'PROJECTION_SEUIL' ;
  733. FINS ;
  734. * Maximum iterations of the volume-preserving bisection algorithm
  735. SI (NON (EXIS tab 'PROJECTION_MAX_IT')) ;
  736. tab.'PROJECTION_MAX_IT' = 100 ;
  737. FINS ;
  738. * Bisection algorithm criterion on the volume-preserving threshold value
  739. SI (NON (EXIS tab 'PROJECTION_SEUIL_CRITERE')) ;
  740. tab.'PROJECTION_SEUIL_CRITERE' = 1.0e-7 ;
  741. FINS ;
  742. * Bisection algorithm criterion on the volume-preserving difference rate
  743. SI (NON (EXIS tab 'PROJECTION_VOLUME_CRITERE')) ;
  744. tab.'PROJECTION_VOLUME_CRITERE' = 1.0e-3 ;
  745. FINS ;
  746.  
  747. * Verification
  748. * !!!!!!!!!!!!
  749.  
  750. SI ((NEG tab.'PROJECTION' 'SIGMOID_TANH') ET
  751. (EXIS tab 'PROJECTION_SEUIL')) ;
  752. ERRE (CHAI 'La seuil de projection n est pas compatible'
  753. ' avec la fonction de projection'
  754. ' ' tab.'PROJECTION' '.') ;
  755. FINS ;
  756.  
  757. **********************************************************************
  758. * Physical density penalization (Z) *
  759. **********************************************************************
  760.  
  761. * Penalization function
  762. SI (NON (EXIS tab 'PENALISATION')) ;
  763. tab.'PENALISATION' = MOT 'SIMP' ;
  764. FINS ;
  765.  
  766. * Penalty factor (P)
  767. SI (NON (EXIS tab 'PENALISATION_P')) ;
  768. tab.'PENALISATION_P' = 3.0 ;
  769. FINS ;
  770.  
  771. * List of material components that are proportional to the penalized
  772. * physical densities (Z)
  773. SI (NON (EXIS tab 'COMPOSANTES')) ;
  774. tab.'COMPOSANTES' = MOTS 'YOUN' 'K' 'RHO' ;
  775. FINS ;
  776.  
  777. * Ratio between the mechanical stiffness of the voids and the material
  778. SI (NON (EXIS tab 'RAPPORT_RAIDEURS_MECANIQUES')) ;
  779. SI (Lmcn OU LT) ;
  780. tab.'RAPPORT_RAIDEURS_MECANIQUES' = 1.0e-8 ;
  781. SINO ;
  782. tab.'RAPPORT_RAIDEURS_MECANIQUES' = 0.0 ;
  783. FINS ;
  784. FINS ;
  785.  
  786. * Ratio between the thermal stiffness of the voids and the material
  787. SI (NON (EXIS tab 'RAPPORT_RAIDEURS_THERMIQUES')) ;
  788. tab.'RAPPORT_RAIDEURS_THERMIQUES' = 0.001 ;
  789. FINS ;
  790.  
  791. * Minimal threshold value of the penalized physical densities (Z) to
  792. * save mesh elements
  793. SI (NON (EXIS tab 'SEUIL_ELEMENTS_ACTIFS')) ;
  794. tab.'SEUIL_ELEMENTS_ACTIFS' = 1.0e-9 ;
  795. FINS ;
  796.  
  797.  
  798. **********************************************************************
  799. * Convergence *
  800. **********************************************************************
  801.  
  802. * Maximum number of optimization cycles
  803. SI (NON (EXIS tab 'MAX_CYCLES')) ;
  804. tab.'MAX_CYCLES' = 100 ;
  805. FINS ;
  806.  
  807. * Convergence criterion
  808. SI (NON (EXIS tab 'CONVERGENCE_CRITERE')) ;
  809. tab.'CONVERGENCE_CRITERE' = 0.01 ;
  810. FINS ;
  811.  
  812. * Initialize or reset convergence logical
  813. tab.'CONVERGENCE' = FAUX ;
  814.  
  815. * Stop optimization trigger
  816. Ltab.'STOP' = FAUX ;
  817.  
  818. * Verification
  819. * !!!!!!!!!!!!
  820.  
  821. * Make sure the optimization loop will start
  822. SI ((Wtab.'CYCLE') > tab.'MAX_CYCLES') ;
  823. SAUT 1 'LIGN' ;
  824. MESS ' /!\ ALERTE | Reprise de TOPOPTIM impossible. |' ;
  825. MESS ' ====== | Le nombre maximum de cycles a deja ete atteint. |' ;
  826. SAUT 1 'LIGN' ;
  827. FINS ;
  828.  
  829.  
  830. **********************************************************************
  831. * Parameters evolving over optimization cycles *
  832. **********************************************************************
  833.  
  834. * Input parameters that may be evolutions over optimization cycles
  835. * (otherwise they are scalar values)
  836. Wtab.'EVOLUTIONS' = MOTS 'PENALISATION_P' 'OC_D' 'OC_Q' 'PROJECTION_RAIDEUR' ;
  837.  
  838. * Initialization call to TOPOEVAL
  839. * Remark: this can be needed for the call to TOPOPHYS at the end of
  840. * TOPOBOOT.
  841. TOPOEVOL tab ;
  842.  
  843. **********************************************************************
  844. * On-the-fly monitoring *
  845. **********************************************************************
  846.  
  847. * Plot results on-the-fly
  848. SI (NON (EXIS tab 'TRAC')) ;
  849. tab.'TRAC' = VRAI ;
  850. FINS ;
  851.  
  852. * Table of data for visualization
  853. Wtab.'VISU' = TABL ;
  854.  
  855. * User list of variable names to be printed on the fly
  856. SI (EXIS tab 'MESS') ;
  857. SI (NEG (TYPE tab.'MESS') 'LISTMOTS') ;
  858. tab.'MESS' = MOTS tab.'MESS' ;
  859. FINS ;
  860. SINO ;
  861. tab.'MESS' = MOTS ;
  862. FINS ;
  863.  
  864. * Full list of variable names to be printed on the fly
  865. * Remark: order will be preserved when printed
  866. tmp = MOTS ;
  867. tmp = tmp ET (MOTS 'OBJECTIF') ;
  868. SI Ltab.'CONTRAINTE_SIGMA_VM' ;
  869. tmp = tmp ET (MOTS 'SIGMA_VM_MAX') ;
  870. FINS ;
  871. SI (Ltab.'CONTRAINTE_VOLUME' ET (NEG tab.'OPTIMISEUR' 'OC')) ;
  872. * Not shown in the case of volume minimization as the objective
  873. * corresponds to volume fraction and is already displayed
  874. * OU Ltab.'OBJECTIF_VOLUME'
  875. tmp = tmp ET (MOTS 'FRACTION_VOLUME') ;
  876. FINS ;
  877. tmp = tmp ET (MOTS 'MAX_X_CHANGE') ;
  878. * Add any requested variables
  879. tmp = tmp ET tab.'MESS' ;
  880. * Time / cycle
  881. tmp = tmp ET (MOTS 'TEMPS_CYCLE') ;
  882. * Number of active elements
  883. SI (NON ((LM ET (tab.'RAPPORT_RAIDEURS_MECANIQUES' >
  884. tab.'SEUIL_ELEMENTS_ACTIFS')) OU
  885. (LT ET (tab.'RAPPORT_RAIDEURS_THERMIQUES' >
  886. tab.'SEUIL_ELEMENTS_ACTIFS')))) ;
  887. tmp = tmp ET (MOTS 'NB_ACTIVE_ELEM') ;
  888. FINS ;
  889. Wtab.'VISU'.'VARIABLES' = tmp ;
  890.  
  891.  
  892. **********************************************************************
  893. * Output data *
  894. **********************************************************************
  895.  
  896. * Logical to save data on a file
  897. SI (NON (EXIS tab 'SAUV')) ;
  898. tab.'SAUV' = FAUX ;
  899. FINS ;
  900.  
  901. * Save data that might be needed in case of restart
  902. SI (NON (EXIS tab 'SAUVEGARDE_DE_REPRISE')) ;
  903. tab.'SAUVEGARDE_DE_REPRISE' = VRAI ;
  904. FINS ;
  905.  
  906. * Cycles to be saved
  907. SI (NON (EXIS tab 'CYCLES_SAUVES')) ;
  908. tab.'CYCLES_SAUVES' = LECT ;
  909. FINS ;
  910.  
  911. * Data to be saved
  912. SI (NON (EXIS tab 'MES_SAUVEGARDES')) ;
  913. tab.'MES_SAUVEGARDES' = TABL ;
  914. FINS ;
  915. SI (NON (EXIS tab.'MES_SAUVEGARDES' 'X')) ;
  916. tab.'MES_SAUVEGARDES'.'X' = VRAI ;
  917. FINS ;
  918. SI (NON (EXIS tab.'MES_SAUVEGARDES' 'X_FILTRE')) ;
  919. tab.'MES_SAUVEGARDES'.'X_FILTRE' = VRAI ;
  920. FINS ;
  921. SI (NON (EXIS tab.'MES_SAUVEGARDES' 'TOPOLOGIE')) ;
  922. tab.'MES_SAUVEGARDES'.'TOPOLOGIE' = VRAI ;
  923. FINS ;
  924. SI (NON (EXIS tab.'MES_SAUVEGARDES' 'MAILLAGE')) ;
  925. tab.'MES_SAUVEGARDES'.'MAILLAGE' = VRAI ;
  926. FINS ;
  927. SI (NON (EXIS tab.'MES_SAUVEGARDES' 'RESOLUTION')) ;
  928. tab.'MES_SAUVEGARDES'.'RESOLUTION' = FAUX ;
  929. FINS ;
  930.  
  931. * Only for step-by-step resolution
  932. SI Ltab.'PASAPAS' ;
  933. * Save time list
  934. SI (NON (EXIS resB 'TEMPS_SAUVES')) ;
  935. tmp = EXTR (LECT 1 (DIME resB.'TEMPS_CALCULES')) resB.'TEMPS_CALCULES' ;
  936. SINO ;
  937. tmp = resB.'TEMPS_SAUVES' ;
  938. FINS ;
  939. Wtab.'TEMPS_SAUVES' = tmp ;
  940. FINS ;
  941.  
  942. * List of names of output evolutions
  943. SI (NON (EXIS tab 'EVOLUTIONS_SAUVEES')) ;
  944. * Copy 'VISU'.'VARIABLES' without 'EVOLUTIONS'
  945. * tmp = MOTS ;
  946. * REPE itr (DIME Wtab.'VISU'.'VARIABLES') ;
  947. * tmp1 = EXTR Wtab.'VISU'.'VARIABLES' &itr ;
  948. * SI (NON (EXIS Wtab.'EVOLUTIONS' tmp1)) ;
  949. * tmp = tmp ET (MOTS tmp1) ;
  950. * FINS ;
  951. * FIN itr ;
  952. tmp = Wtab.'VISU'.'VARIABLES' ;
  953. * Save them by default
  954. tab.'EVOLUTIONS_SAUVEES' = tmp ;
  955. SINO ;
  956. SI (EGA (TYPE tab.'EVOLUTIONS_SAUVEES') 'MOT') ;
  957. tab.'EVOLUTIONS_SAUVEES' = MOTS tab.'EVOLUTIONS_SAUVEES' ;
  958. FINS ;
  959. FINS ;
  960.  
  961. * Table of output evolutions
  962. SI (NON (EXIS tab 'EVOLUTIONS')) ;
  963. tab.'EVOLUTIONS' = TABL ;
  964. FINS ;
  965.  
  966. * Table of evolution default colors
  967. tmp = TABL ;
  968. tmp.'TEMPS_CYCLE' = MOT 'VERT' ;
  969. tmp.'OBJECTIF' = MOT 'ROUG' ;
  970. tmp.'FRACTION_VOLUME' = MOT 'JAUN' ;
  971. tmp.'SIGMA_VM_MAX' = MOT 'CORA' ;
  972. tmp.'MAX_X_CHANGE' = MOT 'ORAN' ;
  973. tmp.'NB_ACTIVE_ELEM' = MOT 'AZUR' ;
  974. tmp.'PENALISATION_P' = MOT 'ROSE' ;
  975. tmp.'OC_Q' = MOT 'GRIS' ;
  976. tmp.'OC_D' = MOT 'CYAN' ;
  977. tmp.'PROJECTION_RAIDEUR' = MOT 'BLAN' ;
  978. Wtab.'EVOLUTIONS_COULEUR' = tmp ;
  979.  
  980. * Design variable output table
  981. SI (NON (EXIS tab 'X')) ;
  982. tab.'X' = TABL ;
  983. FINS ;
  984.  
  985. * Intermediate densities output table
  986. SI (NON (EXIS tab 'X_FILTRE')) ;
  987. tab.'X_FILTRE' = TABL ;
  988. FINS ;
  989.  
  990. * Topology output table
  991. SI (NON (EXIS tab 'TOPOLOGIE')) ;
  992. tab.'TOPOLOGIE' = TABL ;
  993. FINS ;
  994.  
  995. * Mesh output table
  996. SI (NON (EXIS tab 'MAILLAGE')) ;
  997. tab.'MAILLAGE' = TABL ;
  998. FINS ;
  999.  
  1000. * Resolution output table
  1001. SI (NON (EXIS tab 'RESOLUTION')) ;
  1002. tab.'RESOLUTION' = TABL ;
  1003. FINS ;
  1004.  
  1005.  
  1006. **********************************************************************
  1007. * Unitary (uni) and volume (V) element fields *
  1008. **********************************************************************
  1009.  
  1010. * For the mechanical (M) model
  1011. SI LM ;
  1012. * Unitary field
  1013. uniMD = MANU 'CHML' modMD 'SCAL' 1.0 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1014. * Volume of each element
  1015. VMD = INTG 'ELEM' uniMD modMD matMB ;
  1016. * Change the unitary field so that it is not considered as constant
  1017. * to avoid problems with the function POIN 'SUPE'
  1018. uniMD = VMD / VMD ;
  1019. Wtab.'MECANIQUE'.'UNIT_D' = uniMD ;
  1020. Wtab.'MECANIQUE'.'VOLUME_D' = VMD ;
  1021. SI LF ;
  1022. * Unitary field
  1023. uniMF = MANU 'CHML' modMF 'SCAL' 1.0 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1024. * Volume of each element
  1025. VMF = INTG 'ELEM' uniMF modMF matMB ;
  1026. Wtab.'MECANIQUE'.'UNIT_F' = uniMF ;
  1027. Wtab.'MECANIQUE'.'VOLUME_F' = VMF ;
  1028. FINS ;
  1029. FINS ;
  1030.  
  1031. * For the thermal (T) model
  1032. SI LT ;
  1033. * Unitary field
  1034. uniTD = MANU 'CHML' modTD 'SCAL' 1.0 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1035. * In thermal mode, 'GRAVITE' option is not respected
  1036. * This issue is resolved by using CHAN 'GRAVITE'
  1037. uniTD = CHAN 'GRAVITE' uniTD modTD ;
  1038. * Volume of each element
  1039. VTD = INTG 'ELEM' uniTD modTD matTB ;
  1040. * In thermal mode, INTG 'ELEM' is not given at 'GRAVITE' even if
  1041. * input fields were defined at 'GRAVITE'
  1042. * This problem is solved by using CHAN 'GRAVITE'
  1043. VTD = CHAN 'GRAVITE' VTD modTD ;
  1044. * Divide the element volume field by itself to get uniTD so that
  1045. * it is not considered as constant and avoid problems with the
  1046. * function POIN 'SUPE'
  1047. uniTD = VTD / VTD ;
  1048. Wtab.'THERMIQUE'.'UNIT_D' = uniTD ;
  1049. Wtab.'THERMIQUE'.'VOLUME_D' = VTD ;
  1050. SI LF ;
  1051. * Unitary field
  1052. uniTF = MANU 'CHML' modTF 'SCAL' 1.0 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1053. * In thermal mode, 'GRAVITE' option is not respected
  1054. * This issue is resolved by using CHAN 'GRAVITE'
  1055. uniTF = CHAN 'GRAVITE' uniTF modTF ;
  1056. * Volume of each element
  1057. VTF = INTG 'ELEM' uniTF modTF matTB ;
  1058. * In thermal mode, INTG 'ELEM' is not given at 'GRAVITE' even if
  1059. * input fields were defined at 'GRAVITE'
  1060. * This problem is solved by using CHAN 'GRAVITE'
  1061. VTF = CHAN 'GRAVITE' VTF modTF ;
  1062. * Divide the element volume field by itself to get uniTF so that
  1063. * it is not considered as constant and avoid problems with the
  1064. * function POIN 'SUPE'
  1065. uniTF = VTF / VTF ;
  1066. Wtab.'THERMIQUE'.'UNIT_F' = uniTF ;
  1067. Wtab.'THERMIQUE'.'VOLUME_F' = VTF ;
  1068. FINS ;
  1069. FINS ;
  1070.  
  1071. **********************************************************************
  1072. * Default model, characteristics, unitary and volume element fields *
  1073. **********************************************************************
  1074.  
  1075. SI LM ;
  1076. * If a mechanical (M) model exists
  1077. Wtab.'MODELE_B' = modMB ;
  1078. Wtab.'MODELE_D' = modMD ;
  1079. Wtab.'CARACTERISTIQUES_B' = matMB ;
  1080. Wtab.'CARACTERISTIQUES_D' = matMD ;
  1081. SI LF ;
  1082. Wtab.'MODELE_F' = modMF ;
  1083. Wtab.'CARACTERISTIQUES_F' = matMF ;
  1084. FINS ;
  1085. uniD = uniMD ;
  1086. SI LF ;
  1087. uniF = uniMF ;
  1088. FINS ;
  1089. Wtab.'VOLUME_D' = VMD ;
  1090. Wtab.'VOLUME_F' = VMF ;
  1091. SINO ;
  1092. * If only a thermal (T) model exists
  1093. Wtab.'MODELE_B' = modTB ;
  1094. Wtab.'MODELE_D' = modTD ;
  1095. Wtab.'CARACTERISTIQUES_B' = matTB ;
  1096. Wtab.'CARACTERISTIQUES_D' = matTD ;
  1097. SI LF ;
  1098. Wtab.'MODELE_F' = modTF ;
  1099. Wtab.'CARACTERISTIQUES_F' = matTF ;
  1100. FINS ;
  1101. uniD = uniTD ;
  1102. SI LF ;
  1103. uniF = uniTF ;
  1104. FINS ;
  1105. Wtab.'VOLUME_D' = VTD ;
  1106. Wtab.'VOLUME_F' = VTF ;
  1107. FINS ;
  1108. Wtab.'UNIT_D' = uniD ;
  1109. SI LF ;
  1110. Wtab.'UNIT_F' = uniF ;
  1111. FINS ;
  1112.  
  1113.  
  1114. **********************************************************************
  1115. * Design zone (D) various data: zero field, centroids & total volume *
  1116. **********************************************************************
  1117.  
  1118. * Zero element field
  1119. Wtab.'ZERO_D' = uniD * 0.0 ;
  1120.  
  1121. * Node mesh of the centroids
  1122. Wtab.'MAILLAGE_GRAVITE_D' = uniD POIN 'SUPE' -1.0 ;
  1123.  
  1124. SI LF ;
  1125. SI LM ;
  1126. VtotD = INTG uniD modMD matMD ;
  1127. * VtotF = INTG uniF modMF matMF ;
  1128. SINO ;
  1129. VtotD = INTG uniD modTD matTD ;
  1130. * VtotF = INTG uniF modTF matTF ;
  1131. FINS ;
  1132. * Wtab.'VOLUME_TOTAL_B' = VtotD + VtotF ;
  1133. SINO ;
  1134. SI LM ;
  1135. VtotD = INTG uniD modMD matMD ;
  1136. SINO ;
  1137. VtotD = INTG uniD modTD matTD ;
  1138. FINS ;
  1139. * Wtab.'VOLUME_TOTAL_B' = VtotD ;
  1140. FINS ;
  1141. Wtab.'VOLUME_TOTAL_D' = VtotD ;
  1142.  
  1143.  
  1144. **********************************************************************
  1145. * Restart (R) *
  1146. **********************************************************************
  1147.  
  1148. * Remark: The following inputs are not supposed to be provided by the
  1149. * user. They are supposed to be generated by TOPOPTIM during a
  1150. * previous call.
  1151.  
  1152. * List of restarts
  1153. * ****************
  1154.  
  1155. * Initialize or update the list of restarts
  1156. SI (EGA Wtab.'CYCLE' 1) ;
  1157. tab.'REPRISES' = LECT ;
  1158. SINO ;
  1159. * It should exist, but this prevents any error if it's missing
  1160. SI (NON (EXIS tab 'REPRISES')) ;
  1161. tab.'REPRISES' = LECT ;
  1162. FINS ;
  1163. tab.'REPRISES' = tab.'REPRISES' ET cyc ;
  1164. FINS ;
  1165.  
  1166. * Restart data table
  1167. * ******************
  1168.  
  1169. SI (EXIS tab 'RTABLE') ;
  1170.  
  1171. Rtab = tab.'RTABLE' ;
  1172.  
  1173. * Initialize TOPOMODI for loading and mechanism
  1174. TOPOMODI tab (CHAI 'CHARGEMENT') Rtab.'CHARGEMENT' ;
  1175. SI Ltab.'MECANISME' ;
  1176. TOPOMODI tab (CHAI 'MECANISME') Rtab.'MECANISME' ;
  1177. FINS ;
  1178.  
  1179. * If any hat filter matrix exists
  1180. SI (EXIS Rtab 'FILTRE_CHAPEAU_NORMALISE') ;
  1181. * We will try to use it
  1182. Wtab.'FILTRE_CHAPEAU_NORMALISE' = Rtab.'FILTRE_CHAPEAU_NORMALISE' ;
  1183. * If a modified matrix exists too
  1184. SI (EXIS Rtab 'FILTRE_CHAPEAU_MODIFIE') ;
  1185. * We will try to use it
  1186. Wtab.'FILTRE_CHAPEAU_MODIFIE' = Rtab.'FILTRE_CHAPEAU_MODIFIE' ;
  1187. FINS ;
  1188. * Get their corresponding identification data
  1189. Wtab.'FILTRE_CHAPEAU_ID' = Rtab.'FILTRE_CHAPEAU_ID' ;
  1190.  
  1191. * Finally, as Wtab.'MAILLAGE_GRAVITE_D' was recreated, the saved
  1192. * hat filter matrix is not compatible. We need to fuse the
  1193. * matrix mesh nodes with those of Wtab.'MAILLAGE_GRAVITE_D'
  1194. tmp1 = Wtab.'MAILLAGE_GRAVITE_D' ;
  1195. tmp2 = CHAN POI1 (EXTR Wtab.'FILTRE_CHAPEAU_NORMALISE' 'MAIL') ;
  1196. ELIM tmp1 tmp2 tab.'ELIM_CRITERE' ;
  1197. SI ((NBEL (DIFF tmp1 tmp2)) > 0) ;
  1198. * This situation should never happen. Nevertheless, if it
  1199. * does, then we will force the regeneration of the hat filter
  1200. * matrix by resetting one of its identification data
  1201. Wtab.'FILTRE_CHAPEAU_ID'.'MODEL' = VIDE 'MMODEL' ;
  1202. FINS ;
  1203. FINS ;
  1204.  
  1205. * Reload the previous MMA table
  1206. SI (EXIS Rtab 'MMA') ;
  1207. Wtab.'MMA' = Rtab.'MMA' ;
  1208. FINS ;
  1209.  
  1210. * Use the last density threshold projection
  1211. * if it has been saved in Rtab and if constant volume projection
  1212. SI ((EXIS Rtab 'PROJECTION_SEUIL') ET Ltab.'PROJECTION_VOLUME_CONSTANT') ;
  1213. Wtab.'PROJECTION_SEUIL' = Rtab.'PROJECTION_SEUIL' ;
  1214. FINS ;
  1215.  
  1216. FINS ;
  1217.  
  1218.  
  1219. **********************************************************************
  1220. * Initial design variables and physical densities *
  1221. **********************************************************************
  1222.  
  1223. * If floats are given as initial design variables (X)
  1224. * or initial physical densities (Y)
  1225. * transform them into a homogeneous fields on B
  1226. * ------------------------------------------------------------------
  1227.  
  1228. SI (EXIS tab.'X' cyc) ;
  1229. SI (EGA (TYPE tab.'X'.cyc) 'FLOTTANT') ;
  1230. tab.'X'.cyc = uniD * tab.'X'.cyc ;
  1231. SI LF ;
  1232. * Combine the field on D with the unitary field on F
  1233. * This creates a 2-zone field merged into a single zone
  1234. * field, preserving the original element order using REDU
  1235. tab.'X'.cyc = REDU (tab.'X'.cyc ET uniF) Wtab.'MODELE_B' ;
  1236. FINS ;
  1237. FINS ;
  1238. FINS ;
  1239.  
  1240. SI (EXIS tab.'X_FILTRE' cyc) ;
  1241. SI (EGA (TYPE tab.'X_FILTRE'.cyc) 'FLOTTANT') ;
  1242. tab.'X_FILTRE'.cyc = uniD * tab.'X_FILTRE'.cyc ;
  1243. SI LF ;
  1244. * Combine the field on D with the unitary field on F
  1245. * This creates a 2-zone field merged into a single zone
  1246. * field, preserving the original element order using REDU
  1247. tab.'X_FILTRE'.cyc = REDU (tab.'X_FILTRE'.cyc ET uniF)
  1248. Wtab.'MODELE_B' ;
  1249. FINS ;
  1250. FINS ;
  1251. FINS ;
  1252.  
  1253. SI (EXIS tab.'TOPOLOGIE' cyc) ;
  1254. SI (EGA (TYPE tab.'TOPOLOGIE'.cyc) 'FLOTTANT') ;
  1255. tab.'TOPOLOGIE'.cyc = uniD * tab.'TOPOLOGIE'.cyc ;
  1256. SI LF ;
  1257. * Combine the field on D with the unitary field on F
  1258. * This creates a 2-zone field merged into a single zone
  1259. * field, preserving the original element order using REDU
  1260. tab.'TOPOLOGIE'.cyc = REDU (tab.'TOPOLOGIE'.cyc ET uniF)
  1261. Wtab.'MODELE_B' ;
  1262. FINS ;
  1263. FINS ;
  1264. FINS ;
  1265.  
  1266. * If there are initial design variables (X)
  1267. * and/or initial intermediate densities (S)
  1268. * and/or initial physical densities (Y)
  1269. * and/or a restart table (that always contains X, S and Y)
  1270. * then we will use those data at best to initilize X, S and Y
  1271. * -----------------------------------------------------------
  1272.  
  1273. * Initialization
  1274. LX = EXIS tab.'X' cyc ;
  1275. LS = EXIS tab.'X_FILTRE' cyc ;
  1276. LY = EXIS tab.'TOPOLOGIE' cyc ;
  1277. LRtab = EXIS tab 'RTABLE' ;
  1278.  
  1279. * If some initial values are provided
  1280. SI (LX OU LS OU LY OU LRtab) ;
  1281.  
  1282. * Define at least X
  1283. * -----------------
  1284.  
  1285. * By default we will use X, S and Y from user defined input
  1286. * otherwise from Rtab
  1287. SI LX ;
  1288. XB = tab.'X'.cyc ;
  1289. FINS ;
  1290. SI LS ;
  1291. SB = tab.'X_FILTRE'.cyc ;
  1292. FINS ;
  1293. SI LY ;
  1294. YB = tab.'TOPOLOGIE'.cyc ;
  1295. FINS ;
  1296. SI LRtab ;
  1297. RXB = tab.'RTABLE'.'X_B' ;
  1298. RSB = tab.'RTABLE'.'S_B' ;
  1299. RYB = tab.'RTABLE'.'Y_B' ;
  1300. FINS ;
  1301.  
  1302. * If the only existing X, S and Y are from Rtab
  1303. SI (LRtab ET (NON LX) ET (NON LS) ET (NON LY)) ;
  1304. * We will use them together
  1305. XB = RXB ;
  1306. LX = VRAI ;
  1307. SB = RSB ;
  1308. LS = VRAI ;
  1309. YB = RYB ;
  1310. LY = VRAI ;
  1311. FINS ;
  1312.  
  1313. * If X is given with Rtab
  1314. SI (LRtab ET LX ET (NON LS) ET (NON LY)) ;
  1315. * If it is the same as the one in Rtab
  1316. SI (EGA XB RXB) ;
  1317. * Then we can use S and Y from Rtab
  1318. SB = RSB ;
  1319. LS = VRAI ;
  1320. YB = RYB ;
  1321. LY = VRAI ;
  1322. FINS ;
  1323. FINS ;
  1324.  
  1325. * Verification
  1326. * !!!!!!!!!!!!
  1327.  
  1328. * If X does not exist at this step
  1329. * Remark: It means Rtab didn't exist either, otherwise X would have
  1330. * been taken from Rtab.
  1331. SI (NON LX) ;
  1332. tmp = CHAI 'Vous avez fourni des valeurs imposees' ;
  1333. SI LS ;
  1334. tmp = CHAI tmp ' des densites intermediaires' ;
  1335. FINS ;
  1336. SI (LS ET LY) ;
  1337. tmp = CHAI tmp ' et' ;
  1338. FINS ;
  1339. SI LY ;
  1340. tmp = CHAI tmp ' de la topologie' ;
  1341. FINS ;
  1342. tmp = CHAI tmp ' pour le prochain cycle sans avoir fourni'
  1343. ' les variables de conceptions correspondantes' ;
  1344. SI (NON LS) ;
  1345. tmp = CHAI tmp ' ni les densites intermediaires,' ;
  1346. FINS ;
  1347. SI (NON LY) ;
  1348. tmp = CHAI tmp ' ni la topologie,' ;
  1349. FINS ;
  1350. ERRE (CHAI tmp ' qui sont indispensables dans ce cas.') ;
  1351. FINS ;
  1352.  
  1353. * If Y is missing but not S
  1354. SI ((LS ET (NON LY)) OU ((NON LS) ET LY));
  1355. tmp = CHAI 'Vous avez fourni des valeurs imposees des'
  1356. ' variables de conceptions et' ;
  1357. SI LS ;
  1358. tmp = CHAI tmp ' des densites intermediaires' ;
  1359. FINS ;
  1360. SI LY ;
  1361. tmp = CHAI tmp ' de la topologie' ;
  1362. FINS ;
  1363. tmp = CHAI tmp ' mais sans les valeurs imposees' ;
  1364. SI (NON LS) ;
  1365. tmp = CHAI tmp ' des densites intermediaires,' ;
  1366. FINS ;
  1367. SI (NON LY) ;
  1368. tmp = CHAI tmp ' de la topologie,' ;
  1369. FINS ;
  1370. ERRE (CHAI tmp ' qui sont alors indispensables. Ou bien vous'
  1371. ' pouvez ne fournir que les variables de'
  1372. ' conceptions seules.') ;
  1373. FINS ;
  1374.  
  1375.  
  1376. * Projection of X, S and Y on D
  1377. * -----------------------------
  1378.  
  1379. * This projection is used for remeshing compatibility but
  1380. * also in case the active zone was updated or the model etc...
  1381. * but also because X, S and Y are given on B while we
  1382. * need them only on D.
  1383.  
  1384. * Logical for identical S and X
  1385. LSegaX = FAUX ;
  1386. SI (LS ET LX) ;
  1387. * If they are identical
  1388. LSegaX = EGA SB XB ;
  1389. FINS ;
  1390.  
  1391. * Logical for identical Y and S
  1392. LYegaS = FAUX ;
  1393. SI (LY ET LS) ;
  1394. * If they are identical
  1395. LYegaS = EGA YB SB ;
  1396. FINS ;
  1397.  
  1398. * Logical for identical Y and X
  1399. LYegaX = FAUX ;
  1400. SI (LY ET LX) ;
  1401. * If they are identical
  1402. LYegaX = EGA YB XB ;
  1403. FINS ;
  1404.  
  1405. SI LM ;
  1406. * Project the input topology element field at the centroids of
  1407. * the elements of the model modMD
  1408. SI LX ;
  1409. tmp = PROI Wtab.'MAILLAGE_GRAVITE_D' XB ;
  1410. XD = MANU 'CHML' modMD 'REPA' 'SCAL' (EXTR tmp 'VALE') 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1411. FINS ;
  1412. SI (LS ET (NON LSegaX)) ;
  1413. tmp = PROI Wtab.'MAILLAGE_GRAVITE_D' SB ;
  1414. SD = MANU 'CHML' modMD 'REPA' 'SCAL' (EXTR tmp 'VALE') 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1415. FINS ;
  1416. SI (LY ET (NON LYegaS) ET (NON LYegaX)) ;
  1417. tmp = PROI Wtab.'MAILLAGE_GRAVITE_D' YB ;
  1418. YD = MANU 'CHML' modMD 'REPA' 'SCAL' (EXTR tmp 'VALE') 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1419. FINS ;
  1420. SINO ;
  1421. * Project the input topology element field at the centroids of
  1422. * the elements of the model modTD
  1423. SI LX ;
  1424. tmp = PROI Wtab.'MAILLAGE_GRAVITE_D' XB ;
  1425. XD = MANU 'CHML' modTD 'REPA' 'SCAL' (EXTR tmp 'VALE') 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1426. * In thermal mode, 'GRAVITE' option is not respected
  1427. * This issue is resolved using CHAN 'GRAVITE'
  1428. XD = CHAN 'GRAVITE' XD modTD ;
  1429. FINS ;
  1430. SI (LS ET (NON LSegaX)) ;
  1431. tmp = PROI Wtab.'MAILLAGE_GRAVITE_D' SB ;
  1432. SD = MANU 'CHML' modTD 'REPA' 'SCAL' (EXTR tmp 'VALE') 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1433. * In thermal mode, 'GRAVITE' option is not respected
  1434. * This issue is resolved using CHAN 'GRAVITE'
  1435. SD = CHAN 'GRAVITE' SD modTD ;
  1436. FINS ;
  1437. SI (LY ET (NON LYegaS) ET (NON LYegaX)) ;
  1438. tmp = PROI Wtab.'MAILLAGE_GRAVITE_D' YB ;
  1439. YD = MANU 'CHML' modTD 'REPA' 'SCAL' (EXTR tmp 'VALE') 'TYPE' 'SCALAIRE' 'GRAVITE' ;
  1440. * In thermal mode, 'GRAVITE' option is not respected
  1441. * This issue is resolved using CHAN 'GRAVITE'
  1442. YD = CHAN 'GRAVITE' YD modTD ;
  1443. FINS ;
  1444. FINS ;
  1445.  
  1446. SI LSegaX ;
  1447. SD = XD ;
  1448. FINS ;
  1449. SI LYegaS ;
  1450. YD = SD ;
  1451. FINS ;
  1452. SI LYegaX ;
  1453. YD = XD ;
  1454. FINS ;
  1455.  
  1456. * Add requested restrictions on X in case they are not already respected
  1457. * ----------------------------------------------------------------------
  1458.  
  1459. * It must be done on initial X as further calls to TOPORSTR during
  1460. * optimisation loop will affect only the increments of X, not X itself.
  1461. * Remark: Y does not respect the restrictions in the case of density
  1462. * filtering and does not need to (but it usuallly close to respect them).
  1463. XD = TOPORSTR tab XD ;
  1464.  
  1465. * Save X
  1466. * ------
  1467.  
  1468. Wtab.'X_D' = XD ;
  1469.  
  1470. * Save S and Y or generate them from X if they do not exist
  1471. * ---------------------------------------------------------
  1472.  
  1473. SI (LS ET LY) ;
  1474. Wtab.'S_D' = SD ;
  1475. Wtab.'Y_D' = YD ;
  1476. SINO ;
  1477. * Generate S and Y from X on D
  1478. * Remark: this is done using the filtering and projection
  1479. * parameters of the current cycle while S and Y shoud
  1480. * have been generated at the end of the previous cycle
  1481. * with the previous parameters.
  1482. TOPOPHYS tab ;
  1483. FINS ;
  1484.  
  1485. SINO ;
  1486. SI (NEG cyc 1) ;
  1487. MESS (CHAI 'Le cycle de depart est le' ' ' cyc '.') ;
  1488. MESS (CHAI 'Or la topologie' ' ' cyc ' n''existe pas.') ;
  1489. ERRE 'Veuillez preciser la topologie du nouveau cycle.' ;
  1490. SINO ;
  1491. SI Ltab.'CONTRAINTE_VOLUME' ;
  1492. Wtab.'X_D' = uniD * tab.'FRACTION_VOLUME_LIMITE' ;
  1493. SINO ;
  1494. Wtab.'X_D' = uniD * 0.5 ;
  1495. FINS ;
  1496. * Get Y from X on D
  1497. TOPOPHYS tab ;
  1498. FINS ;
  1499. FINS ;
  1500.  
  1501. * Remark : After TOPOPHYS, we may not respect the volume fraction of
  1502. * Y in the case of volume constraint at first iteration.
  1503. * It should not be a problem either with OC nor MMA.
  1504. * We could scale the fields to fit the volume fraction but
  1505. * it should be done preserving X_MIN_SEUIL<X<1...
  1506.  
  1507. FINP ;
  1508.  
  1509.  
  1510.  

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