My Project
programmer's documentation
|
C user functions for optional modification of the mesh. These subroutines are called in all cases.
Several functions are present in the file, each specific to different modification types.
Mesh modifications not available through specialized functions should be defined in cs_user_mesh_modify.
For example, to modify coordinates, the following code can be added:
It is possible to add cells by extruding selected boundary faces. A simplified usage is available through the cs_mesh_extrude_constant, while extruding a mesh with vertex-local extrusion parameters is available through cs_mesh_extrude.
The example which follows illustrates the use of the simplified function.
The example which follows illustrates the use of the advanced function to impose the vector of extrusion.
The example which follows illustrates how to tag the extruded cells with a user defined criteria.
Boundary faces extrusion can also be used to insert boundary layer cells, by first shrinking the mesh around the selected zones so as to accomodate for added cells. The following example shows how this can be done for 2 different zones, using different parameters for each zone. Note that adjacent zones with a different number of inserted layers are possible. Also a positive zone thickness implies a fixed thicknesss, while a negative thickness is interpreted as a ratio relative to the mean adjacent cell size, allowing for automatic and adapted local thickness definition.
Groups of cells, interior, and boundary faces may be created or modified, using the cs_mesh_group_cells_set, cs_mesh_group_i_faces_set, cs_mesh_group_b_faces_set functions to assign a group to selected elements, removing all previous group attributions for those elements, and cs_mesh_group_cells_add, cs_mesh_group_i_faces_add, cs_mesh_group_b_faces_add may be used to add those elements to a group while also keeping previous group information for those elements.
The mesh is not marked as modified by default for this "light" modification, so the user may force this using a modification flag, as in the example here:
The user can also add groups for boundary faces:
Cells may be refined automatically, using templates adapted to each cell type (see cs_mesh_refine.c").
This simply required selecting the cells to refine and whether the refinement should be partially propagated to neighboring cells (conforming) or not.
The following code shows an example of mesh refinement for a given region.
The user function cs_user_mesh_input allows a detailed selection of imported meshes read, reading files multiple times, applying geometric transformations, and renaming groups.
The following code shows an example of mesh reading with no transformation.
A mesh can also be read while its groups are renamed, and its geometry transformed.
The user function cs_user_mesh_save can enable or disable mesh saving. By default, mesh is saved when modified. The following code shows an example of disabled saving.
The cs_user_mesh_warping function allows the user to cut the warped faces of his mesh using the cs_mesh_warping_set_defaults function to define the maximum warped angle.
The smoothing utilities may be useful when the calculation mesh has local defects. The principle of smoothers is to mitigate the local defects by averaging the mesh quality. This procedure can help for calculation robustness or/and results quality. The user function cs_user_mesh_smoothe allows to use different smoothing functions detailed below.
The following code shows an example of use of the cs_mesh_smoother functions, cs_mesh_smoother_fix_by_feature which fixes all boundary vertices that have one of their feature angles less than the maximum feature angle defined by the user and cs_mesh_smoother_unwarp which reduces face warping in the calculation mesh.
Bad cells of a mesh can be tagged based on user-defined geometric criteria. The following example shows how to tag cells that have a volume below a certain value and then post-process the tagged cells. This is done using the cs_user_mesh_bad_cells_tag function.
Conforming joining of possibly non-conforming meshes may be done by the cs_user_join user function. For a simple mesh joining, the cs_join_add subroutine is sufficient.
For a more complex mesh, or a mesh with thin walls which we want to avoid transforming into interior faces, the user can use the cs_join_set_advanced_param function to define a specific mesh joining.
Handling of periodicity can be performed with the cs_user_periodicity function.
The following example illustrates the periodicity of translation case using the cs_join_perio_add_translation subroutine.
The following example illustrates the periodicity of rotation case using the cs_join_perio_add_rotation subroutine.
The following example illustrates a more general case of periodicity which combines different kinds of transformation. The function cs_join_perio_add_mixed is used.
As with the Advanced mesh joining subsection, a more complex periodicity can be defined using the cs_join_set_advanced_param subroutine.
The user function cs_user_mesh_boundary allows insertion of boundaries in the calculation mesh. This function transforms the selected interior faces into boundary faces, on which boundary conditions can (and must) be applied. Vertices are also split so as to be distinct on each side of the boundary.
Boundaries can be directly inserted based on a selection of interior faces, such as shown here:
Boundaries can also be inserted between a set of selected cells and the rest of the mesh. In this case, a mesh group name can be assigned to the added boundary faces.