Télécharger topoobje.procedur

Retour à la liste

Numérotation des lignes :

  1. * TOPOOBJE PROCEDUR FD218221 25/12/18 21:15:09 12429
  2.  
  3. ************************************************************************
  4. ** Procedure called by TOPOPTIM to calculate:
  5. **
  6. ** 1 - The objective function, which can be:
  7. ** - Mechanism output displacement maximization (based on
  8. ** compliance);
  9. ** - Compliance minimization (or more precisely, "2 * the total
  10. ** elastic strain energy" in mechanics and "total thermal
  11. ** compliance" in thermal problems);
  12. ** - Total volume fraction.
  13. **
  14. ** 2 - The volume-normalized objective sensitivity (w.r.t X)
  15. ** Defined as ∂obj/∂X / vol1_e
  16. **
  17. ** For compliance:
  18. ** - ∂cpl/∂X / vol1_e = - dZ/dX * q1_e / vol1_e
  19. ** Only the explicit part is included (ignoring U(X) dependence).
  20. ** The minus sign compensates for the missing implicit contribution,
  21. ** ensuring the optimizer moves densities in the correct direction.
  22. **
  23. ** Finally, any requested restrictions and/or filtering are applied.
  24. **
  25. ** Author:
  26. ** Guenhael Le Quilliec (LaMe - Polytech Tours)
  27. **
  28. ** Version:
  29. ** 2.0 2025/11/17 Renamed TOPOOBJE and made compatible with
  30. ** TOPOPTIM V4.0. Added total volume fraction objective.
  31. ** Call TOPORSTR and filter the objective sensitivity at
  32. ** the end of TOPOOBJE.
  33. ** 1.0 2021/04/15 Initial version of TOPOSENS
  34. ************************************************************************
  35.  
  36. DEBP TOPOOBJE tab*'TABLE' ;
  37.  
  38. * General input data
  39. * ******************
  40.  
  41. Wtab = tab.'WTABLE' ;
  42. Ltab = Wtab.'LOGIQUE' ;
  43.  
  44.  
  45. **********************************************************************
  46. * Compliance and its sensitivity *
  47. **********************************************************************
  48.  
  49. SI Ltab.'OBJECTIF_COMPLIANCE' ;
  50.  
  51. * Input data
  52. * **********
  53.  
  54. wgtmcn = tab.'POIDS_MECANISME' ;
  55. wgtM = tab.'POIDS_ENERGIE_DEFO' ;
  56. wgtT = tab.'POIDS_TEMPERATURE' ;
  57. ctrmshD = Wtab.'MAILLAGE_GRAVITE_D' ;
  58. resA = Wtab.'RESOLUTION_A' ;
  59. SI Ltab.'CAS_MULTIPLES' ;
  60. nbrcas = Wtab.'NB_CAS' ;
  61. FINS ;
  62. SI Ltab.'MECANIQUE' ;
  63. modMD = Wtab.'MECANIQUE'.'MODELE_D' ;
  64. FINS ;
  65. SI Ltab.'THERMIQUE' ;
  66. modTD = Wtab.'THERMIQUE'.'MODELE_D' ;
  67. FINS ;
  68.  
  69. * Mesh, model, material, and "physical density derivative factor" (dZ/dY / Z) belonging to I
  70. * ******************************************************************************************
  71.  
  72. mshI = Wtab.'MAILLAGE_I' ;
  73. SI Ltab.'MECANIQUE' ;
  74. modMI = Wtab.'MECANIQUE'.'MODELE_I' ;
  75. ZmatMI = Wtab.'MECANIQUE'.'CARACTERISTIQUES_Z_I' ;
  76. dZdY_ZMI = Wtab.'MECANIQUE'.'SENSIBILITE_Z_I' /
  77. Wtab.'MECANIQUE'.'Z_I' ;
  78. FINS ;
  79. SI Ltab.'THERMIQUE' ;
  80. modTI = Wtab.'THERMIQUE'.'MODELE_I' ;
  81. ZmatTI = Wtab.'THERMIQUE'.'CARACTERISTIQUES_Z_I' ;
  82. dZdY_ZTI = Wtab.'THERMIQUE'.'SENSIBILITE_Z_I' /
  83. Wtab.'THERMIQUE'.'Z_I' ;
  84. FINS ;
  85.  
  86. * Initialization
  87. * **************
  88.  
  89. O = 0.0 ;
  90. dOdYI = Wtab.'VIDE' ;
  91.  
  92. * Compliance and its sensitivity for mechanisms
  93. * *********************************************
  94.  
  95. SI Ltab.'MECANISME' ;
  96. SI Ltab.'CAS_MULTIPLES' ;
  97. REPE itr nbrcas ;
  98. * Handle and response stress and strain
  99. SI Ltab.'PASAPAS' ;
  100. tmp = resA.&itr.'MECANISME_ENTREE'.'MAX_ID' ;
  101. siginpI = REDU (resA.&itr.'MECANISME_ENTREE'.'CONTRAINTES'.tmp) mshI ;
  102. epsinpI = ELAS modMI siginpI ZmatMI ;
  103. tmp = resA.&itr.'MECANISME_SORTIE'.'MAX_ID' ;
  104. sigoutI = REDU (resA.&itr.'MECANISME_SORTIE'.'CONTRAINTES'.tmp) mshI ;
  105. * epsoutI = ELAS modMI sigoutI ZmatMI ;
  106. SINO ;
  107. * siginpI = REDU (resA.&itr.'MECANISME_ENTREE'.'CONTRAINTES') mshI ;
  108. epsinpI = REDU (resA.&itr.'MECANISME_ENTREE'.'DEFORMATIONS') mshI ;
  109. sigoutI = REDU (resA.&itr.'MECANISME_SORTIE'.'CONTRAINTES') mshI ;
  110. * epsoutI = REDU (resA.&itr.'MECANISME_SORTIE'.'DEFORMATIONS') mshI ;
  111. FINS ;
  112. cpl dcpldYI = TOPOCMPL modMI ZmatMI dZdY_ZMI sigoutI epsinpI ;
  113. O = O + ((wgtmcn / nbrcas) * cpl) ;
  114. SI (EGA dOdYI Wtab.'VIDE') ;
  115. dOdYI = ((wgtmcn / nbrcas) * dcpldYI) ;
  116. SINO ;
  117. dOdYI = dOdYI + ((wgtmcn / nbrcas) * dcpldYI) ;
  118. FINS ;
  119. FIN itr ;
  120. SINO ;
  121. * Handle and response stress and strain
  122. SI Ltab.'PASAPAS' ;
  123. tmp = resA.'MECANISME_ENTREE'.'MAX_ID' ;
  124. siginpI = REDU (resA.'MECANISME_ENTREE'.'CONTRAINTES'.tmp) mshI ;
  125. epsinpI = ELAS modMI siginpI ZmatMI ;
  126. tmp = resA.'MECANISME_SORTIE'.'MAX_ID' ;
  127. sigoutI = REDU (resA.'MECANISME_SORTIE'.'CONTRAINTES'.tmp) mshI ;
  128. * epsoutI = ELAS modMI sigoutI ZmatMI ;
  129. SINO ;
  130. * siginpI = REDU (resA.'MECANISME_ENTREE'.'CONTRAINTES') mshI ;
  131. epsinpI = REDU (resA.'MECANISME_ENTREE'.'DEFORMATIONS') mshI ;
  132. sigoutI = REDU (resA.'MECANISME_SORTIE'.'CONTRAINTES') mshI ;
  133. * epsoutI = REDU (resA.'MECANISME_SORTIE'.'DEFORMATIONS') mshI ;
  134. FINS ;
  135. cpl dcpldYI = TOPOCMPL modMI ZmatMI dZdY_ZMI sigoutI epsinpI ;
  136. O = O + (wgtmcn * cpl) ;
  137. SI (EGA dOdYI Wtab.'VIDE') ;
  138. dOdYI = (wgtmcn * dcpldYI) ;
  139. SINO ;
  140. dOdYI = dOdYI + (wgtmcn * dcpldYI) ;
  141. FINS ;
  142. FINS ;
  143. FINS ;
  144.  
  145. * Compliance and its sensitivity
  146. * ******************************
  147.  
  148. * SI (Ltab.'MECANIQUE' ET ((ABS wgtM) > tab.'PRECISION')) ;
  149. SI (Ltab.'MECANIQUE' ET (NEG wgtM 0.0)) ;
  150. SI Ltab.'CAS_MULTIPLES' ;
  151. REPE itr nbrcas ;
  152. SI Ltab.'PASAPAS' ;
  153. tmp = resA.&itr.'MAX_ID' ;
  154. sigI = REDU (resA.&itr.'CONTRAINTES'.tmp) mshI ;
  155. epsI = ELAS modMI sigI ZmatMI ;
  156. SINO ;
  157. sigI = REDU (resA.&itr.'CONTRAINTES') mshI ;
  158. epsI = REDU (resA.&itr.'DEFORMATIONS') mshI ;
  159. FINS ;
  160. cpl dcpldYI = TOPOCMPL modMI ZmatMI dZdY_ZMI sigI epsI ;
  161. O = O + ((wgtM / nbrcas) * cpl) ;
  162. SI (EGA dOdYI Wtab.'VIDE') ;
  163. dOdYI = ((-1.0 * wgtM / nbrcas) * dcpldYI) ;
  164. SINO ;
  165. dOdYI = dOdYI - ((wgtM / nbrcas) * dcpldYI) ;
  166. FINS ;
  167. FIN itr ;
  168. SINO ;
  169. SI Ltab.'PASAPAS' ;
  170. tmp = resA.'MAX_ID' ;
  171. sigI = REDU (resA.'CONTRAINTES'.tmp) mshI ;
  172. epsI = ELAS modMI sigI ZmatMI ;
  173. SINO ;
  174. sigI = REDU (resA.'CONTRAINTES') mshI ;
  175. epsI = REDU (resA.'DEFORMATIONS') mshI ;
  176. FINS ;
  177. cpl dcpldYI = TOPOCMPL modMI ZmatMI dZdY_ZMI sigI epsI ;
  178. O = O + (wgtM * cpl) ;
  179. SI (EGA dOdYI Wtab.'VIDE') ;
  180. dOdYI = ((-1.0 * wgtM) * dcpldYI) ;
  181. SINO ;
  182. dOdYI = dOdYI - (wgtM * dcpldYI) ;
  183. FINS ;
  184. FINS ;
  185. FINS ;
  186.  
  187. * Thermal compliance and its sensitivity
  188. * **************************************
  189.  
  190. * SI (Ltab.'THERMIQUE' ET ((ABS wgtT) > tab.'PRECISION')) ;
  191. SI (Ltab.'THERMIQUE' ET (NEG wgtT 0.0)) ;
  192. SI Ltab.'CAS_MULTIPLES' ;
  193. REPE itr nbrcas ;
  194. * Temperature nodal field
  195. SI Ltab.'PASAPAS' ;
  196. tmp = resA.&itr.'MAX_ID' ;
  197. TA = REDU (resA.&itr.'TEMPERATURES'.tmp) mshI ;
  198. SINO ;
  199. TA = REDU (resA.&itr.'TEMPERATURES') mshI ;
  200. FINS ;
  201. cpl dcpldYI = TOPOCMPL modTI ZmatTI dZdY_ZTI TA ;
  202. * Switch the model of the element field eneK from Therm to Mecha
  203. SI Ltab.'MECANIQUE' ;
  204. * Remark: values of any element of I missing in D will be set to 0.0
  205. dcpldYD = TOPOCHAN (REDU dcpldYI modTD) modMD ctrmshD ;
  206. dcpldYI = REDU dcpldYD modMI ;
  207. FINS ;
  208. O = O + ((wgtT / nbrcas) * cpl) ;
  209. SI (EGA dOdYI Wtab.'VIDE') ;
  210. dOdYI = ((-1.0 * wgtT / nbrcas) * dcpldYI) ;
  211. SINO ;
  212. dOdYI = dOdYI - ((wgtT / nbrcas) * dcpldYI) ;
  213. FINS ;
  214. FIN itr ;
  215. SINO ;
  216. * Temperature nodal field
  217. SI Ltab.'PASAPAS' ;
  218. tmp = resA.'MAX_ID' ;
  219. TA = REDU (resA.'TEMPERATURES'.tmp) mshI ;
  220. SINO ;
  221. TA = REDU (resA.'TEMPERATURES') mshI ;
  222. FINS ;
  223. cpl dcpldYI = TOPOCMPL modTI ZmatTI dZdY_ZTI TA ;
  224. * Switch the model of the element field eneK from Therm to Mecha
  225. SI Ltab.'MECANIQUE' ;
  226. * Remark: values of any element of I missing in D will be set to 0.0
  227. dcpldYD = TOPOCHAN (REDU dcpldYI modTD) modMD ctrmshD ;
  228. dcpldYI = REDU dcpldYD modMI ;
  229. FINS ;
  230. O = O + (wgtT * cpl) ;
  231. SI (EGA dOdYI Wtab.'VIDE') ;
  232. dOdYI = ((-1.0 * wgtT) * dcpldYI) ;
  233. SINO ;
  234. dOdYI = dOdYI - (wgtT * dcpldYI) ;
  235. FINS ;
  236. FINS ;
  237. FINS ;
  238.  
  239. * Get the objective sensitivity with respect to physical densities Y on D
  240. * ***********************************************************************
  241.  
  242. * If it is empty
  243. SI (EGA dOdYI Wtab.'VIDE') ;
  244. * Return a zero field
  245. dOdYD = Wtab.'ZERO_D' ;
  246. SINO ;
  247. * Use REDU to get O on D from I.
  248. * Remark: values of any element of D missing in I will be set to 0.0
  249. dOdYD = REDU dOdYI Wtab.'MODELE_D' ;
  250. FINS ;
  251.  
  252. * Normalization
  253. * *************
  254.  
  255. * Volume-normalized objective sensitivity
  256. NdOdYD = dOdYD / Wtab.'VOLUME_D' ;
  257.  
  258. FINS ;
  259.  
  260.  
  261. **********************************************************************
  262. * Volume ratio and its sensitivity *
  263. **********************************************************************
  264.  
  265. SI Ltab.'OBJECTIF_VOLUME' ;
  266.  
  267. * Input data
  268. * **********
  269.  
  270. uniD = Wtab.'UNIT_D' ;
  271. modD = Wtab.'MODELE_D' ;
  272. matD = Wtab.'CARACTERISTIQUES_D' ;
  273. VtotD = Wtab.'VOLUME_TOTAL_D' ;
  274.  
  275. * Objective to be minimized
  276. * *************************
  277.  
  278. * Total material volume normalized by the total element volume
  279. SI (TOPOMODI tab (CHAI 'FRACTION_VOLUME') Wtab.'Y_D' modD matD) ;
  280. Wtab.'FRACTION_VOLUME' = (INTG Wtab.'Y_D' modD matD) / VtotD ;
  281. FINS ;
  282. O = Wtab.'FRACTION_VOLUME' ;
  283.  
  284. * Volume-normalized objective sensitivity with respect to Y
  285. SI (TOPOMODI tab (CHAI 'UNIT_D_/_VTOT_D') uniD VtotD) ;
  286. Wtab.'UNIT_D_/_VTOT_D' = uniD / VtotD ;
  287. FINS ;
  288. NdOdYD = Wtab.'UNIT_D_/_VTOT_D' ;
  289.  
  290. FINS ;
  291.  
  292.  
  293. **********************************************************************
  294. * Postprocessing of the objective and its sensitivity *
  295. **********************************************************************
  296.  
  297. * Correct the sensitivity
  298. * ***********************
  299.  
  300. * Modify sensitivity to get derivative with respect to X instead of Y
  301. NdOdXD = TOPODYDX tab NdOdYD ;
  302.  
  303. * Add any requested restrictions
  304. * ******************************
  305.  
  306. NdOdXD = TOPORSTR tab NdOdXD ;
  307.  
  308. * Objective sensitivity filtering
  309. * *******************************
  310.  
  311. SI Ltab.'FILTRE_SENSIBILITE_OBJECTIF' ;
  312. tmp = NdOdXD * Wtab.'Y_D' ;
  313. tmp = TOPOFILT tab tmp ;
  314. NdOdXD = tmp / (BORN Wtab.'Y_D' 'SCAL' 'MINI' tab.'ZERO_DIVISION') ;
  315. FINS ;
  316.  
  317. * Save output data
  318. * ****************
  319.  
  320. * Save the compliance value and its sensitivity field before applying restrictions
  321. Wtab.'OBJECTIF' = O ;
  322. Wtab.'SENSIBILITE_NORMALISEE_OBJECTIF_D' = NdOdXD ;
  323.  
  324. FINP ;
  325.  
  326.  
  327.  

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