Télécharger topocont.procedur

Retour à la liste

Numérotation des lignes :

  1. * TOPOCONT PROCEDUR FD218221 25/12/18 21:15:04 12429
  2.  
  3. ************************************************************************
  4. ** Procedure called by TOPOPTIM to calculate:
  5. **
  6. ** 1 - The constraints
  7. ** Each constraint must be in the form G(X) = f(X) - f_lim <= 0,
  8. ** with 1 < f_lim < 100, and G differentiable with respect to the
  9. ** design variables X.
  10. **
  11. ** 2 - Their volume-normalized sensitivities
  12. ** Defined as dG/dX / vol1_e.
  13. **
  14. ** Finally, any requested filtering is applied.
  15. **
  16. ** Author:
  17. ** Guenhael Le Quilliec (LaMe - Polytech Tours)
  18. **
  19. ** Version:
  20. ** 1.0 2025/11/10 Initial version
  21. ************************************************************************
  22.  
  23. DEBP TOPOCONT tab*'TABLE' ;
  24.  
  25. * General input data
  26. * ******************
  27.  
  28. Wtab = tab.'WTABLE' ;
  29. Ltab = Wtab.'LOGIQUE' ;
  30.  
  31. * Initialization
  32. * **************
  33.  
  34. nbrG = 0 ;
  35. Glst = PROG ;
  36. NdGdXDtab = TABL ;
  37. NdGdYDtab = TABL ;
  38.  
  39. **********************************************************************
  40. * Volume constraint and its sensitivity *
  41. **********************************************************************
  42.  
  43. SI Ltab.'CONTRAINTE_VOLUME' ;
  44.  
  45. * Input data
  46. * **********
  47.  
  48. uniD = Wtab.'UNIT_D' ;
  49. modD = Wtab.'MODELE_D' ;
  50. matD = Wtab.'CARACTERISTIQUES_D' ;
  51. VtotDlim = Wtab.'VOLUME_TOTAL_D' * tab.'FRACTION_VOLUME_LIMITE' ;
  52.  
  53. resB = Wtab.'RESOLUTION_B' ;
  54.  
  55. * Logical for physical density dependent loading
  56. LdFdY = EXIS resB 'SENSIBILITE_NORMALISEE_CHARGEMENT' ;
  57.  
  58. * TODO faire en sorte que ça soit compatible.
  59. SI LdFdY ;
  60. ERRE 'Actuellement la contrainte de volume n''est pas compatible avec un chargement dependant de la topologie.' ;
  61. FINS ;
  62.  
  63. * Volume constraint (G)
  64. * *********************
  65.  
  66. * Lets note y_e be the element value of Y.
  67. * The volume constraint function is:
  68. * G = vol_tot(Y) / vol_tot_lim - 1 <= 0
  69. * = Σ vol_e(y_e) / vol_tot_lim - 1
  70.  
  71. * Note: not calculated for OC optimizer, as it is not used.
  72. SI (NEG tab.'OPTIMISEUR' 'OC') ;
  73. G = ((INTG Wtab.'Y_D' modD matD) / VtotDlim) - 1.0 ;
  74. Glst = Glst ET (PROG G) ;
  75. FINS ;
  76.  
  77. * Normalized sensitivity with respect to Y
  78. * ****************************************
  79.  
  80. * Its sensitivity w.r.t. y_e is:
  81. * dG/dy_e = d_vol_e(y_e)/dy_e / vol_tot_lim
  82. * = d(y_e*vol1_e)/dy_e / vol_tot_lim
  83. * = vol1_e / vol_tot_lim
  84.  
  85. * Its normalized sensitivity w.r.t. y_e is:
  86. * dG/dy_e / vol1_e = 1 / vol_tot_lim
  87.  
  88. SI (TOPOMODI tab (CHAI 'UNIT_D_/_VTOTMAX') uniD VtotDlim) ;
  89. Wtab.'UNIT_D_/_VTOTMAX' = uniD / VtotDlim ;
  90. FINS ;
  91. NdGdYD = Wtab.'UNIT_D_/_VTOTMAX' ;
  92.  
  93. * Output normalized constraint sensitivity
  94. nbrG = nbrG + 1 ;
  95. NdGdYDtab.(nbrG) = NdGdYD ;
  96. * TODO This line is optional but allows retrieving the name of the N-th constraint in the sensitivity table.
  97. * NdGdXDtab.(CHAI (DIME cst)) = CHAI 'CONTRAINTE_NORMALISEE_VOLUME' ;
  98.  
  99. FINS ;
  100.  
  101.  
  102. **********************************************************************
  103. * Von Mises stress constraint and its sensitivity *
  104. **********************************************************************
  105.  
  106. *SI Ltab.'CONTRAINTE_SIGMA_VM' ;
  107. SI (Ltab.'VERBART' OU Ltab.'CONIGLIO') ;
  108.  
  109. * Input data
  110. * **********
  111.  
  112. modMD = Wtab.'MECANIQUE'.'MODELE_D' ;
  113. resA = Wtab.'RESOLUTION_A' ;
  114. YD = Wtab.'Y_D' ;
  115. vnmlim = tab.'SIGMA_VM_LIMITE' ;
  116.  
  117. * Mesh, model, material, and densities belonging to I
  118. * ***************************************************
  119.  
  120. mshI = Wtab.'MAILLAGE_I' ;
  121. modMI = Wtab.'MECANIQUE'.'MODELE_I' ;
  122. matMI = Wtab.'MECANIQUE'.'CARACTERISTIQUES_I' ;
  123. YI = REDU YD mshI ;
  124. VMI = REDU Wtab.'VOLUME_D' mshI ;
  125.  
  126. * Elastic strains on I (at centroids)
  127. * ***********************************
  128.  
  129. SI Ltab.'PASAPAS' ;
  130. tmp = REDU resA.'CONTRAINTES'.(resA.'MAX_ID') mshI ;
  131. epsI = ELAS modMI tmp matMI ;
  132. SINO ;
  133. epsI = REDU (resA.'DEFORMATIONS') mshI ;
  134. FINS ;
  135. epsI = CHAN 'GRAVITE' epsI modMI ;
  136.  
  137. * Normalized microscopic von Mises stresses on D
  138. * **********************************************
  139.  
  140. * Microscopic stresses using full-density stiffness E(X=1) on I
  141. micsigI = ELAS modMI epsI matMI ;
  142. * micsigI = CHAN 'GRAVITE' micsigI modMI ;
  143. * Microscopic von Mises stresses on I
  144. micvnmI = CHAN 'TYPE' (VMIS modMI micsigI matMI) 'SCALAIRE' ;
  145. * TODO Ne conserver que le max par élément? Ça va compliquer le calcule de sa sensibilité peut être
  146. micvnmI = CHAN 'GRAVITE' micvnmI modMI ;
  147. * Normalized microscopic von Mises stresses on I
  148. NmicvnmI = micvnmI / vnmlim ;
  149. * Normalized microscopic von Mises stresses on D
  150. * Remark: values of any element of I missing in D are set to 0.0
  151. NmicvnmD = REDU NmicvnmI modMD ;
  152.  
  153. * Local constraints (g) and their derivatives with respect to Y on D
  154. * ******************************************************************
  155.  
  156. * Local constraints on the microscopic von Mises stress ratio
  157. * Note: use Nmicvnm instead of micvnm to avoid infinite output
  158. gmicvnmD = NmicvnmD - 1.0 ;
  159. * Local constraints to be aggregated, as proposed by Verbart et al. 2017
  160. gD = YD * gmicvnmD ;
  161. * Its maximum in D
  162. maxg = MAXI gD ;
  163.  
  164. * If the Coniglio constraints are requested instead of Verbart
  165. SI Ltab.'CONIGLIO' ;
  166. * Local constraints to be aggregated, as proposed by Coniglio et al. 2018
  167. gD = gD - maxg ;
  168. FINS ;
  169.  
  170. * Their derivatives with respect to Y
  171. dgdYD = gmicvnmD ;
  172.  
  173. * Local constraint aggregation and its derivative with respect to g on D
  174. * ***********************************************************************
  175.  
  176. agg daggdgD = TOPOAGRE tab gD modMD ;
  177.  
  178. * Maximum von Mises stress
  179. * ************************
  180.  
  181. * Compute maximum von Mises stress for on-the-fly display
  182. maxvnm = (maxg + 1.0) * vnmlim ;
  183.  
  184. * **************************************************************
  185. * **************************************************************
  186.  
  187. * Global constraint (G) on D
  188. * **************************
  189.  
  190. SI Ltab.'VERBART' ;
  191. * Approximation of max(g), as proposed by Verbart et al. 2017
  192. G = agg ;
  193. SINO ;
  194. * Global constraint as proposed by Coniglio et al. 2018
  195. G = agg + maxg ;
  196. FINS ;
  197.  
  198. Glst = Glst ET (PROG G) ;
  199.  
  200. * Sensitivity / Gradient / Total derivative of G on D
  201. * ***************************************************
  202.  
  203. * Computing the total derivative of G with respect to X
  204. * (using adjoint vector method)
  205.  
  206. * 1) Partial derivative of G with respect to the physical densities Y on D
  207. * ------------------------------------------------------------------------
  208.  
  209. * ∂G/∂Y = ∂agg/∂g * ∂g/∂Y
  210. dGdYD = daggdgD * dgdYD ;
  211.  
  212. * 2) Partial derivative of G with respect to the displacements U on I
  213. * -------------------------------------------------------------------
  214.  
  215. * ∂micvnm/∂U = ∂micvnm/∂σ_mic * ∂σ_mic/∂ε * ∂ε/∂U
  216. * = ∂((σ_micᵀ*V*σ_mic)**0.5)/∂σ_mic * ∂(D_1 ε)/∂ε * ∂(B*U)/∂U
  217. * = (V*σ_mic)ᵀ / micvnm * D_1 * B
  218.  
  219. * ∂g/∂U = Y * ∂gmicvnm/∂U
  220. * = Y/σvm_lim * ∂micvnm/∂U
  221. * = Y/(σvm_lim*micvnm) * (V * σ_mic)ᵀ * D_1 * B
  222. * = Y/(σvm_lim*micvnm) * Bᵀ * D_1 * V * σ_mic
  223.  
  224. * ∂G/∂U = ∂agg/∂g * ∂g/∂U
  225. * = ∂agg/∂g * Y/(σvm_lim*micvnm) * Bᵀ * D_1 * V * σ_mic
  226.  
  227. * With:
  228. * - B : the strain-displacement matrix
  229. * - D_1 : the full-density stiffness matrix (Y=1)
  230. * - V : the von Mises matrix such that vnm² = σᵀ V σ
  231. * - σ_mic : the microscopic stresses
  232.  
  233. * Remarks:
  234. * 1) Using BSIG instead of Bᵀ produces integrated output.
  235. * Divide by vol1_e for expected values.
  236. * 2) Calculated on I; zero for void elements of D.
  237. * 3) ∂G/∂U is a nodal field. Non-zero values belong to I,
  238. * but can be applied to any mesh containing I.
  239.  
  240. tmp = TOPODVSA micsigI modMI matMI (((REDU daggdgD mshI) * YI) /
  241. (vnmlim * micvnmI * VMI)) ;
  242. dGdUI = BSIG modMI tmp ;
  243.  
  244. * 3) Normalized total derivative of G with respect to the physical densities Y on D
  245. * ---------------------------------------------------------------------------------
  246.  
  247. * Compute the volume-normalized total derivative of G w.r.t. Y,
  248. * via the adjoint method
  249. * dG/dY / vol1_e = (∂G/∂Y + ∂G/∂U * ∂U/∂Y) / vol1_e
  250. NtotdGdYD = TOPOADJO tab dGdYD dGdUI ;
  251.  
  252. * Output normalized constraint sensitivity
  253. nbrG = nbrG + 1 ;
  254. NdGdYDtab.(nbrG) = NtotdGdYD ;
  255. * TODO This line is optional but allows retrieving the name of the N-th constraint in the sensitivity table.
  256. * NdGdXDtab.(CHAI (DIME cst)) = CHAI 'CONTRAINTE_NORMALISEE_SIGMA_VM' ;
  257.  
  258. FINS ;
  259. *FINS ;
  260.  
  261.  
  262. **********************************************************************
  263.  
  264. * Constraint sensitivities with respect to design variables X on D
  265. * ****************************************************************
  266.  
  267. * As Y=X when X is not projected nor filtered, dG/dx_e = dG/dy_e.
  268. * Otherwise Y≠X and we need to calculate dG/dx_e from dG/dy_e:
  269. * dG/dx_e = dG/dy_e * dy_e/dx_e
  270. * = dG/dy_e * dy_e/ds_e * ds_e/dx_e
  271.  
  272. * dG/dy_e / vol1_e = dG/dy_e * dy_e/dx_e / vol1_e
  273. REPE itr nbrG ;
  274. NdGdXDtab.&itr = TOPODYDX tab NdGdYDtab.&itr ;
  275. FIN itr ;
  276.  
  277. * Constraint sensitivities filtering
  278. * **********************************
  279.  
  280. SI Ltab.'FILTRE_SENSIBILITES_CONTRAINTES' ;
  281. REPE itr nbrG ;
  282. tmp = NdGdXDtab.&itr * Wtab.'Y_D' ;
  283. tmp = TOPOFILT tab tmp ;
  284. NdGdXDtab.&itr = tmp /
  285. (BORN Wtab.'Y_D' 'SCAL' 'MINI' tab.'ZERO_DIVISION') ;
  286. FIN itr ;
  287. FINS ;
  288.  
  289. * Output data
  290. * ***********
  291.  
  292. Wtab.'CONTRAINTES' = Glst ;
  293. Wtab.'SENSIBILITES_NORMALISEES_CONTRAINTES_D' = NdGdXDtab ;
  294.  
  295. * In the specific case of stress constraint
  296. SI Ltab.'CONTRAINTE_SIGMA_VM' ;
  297. * Save the maximum von Mises stress
  298. Wtab.'SIGMA_VM_MAX' = maxvnm ;
  299. * Save Microscopic von Mises stresses on I for on-the-fly field
  300. * visualization if TRAC is activated
  301. SI tab.'TRAC' ;
  302. Wtab.'MICROSCOPIC_VM_I' = micvnmI ;
  303. FINS ;
  304. FINS ;
  305.  
  306. FINP ;
  307.  
  308.  
  309.  

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