More advanced mesh element selection is possible using cs_post_define_volume_mesh_by_func or cs_post_define_surface_mesh_by_func, which allow defining volume or surface meshes using user-defined element lists.
The possibility to modify a mesh over time is limited by the most restrictive writer which is associated with. For instance, if writer 1 allows the modification of the mesh topology (argument time_dep
= FVM_WRITER_TRANSIENT_CONNECT in the call to cs_post_define_writer) and writer 2 allows no modification (time_dep
= FVM_WRITER_FIXED_MESH), a user post-processing mesh associated with writers 1 and 2 will not be modifiable, but a mesh associated with writer 1 only will be modifiable. The modification can be done by using the advanced cs_post_define_volume_mesh_by_func or cs_post_define_surface_mesh_by_func, associated with a user-defined selection function based on time-varying criteria (such as field values being above a given threshold). If the time_dep
argument is set to true
, the mesh will be redefined using the selection function at each output time step for every modifiable mesh.
In the following example, we build a surface mesh containing interior faces separating cells of group "2" from those of group "3", (assuming no cell has both colors), as well as boundary faces of group "4".
This is done by first defining 2 selection functions, whose arguments and behavior match the cs_post_elt_select_t type.
The function for selection of interior faces separating cells of two groups also illustrates the usage of the cs_selector_get_family_list function to build a mask allowing direct checking of this criterion when comparing cells adjacent to a given face:
The function for selection of boundary faces is simpler, as it simply needs to apply the selection criterion for boundary faces:
Given these two functions, the mesh can be defined using the cs_post_define_surface_mesh_by_func function, passing it the user-defined selection functions (actually, function pointers):
A mesh defined through the advanced cs_post_define_surface_mesh_by_func, cs_post_define_volume_mesh_by_func, or cs_post_define_particles_mesh_by_func may vary in time, as long as the matching time_varying
argument is set to true
, and the mesh (or aliases thereof) id only associated to writers defined with the FVM_WRITER_TRANSIENT_CONNECT option. In the case of particles, which always vary in time, this allows also varying the selection (filter) function with time.
In the following example, we build a volume mesh containing cells with values of field named "He_fraction" greater than 0.05.
First, we define the selection function:
Then, we simply define matching volume mesh passing the associated selection function pointer:
The matching function will be called at all time steps requiring output of this mesh.
In cases where a mesh containing polygonal elements is output through a writer configured to divide polygons into triangles (for example when visualization tools do not support polygons, or when highly non convex faces lead to visualization artifacts), it may be useful to extract a mesh containing the edges of the original mesh so as to view the polygon boundaries as an overlay.
In the following example, we build such a mesh (with id 5), based on the faces of a mesh with id 1:
In the below example, edge meshes illustrating various space-filling curves possibilities are output.
First the below functions write the various space-filling curves either in serial or parallel.
Then a fake cell selection function is used to call the writing of the space-filling curves at the correct step.
Finally edge meshes are defined to illustrate the various possibilities.