Retaining mesh groups from cgns file with cs_preprocess

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Oscar
Posts: 25
Joined: Tue Aug 02, 2016 11:38 pm

Retaining mesh groups from cgns file with cs_preprocess

Post by Oscar »

Hello,

First off I'm not sure I understand the terminology employed by code_saturne so forgive me if I confuse things.

I have a mesh in cgns format that I convert to something code_saturne can read by using

Code: Select all

cs_preprocess <cgns_file>
This gives the following output:

Code: Select all

  .------------------------------.
  |                              |
  |   Code_Saturne Preprocessor  |
  |                              |
  `------------------------------'

  code_saturne version 4.0.5   (built Tue 02 Aug 2016 16:26:49 BST)

  CGNS 3.3.0 file format support
  Reading of compressed files ('.gz') with Zlib 1.2.3



Case configuration
------------------

  Date                : Sat 17 Sep 2016 09:52:43 BST
  System              : Linux 2.6.32-573.26.1.el6.x86_64
  Machine             : login-sand6
  Processor           : Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
  Memory              : 131712492
  User                : ow222 (Oscar Wilsby)
  Directory           : /scratch/ow222/codeSaturneWork/AnnularCascade/MESH

  Case name           : preprocess
  Mesh file           : rotor_annular_cascade_ref1.cgns



Reading mesh from file in CGNS format
----------------------
  Mesh file: rotor_annular_cascade_ref1.cgns


  CGNS version       : 2.4
  Base name          : Base
  Physical dimension : 3
  Cell dimension     : 3
  Number of zones    : 1

    Zone 1: "Passage"; type "Unstructured"

      2011878 vertices; 1924224 cells
      (cartesian coordinates, "RealDouble" precision, unit "Null")
      Section  1: "Passage Main";
                   (indices 1 to 1924224, type "HEXA_8")
      Section  2: "HUB";
                   (indices 1924225 to 1984356, type "QUAD_4")
      Section  3: "SHROUD";
                   (indices 1984357 to 2044488, type "QUAD_4")
      Section  4: "INFLOW";
                   (indices 2044489 to 2048520, type "QUAD_4")
      Section  5: "OUTFLOW";
                   (indices 2048521 to 2052168, type "QUAD_4")
      Section  6: "BLADE";
                   (indices 2052169 to 2073288, type "QUAD_4")
      Section  7: "PER1";
                   (indices 2073289 to 2085576, type "QUAD_4")
      Section  8: "PER2";
                   (indices 2085577 to 2097864, type "QUAD_4")

  CGNS boundary condition information:

    Zone 1
      BC  1: "HUB" ("Null" on "FaceCenter")
      BC  2: "SHROUD" ("Null" on "FaceCenter")
      BC  3: "INFLOW" ("Null" on "FaceCenter")
      BC  4: "OUTFLOW" ("Null" on "FaceCenter")
      BC  5: "BLADE" ("Null" on "FaceCenter")
      BC  6: "PER1" ("Null" on "FaceCenter")
      BC  7: "PER2" ("Null" on "FaceCenter")

  Number of vertices                          :  2011878
  Number of faces                             :   173640
  Number of cells                             :  1924224
  Group "HUB"
    Number of faces    :    60132
  Group "SHROUD"
    Number of faces    :    60132
  Group "INFLOW"
    Number of faces    :     4032
  Group "OUTFLOW"
    Number of faces    :     3648
  Group "BLADE"
    Number of faces    :    21120
  Group "PER1"
    Number of faces    :    12288
  Group "PER2"
    Number of faces    :    12288

  Wall-clock time: 0.921560 s; CPU time: 0.727890 s


Done reading mesh
-----------------
  Theoretical mesh size:               124.070 Mb
  Theoretical current memory:          170.117 Mb
  Theoretical peak memory:             315.546 Mb
  Total memory used:                   451.336 Mb

  Domain coordinate extents:

  [-4.00000e-02, -2.38927e-02,  4.00000e-02]
  [-3.14510e-02,  1.43144e-02,  8.00000e-02]
  Number of elements                    quad4 :   173640
  Number of elements                    hexa8 :  1924224



Defining families
-----------------


  Element orientation check.


End of conversion to descending connectivity
--------------------------------------------
  Theoretical mesh size:               289.254 Mb
  Theoretical current memory:          335.302 Mb
  Theoretical peak memory:             865.414 Mb
  Total memory used:                  1016.766 Mb


Main mesh properties
--------------------

  Number of cells:                               1924224
  Number of internal faces:                      5685852
  Number of boundary faces:                       173640
  Number of vertices:                            2011878


Definition of face and cell families
------------------------------------

  Family 1
         Group "BLADE"
  Number of boundary faces :    21120
  Family 2
         Group "HUB"
  Number of boundary faces :    60132
  Family 3
         Group "INFLOW"
  Number of boundary faces :     4032
  Family 4
         Group "OUTFLOW"
  Number of boundary faces :     3648
  Family 5
         Group "PER1"
  Number of boundary faces :    12288
  Family 6
         Group "PER2"
  Number of boundary faces :    12288
  Family 7
         Group "SHROUD"
  Number of boundary faces :    60132
  Family 7
         Default family
         (no group)
  Number of cells          :  1924224
  Number of internal faces :  5685852


Write output for Kernel
-----------------------

  Opening file: mesh_input

  Wrote: "start_block:dimensions"
  Wrote: "n_cells"                         ; Type: "u8"; Size: 1
  Wrote: "n_faces"                         ; Type: "u8"; Size: 1
  Wrote: "n_vertices"                      ; Type: "u8"; Size: 1
  Wrote: "face_vertices_size"              ; Type: "u8"; Size: 1
  Wrote: "n_group_classes"                 ; Type: "i8"; Size: 1
  Wrote: "n_group_class_props_max"         ; Type: "i8"; Size: 1
  Wrote: "n_groups"                        ; Type: "u8"; Size: 1
  Wrote: "group_name_index"                ; Type: "i8"; Size: 8
  Wrote: "group_name"                      ; Type: "c "; Size: 42
  Wrote: "group_class_properties"          ; Type: "i8"; Size: 8
  Wrote: "end_block:dimensions"
  Wrote: "start_block:data"
  Wrote: "face_cells"                      ; Type: "i8"; Size: 11718984
  Wrote: "cell_group_class_id"             ; Type: "i8"; Size: 1924224
  Wrote: "face_group_class_id"             ; Type: "i8"; Size: 5859492
  Wrote: "face_vertices_index"             ; Type: "u8"; Size: 5859493
  Wrote: "face_vertices"                   ; Type: "i8"; Size: 23437968
  Wrote: "vertex_coords"                   ; Type: "r8"; Size: 6035634
  Wrote: "end_block:data"
  Wrote: "EOF"

  Closing file: mesh_input


Time and memory summary
-----------------------

  User CPU time                       (sec)   :        2.72
  System CPU time                     (sec)   :       36.02
  Total time                          (sec)   :       39.28
  Total CPU time / Total time                 :        0.99

Memory use summary:

  Total memory used:                                1016.766 Mb
  Theoretical instrumented dynamic memory:           865.414 Mb


  .-----------------------.
  |                       |
  |  Preprocessor finish  |
  |                       |
  `-----------------------'

Now the groups that are listed (BLADE, INFLOW, OUTFLOW...) are quite useful to be able to select individually from a post processing standpoint in paraview which I usually do (via scripting) by using

Code: Select all

 PVReader.MeshRegions = ['DesiredGroupName']
. I think this can also be done by using the extract block filter (I'm not sure what the difference is so if someone could clarify that would be great!)

However when I try to do this in paraview I can only select "Fluid Domain" and/or "Boundary" and so it seems all the other groups originally present in my mesh have all been lumped into this single "Boundary" group. The things I have tried so far are playing around with the options I can pass to cs_preprocess like

- --grp-cel <keyword>
- --grp-fac <keyword>

but It doesn't make a difference.


Is there a simple way to retain the boundary groups present in my original mesh?
Luciano Garelli
Posts: 282
Joined: Fri Dec 04, 2015 1:42 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Luciano Garelli »

Hello Oscar,

CS by default create the boundary domain with all boundary faces, but you can use the same selection criterion that you use for the BC to write specifics boundaries zones. This is done in the writer of the output control by adding new zones.

I hope that this help you.

Regards,

Luciano
Oscar
Posts: 25
Joined: Tue Aug 02, 2016 11:38 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Oscar »

Hi Luciano,

Thanks I got it to work for one boundary zone, but I was wondering if you could advise how to do it for multiple: In cs_user_postprocess.c I have:

Code: Select all

  if (true) {

    /* De-activate boundary mesh output by redefining it with no writer
       association (default is:
       int n_writers = 1;
       const int writer_ids[] = {-1});
    */

    int n_writers = 2;
    const int writer_ids[] = {-1};

    cs_post_define_surface_mesh(-2,          /* mesh_id of main boundary mesh */
                                "BLADE",  /* mesh name */
                                NULL,        /* interior face selection criteria */
                                "BLADE",     /* boundary face selection criteria */
                                true,        /* add_groups */
                                true,        /* automatic variables output */
                                n_writers,
                                writer_ids);
    cs_post_define_surface_mesh(-2,          /* mesh_id of main boundary mesh */
                                "INFLOW",  /* mesh name */
                                NULL,        /* interior face selection criteria */
                                "INFLOW",     /* boundary face selection criteria */
                                true,        /* add_groups */
                                true,        /* automatic variables output */
                                n_writers,
                                writer_ids);
  }
the problem is I'm not quite sure if I need to define a separate writer for each zone, and how to initialise the writer_ids array.


Kind regards,

Oscar
Luciano Garelli
Posts: 282
Joined: Fri Dec 04, 2015 1:42 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Luciano Garelli »

Hello Oscar,

If I'm not misunderstanding your question you can retain the boundaries group through the the GUI of CS. You have to go to the "Mesh" tab In the "Calculation Control" -> "Output Control" section and there you can use the same selection criteria that you use to set up the boundaries condition. In "Type" you have to choose "Boundary faces" and then you have to select the default writer (results) or you can another writer if you want.

I attach a figure where I select the Hot and Cold boundaries of the heat square cavity,

Regards,

Luciano
Attachments
output4.jpg
Oscar
Posts: 25
Joined: Tue Aug 02, 2016 11:38 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Oscar »

Many thanks for your response - unfortunately I don't use the GUI (I should have specified). Ill continue searching for the correct syntax. Many thanks for your help.

Oscar
Yvan Fournier
Posts: 4075
Joined: Mon Feb 20, 2012 3:25 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Yvan Fournier »

Hello,

In that case, you need to create postprocessing meshes in cs_user_postprocess.c.

When running in "mesh quality control mode", the output mesh is split into several parts based on groups, but when doing a standard run, it is split by default only into the volume and boundary parts.

Regards,

Yvan
Oscar
Posts: 25
Joined: Tue Aug 02, 2016 11:38 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Oscar »

Hi Yvan,

Thanks for your response - could you please provide an example on how to do this. At the moment I have only been able to add one boundary zone to the boundary parts using the code you can see in my message above. I would like to add all of the boundary zones (BLADE, PER1, PER2, INFLOW, OUTFLOW, HUB, SHORUD) as boundary mesh parts.

Kind regards,

Oscar
Yvan Fournier
Posts: 4075
Joined: Mon Feb 20, 2012 3:25 pm

Re: Retaining mesh groups from cgns file with cs_preprocess

Post by Yvan Fournier »

Hello,

Check the Doxygen documentation for cs_post_define_surface_mesh: the first argument is a mesh id, and you need to use a separate id for each additional mesh (using the same id amounts tou redefinition).

Regards,

Yvan

PS: using a MED format output allows keeping all group names in the output, though it also has disadvantages (larger file size and limited to SALOME PARAVIS reader).
Post Reply