Creating a Model of a Wrench and its FEM Mesh in ISCAD Using Parametric Sketches - hkroeger/insightcae GitHub Wiki
In this example, a geometrical model of a wrench is created in ISCAD for the purpose of finite element analysis. The meshing is done through ISCAD's gmsh front end and the mesh is stored in Code_Aster compatible MED format. The outline of the wrench is taken from a parametric sketch.
The ISCAD script file is named "jaw_wrench.iscad". It starts with some basic parameters:
SW=8; # wrench size
t=2; # thickness of the wrench
The command for importing a sketch reads:
wrench_outline = Sketch( XY, "jaw_wrench.fcstd", 'sketch', swo=SW+2 );
The first parameter is the datum plane, where the sketch shall be placed. The coordinate planes XY, YZ and XZ are predefined in every model. The second parameter is the name of a sketch input file. Here, the sketch is imported from a FreeCAD model. Alternatively, a DXF file might be used. The third parameter is the name of the sketch inside the FreeCAD model. If a DXF file is to be read, this string should be the name of the layer which contains the sketch. The FreeCAD sketch is regenerated upon import and its parameters can be changed. The parameters to be changed can be appended as a comma-separated list to the arguments of the Sketch command. The LHS is the FreeCAD name of the dimension (has to be set inside FreeCAD, see the image below) and the RHS is an expression of ISCAD variables. The sketch in the current example could look like below:
Once the "Sketch" command is entered in the ISCAD script editor, FreeCAD can be started from within ISCAD by right-clicking on the "Sketch" command and selecting "Edit sketch...". If the sketch file does not yet exist, it will be created.
The next step is to extruded the sketch:
wrench_body = Extrusion(wrench_outline, t*EZ, centered);
The cutout for the screw head is done next by subtracting a tool feature. This tool is created from some boolean operations ("|" means boolean union and the result of "&" is the boolean intersection):
jaw_tool =
Box ( O, SW*EX, 2*t*EZ, -0.75*SW*EY, center xy )
|
(
Cylinder ( -0.5*SW*EY, ax 2*t*EZ, 1.25*SW, centered )
&
Box ( O, SW*EX, 2*t*EZ, -2*SW*EY, center xy )
)
;
Finally, the edges of the "wrench_body" are filleted and the jaw tool is subtracted:
wrench:
Fillet(wrench_body?alledges, 0.9)
-
jaw_tool
;
The last step is to do the meshing. After the geometry creation statements, an optional post processing section can appear in ISCAD scripts. It is started by "@post". In this section, different evaluation procedures may be defined. Here we use a single "gmsh" procedure:
@post
gmsh("wrench.med") << wrench
L =(3 0.5)
linear
faceGroups (
scr = wrench?faces('isCoincident(%0)', jaw_tool?allfaces) @ 0.5
)
volumeGroups (
vscr = wrench?allsolids
)
;
The above procedure calls gmsh to create a mesh file "wrench.med" from the geometry feature "wrench". The mesh size is between 3mm and 0.5mm. When the keyword "linear" appears after the size specification, only linear elements are created. If it is omitted, quadratic elements are used. After that, groups of vertices, edges, faces and/or volumes can be specified for later use in the FEM model. Here, we create a face group from all faces of "wrench" which coincide geometrically with any of the faces of "jaw_tool". These will contain the faces which are potentially in contact with the screw head and may be used in the FEM model for contact conditions or for load application. The group is named "scr" in the resulting MED file. Optionally, a "@" sign followed by a mesh size may be inserted after the group definition. This sets the mesh size on all vertices of the entity to the specified size. Additionally, we need to create a volume group containing all volumes of the model. This determines which part of the model volume is meshed at all.
Once the "@post" section is completed as above, the meshing will be executed on the next model rebuild, if the "Skip Postproc Actions" checkbox is unchecked. Note that it is checked by default. It is also possible to execute iscad in batch mode from the command line ("iscad -b "). Then no GUI will be started, but all statements in the "@post" section are executed.
Once the gmsh procedure was executed by one of these ways, a file "wrench.med" will appear. It can be inspected e.g. by gmsh. The result should look like below and can be used on a Code_Aster FEM analysis: