* TOPOSURF PROCEDUR FD218221 21/04/14 21:15:09 10965 ************************************************************************ ** Extraction procedure of a smoothed surface from a topology ** ** Author: ** Guenhael Le Quilliec (LaMe - Polytech Tours) ** ** Version: ** 3.1 2020/04/13 Updated to make it compatible with thermic models ** and fix an issue when OPTI ELEM is not defined ** 3.0 2018/01/29 Updated to make it independant of TOPOPTIM version, ** fix some issues with PYR5 and PRI6 elements, ** compatibility with quadratic elements, ** the model is no longer an input argument, ** all input arguments are now provided in a table ** 2.0 2018/01/26 Updated to make it compatible with TOPOPTIM V2.1 ** 1.0 2016/12/13 Original version compatible with TOPOPTIM V1.0 ************************************************************************ ********************************************************************** * INPUT * ********************************************************************** * Topology Topo0 = tab0.'TOPOLOGIE' ; * Model Mod0 = tab0.'MODELE' ; * Filter rate tab0.'TAUX_FILTRAGE' = 1 ; FINS ; Filter0 = tab0.'TAUX_FILTRAGE' ; * Isovalue tab0.'ISOVALEUR' = 0.5 ; FINS ; Iso0 = tab0.'ISOVALEUR' ; * Default minimum size of the output surface elements tab0.'ELIMINATION' = 1.0e-6 ; FINS ; Elim0 = tab0.'ELIMINATION' ; * Orientation of the output surface will be applied by default tab0.'ORIENTATION' = VRAI ; FINS ; Orie0 = tab0.'ORIENTATION' ; * Default value of the extra thickness * This value should be very low compared to the element size * when the domain is not convex. * If not, Enve1 might be wrong and GRAD won't work tab0.'SUREPAISSEUR' = 1.0e-3 ; FINS ; Shift0 = tab0.'SUREPAISSEUR' ; * Default value of the thickness of the output mesh when the input * model is 2D tab0.'EPAISSEUR' = 1.0 ; FINS ; Thick0 = tab0.'EPAISSEUR' ; ********************************************************************** * PREPROCESSING * ********************************************************************** * Mesh * Types of elements * If the model is mechanical * Create a random material * Unitary field * Volume of each element SINO ; * Random mechanical model * Create a random material * Unitary field * Volume of each element * Express the input topology element field at the barycenters of the * elements of the model Mod0 FINS ; * Make sure that the topology field is not composed of zones where * the values are constant so that to avoid problems with the function * POIN 'SUPE' * If the mesh is quadratic * Change it to linear * Update types of elements * Create a random model * Update the random material * Update the unitary field * Update the volume of each element * Express the input topology element field at the barycenters of the * elements of the model Mod0 FINS ; * Filtering the topology field SI (Filter0 > 0) ; REPE Loop1 Filter0 ; Mod0 'GRAVITE' ; FIN Loop1 ; FINS ; * Node topology field * Save the options 'DIME', 'MODE', 'ELEM' * 2D Topology * TODO Make it compatible with 3D in case of shell elements * Switch to 2D * If the reasult has to stay in 2D SI ((ABS Thick0) < 1.0e-9) ; Type3D = FAUX ; * Change option 'ELEM' to TRI3 * Change the element type of the mesh * Domain boundary * Shifted boundary Norm0 ; * External layer of elements * Add a field for the shifted boundary Ch0 = Ch0 ET * New model * Element field * Extract the iso surface * Fuse the nodes ELIM Surf0 Elim0 ; * If the surface has to be oriented SI Orie0 ; * Fuse any superposed element * Considered element SI (N1 > N2) ; N0 = N2 ; N2 = N1 ; N1 = N0 ; FINS ; FINS ; FIN Loop1 ; Surf0 = Surf0 ET Surf1.(Ind0.&Loop1) ; FIN Loop1 ; * Create the gradient field giving the orientation -1.0 'NATURE' 'DIFFUS') ; * Centers of mass SI (&Loop1 NEG 1) ; SINO ; FINS ; FIN Loop1 ; * Projection of the gradient on the centers of mass * Initialization of the loop on each elements Inv0 = (0.0 0.0) ET (0.0 0.0) ; * Loop on each element of the surface * Considered element * Compute the normal direction of the element * Center of mass * Desired orientation G0 = (G1 G2) ; * Add the element to inverse Inv0 = Inv0 ET Elem0 ; FINS ; FIN Loop1 ; * If there are some elements to invert FINS ; FINS ; * Give information about the output mesh quality VERM Surf0 ; SINO ; Type3D = VRAI ; * Force the option 'DIME' to 3D Dime0 = 3 ; * Switch to 3D * Change option 'ELEM' to CUB8 * Create the second side of the 3D mesh from the 2D mesh * Create the 3D mesh * Create the 3D topology field Ch0 = Ch0 ET ChR0 ; * Create the 3D model FINS ; SINO ; Type3D = VRAI ; FINS ; * 3D Topology SI Type3D ; * Change option 'ELEM' to CUB8 * Domain boundary * Normal direction on the domain boundary * Partitionate the surfaces NbPart0 = 32 ; NbPart0 = 16 ; FINS ; NbPart0 = 8 ; FINS ; * Since PART does not always respect NbPart0, we redefine it REPE Loop1 NbPart0 ; QUIT Loop1 ; FINS ; NbPart0 = NbPart0 - 1 ; FIN Loop1 ; * External layer of elements * Loop on each entry of PEnve0 REPE Loop1 NbPart0 ; SI (&Loop1 > 1) ; Enve1 = Enve1 ET PEnve1 ; ELIM Enve1 PEnve1 Elim0 ; SINO ; Enve1 = PEnve1 ; FINS ; FIN Loop1 ; Layer0 = ET Layer0 ; * Add a field for the shifted boundary Ch0 = Ch0 ET * Create a mesh that will be compatible with ISOV IsoMsh0 = Msh0 ET Layer0 ; SI ((EGA Type1 'TET4') OU (EGA Type1 'CUB8')) ; SINO ; * Using CHAN 'TET4' is not a good option as the edges * of the new elements won't necessary share the edges * of the neigbor elements and this may create holes * after using ISOV. * IsoMail1.&Loop1 = CHAN TET4 (IsoMsh0 ELEM Type1) ; * We change incompatible elements with ISOV by CUB8 * **** SI (EGA Type1 PRI6) ; * Loop on each element * Considered element * Nodes of the element * Manualy change this PRI6 by a CUB8 Volu1 = Volu1 ET FIN Loop2 ; FINS ; SI (EGA Type1 PYR5) ; * Loop on each element * Considered element * Nodes of the element * Manualy change this PYR5 by a CUB8 Volu1 = Volu1 ET FIN Loop2 ; FINS ; IsoMail1.&Loop1 = Volu1 ; * **** FINS ; FIN Loop1 ; IsoMsh0 = ET IsoMail1 ; * New model * Element field * Extract the iso surface * Change the surface to TRI3 SI (EGA Type1 'TRI3') ; SINO ; SI (NEG Type1 'POI1') ; FINS ; FINS ; FIN Loop1 ; Surf0 = ET Surf1 ; * Fuse the nodes ELIM Surf0 Elim0 ; * Remove any elements with fused nodes FINS ; FIN Loop1 ; FINS ; * If the surface has to be oriented SI Orie0 ; * Fuse any superposed element * Considered element FINS ; FIN Loop1 ; Surf0 = Surf0 ET Surf1.(Ind0.&Loop1) ; FIN Loop1 ; * Create the gradient field giving the orientation * Centers of mass SI (&Loop1 NEG 1) ; SINO ; FINS ; FIN Loop1 ; * Projection of the gradient on the centers of mass * Initialization of the loop on each elements Inv0 = (0.0 0.0 0.0) ET (0.0 0.0 0.0) ; * Loop on each element of the surface * Considered element * Compute the normal direction of the element * Center of mass * Desired orientation G0 = (G1 G2 G3) ; * Add the element to inverse Inv0 = Inv0 ET Elem0 ; FINS ; FIN Loop1 ; * If there are some elements to invert FINS ; FINS ; * Give information about the output mesh quality VERM Surf0 ; FINS ; * Restore the initial options SI (NEG ElemOpt0 ' ') ; FINS ; FINP Surf0 ;
© Cast3M 2003 - Tous droits réservés.
Mentions légales