1 .. _cartesian_algo_page:
3 *********************************
4 Body Fitting 3D meshing algorithm
5 *********************************
7 Body Fitting algorithm generates hexahedrons of a Cartesian grid in
8 the internal part of geometry and polyhedrons and other types of
9 elements at the intersection of Cartesian cells with the geometrical
10 boundary. The algorithm supports construction of
11 :ref:`viscous boundary layers<cartesian_VL_anchor>` (use
12 :ref:`Viscous Layers hypothesis <viscous_layers_anchor>` to define them).
14 .. image:: ../images/cartesian3D_sphere.png
18 A sphere meshed by Body Fitting algorithm
20 The meshing algorithm is as follows.
22 #. Lines of a Cartesian structured grid defined by :ref:`Body Fitting Parameters <cartesian_hyp_anchor>` hypothesis are intersected with the geometry boundary, thus nodes lying on the boundary are found. This step also allows finding out for each node of the Cartesian grid if it is inside or outside the geometry.
23 #. For each cell of the grid, check how many of its nodes are outside of the geometry boundary. Depending on a result of this check
25 * skip a cell, if all its nodes are outside
26 * skip a cell, if it is too small according to **Size Threshold** parameter
27 * add a hexahedron in the mesh, if all nodes are inside
28 * add a polyhedron or another cell type in the mesh, if some nodes are inside and some outside.
30 .. _cartesian_VL_anchor:
32 **Viscous boundary layers** are constructed as follows:
34 * create an offset geometry with offset value equal to full layers thickness by using BRepOffset_MakeOffset OCCT class;
35 * mesh the offset geometry with the Body Fitting algorithm;
36 * create prisms of the layers by projecting boundary nodes of offset geometry onto the boundary of initial geometry.
38 .. note:: Viscous layers can't be constructed on geometry with **shared/internal** faces.
40 To apply the algorithm when you define your mesh, select **Body Fitting** in the list of 3D algorithms and add **Body Fitting Parameters** hypothesis. The following dialog will appear:
42 .. _cartesian_hyp_anchor:
44 Body Fitting Parameters hypothesis
45 ##################################
47 .. image:: ../images/cartesian3D_hyp.png
51 Body Fitting Parameters hypothesis dialog
53 This dialog allows to define
55 * **Name** of the algorithm.
56 * Minimal size of a cell truncated by the geometry boundary. If the size of a truncated grid cell is **Threshold** times less than a initial cell size, then a mesh element is not created.
57 * **Implement Edges** check-box activates incorporation of geometrical edges in the mesh.
59 .. image:: ../images/cartesian_implement_edge.png
63 Implement Edges switched off to the left and on to the right
65 * **Create Faces** check-box activates creation on mesh faces.
66 * **Consider Shared and Internal Faces** check-box activates treatment of faces shared by solids and internal. By default the algorithm considers only outer boundaries of the geometry.
67 * **Apply Threshold to Shared / Internal Faces** check-box activates application of **Threshold** to cells cut by shared and internal faces, that can cause appearance of holes inside the mesh.
68 * **Set Quanta** check-box activates application of **Quanta Value** to replace **polyhedrons** by hexahedrons at the boundary of the geometry.
69 * **Quanta Value** the relation between the volume of a polyhedrons and the equivalent hexahedron at the solid boundary. When **Set Quanta** is checked, those elements are replaced by hexahedrons if the volume of the polyhedron divided by the equivalente hexahedron is bigger than **Quanta**.
70 * **Definition mode** allows choosing how Cartesian structured grid is defined. Location of nodes along each grid axis is defined individually:
72 * You can specify the **Coordinates** of grid nodes. **Insert** button inserts a node at **Step** distance (negative or positive) from the selected node. **Delete** button removes the selected node. Double click on a coordinate in the list enables its edition. **Note** that node coordinates are measured along directions of axes that can differ from the directions of the Global Coordinate System.
73 * You can define the **Spacing** of a grid as an algebraic formula *f(t)* where *t* is a position along a grid axis normalized at [0.0,1.0]. *f(t)* must be non-negative at 0. <= *t* <= 1. The whole extent of geometry can be divided into ranges with their own spacing formulas to apply; a t varies between 0.0 and 1.0 within each **Range**. **Insert** button divides a selected range into two. **Delete** button adds the selected sub-range to the previous one. Double click on a range in the list enables edition of its right boundary. Double click on a function in the list enables its edition.
75 .. note:: The actual grid spacing can slightly differ from the defined one. This is done for the best fitting of polyhedrons and for a better mesh quality on the interval boundaries. For example, if a constant **Spacing** is defined along an axis, the actual grid will fill the shape's dimension L along this axis with round number of equal cells: Spacing_actual = L / round( L / Spacing_defined ).
77 * **Fixed Point** group allows defining an exact location of a grid node in the direction defined by spacing. The following cases are possible:
79 * If all three directions are defined by spacing, there will be a mesh node at the **Fixed Point**.
80 * If two directions are defined by spacing, there will be at least a link between mesh nodes passing through the **Fixed Point**.
81 * If only one direction is defined by spacing, there will be at least an element facet passing through the **Fixed Point**.
82 * If no directions are defined by spacing, **Fixed Point** is disabled.
84 * **Directions of Axes** group allows setting the directions of grid axes.
86 * If **Orthogonal Axes** check-box is activated the axes remain orthogonal during their modification.
87 * Selection buttons enable snapping corresponding axes to direction of a geometrical edge selected in the Object Browser. Edge direction is defined by coordinates of its end points.
88 * **Optimal Axes** button runs an algorithm that tries to set the axes to maximize the number of generated hexahedra.
89 * **Reset** button returns the axes in a default position parallel to the axes of the Global Coordinate System.
94 **See Also** a sample TUI Script of a :ref:`tui_cartesian_algo`.