## How to deal with CAD-geometry

In general hexahedra-elements perform better than tets but if the mesh should be derived from a cad-geometry it is often more convenient to create a tetrahedra mesh as to modify or rebuild the geometry to make it meshable with hexahedra-elements. The following section gives some hints which alternatives are available:

• The CAD format is supported by a stand alone translator (see the calculix home pages). In this case the user can mesh the surfaces with structured- [14] (elty setname tr3 etc.) or unstructured triangles [15] (elty setname tr3u etc.). The user might modify this surface mesh until he is happy with it. The surface mesh can then be filled with tets created by an external auto-mesher called from within cgx (mesh setname tet). The cgx uses the tet-mesher from NETGEN [4] or TETGEN [5] for this task. The command ”asgn” is used to switch between them.

Therefore cgx can only generate a tet-mesh if one of these programs are accessible. For the full functionallity replace the original ng_vol source file in the NETGEN package with the modified program ng_vol from the cgx-distribution and build it again. This version regards a target element size. Tetgen is able to regard that size unchanged.

• For CAD models in STEP- or IGES-format you may consider to use a tet-mesher like NETGEN [4] which often generates quite nice tet-meshes with very few user interaction. You can read this meshes with cgx and combine them with cgx-geometry and meshes. Then create your boundary conditions etc. You might read the native-netgen format (.vol) instead of abaqus-format because this includes the 2D meshing regions in separate sets which can be used to apply boundary conditions (“cgx -ng file.vol”, see ”Program Parameters”). See “prnt” how to list the available sets.

• A simple step-reader is integrated in cgx (cgx -step filename). It can deal with points and lines. This is sufficient for axis-symmetric structures like a rotor but the experienced user might also use the following approach for more complex geometries: You start with a file containing a 2D-section, subdivide it in mesh-able surfaces and sweep it in the 3rd dimension to create your geometry (see swep). If features exist in the 3rd dimension then this features must be included in the 2D-section. Sweep the 2D-section to the location were the feature starts, then right to the end and at last to the end of the geometry. Delete the unwanted bodies before and after the feature. You might project the sweped sections to a target surface if the feature is shaped in the 3rd dimension (see proj).

Sometimes the geometry consists of several (maybe even identical) parts which are arranged on different positions in space. This is called assembly. When cgx is started with the parameter “-stepsplit” instead of “-step” it will write the single parts to separate directories using their original coordinate systems. The user can prepare meshable geometry or meshes based on them. But he must use the filenames which he finds there. The final meshed assembly can be build afterwards by calling the fbl-file which was written by cgx. This fbl-file contains the original step-commands to position and eventually duplicate the single geometries/meshes from the subdirectories.

The following section describes the process to generate a tet-mesh with cgx based on a cad model:

• Install and use the propper interface program to convert the cad format to fbd format (You find example data (vda,iges,step) in CalculiX/cgx_x.x/examples/cad)
 (ie: vda2fbd halter.vda > halter.fbd).

Remark: In some cases the header of the vda file causes trouble and must be modified to make the program run.

• Start cgx with that file (cgx -a halter.fbd). Usually some warnings appear on the screen but the program will fix that automatically (triggered by the parameter -a). After all geometry has been read the program will merge points and lines to close the volume (body). WARNING: If no body exists the user has to manually merge all line end-points individually for all parts. Otherwhise intentionally unconnected parts could be merged at some locations. If the model consists of only one part a 'merg p all' should work. Finally the line divisions are determined based on default values. Use “plot lc all r 3“ to see the lines in red 3 digit whide with node spacing as defined by the line divisions. The current default values lead to approximatelly 200 elements over the length of the model. The default values are defined in cgx.h, see GTOL_NODE_DIST and GTOL. You may use now the command div in the 'auto' mode to change the element sizes to your needs individually in each relevant region.

• If problems occur the user might start the program with option -b instead of -a (cgx -b halter.fbd). Then no automatic pre-processing is done and the user has to prepare the geometry manually. This commands are executed when starting with -a:
      # merge only points which are referenced by lines
seta LBUF l all
comp LBUF e
merg p LBUF
# delete zero length lines
del l0 all
# set the line divisions
div all auto

The user may use this command sequence when he reads a cad fbd file during run time (“read cadfile.fbd”). See the commands merg, div, qdiv, qlin, comp and rep.

• A default element type was assigned to all surfaces (tr6u) if you had started cgx with parameter -a. You may change the element type with elty. In most cases it is advisable to use this triangles first (tr6u) and not directly tetraeders (te10) because a surface mesh can be interactively improved before the tets are generated. Remark: You can assign tets only to a set holding one or more bodies. The body related surfaces get a preliminary triangle element type assigned as a basis for the tets. If no body exists you may create one with “body ! all”. You assign the tet element type with the “elty” command (elty setname te10).

• All surfaces should be shaded and filled with triangles. This has to be done manually by typing “mesh all” (see mesh) or “rep all” which just calculates the interior shape of the surfaces. In most cases “mesh” is preferable since it does both at the same time. Since the surface meshing of a CAD geometry can be very time consuming a default number of threads is used when the model is opened in the auto mode (cgx -a file). The actual number of threads will be listed when using the command “prnt info”. The user might change this value with the command asgn before he starts meshing. The default is set in cgx.h, see NTHREADS.

• Use then “plus si all” to display the shaded surfaces. If a surface points inwards it is not illuminated and appears only dark grey. Flip the surfaces in a way that its normal direction points outwards. Use ”qflp” abd press the ”a” key to swith to the “auto” mode and then select a correctly oriented surface by pressing key ”s”, all other surfaces will immediatelly use the same orientation (if it's a closed volume). Add now the element faces with ”plus f all“.

• If some surfaces could not be meshed then modify the divisions of the lines of this surfaces (see ”qmsh”, key 'l') and/or chose the structured element type tr6 for this surfaces (see ”qmsh”, key 'x'). Or change the element-size (see ”qmsh”, key 'h' or 't') inside the surfaces. The command ”qmsh” fixes parts of the surface-mesh in a convenient way since this command combines several other ones. For convenient usage of “qmsh” display the surfaces “plot si all“ together with faces “plus f all“ and add the lines with “plus lc all r 3“).

Remark: In some cases surfaces are not meshable when you had combined surfaces with “qmsh”. The referenced NURBS might be too small to cover the whole surface. Without such a related nurbs no unstructured mesh can be created. If structured elements are no solution you may delete the related NURBS from the surface definition with ”qsur” using key 'b'. Then store the surface in a set and create a new NURBS with “nurs ! setname”. The surfaces stored in the set will produce NURBS based on the Coons algorithm [14]. If the surface shape matches a primitive shape you may also use the ”qshp” or ”shpe” command to generate such a shape and assign it to the surface.

• Check the mesh. If the command ”prnt info” lists ”ed:0” then no model edges exist and the mesh is closed and ready to be used for tet meshing. If edges exist then the surface mesh is not closed which means that not all shells have exactly one neighbor at each edge. This free edges exist usually at the location of lines and the problem can often be solved by changing the divsion of the underlying lines. The edges are displayed by default but might be hidden by other entities. To increase the size of the representation up to 10 pixels use ”view ed 10”. This can be seen on figure 14. Then chose the line under one edge with “qmsh” and change the line division to a higher or lower number until the edge disapears. Actually cgx detects this edges after meshing and tries to solve the problem by increasing the division of the related lines incrementally, but only a few times. The remaining lines are stored in set “-EDGE” and can be displayed as well for manual adjustments.

• Generate the tet mesh (“mesh all tet“). A target-size for the tet-elements can be specified if “ng_vol” from the cgx distribution was installed (for example “mesh all tet 2.5“ will define a maximum element-size of “2.5”). If the model consists of several unconnected parts separate them in single sets and mesh one after the other (see seta, qadd, qrem, comp).

• Create sets of nodes, faces or elements to create boundary conditions (if you had not created them already based on the geometry) and export them with ”send”.

• Create the input deck for ccx with an editor and start the calculation.

• Look at the results with cgx (cgx results.frd).

• It should be mentioned that only the set which was used for tet meshing will hold the created tet elements.
• If a te10 meshed body shares surfaces with a he20 meshed body equations connecting tet related nodes which are not used by the hex elements are generated and will be written into the mesh file together with the nodes and elements. But this feature works only if all related bodies are meshed together with just one 'mesh' command. So create and use a set holding all adjacent bodies for use with the 'mesh' command. This feature requires in any case a body for the tet meshed structure. Bodies which do not share common surfaces with the tet body can be meshed in separate steps.
• For cyclic symmetric boundary conditions it is preferable to have the same mesh on both connected surfaces. To archive this the user should not mesh one of this sides. Instead he copies the elements of the meshed side to the location of the un-meshed side (see ”copy”). Then he flips the orientation of this elements (see ”flip” option 'e') and merges the nodes in that region (usually just ”merg n all”). Now the tet mesh can be generated.
• Sometimes a surface is not meshable because a line runs right into it (a sliver, see figure 15). The following commands can be used to remove it:
  qlin (select the lines with 'a', 'x')
qpnt (select the line endpoint 'p', in the figure marked with
DL2M and place it over the other endpoint 'p')
The line(s) are now deleted. Often such a surface is only
meshable with a regular mesh (tr6), so change the type
and mesh then:
qmsh (select the surface 's' and change the type 'x' and mesh
'm')