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

« back to all changes in this revision

Viewing changes to preprocessor/pre-post/ecs_pre_ccm.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*============================================================================
 
2
 * Read mesh from STAR-CCM+ format file
 
3
 *============================================================================*/
 
4
 
 
5
/*
 
6
  This file is part of Code_Saturne, a general-purpose CFD tool.
 
7
 
 
8
  Copyright (C) 1998-2011 EDF S.A.
 
9
 
 
10
  This program is free software; you can redistribute it and/or modify it under
 
11
  the terms of the GNU General Public License as published by the Free Software
 
12
  Foundation; either version 2 of the License, or (at your option) any later
 
13
  version.
 
14
 
 
15
  This program is distributed in the hope that it will be useful, but WITHOUT
 
16
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
17
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
18
  details.
 
19
 
 
20
  You should have received a copy of the GNU General Public License along with
 
21
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
22
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
23
*/
 
24
 
 
25
/*----------------------------------------------------------------------------*/
 
26
 
 
27
#include "cs_config.h"
 
28
 
 
29
#if defined(HAVE_CCM)
 
30
 
 
31
/*----------------------------------------------------------------------------
 
32
 * Standard C library headers
 
33
 *----------------------------------------------------------------------------*/
 
34
 
 
35
#include <assert.h>
 
36
#include <math.h>
 
37
#include <stdlib.h>
 
38
#include <string.h>
 
39
 
 
40
/*----------------------------------------------------------------------------
 
41
 * Local headers
 
42
 *----------------------------------------------------------------------------*/
 
43
 
 
44
#include "ecs_def.h"
 
45
#include "ecs_elt_typ_liste.h"
 
46
#include "ecs_mem.h"
 
47
#include "ecs_tab.h"
 
48
 
 
49
#include "ecs_descr.h"
 
50
#include "ecs_descr_chaine.h"
 
51
#include "ecs_maillage.h"
 
52
#include "ecs_maillage_priv.h"
 
53
 
 
54
/*----------------------------------------------------------------------------
 
55
 *  Fichiers `include' visibles du  paquetage courant
 
56
 *----------------------------------------------------------------------------*/
 
57
 
 
58
#include "ecs_maillage_pre.h"
 
59
 
 
60
/*----------------------------------------------------------------------------
 
61
 *  Header for the current file
 
62
 *----------------------------------------------------------------------------*/
 
63
 
 
64
#include "ecs_pre_ccm.h"
 
65
 
 
66
/*----------------------------------------------------------------------------*/
 
67
 
 
68
#ifdef __cplusplus
 
69
extern "C" {
 
70
#endif
 
71
 
 
72
#include <libccmio/ccmio.h>
 
73
#include <libccmio/ccmioversion.h>
 
74
 
 
75
#ifdef __cplusplus
 
76
}
 
77
#endif
 
78
 
 
79
/*=============================================================================
 
80
 * Local Macro Definitions
 
81
 *============================================================================*/
 
82
 
 
83
#if (kCCMIOVersion == 20601)
 
84
typedef CCMIOSize CCMIOSize_t;
 
85
#endif
 
86
 
 
87
/*=============================================================================
 
88
 * Local Type Definitions
 
89
 *============================================================================*/
 
90
 
 
91
/* Vertices definition */
 
92
 
 
93
typedef struct {
 
94
  size_t           n_nodes; /* Number of vertices */
 
95
  ecs_int_t       *id;      /* Vertex labels */
 
96
  ecs_coord_t     *coord;   /* Coordinates (interlaced) */
 
97
} _nodes_t;
 
98
 
 
99
 
 
100
/* Face definitions (boundary and internal) */
 
101
 
 
102
typedef struct {
 
103
  size_t        n_faces;        /* Number of */
 
104
  ecs_int_t    *nbr_n;          /* Number of vertices/face */
 
105
  size_t        taille_connect; /* Connectivity size */
 
106
  ecs_int_t    *connect;        /* Vertices connectivity */
 
107
  ecs_int_t    *icel1;          /* Cell on positive face side */
 
108
  ecs_int_t    *icel2;          /* Cell on negative face side */
 
109
  ecs_int_t    *icoul;          /* Face colors */
 
110
} _faces_t;
 
111
 
 
112
/* Cell definitions */
 
113
 
 
114
typedef struct {
 
115
  size_t           n_cells;    /* Number of cells */
 
116
  ecs_int_t       *id;         /* Cell ids */
 
117
  ecs_int_t       *icoul;      /* Cell colors (types) */
 
118
} _cells_t;
 
119
 
 
120
/*============================================================================
 
121
 * Private function definitions
 
122
 *============================================================================*/
 
123
 
 
124
/*----------------------------------------------------------------------------
 
125
 * Read vertex data.
 
126
 *----------------------------------------------------------------------------*/
 
127
 
 
128
static void
 
129
_read_vertices(CCMIOID   vertices,
 
130
               _nodes_t *nodes)
 
131
{
 
132
  unsigned int i;
 
133
  float scale;
 
134
  double *verts_coo;
 
135
  CCMIOID map_id;
 
136
#if (kCCMIOVersion == 20601)
 
137
  int dims = 1;
 
138
  CCMIOSize n_vertices = 0, size;
 
139
#else
 
140
  CCMIOSize_t dims = 1, n_vertices = 0, size;
 
141
#endif
 
142
  int *map_data;
 
143
  CCMIOError err = kCCMIONoErr;
 
144
 
 
145
  /* Get description */
 
146
 
 
147
  CCMIOEntityDescription(&err, vertices, &size, NULL);
 
148
 
 
149
  if (err == kCCMIONoErr && size > 0) {
 
150
    char *s_descr;
 
151
    ECS_MALLOC(s_descr, size + 1, char);
 
152
    CCMIOEntityDescription(&err, vertices, &size, s_descr);
 
153
    if (err == kCCMIONoErr)
 
154
      printf(_("\n  Vertex coordinates set: %s\n"), s_descr);
 
155
    ECS_FREE(s_descr);
 
156
  }
 
157
 
 
158
  /* Read data */
 
159
 
 
160
  CCMIOEntitySize(&err, vertices, &n_vertices, NULL);
 
161
  if (err != kCCMIONoErr)
 
162
    ecs_error(__FILE__, __LINE__, 0,
 
163
              _("Error %d reading vertex information in STAR-CCM+ file."),
 
164
              (int)err);
 
165
 
 
166
  nodes->n_nodes = (ecs_int_t)n_vertices;
 
167
 
 
168
  ECS_MALLOC(verts_coo, 3*nodes->n_nodes, double);
 
169
  ECS_MALLOC(map_data, nodes->n_nodes, int);
 
170
 
 
171
  CCMIOReadVerticesd(&err, vertices, &dims, &scale, &map_id, verts_coo,
 
172
                     0, n_vertices);
 
173
  CCMIOReadMap(&err, map_id, map_data, 0, n_vertices);
 
174
 
 
175
  /* Transfer to local node structure */
 
176
 
 
177
  ECS_MALLOC(nodes->id, nodes->n_nodes, ecs_int_t);
 
178
  ECS_MALLOC(nodes->coord, 3*nodes->n_nodes, ecs_coord_t);
 
179
 
 
180
  for (i = 0; i < n_vertices; i++) {
 
181
 
 
182
    nodes->id[i] = map_data[i];
 
183
 
 
184
    nodes->coord[dims*i  ] = scale*verts_coo[dims*i];
 
185
    nodes->coord[dims*i+1] = scale*verts_coo[dims*i+1];
 
186
    nodes->coord[dims*i+2] = scale*verts_coo[dims*i+2];
 
187
 
 
188
  }
 
189
 
 
190
  ECS_FREE(map_data);
 
191
  ECS_FREE(verts_coo);
 
192
}
 
193
 
 
194
/*----------------------------------------------------------------------------
 
195
 * Read cell data.
 
196
 *----------------------------------------------------------------------------*/
 
197
 
 
198
static void
 
199
_read_cells(CCMIOID   topology,
 
200
            _cells_t *cells)
 
201
{
 
202
  unsigned int i;
 
203
 
 
204
  CCMIOID map_id, id;
 
205
  CCMIOSize_t n_cells;
 
206
  CCMIOError err = kCCMIONoErr;
 
207
 
 
208
  int *map_data;
 
209
  int *cell_type;
 
210
 
 
211
  static const int k_cell_inc = 4;
 
212
 
 
213
  CCMIOGetEntity(&err, topology, kCCMIOCells, 0, &id);
 
214
  CCMIOEntitySize(&err, id, &n_cells, NULL);
 
215
 
 
216
  ECS_MALLOC(cell_type, n_cells, int);
 
217
  ECS_MALLOC(map_data, n_cells, int);
 
218
 
 
219
  for (i = 0;  i < n_cells;  i += k_cell_inc) {
 
220
    CCMIOReadCells(&err, id, &map_id, &cell_type[i], i, i + k_cell_inc);
 
221
    CCMIOReadMap(&err, map_id, &map_data[i], i, i + k_cell_inc);
 
222
  }
 
223
 
 
224
  /* Transfer to local cell structure */
 
225
 
 
226
  cells->n_cells = (ecs_int_t) n_cells;
 
227
 
 
228
  ECS_MALLOC(cells->id, n_cells, ecs_int_t);
 
229
  ECS_MALLOC(cells->icoul, n_cells, ecs_int_t);
 
230
 
 
231
  for (i = 0; i < n_cells; i++) {
 
232
    cells->id[i] = map_data[i];
 
233
    cells->icoul[i] = cell_type[i];
 
234
  }
 
235
 
 
236
  ECS_FREE(map_data);
 
237
  ECS_FREE(cell_type);
 
238
}
 
239
 
 
240
/*----------------------------------------------------------------------------
 
241
 * Read mesh.
 
242
 *----------------------------------------------------------------------------*/
 
243
 
 
244
static void
 
245
_read_mesh(CCMIOID   vertices,
 
246
           CCMIOID   topology,
 
247
           _nodes_t *nodes,
 
248
           _faces_t *i_faces,
 
249
           _faces_t *b_faces,
 
250
           _cells_t *cells)
 
251
{
 
252
  size_t i;
 
253
  int j;
 
254
  CCMIOID map_id, id;
 
255
  CCMIOError err = kCCMIONoErr;
 
256
  CCMIOSize_t n_faces, size;
 
257
  int *face_nverts; int *face_cells;
 
258
  size_t pos, cpt;
 
259
 
 
260
  _read_vertices(vertices,
 
261
                 nodes);
 
262
 
 
263
  _read_cells(topology,
 
264
              cells);
 
265
 
 
266
  /* Read the topology description. */
 
267
 
 
268
  CCMIOEntityDescription(&err, topology, &size, NULL);
 
269
 
 
270
  if (err == kCCMIONoErr && size > 0) {
 
271
    char *s_descr;
 
272
    ECS_MALLOC(s_descr, size + 1, char);
 
273
    CCMIOEntityDescription(&err, topology, &size, s_descr);
 
274
    if (err == kCCMIONoErr)
 
275
      printf(_("  Face-based topology: %s\n"), s_descr);
 
276
    ECS_FREE(s_descr);
 
277
  }
 
278
 
 
279
  /* Read the internal faces. */
 
280
 
 
281
  CCMIOGetEntity(&err, topology, kCCMIOInternalFaces, 0, &id);
 
282
 
 
283
  CCMIOEntityDescription(&err, id, &size, NULL);
 
284
 
 
285
  if (err == kCCMIONoErr && size > 0) {
 
286
    char *s_descr;
 
287
    ECS_MALLOC(s_descr, size + 1, char);
 
288
    CCMIOEntityDescription(&err, id, &size, s_descr);
 
289
    if (err == kCCMIONoErr)
 
290
      printf(_("    Faces: %s\n"), s_descr);
 
291
    ECS_FREE(s_descr);
 
292
  }
 
293
 
 
294
  /* Read internal faces data */
 
295
 
 
296
  CCMIOEntitySize(&err, id, &n_faces, NULL);
 
297
 
 
298
  ECS_MALLOC(face_cells, 2*n_faces, int);
 
299
 
 
300
  CCMIOReadFaces(&err, id, kCCMIOInternalFaces, NULL, &size, NULL,
 
301
                 kCCMIOStart, kCCMIOEnd);
 
302
 
 
303
  if (err != kCCMIONoErr)
 
304
    ecs_error(__FILE__, __LINE__, 0,
 
305
              _("Error %d reading faces information in STAR-CCM+ file."),
 
306
              (int)err);
 
307
 
 
308
  ECS_MALLOC(face_nverts, size, int);
 
309
 
 
310
  CCMIOReadFaces(&err, id, kCCMIOInternalFaces, &map_id, NULL, face_nverts,
 
311
                 kCCMIOStart, kCCMIOEnd);
 
312
 
 
313
  if (err != kCCMIONoErr)
 
314
    ecs_error(__FILE__, __LINE__, 0,
 
315
              _("Error %d reading internal faces in STAR-CCM+ file."),
 
316
              (int)err);
 
317
 
 
318
  CCMIOReadFaceCells(&err, id, kCCMIOInternalFaces, face_cells,
 
319
                     kCCMIOStart, kCCMIOEnd);
 
320
 
 
321
  if (err != kCCMIONoErr)
 
322
    ecs_error(__FILE__, __LINE__, 0,
 
323
              _("Error %d reading face->cell connectivity in STAR-CCM+ file."),
 
324
              (int)err);
 
325
 
 
326
  /* Map data is not used here; if it were necessary, we would have:
 
327
   *
 
328
   * int *map_data;
 
329
   *
 
330
   * ECS_MALLOC(map_data, n_faces, int);
 
331
   * CCMIOReadMap(&err, map_id, map_data, kCCMIOStart, kCCMIOEnd);
 
332
   * ECS_FREE(map_data);
 
333
   */
 
334
 
 
335
  if (err != kCCMIONoErr)
 
336
    ecs_error(__FILE__, __LINE__, 0,
 
337
              _("Error %d reading map in STAR-CCM+ file."),
 
338
              (int)err);
 
339
 
 
340
  /* Transfer to local face structure */
 
341
 
 
342
  i_faces->n_faces = n_faces;
 
343
  i_faces->taille_connect = size;
 
344
 
 
345
  ECS_MALLOC(i_faces->nbr_n, n_faces, ecs_int_t);
 
346
 
 
347
  ECS_MALLOC(i_faces->icel1, n_faces, ecs_int_t);
 
348
  ECS_MALLOC(i_faces->icel2, n_faces, ecs_int_t);
 
349
  ECS_MALLOC(i_faces->icoul, n_faces, ecs_int_t);
 
350
 
 
351
  i_faces->taille_connect = size - n_faces;
 
352
 
 
353
  ECS_MALLOC(i_faces->connect, i_faces->taille_connect, ecs_int_t);
 
354
 
 
355
  for (i = 0, pos = 0, cpt = 0; i < i_faces->n_faces; i++) {
 
356
 
 
357
    i_faces->nbr_n[i] = face_nverts[pos];
 
358
    i_faces->icel1[i] = face_cells[2*i];
 
359
    i_faces->icel2[i] = face_cells[2*i+1];
 
360
    assert(i_faces->icel1[i] > 0);
 
361
    assert(i_faces->icel2[i] > 0);
 
362
    i_faces->icoul[i] = 0;
 
363
 
 
364
    for (j = 0; j < i_faces->nbr_n[i]; j++)
 
365
      i_faces->connect[cpt + j] = (ecs_int_t) face_nverts[pos + j + 1];
 
366
 
 
367
    cpt += i_faces->nbr_n[i];
 
368
    pos += face_nverts[pos] + 1;
 
369
  }
 
370
 
 
371
  ECS_FREE(face_nverts);
 
372
  ECS_FREE(face_cells);
 
373
 
 
374
  /* Read the boundary faces */
 
375
 
 
376
  {
 
377
#if (kCCMIOVersion == 20601)
 
378
    int _index = 0;
 
379
#else
 
380
    CCMIOSize_t _index = 0;
 
381
#endif
 
382
    int i_beg = 0;
 
383
    int i_beg_c = 0;
 
384
 
 
385
    b_faces->n_faces = 0;
 
386
    b_faces->taille_connect = 0;
 
387
 
 
388
    while (   CCMIONextEntity(NULL, topology, kCCMIOBoundaryFaces, &_index, &id)
 
389
           == kCCMIONoErr) {
 
390
 
 
391
      int boundary_id;
 
392
 
 
393
      CCMIOEntityDescription(&err, id, &size, NULL);
 
394
 
 
395
      if (err == kCCMIONoErr && size > 0) {
 
396
        char *s_descr;
 
397
        ECS_MALLOC(s_descr, size + 1, char);
 
398
        CCMIOEntityDescription(&err, id, &size, s_descr);
 
399
        if (err == kCCMIONoErr)
 
400
          printf(_("    Faces: %s\n"), s_descr);
 
401
        ECS_FREE(s_descr);
 
402
      }
 
403
 
 
404
      CCMIOEntitySize(&err, id, &n_faces, NULL);
 
405
 
 
406
      ECS_REALLOC(face_cells, 2*n_faces, int);
 
407
 
 
408
      CCMIOReadFaces(&err, id, kCCMIOBoundaryFaces, NULL, &size, NULL,
 
409
                     kCCMIOStart, kCCMIOEnd);
 
410
 
 
411
      ECS_MALLOC(face_nverts, size, int);
 
412
 
 
413
      CCMIOReadFaces(&err, id, kCCMIOBoundaryFaces, &map_id, NULL,
 
414
                     face_nverts, kCCMIOStart, kCCMIOEnd);
 
415
      CCMIOReadFaceCells(&err, id, kCCMIOBoundaryFaces, face_cells,
 
416
                         kCCMIOStart, kCCMIOEnd);
 
417
 
 
418
      /* Map data is not used here; if it were necessary, we would have:
 
419
       *
 
420
       * int *map_data;
 
421
       *
 
422
       * ECS_MALLOC(map_data, n_faces, int);
 
423
       * CCMIOReadMap(&err, map_id, map_data, kCCMIOStart, kCCMIOEnd);
 
424
       * ECS_FREE(map_data);
 
425
      */
 
426
 
 
427
      CCMIOGetEntityIndex(&err, id, &boundary_id);
 
428
 
 
429
      /* Transfer to local face structure */
 
430
 
 
431
      b_faces->n_faces += n_faces;
 
432
      b_faces->taille_connect += (size - n_faces);
 
433
 
 
434
      if (i_beg == 0) {
 
435
        ECS_MALLOC(b_faces->nbr_n, b_faces->n_faces, ecs_int_t);
 
436
        ECS_MALLOC(b_faces->icel1, b_faces->n_faces, ecs_int_t);
 
437
        ECS_MALLOC(b_faces->icel2, b_faces->n_faces, ecs_int_t);
 
438
        ECS_MALLOC(b_faces->connect, b_faces->taille_connect, ecs_int_t);
 
439
        ECS_MALLOC(b_faces->icoul, b_faces->n_faces, ecs_int_t);
 
440
      }
 
441
      else {
 
442
        ECS_REALLOC(b_faces->nbr_n, b_faces->n_faces, ecs_int_t);
 
443
        ECS_REALLOC(b_faces->icel1, b_faces->n_faces, ecs_int_t);
 
444
        ECS_REALLOC(b_faces->icel2, b_faces->n_faces, ecs_int_t);
 
445
        ECS_REALLOC(b_faces->connect, b_faces->taille_connect, ecs_int_t);
 
446
        ECS_REALLOC(b_faces->icoul, b_faces->n_faces, ecs_int_t);
 
447
      }
 
448
 
 
449
      for (i = 0, pos = 0, cpt = 0; i < (size_t)n_faces; i++) {
 
450
 
 
451
        b_faces->nbr_n[i_beg + i] = face_nverts[pos];
 
452
        b_faces->icel1[i_beg + i] = face_cells[i];
 
453
        b_faces->icel2[i_beg + i] = -1;
 
454
        assert(b_faces->icel1[i_beg + i] > 0);
 
455
        b_faces->icoul[i_beg + i] = boundary_id;
 
456
 
 
457
        for (j = 0; j < b_faces->nbr_n[i_beg + i]; j++)
 
458
          b_faces->connect[i_beg_c + cpt + j] = face_nverts[pos + j + 1];
 
459
 
 
460
        cpt += b_faces->nbr_n[i_beg + i];
 
461
        pos += face_nverts[pos] + 1;
 
462
      }
 
463
 
 
464
      i_beg += n_faces;
 
465
      i_beg_c += (size - n_faces);
 
466
 
 
467
      ECS_FREE(face_nverts);
 
468
      ECS_FREE(face_cells);
 
469
    }
 
470
  }
 
471
 
 
472
  printf("\n");
 
473
}
 
474
 
 
475
/*----------------------------------------------------------------------------
 
476
 * Extract a mesh's cell -> faces connectivity.
 
477
 *
 
478
 * We consider a common numbering for interior and boundary faces, in which
 
479
 * boundary faces are defined first. The common id of the i-th boundary
 
480
 * face is thus i, while that of the j-th interior face is nbr_fbr + j.
 
481
 *----------------------------------------------------------------------------*/
 
482
 
 
483
static void
 
484
ecs_pre_ccm__cel_fac(const _faces_t         *faces,
 
485
                     const _cells_t         *cels,
 
486
                     ecs_int_t       **const p_pos_cel_fac,
 
487
                     ecs_int_t       **const p_val_cel_fac)
 
488
{
 
489
  ecs_int_t    icel, icel1, icel2, n_cells_loc;
 
490
  size_t       ifac;
 
491
 
 
492
  ecs_int_t  * cpt_cel_fac = NULL;
 
493
  ecs_int_t  * pos_cel_fac = NULL;
 
494
  ecs_int_t  * val_cel_fac = NULL;
 
495
 
 
496
  /* Allocate and initialize position index */
 
497
 
 
498
  n_cells_loc = cels->n_cells;
 
499
 
 
500
  ECS_MALLOC(pos_cel_fac, n_cells_loc + 1, ecs_int_t);
 
501
 
 
502
  for (icel = 0; icel < n_cells_loc + 1; icel++)
 
503
    pos_cel_fac[icel] = 0;
 
504
 
 
505
  /* Count number of faces per cell
 
506
   * (we assign the temporary counter for icel to pos_cel_fac[icel + 1]
 
507
   * instead of pos_cel_fac[icel] so as to simplify the next step) */
 
508
 
 
509
  for (ifac = 0; ifac < faces->n_faces; ifac++) {
 
510
    icel1 = faces->icel1[ifac] - 1;
 
511
    icel2 = faces->icel2[ifac] - 1;
 
512
    pos_cel_fac[icel1 + 1] += 1;
 
513
    if (icel2 >= 0)
 
514
      pos_cel_fac[icel2 + 1] += 1;
 
515
  }
 
516
 
 
517
  /* Build position index */
 
518
 
 
519
  pos_cel_fac[0] = 1;
 
520
  for (icel = 0; icel < n_cells_loc; icel++)
 
521
    pos_cel_fac[icel + 1] = pos_cel_fac[icel] + pos_cel_fac[icel + 1];
 
522
 
 
523
  /* Build array of values */
 
524
 
 
525
  ECS_MALLOC(val_cel_fac, pos_cel_fac[n_cells_loc] - 1, ecs_int_t);
 
526
  ECS_MALLOC(cpt_cel_fac, n_cells_loc, ecs_int_t);
 
527
 
 
528
  for (icel = 0; icel < n_cells_loc; icel++)
 
529
    cpt_cel_fac[icel] = 0;
 
530
 
 
531
  for (ifac = 0; ifac < faces->n_faces; ifac++) {
 
532
    icel1 = faces->icel1[ifac] - 1;
 
533
    icel2 = faces->icel2[ifac] - 1;
 
534
    assert(icel1 >= 0);
 
535
    val_cel_fac[pos_cel_fac[icel1] + cpt_cel_fac[icel1] - 1] = (ifac + 1);
 
536
    cpt_cel_fac[icel1] += 1;
 
537
    if (icel2 >= 0) {
 
538
      val_cel_fac[pos_cel_fac[icel2] + cpt_cel_fac[icel2] - 1] = -(ifac + 1);
 
539
      cpt_cel_fac[icel2] += 1;
 
540
    }
 
541
  }
 
542
 
 
543
  ECS_FREE(cpt_cel_fac);
 
544
 
 
545
  /* Return values */
 
546
 
 
547
  *p_pos_cel_fac = pos_cel_fac;
 
548
  *p_val_cel_fac = val_cel_fac;
 
549
 
 
550
#if 0 && defined(DEBUG) && !defined(NDEBUG)
 
551
  {
 
552
    ecs_int_t ipos, ival;
 
553
 
 
554
    printf("dbg : cs_loc_maillage_ret_cel_fac\n"
 
555
           "nombre de cellules extraites = %d\n", n_cells_extr);
 
556
    for (ipos = 0; ipos < n_cells_extr; ipos++) {
 
557
      printf("  cellule %d\n", ipos);
 
558
      printf("    pos_cel_fac[%d] = %d\n", ipos, pos_cel_fac[ipos]);
 
559
      for (ival = pos_cel_fac[ipos]     - 1;
 
560
           ival < pos_cel_fac[ipos + 1] - 1;
 
561
           ival++)
 
562
        printf("      val_cel_fac[%d] = %d\n", ival, val_cel_fac[ival]);
 
563
    }
 
564
    printf("  pos_cel_fac[%d] = %d\n", ipos, pos_cel_fac[ipos]);
 
565
  }
 
566
#endif
 
567
 
 
568
}
 
569
 
 
570
/*----------------------------------------------------------------------------
 
571
 * Build mesh structure
 
572
 *----------------------------------------------------------------------------*/
 
573
 
 
574
static ecs_maillage_t *
 
575
ecs_pre_ccm__prepa_mail(_nodes_t    *noeuds,
 
576
                        _faces_t    *faces,
 
577
                        _cells_t    *cels,
 
578
                        ecs_int_t   *pos_cel_fac,
 
579
                        ecs_int_t   *val_cel_fac)
 
580
{
 
581
  /* Temporary arrays used before transfer to mesh structure */
 
582
 
 
583
  size_t       cpt_elt_ent        [ECS_N_ENTMAIL]; /* N. elts per entity */
 
584
  ecs_int_t    cpt_coul_ent       [ECS_N_ENTMAIL]; /* Color counter */
 
585
  size_t       cpt_val_som_ent    [ECS_N_ENTMAIL]; /* Connectivity size */
 
586
  ecs_int_t  * val_coul_ent       [ECS_N_ENTMAIL]; /* Array of colors */
 
587
  ecs_size_t * cpt_elt_coul_ent   [ECS_N_ENTMAIL];
 
588
  ecs_size_t * elt_pos_som_ent    [ECS_N_ENTMAIL]; /* Vertex positions */
 
589
  ecs_int_t  * elt_val_som_ent    [ECS_N_ENTMAIL]; /* Vertex numbers */
 
590
  ecs_int_t  * elt_val_color_ent  [ECS_N_ENTMAIL]; /* Element colors */
 
591
 
 
592
  size_t ifac;
 
593
  ecs_int_t nbr_som_elt;
 
594
  ecs_int_t icoul;
 
595
 
 
596
  ecs_entmail_t    entmail_e;
 
597
 
 
598
  ecs_int_t      ient;
 
599
  size_t         pos_elt;
 
600
  ecs_int_t      isom;
 
601
  size_t         n_faces;
 
602
  size_t         icel;
 
603
  size_t         pos_fac;
 
604
  ecs_int_t      nbr_som_fac;
 
605
  ecs_int_t      num_som_deb_fac;
 
606
 
 
607
  /* Create intially empty mesh (return value) */
 
608
 
 
609
  ecs_maillage_t  *maillage = ecs_maillage__cree_nodal();
 
610
 
 
611
  /*xxxxxxxxxxxxxxxxxxxxxxxxxxx Instructions xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
 
612
 
 
613
  /* Vertices */
 
614
 
 
615
  ecs_maillage_pre__cree_som(maillage,
 
616
                             noeuds->n_nodes,
 
617
                             noeuds->coord);
 
618
 
 
619
  /* Cells */
 
620
 
 
621
  for (ient = 0; ient < ECS_N_ENTMAIL; ient++) {
 
622
 
 
623
    cpt_elt_ent        [ient] = 0;
 
624
    cpt_val_som_ent    [ient] = 0;
 
625
 
 
626
    elt_pos_som_ent    [ient] = NULL;
 
627
    elt_val_som_ent    [ient] = NULL;
 
628
    elt_val_color_ent  [ient] = NULL;
 
629
 
 
630
    cpt_coul_ent       [ient] = 0;
 
631
    val_coul_ent       [ient] = NULL;
 
632
    cpt_elt_coul_ent   [ient] = NULL;
 
633
 
 
634
  }
 
635
 
 
636
  /* Faces (polygons) */
 
637
 
 
638
  entmail_e = ECS_ENTMAIL_FAC;
 
639
 
 
640
  cpt_elt_ent[entmail_e] = faces->n_faces;
 
641
  cpt_val_som_ent[entmail_e] = faces->taille_connect;
 
642
  elt_val_som_ent[entmail_e] = faces->connect;
 
643
 
 
644
  if (cpt_elt_ent[entmail_e] > 0) {
 
645
 
 
646
    ECS_MALLOC(elt_pos_som_ent[entmail_e],
 
647
               cpt_elt_ent[entmail_e] + 1,
 
648
               ecs_size_t);
 
649
 
 
650
    elt_pos_som_ent[entmail_e][0] = 1;
 
651
 
 
652
    ECS_MALLOC(elt_val_color_ent[entmail_e],
 
653
               cpt_elt_ent[entmail_e],
 
654
               ecs_int_t);
 
655
  }
 
656
 
 
657
  for (ifac = 0; ifac < faces->n_faces; ifac++) {
 
658
 
 
659
    /* Test if color is assigned */
 
660
 
 
661
    for (icoul = 0;
 
662
            icoul < cpt_coul_ent[entmail_e]
 
663
         && val_coul_ent[entmail_e][icoul] != faces->icoul[ifac];
 
664
         icoul++);
 
665
 
 
666
    if (icoul == cpt_coul_ent[entmail_e]) {
 
667
 
 
668
      /* This color value has not been saved yet */
 
669
 
 
670
      ECS_REALLOC(val_coul_ent[entmail_e],
 
671
                  cpt_coul_ent[entmail_e] + 1,
 
672
                  ecs_int_t);
 
673
      ECS_REALLOC(cpt_elt_coul_ent[entmail_e],
 
674
                  cpt_coul_ent[entmail_e] + 1,
 
675
                  ecs_size_t);
 
676
 
 
677
      cpt_elt_coul_ent[entmail_e][icoul] = 0;
 
678
      val_coul_ent[entmail_e][icoul] = faces->icoul[ifac];
 
679
      cpt_coul_ent[entmail_e]++;
 
680
 
 
681
    }
 
682
 
 
683
    /* Assign color */
 
684
 
 
685
    cpt_elt_coul_ent[entmail_e][icoul]++;
 
686
    elt_val_color_ent[entmail_e][ifac] = icoul + 1;
 
687
 
 
688
    nbr_som_elt = faces->nbr_n[ifac];
 
689
 
 
690
    /* Build connectivity */
 
691
 
 
692
    pos_elt = elt_pos_som_ent[entmail_e][ifac];
 
693
 
 
694
    elt_pos_som_ent[entmail_e][ifac + 1] = pos_elt + nbr_som_elt;
 
695
 
 
696
  }
 
697
 
 
698
  /* Cells (polyhedra) */
 
699
 
 
700
  entmail_e = ECS_ENTMAIL_CEL;
 
701
 
 
702
  cpt_elt_ent[entmail_e] = cels->n_cells;
 
703
 
 
704
  n_faces = pos_cel_fac[cels->n_cells] - 1;
 
705
 
 
706
  cpt_val_som_ent[entmail_e] = 0;
 
707
 
 
708
  for (ifac = 0; ifac < n_faces; ifac++)
 
709
    cpt_val_som_ent[entmail_e] += faces->nbr_n[abs(val_cel_fac[ifac])-1] + 1;
 
710
 
 
711
  if (cpt_elt_ent[entmail_e] > 0) {
 
712
 
 
713
    ECS_MALLOC(elt_pos_som_ent[entmail_e],
 
714
               cpt_elt_ent[entmail_e] + 1,
 
715
               ecs_size_t);
 
716
 
 
717
    elt_pos_som_ent[entmail_e][0] = 1;
 
718
 
 
719
    ECS_MALLOC(elt_val_som_ent[entmail_e],
 
720
               cpt_val_som_ent[entmail_e],
 
721
               ecs_int_t);
 
722
 
 
723
    ECS_MALLOC(elt_val_color_ent[entmail_e],
 
724
               cpt_elt_ent[entmail_e],
 
725
               ecs_int_t);
 
726
 
 
727
  }
 
728
 
 
729
  for (icel = 0; icel < cels->n_cells; icel++){
 
730
 
 
731
    /* Position in connectivity */
 
732
 
 
733
    cpt_val_som_ent[entmail_e] = 0;
 
734
 
 
735
    for (ifac = pos_cel_fac[icel] - 1;
 
736
         ifac < (size_t)(pos_cel_fac[icel + 1] - 1);
 
737
         ifac++)
 
738
      cpt_val_som_ent[entmail_e]
 
739
        += faces->nbr_n[abs(val_cel_fac[ifac]) - 1] + 1;
 
740
 
 
741
    elt_pos_som_ent[entmail_e][icel + 1]
 
742
      = elt_pos_som_ent[entmail_e][icel] + cpt_val_som_ent[entmail_e];
 
743
 
 
744
    /* Test if color is assigned */
 
745
 
 
746
    for (icoul = 0;
 
747
            icoul < cpt_coul_ent[entmail_e]
 
748
         && val_coul_ent[entmail_e][icoul] != cels->icoul[icel];
 
749
         icoul++);
 
750
 
 
751
    if (icoul == cpt_coul_ent[entmail_e]) {
 
752
 
 
753
      /* This color value has not been saved yet */
 
754
 
 
755
      ECS_REALLOC(val_coul_ent[entmail_e],
 
756
                  cpt_coul_ent[entmail_e] + 1,
 
757
                  ecs_int_t);
 
758
      ECS_REALLOC(cpt_elt_coul_ent[entmail_e],
 
759
                  cpt_coul_ent[entmail_e] + 1,
 
760
                  ecs_size_t);
 
761
 
 
762
      cpt_elt_coul_ent[entmail_e][icoul] = 0;
 
763
      val_coul_ent[entmail_e][icoul] = cels->icoul[icel];
 
764
      cpt_coul_ent[entmail_e]++;
 
765
 
 
766
    }
 
767
 
 
768
    /* Assign color */
 
769
 
 
770
    cpt_elt_coul_ent[entmail_e][icoul]++;
 
771
    elt_val_color_ent[entmail_e][icel] = icoul + 1;
 
772
 
 
773
  }
 
774
 
 
775
  /* Connectivity */
 
776
 
 
777
  /* Loop on all faces of val_cel_fac */
 
778
 
 
779
  cpt_val_som_ent[entmail_e] = 0;
 
780
 
 
781
  for (ifac = 0; ifac < n_faces; ifac++) {
 
782
 
 
783
    pos_fac = elt_pos_som_ent[ECS_ENTMAIL_FAC][abs(val_cel_fac[ifac])-1];
 
784
 
 
785
    nbr_som_fac = faces->nbr_n[abs(val_cel_fac[ifac])-1];
 
786
 
 
787
    /* Orientation */
 
788
 
 
789
    if (val_cel_fac[ifac] < 0) {
 
790
 
 
791
      num_som_deb_fac = faces->connect[pos_fac + (nbr_som_fac - 1) -1];
 
792
 
 
793
      for (isom = 0; isom < nbr_som_fac; isom++)
 
794
        elt_val_som_ent[entmail_e][cpt_val_som_ent[entmail_e] + isom]
 
795
          = faces->connect[pos_fac -1 + ((nbr_som_fac - 1) - isom)];
 
796
 
 
797
    }
 
798
 
 
799
    else {
 
800
 
 
801
      num_som_deb_fac = faces->connect[pos_fac - 1];
 
802
 
 
803
      for (isom = 0; isom < nbr_som_fac; isom++)
 
804
        elt_val_som_ent[entmail_e][cpt_val_som_ent[entmail_e] + isom]
 
805
          = faces->connect[pos_fac -1 + isom];
 
806
 
 
807
    }
 
808
 
 
809
    elt_val_som_ent[entmail_e][cpt_val_som_ent[entmail_e] + isom]
 
810
      = num_som_deb_fac;
 
811
 
 
812
    cpt_val_som_ent[entmail_e] += nbr_som_fac + 1;
 
813
 
 
814
  }
 
815
 
 
816
  /* Transfer values read to mesh entity structures */
 
817
 
 
818
  ecs_maillage_pre__cree_elt(maillage,
 
819
                             cpt_elt_ent,
 
820
                             elt_pos_som_ent,
 
821
                             elt_val_som_ent,
 
822
                             NULL,
 
823
                             elt_val_color_ent,
 
824
                             cpt_coul_ent,
 
825
                             val_coul_ent,
 
826
                             cpt_elt_coul_ent);
 
827
 
 
828
  ECS_FREE(pos_cel_fac);
 
829
  ECS_FREE(val_cel_fac);
 
830
 
 
831
  return maillage;
 
832
}
 
833
 
 
834
/*============================================================================
 
835
 * Public function definitions
 
836
 *============================================================================*/
 
837
 
 
838
/*----------------------------------------------------------------------------
 
839
 * Read of mesh from a STAR-CCM+ format file.
 
840
 *
 
841
 * parameters:
 
842
 *   nom_fic_maillage <-- mesh file name
 
843
 *   num_maillage     <-- mesh number
 
844
 *----------------------------------------------------------------------------*/
 
845
 
 
846
ecs_maillage_t *
 
847
ecs_pre_ccm__lit_maillage(const char  *nom_fic_maillage,
 
848
                          int          num_maillage)
 
849
{
 
850
  ecs_maillage_t * maillage = NULL;
 
851
 
 
852
  CCMIOID root, state, processor, vertices, topology;
 
853
  CCMIOError err;
 
854
 
 
855
#if (kCCMIOVersion == 20601)
 
856
  int i = 0;
 
857
  unsigned int size;
 
858
#else
 
859
  CCMIOSize_t i = 0;
 
860
  CCMIOSize_t size = 0;
 
861
#endif
 
862
 
 
863
  _nodes_t *nodes;
 
864
  _faces_t *liste_faces_bord;
 
865
  _faces_t *liste_faces_internes;
 
866
  _faces_t *liste_faces;
 
867
  _cells_t *liste_cels;
 
868
 
 
869
  ecs_tab_int_t tab_connect;
 
870
  ecs_tab_int_t tab_label;
 
871
 
 
872
  size_t    nbr_fabord;
 
873
  size_t    nbr_faint;
 
874
  size_t    n_faces;
 
875
  size_t    isom, ifac;
 
876
 
 
877
  ecs_int_t *pos_cel_fac;
 
878
  ecs_int_t *val_cel_fac;
 
879
 
 
880
  int       n_states = 0;
 
881
  size_t    taille_connect_bord = 0;
 
882
  size_t    taille_connect_interne = 0;
 
883
  size_t    taille_connect = 0;
 
884
 
 
885
  int   version = 0, maj_ver = 0, min_ver = 0, rel_ver = 0;
 
886
 
 
887
  CCMIOID *states = NULL;
 
888
  char *title = NULL;
 
889
 
 
890
  /*Xxxxxxxxxxxxxxxxxxxxxxxxxxx Instructions xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
 
891
 
 
892
  err = CCMIOOpenFile(NULL, nom_fic_maillage, kCCMIORead, &root);
 
893
 
 
894
  CCMIOGetVersion(&err, root.node, &version);
 
895
 
 
896
  maj_ver =  version / 10000;
 
897
  min_ver = (version % 10000)/ 100;
 
898
  rel_ver = (version % 100);
 
899
 
 
900
  CCMIOGetTitle(&err, root.node, &title);
 
901
 
 
902
  printf(_("\n\n"
 
903
           "Reading mesh from file in STAR-CCM+ format\n"
 
904
           "----------------------\n"));
 
905
 
 
906
  printf(_("  Mesh file: %s\n\n\n"
 
907
           "  STAR-CCM+ format version: %1d.%1d.%1d\n"
 
908
           "  Title: %s\n\n"),
 
909
             nom_fic_maillage, maj_ver, min_ver, rel_ver, title);
 
910
 
 
911
  /* The string 'title' has been allocated inside CCMIOGetTitle */
 
912
 
 
913
  free(title);
 
914
 
 
915
  /* Initialisations */
 
916
 
 
917
  nodes = NULL;
 
918
  liste_faces_bord  = NULL;
 
919
  liste_faces_internes  = NULL;
 
920
  liste_cels  = NULL;
 
921
 
 
922
  ECS_MALLOC(nodes, 1, _nodes_t);
 
923
  ECS_MALLOC(liste_faces_bord, 1, _faces_t);
 
924
  ECS_MALLOC(liste_faces_internes, 1, _faces_t);
 
925
  ECS_MALLOC(liste_cels, 1, _cells_t);
 
926
 
 
927
  /* Search for available states */
 
928
 
 
929
  err = kCCMIONoErr;
 
930
 
 
931
  printf(_("  Available meshes:\n"));
 
932
 
 
933
  while (err == kCCMIONoErr) {
 
934
 
 
935
    char name[kCCMIOMaxStringLength + 1];
 
936
 
 
937
    CCMIONextEntity(&err, root, kCCMIOState, &i, &state);
 
938
 
 
939
    if (err != kCCMIONoErr)
 
940
      break;
 
941
 
 
942
    CCMIOEntityName(&err, state, name);
 
943
 
 
944
    if (err != kCCMIONoErr)
 
945
      ecs_error(__FILE__, __LINE__, 0,
 
946
                _("Error %d reading state name in STAR-CCM+ file."),
 
947
                (int)err);
 
948
 
 
949
    printf("    %2d: \"%s\"\n", n_states + 1, name);
 
950
 
 
951
    ECS_REALLOC(states, n_states + 1, CCMIOID);
 
952
    states[n_states] = state;
 
953
 
 
954
    n_states += 1;
 
955
  }
 
956
 
 
957
  err = kCCMIONoErr;
 
958
 
 
959
  if (num_maillage == 0) {
 
960
    printf(_("\n  No mesh was specified; the first is read.\n\n"));
 
961
    state = states[0];
 
962
  }
 
963
  else {
 
964
    printf(_("\n  Mesh number %d was specified.\n\n"), num_maillage);
 
965
    if (num_maillage > 0 && num_maillage <= n_states)
 
966
      state = states[num_maillage - 1];
 
967
    else if (num_maillage > 0)
 
968
      ecs_error(__FILE__, __LINE__, 0,
 
969
              _("The specified mesh number (%d) is greater than\n"
 
970
                "the number of meshes defined (%d) in file\n%s.\n"),
 
971
              num_maillage, n_states, nom_fic_maillage);
 
972
    else
 
973
      ecs_error(__FILE__, __LINE__, 0,
 
974
              _("The specified mesh number (%d) is negative."),
 
975
              num_maillage);
 
976
  }
 
977
 
 
978
  ECS_FREE(states);
 
979
 
 
980
  CCMIOEntityDescription(&err, state, &size, NULL);
 
981
 
 
982
  if (err != kCCMIONoErr)
 
983
    ecs_error(__FILE__, __LINE__, 0,
 
984
              _("Error %d reading entity description in STAR-CCM+ file."),
 
985
              (int)err);
 
986
 
 
987
  if (size > 0) {
 
988
    char *desc;
 
989
    ECS_MALLOC(desc, size + 1, char);
 
990
    CCMIOEntityDescription(&err, state, NULL, desc);
 
991
    printf("  Mesh/state description: %s)\n", desc);
 
992
    ECS_FREE(desc);
 
993
  }
 
994
 
 
995
  i = 0;
 
996
  CCMIONextEntity(&err, state, kCCMIOProcessor, &i, &processor);
 
997
 
 
998
  if (err != kCCMIONoErr)
 
999
    ecs_error(__FILE__, __LINE__, 0,
 
1000
              _("Error %d reading processor information in STAR-CCM+ file."),
 
1001
              (int)err);
 
1002
 
 
1003
  CCMIOReadProcessor(&err, processor, &vertices, &topology, NULL, NULL);
 
1004
 
 
1005
  if (err != kCCMIONoErr)
 
1006
    ecs_error(__FILE__, __LINE__, 0,
 
1007
              _("Error %d reading vertices and topology information\n"
 
1008
                "in STAR-CCM+ file."), (int)err);
 
1009
 
 
1010
  _read_mesh(vertices,
 
1011
             topology,
 
1012
             nodes,
 
1013
             liste_faces_internes,
 
1014
             liste_faces_bord,
 
1015
             liste_cels);
 
1016
 
 
1017
  /* Fermetures */
 
1018
 
 
1019
  CCMIOCloseFile(&err, vertices);
 
1020
  CCMIOCloseFile(&err, topology);
 
1021
 
 
1022
  CCMIOCloseFile(&err, root);
 
1023
 
 
1024
  /* Switch to preprocessor type structure */
 
1025
 
 
1026
  /* switching to indexes is done before appending faces so as to keep
 
1027
     icel2 = -1 for boundary faces */
 
1028
 
 
1029
  /* vertex labels */
 
1030
 
 
1031
  /* boundary faces */
 
1032
 
 
1033
  tab_connect.nbr = liste_faces_bord->taille_connect;
 
1034
  tab_connect.val = liste_faces_bord->connect;
 
1035
 
 
1036
  tab_label.nbr = nodes->n_nodes;
 
1037
  tab_label.val = nodes->id;
 
1038
 
 
1039
  ecs_tab_int__ref_en_indice(tab_connect, tab_label, false);
 
1040
  liste_faces_bord->connect = tab_connect.val;
 
1041
 
 
1042
  /* interior faces */
 
1043
 
 
1044
  tab_connect.nbr = liste_faces_internes->taille_connect;
 
1045
  tab_connect.val = liste_faces_internes->connect;
 
1046
 
 
1047
  ecs_tab_int__ref_en_indice(tab_connect, tab_label, false);
 
1048
  liste_faces_internes->connect = tab_connect.val;
 
1049
 
 
1050
  /* cell labels */
 
1051
 
 
1052
  tab_label.nbr = liste_cels->n_cells;
 
1053
  tab_label.val = liste_cels->id;
 
1054
  tab_connect.nbr = liste_faces_bord->n_faces;
 
1055
 
 
1056
  /* For boundary faces, only icel1 is handled (icel2 = -1) */
 
1057
 
 
1058
  tab_connect.val = liste_faces_bord->icel1;
 
1059
  ecs_tab_int__ref_en_indice(tab_connect, tab_label, false);
 
1060
  liste_faces_bord->icel1 = tab_connect.val;
 
1061
 
 
1062
  /* Interior faces */
 
1063
 
 
1064
  tab_connect.nbr = liste_faces_internes->n_faces;
 
1065
 
 
1066
  tab_connect.val = liste_faces_internes->icel1;
 
1067
  ecs_tab_int__ref_en_indice(tab_connect, tab_label, false);
 
1068
  liste_faces_internes->icel1 = tab_connect.val;
 
1069
 
 
1070
  tab_connect.val = liste_faces_internes->icel2;
 
1071
  ecs_tab_int__ref_en_indice(tab_connect, tab_label, false);
 
1072
  liste_faces_internes->icel2 = tab_connect.val;
 
1073
 
 
1074
  /* shift ... n-1 to 1 ... n */
 
1075
 
 
1076
  for (isom = 0; isom < liste_faces_internes->taille_connect; isom++)
 
1077
    liste_faces_internes->connect[isom] += 1;
 
1078
 
 
1079
  for (isom = 0; isom < liste_faces_bord->taille_connect; isom++)
 
1080
    liste_faces_bord->connect[isom] += 1;
 
1081
 
 
1082
  for (ifac = 0; ifac < liste_faces_internes->n_faces; ifac++){
 
1083
    assert(liste_faces_internes->icel1[ifac] > -1);
 
1084
    liste_faces_internes->icel1[ifac] += 1;
 
1085
    if (liste_faces_internes->icel2[ifac] != -1)
 
1086
      liste_faces_internes->icel2[ifac] += 1;
 
1087
  }
 
1088
 
 
1089
  for (ifac = 0; ifac < liste_faces_bord->n_faces; ifac++)
 
1090
    liste_faces_bord->icel1[ifac] += 1;
 
1091
 
 
1092
  /* Append boundary and interior faces, with interior faces first */
 
1093
 
 
1094
  taille_connect_bord = liste_faces_bord->taille_connect;
 
1095
  taille_connect_interne = liste_faces_internes->taille_connect;
 
1096
 
 
1097
  taille_connect = taille_connect_bord + taille_connect_interne;
 
1098
 
 
1099
  nbr_fabord = liste_faces_bord->n_faces;
 
1100
  nbr_faint  = liste_faces_internes->n_faces;
 
1101
 
 
1102
  n_faces = nbr_fabord + nbr_faint;
 
1103
 
 
1104
  ECS_REALLOC(liste_faces_bord->connect, taille_connect, ecs_int_t);
 
1105
  ECS_REALLOC(liste_faces_bord->icoul, n_faces, ecs_int_t);
 
1106
  ECS_REALLOC(liste_faces_bord->icel1, n_faces, ecs_int_t);
 
1107
  ECS_REALLOC(liste_faces_bord->icel2, n_faces, ecs_int_t);
 
1108
  ECS_REALLOC(liste_faces_bord->nbr_n, n_faces, ecs_int_t);
 
1109
 
 
1110
  liste_faces = liste_faces_bord;
 
1111
 
 
1112
  for (isom = 0; isom < taille_connect_interne; isom++)
 
1113
    liste_faces->connect[taille_connect_bord + isom ]
 
1114
      = liste_faces_internes->connect[isom];
 
1115
 
 
1116
  for (ifac = 0; ifac < nbr_faint; ifac ++){
 
1117
    liste_faces->icoul[nbr_fabord + ifac] = liste_faces_internes->icoul[ifac];
 
1118
    liste_faces->icel1[nbr_fabord + ifac] = liste_faces_internes->icel1[ifac];
 
1119
    liste_faces->icel2[nbr_fabord + ifac] = liste_faces_internes->icel2[ifac];
 
1120
    liste_faces->nbr_n[nbr_fabord + ifac] = liste_faces_internes->nbr_n[ifac];
 
1121
  }
 
1122
 
 
1123
  liste_faces->taille_connect = taille_connect;
 
1124
  liste_faces->n_faces = n_faces;
 
1125
 
 
1126
  /* Libération de la memoire */
 
1127
 
 
1128
  ECS_FREE(liste_faces_internes->icoul);
 
1129
  ECS_FREE(liste_faces_internes->icel1);
 
1130
  ECS_FREE(liste_faces_internes->icel2);
 
1131
  ECS_FREE(liste_faces_internes->nbr_n);
 
1132
  ECS_FREE(liste_faces_internes->connect);
 
1133
 
 
1134
  ECS_FREE(liste_faces_internes);
 
1135
 
 
1136
  /* Préparation de la connectivité cellule */
 
1137
 
 
1138
  ecs_pre_ccm__cel_fac(liste_faces,
 
1139
                       liste_cels,
 
1140
                       &pos_cel_fac,
 
1141
                       &val_cel_fac);
 
1142
 
 
1143
  /* Remplissage des tableaux */
 
1144
 
 
1145
  maillage = ecs_pre_ccm__prepa_mail(nodes,
 
1146
                                     liste_faces,
 
1147
                                     liste_cels,
 
1148
                                     pos_cel_fac,
 
1149
                                     val_cel_fac);
 
1150
 
 
1151
  ECS_FREE(nodes->id);
 
1152
  ECS_FREE(nodes);
 
1153
 
 
1154
  ECS_FREE(liste_faces->icel1);
 
1155
  ECS_FREE(liste_faces->icel2);
 
1156
  ECS_FREE(liste_faces->nbr_n);
 
1157
  ECS_FREE(liste_faces->icoul);
 
1158
 
 
1159
  ECS_FREE(liste_faces);
 
1160
 
 
1161
  ECS_FREE(liste_cels->icoul);
 
1162
  ECS_FREE(liste_cels->id);
 
1163
 
 
1164
  ECS_FREE(liste_cels);
 
1165
 
 
1166
  /* Renvoi de la structure de maillage */
 
1167
 
 
1168
  return maillage;
 
1169
}
 
1170
 
 
1171
/*----------------------------------------------------------------------------*/
 
1172
 
 
1173
#endif /* HAVE_CCM */