~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to examples/3-stratified_junction/case5/cs_user_postprocess.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* Code_Saturne version 2.1.0-alpha1 */
 
3
 
 
4
/*============================================================================
 
5
 *
 
6
 *     This file is part of the Code_Saturne Kernel, element of the
 
7
 *     Code_Saturne CFD tool.
 
8
 *
 
9
 *     Copyright (C) 1998-2011 EDF S.A., France
 
10
 *
 
11
 *     contact: saturne-support@edf.fr
 
12
 *
 
13
 *     The Code_Saturne Kernel is free software; you can redistribute it
 
14
 *     and/or modify it under the terms of the GNU General Public License
 
15
 *     as published by the Free Software Foundation; either version 2 of
 
16
 *     the License, or (at your option) any later version.
 
17
 *
 
18
 *     The Code_Saturne Kernel is distributed in the hope that it will be
 
19
 *     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 
20
 *     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
 *     GNU General Public License for more details.
 
22
 *
 
23
 *     You should have received a copy of the GNU General Public License
 
24
 *     along with the Code_Saturne Kernel; if not, write to the
 
25
 *     Free Software Foundation, Inc.,
 
26
 *     51 Franklin St, Fifth Floor,
 
27
 *     Boston, MA  02110-1301  USA
 
28
 *
 
29
 *============================================================================*/
 
30
 
 
31
/*============================================================================
 
32
 * Define (conforming or non-conforming) mesh joinings.
 
33
 *============================================================================*/
 
34
 
 
35
#if defined(HAVE_CONFIG_H)
 
36
#include "cs_config.h"
 
37
#endif
 
38
 
 
39
/*----------------------------------------------------------------------------
 
40
 * Standard C library headers
 
41
 *----------------------------------------------------------------------------*/
 
42
 
 
43
/*----------------------------------------------------------------------------
 
44
 * BFT library headers
 
45
 *----------------------------------------------------------------------------*/
 
46
 
 
47
#include "bft_mem.h"
 
48
 
 
49
/*----------------------------------------------------------------------------
 
50
 * FVM library headers
 
51
 *----------------------------------------------------------------------------*/
 
52
 
 
53
#include "fvm_writer.h"
 
54
 
 
55
/*----------------------------------------------------------------------------
 
56
 *  Local headers
 
57
 *----------------------------------------------------------------------------*/
 
58
 
 
59
#include "cs_base.h"
 
60
#include "cs_mesh.h"
 
61
#include "cs_selector.h"
 
62
 
 
63
#include "cs_post.h"
 
64
 
 
65
/*----------------------------------------------------------------------------
 
66
 *  Header for the current file
 
67
 *----------------------------------------------------------------------------*/
 
68
 
 
69
#include "cs_prototypes.h"
 
70
 
 
71
/*----------------------------------------------------------------------------*/
 
72
 
 
73
BEGIN_C_DECLS
 
74
 
 
75
/*============================================================================
 
76
 * User function definitions
 
77
 *============================================================================*/
 
78
 
 
79
/*----------------------------------------------------------------------------
 
80
 * Define post-processing writers.
 
81
 *
 
82
 * The default output format and frequency may be configured, and additional
 
83
 * post-processing writers allowing outputs in different formats or with
 
84
 * different format options and output frequency than the main writer may
 
85
 * be defined.
 
86
 *----------------------------------------------------------------------------*/
 
87
 
 
88
void
 
89
cs_user_postprocess_writers(void)
 
90
{
 
91
  /* Every writer has a a strictly positive or negative id. Negative ids
 
92
   * are for predefined writers, positive ids for user writers.
 
93
   * All predefined writers use the settings from writer -1, and
 
94
   * redefining that writer here allows changing from the default or GUI
 
95
   * settings.
 
96
   *
 
97
   * Defining or configuring a writer is done by calling the
 
98
   * cs_post_define_writer() function, whose arguments are:
 
99
   *   writer_id     <-- number of writer to create (< 0 reserved, > 0 for user)
 
100
   *   case_name     <-- associated case name
 
101
   *   dir_name      <-- associated directory name
 
102
   *   fmt_name      <-- associated format name
 
103
   *   fmt_opts      <-- associated format options string
 
104
   *   time_dep      <-- FVM_WRITER_FIXED_MESH if mesh definitions are fixed,
 
105
   *                     FVM_WRITER_TRANSIENT_COORDS if coordinates change,
 
106
   *                     FVM_WRITER_TRANSIENT_CONNECT if connectivity changes
 
107
   *   output_at_end <-- force output at calculation end if not 0
 
108
   *   frequency_n   <-- default output frequency in time-steps, or < 0
 
109
   *   frequency_t   <-- default output frequency in seconds, or < 0
 
110
   *                     (has priority over frequency_n)
 
111
   *
 
112
   * Allowed output format names: "EnSight Gold", "MED", or "CGNS".
 
113
   * (EnSight output is built-in; MED or CGNS are only available if the
 
114
   * code was built with these optional libraries)
 
115
   *
 
116
   * An output options string may contain options (separated by whitespace
 
117
   * or commas) from the following list:
 
118
   *   'text'              (text format, for EnSight)
 
119
   *   'big_endian'        (forces binary EnSight output to 'big-endian' mode)
 
120
   *   'discard_polygons'  (ignore polygon-type faces)
 
121
   *   'discard_polyhedra' (ignore polyhedron-type cells)
 
122
   *   'divide_polygons'   (subdivides polygon-type faces)
 
123
   *   'divide_polyhedra'  (subdivides polyhedron-type cells)
 
124
   *   'split_tensors'     (writes tensors as separate scalars) */
 
125
 
 
126
  /* Default writer time dependency */
 
127
 
 
128
  fvm_writer_time_dep_t   time_dep = FVM_WRITER_FIXED_MESH;
 
129
 
 
130
  /* Default time step or physical time based output frequencies */
 
131
 
 
132
  cs_bool_t  output_at_end = true;
 
133
  int        ntchr = -1;
 
134
  double     frchr = -1.0;
 
135
 
 
136
  /* Default output format and options */
 
137
 
 
138
  const char format_name[] = "EnSight Gold";
 
139
  const char format_options[] = "";
 
140
 
 
141
  /* Define additional writers */
 
142
  /* ------------------------- */
 
143
 
 
144
  ntchr = 5;
 
145
 
 
146
  cs_post_define_writer(1,                            /* writer_id */
 
147
                        "tinf21",                     /* writer name */
 
148
                        "postprocessing",             /* directory name */
 
149
                        "EnSight Gold",               /* format name */
 
150
                        "discard_polygons, discard_polyhedra",
 
151
                        FVM_WRITER_TRANSIENT_CONNECT,
 
152
                        output_at_end,
 
153
                        ntchr,
 
154
                        frchr);
 
155
}
 
156
 
 
157
/*----------------------------------------------------------------------------
 
158
 * Define post-processing meshes.
 
159
 *
 
160
 * The main post-processing meshes may be configured, and additional
 
161
 * post-processing meshes may be defined as a subset of the main mesh's
 
162
 * cells or faces (both interior and boundary).
 
163
 *----------------------------------------------------------------------------*/
 
164
 
 
165
void
 
166
cs_user_postprocess_meshes(void)
 
167
{
 
168
  /* Post-processing meshes may be defined using one of several functions,
 
169
   * whose protypes are defined in cs_post.h; these functions are:
 
170
   *
 
171
   * Functions simplest to use are cs_post_define_volume_mesh() and
 
172
   * cs_post_define_surface_mesh(), which allow defining volume or surface
 
173
   * post-processing meshes using selection criteria.
 
174
   *
 
175
   * parameters for cs_post_define_volume_mesh():
 
176
   *   mesh_id        <-- id of mesh to define (< 0 reserved, > 0 for user)
 
177
   *   mesh_name      <-- associated mesh name
 
178
   *   cell_criteria  <-- selection criteria for cells
 
179
   *   add_groups     <-- if true, add group information if present
 
180
   *   auto_variables <-- if true, automatic output of main variables
 
181
   *   n_writers      <-- number of associated writers
 
182
   *   writer_ids     <-- ids of associated writers
 
183
   *
 
184
   * parameters for cs_post_define_surface_mesh():
 
185
   *   mesh_id         <-- id of mesh to define (< 0 reserved, > 0 for user)
 
186
   *   mesh_name       <-- associated mesh name
 
187
   *   i_face_criteria <-- selection criteria for interior faces
 
188
   *   b_face_criteria <-- selection criteria for boundary faces
 
189
   *   add_groups      <-- if true, add group information if present
 
190
   *   auto_variables  <-- if true, automatic output of main variables
 
191
   *   n_writers       <-- number of associated writers
 
192
   *   writer_ids      <-- ids of associated writers
 
193
   *
 
194
   * If no writer is associated to a mesh, it is not output, and its
 
195
   * construction may be avoided altogether (at least when defined
 
196
   * by one of the above functions).
 
197
   *
 
198
   * More advanced functions are described along with examples below. */
 
199
 
 
200
  /*--------------------------------------------------------------------------*/
 
201
 
 
202
  /* Select interior faces with y = 0. */
 
203
 
 
204
  if (true) {
 
205
 
 
206
    const int n_writers = 2;
 
207
    const int writer_ids[] = {-1};  /* Associate to default writer */
 
208
 
 
209
    /* Select cells with y = 0 */
 
210
    const char *interior_criteria = "plane[0, -1, 0, 0.0, "
 
211
                                    "epsilon = 0.0001]";
 
212
    const char *boundary_criteria = NULL;
 
213
 
 
214
    cs_post_define_surface_mesh(1,               /* mesh id */
 
215
                                "Cut 1",
 
216
                                interior_criteria,
 
217
                                boundary_criteria,
 
218
                                false, /* add_groups */
 
219
                                false, /* auto_variables */
 
220
                                n_writers,
 
221
                                writer_ids);
 
222
 
 
223
  }
 
224
 
 
225
  /*--------------------------------------------------------------------------*/
 
226
 
 
227
  /* Select no cells, will select cells with T < 21 degrees in 'usmpst' */
 
228
 
 
229
  if (true) {
 
230
 
 
231
    const int n_writers = 1;
 
232
    const int writer_ids[] = {1};  /* Associate to writer 1 */
 
233
  
 
234
    cs_post_define_volume_mesh(2,                 /* mesh id */
 
235
                               "celTinf21",
 
236
                               NULL,
 
237
                               false,             /* add_groups */
 
238
                               true,              /* auto_variables */
 
239
                               n_writers,
 
240
                               writer_ids);
 
241
  
 
242
  }
 
243
 
 
244
}
 
245
 
 
246
/*----------------------------------------------------------------------------
 
247
 * Override default frequency or calculation end based output.
 
248
 *
 
249
 * This allows fine-grained control of activation or deactivation,
 
250
 *
 
251
 * parameters:
 
252
 *   nt_max_abs <-- maximum time step number
 
253
 *   nt_cur_abs <-- current time step number
 
254
 *   t_cur_abs  <-- absolute time at the current time step
 
255
 *----------------------------------------------------------------------------*/
 
256
 
 
257
void
 
258
cs_user_postprocess_activate(int     nt_max_abs,
 
259
                             int     nt_cur_abs,
 
260
                             double  t_cur_abs)
 
261
{
 
262
  /* Use the cs_post_activate_writer() function to force the
 
263
   * "active" or "inactive" flag for a specific writer or for all
 
264
   * writers for the current time step.
 
265
 
 
266
   * the parameters for cs_post_activate_writer() are:
 
267
   *   writer_id <-- writer id, or 0 for all writers
 
268
   *   activate  <-- false to deactivate, true to activate */
 
269
 
 
270
  if (false) { /* example: deactivate all output before time step 1000 */
 
271
 
 
272
    if (nt_max_abs < 1000) {
 
273
      int writer_id = 0; /* 0: all writers */
 
274
      cs_post_activate_writer(writer_id, false);
 
275
    }
 
276
 
 
277
  }
 
278
}
 
279
 
 
280
/*============================================================================
 
281
 * Fortran-callable wrapper for user function definitions (do not remove).
 
282
 *============================================================================*/
 
283
 
 
284
/*----------------------------------------------------------------------------
 
285
 * User override of default frequency or calculation end based output.
 
286
 *
 
287
 * Fortran interface:
 
288
 *
 
289
 * subroutine pstusn (ntmabs, ntcabs, ttcabs)
 
290
 * *****************
 
291
 *
 
292
 * integer          ntmabs      : <-- : maximum time step number
 
293
 * integer          ntcabs      : <-- : current time step number
 
294
 * double precision ttcabs      : <-- : absolute time at the current time step
 
295
 *----------------------------------------------------------------------------*/
 
296
 
 
297
void CS_PROCF (pstusn, PSTUSN)
 
298
(
 
299
 const cs_int_t  *ntmabs,
 
300
 const cs_int_t  *ntcabs,
 
301
 const cs_real_t *ttcabs
 
302
)
 
303
{
 
304
  cs_user_postprocess_activate(*ntmabs, *ntcabs, *ttcabs);
 
305
}
 
306
 
 
307
/*----------------------------------------------------------------------------*/
 
308
 
 
309
END_C_DECLS