creating profiles in v7.1.1

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
nvm67
Posts: 2
Joined: Fri Nov 01, 2024 2:16 pm

creating profiles in v7.1.1

Post by nvm67 »

Hi
I am using v7.1.1 and trying to output profiles based on the example provided, however, the profiles directory is created but no files are written in there during runtime.

my domain is a rectangular channel of 0<x<22, 0<y<2, 0<z<0.06 and I want to create y-axis profiles at various x locations.

In cs_user_postprocess.c I first defined additional writer

Code: Select all

 cs_post_define_writer(CS_POST_WRITER_PROFILES,                /* writer_id */
                        "profiles",        /* writer name */
                        "profiles", /* directory name */
                        "plot",           /* format name */
                        "",               /* format options */
                        FVM_WRITER_FIXED_MESH,
                        true,            /* output_at_start */
                        true,            /* output_at_end */
                        1,              /* nt_freq */
                        -1.0);            /* dt_freq */
I then included this function

Code: Select all

void
cs_user_postprocess_probes(void)
{
  /* x vertical profiles; note we declare this array as "static" so that
     its members are garanteed to be present when the _cell_profile_select
     function is called */

  const char *line_defs[]
    = {"12.0", "x12",
       "14.0", "x14",
       "16.0", "x16",
       "18.0", "x18",
       "20.0", "x20"};

  for (int i = 0; i < 5; i++) {

    /* Define profiles */

    const cs_real_t x = atof(line_defs[i*2]);

    const cs_real_t start_coords[3] = {x, 0., 0.03};
    const cs_real_t end_coords[3]   = {x, 1.0, 0.03};

    cs_probe_set_t *pset
      = cs_probe_set_create_from_segment(line_defs[i*2+1],
                                         -1,  /* Automatic sampling */
                                         start_coords,
                                         end_coords);
    cs_probe_set_snap_mode(pset, CS_PROBE_SNAP_VERTEX);
    /* Associate writers */

    const int writer_ids[] = {CS_POST_WRITER_PROFILES};
//    const int writer_ids[] = {3};
    cs_probe_set_associate_writers(pset, 1, writer_ids);
  }

}

Please let me know what I am doing wrong,

Thanks
Yvan Fournier
Posts: 4168
Joined: Mon Feb 20, 2012 3:25 pm

Re: creating profiles in v7.1.1

Post by Yvan Fournier »

Hello,

You also need to tell the probe set which field values to plot :

- Either using cs_user_postprocess_values, as per the example.

- Or calling
cs_probe_set_auto_var(pset, true);
after the probe set creation to simply output all fields output with regular probes (i.e. as set in the GUI).

You can also combine both (i.e. using cs_user_postprocess_values to add output columns for specific values in addition to the "auto" variables).

If you have a single probe set, you can also define if using the GUI (though the "create_from_segment" varant is not available yet in the GUI), choose which variables to output, and simply use cs_postprocess_values to add specific or user-defined outputs (such as normalized/adimensional values, ...).

Also note that version 7.1 has been retired since December 2022. Using v8.0 is recommended instead.

Best regards,

Yvan
Post Reply