# Merging Geometry

The steps of the geometry merging algorithm used in CUBIT are outlined below:

1. Check lower order geometry, merge if possible
2. Check topology of current entities
3. Check geometry of current entities
4. If both entities are meshed, check topology of meshes.
5. If geometric topology, geometry, and mesh topology are alike, merge.

Thus, in order for two entities to merge, the entities must correspond geometrically and topologically, and if both are meshed must have topologically equivalent meshes. The geometric correspondence usually comes from constructing the model that way. The topological correspondence can come from that process as well, but also can be accomplished in CUBIT using Imprinting.

If both entities are meshed, they can only be merged if the meshes are topologically identical. This means that the entities must have the same number of each kind of mesh entity, and those mesh entities must be connected in the same way. The mesh on each entity need not have nodes in identical positions. If the node positions are not identical, the position of the nodes on the entity with the lowest ID will be used in the resulting merged mesh.

There are several options for merging geometry in CUBIT.

## Merge geometry automatically

Merge All [Group|Body|Surface|Curve|Vertex] [group_results][tolerance <value>]

All topological entities in the model or in the specified bodies are examined for geometric and topological correspondence, and are merged if they pass the test.

If a specific entity type is specified with the Merge all, only complete entities of that type are merged. For example, if Merge all surface is entered, only vertices which are part of corresponding surfaces being merged; vertices which correspond but which are not part of corresponding surfaces will not be merged. This command can be used to speed up the merging process for large models, but should be used with caution as it can hide problems with the geometry.

## Test for merging in a specified group of geometry

Merge {Group|Body|Surface|Curve|Vertex} <id_range>[With {Group|Body|Surface|Curve|Vertex} <id_range>] [group_results] [force] [tolerance<value>]

All topological entities in the specified entity list, as well as lower order topology belonging to those entities, are examined for merging. This command can be used to prevent merging of entities which correspond and would otherwise be merged, e.g. slide surfaces.

## Force merge specified geometry entities

Merge Vertex <id> with Vertex <id> Force

Merge Curve <id> with Curve <id> Force

Merge Surface <id> with Surface <id> Force

This command results in the specified entities being merged, whether they pass the geometric correspondence test or not. This command should only be used with caution and when merging otherwise fails; instances where this is required should be reported to the CUBIT development team.

## Preventing geometry from merging

Body <id_range> Merge [On | Off]

Volume <id_range> Merge [On | Off]

Surface <id_range> Merge [On | Off]

Curve <id_range> Merge [On | Off]

Vertex <id_range> Merge [On | Off]

These commands provide a method for preventing entities from merging. If merging is set to off for an entity, merging commands (e.g. "merge all") will not merge that entity with any other.

## Other Merge Commands

Set Merge Test BBox {on|OFF}

This is an additional test for merging to see if a pair of surfaces should merge. First, it creates a bounding box for each surface by summing individual bounding boxes of each of the surface's curves. A comparison is then made to see if these two bounding boxes are within tolerance. This can help to weed out any potential incorrect merges that can result from non-tight bounding boxes.

Set Merge Test InternalSurf {on|OFF|spline}

This is an extra check when merging surfaces. A point on one surface, closest to its centroid is found. Another point, closest to this point is found on the other surface. If these two points are not within merge tolerance, the two surfaces will not be merged. If set to on, all surface types will be included in this check. If set with the spline option, then splines are only checked this way; analytic surfaces are excluded. This is another check to prevent incorrect merges from occurring.