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

« back to all changes in this revision

Viewing changes to users/base/cs_user_join.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
 * Define (conforming or non-conforming) mesh joinings.
 
3
 *============================================================================*/
 
4
 
 
5
/* VERS */
 
6
 
 
7
/*
 
8
  This file is part of Code_Saturne, a general-purpose CFD tool.
 
9
 
 
10
  Copyright (C) 1998-2011 EDF S.A.
 
11
 
 
12
  This program is free software; you can redistribute it and/or modify it under
 
13
  the terms of the GNU General Public License as published by the Free Software
 
14
  Foundation; either version 2 of the License, or (at your option) any later
 
15
  version.
 
16
 
 
17
  This program is distributed in the hope that it will be useful, but WITHOUT
 
18
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
19
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
20
  details.
 
21
 
 
22
  You should have received a copy of the GNU General Public License along with
 
23
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
24
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
25
*/
 
26
 
 
27
/*----------------------------------------------------------------------------*/
 
28
 
 
29
#if defined(HAVE_CONFIG_H)
 
30
#include "cs_config.h"
 
31
#endif
 
32
 
 
33
/*----------------------------------------------------------------------------
 
34
 * Standard C library headers
 
35
 *----------------------------------------------------------------------------*/
 
36
 
 
37
/*----------------------------------------------------------------------------
 
38
 * BFT library headers
 
39
 *----------------------------------------------------------------------------*/
 
40
 
 
41
/*----------------------------------------------------------------------------
 
42
 * FVM library headers
 
43
 *----------------------------------------------------------------------------*/
 
44
 
 
45
/*----------------------------------------------------------------------------
 
46
 *  Local headers
 
47
 *----------------------------------------------------------------------------*/
 
48
 
 
49
#include "cs_base.h"
 
50
#include "cs_join.h"
 
51
 
 
52
/*----------------------------------------------------------------------------
 
53
 *  Header for the current file
 
54
 *----------------------------------------------------------------------------*/
 
55
 
 
56
#include "cs_prototypes.h"
 
57
 
 
58
/*----------------------------------------------------------------------------*/
 
59
 
 
60
BEGIN_C_DECLS
 
61
 
 
62
/*============================================================================
 
63
 * User function definitions
 
64
 *============================================================================*/
 
65
 
 
66
/*----------------------------------------------------------------------------
 
67
 * Define mesh joinings.
 
68
 *
 
69
 * This is done by calling the cs_join_add() function for each joining
 
70
 * operation to add.
 
71
 *
 
72
 * The arguments to cs_join_add() are:
 
73
 *   sel_criteria <-- boundary face selection criteria string
 
74
 *   fraction     <-- value of the fraction parameter;
 
75
 *                    the initial tolerance radius associated to each vertex
 
76
 *                    is equal to the lenght of the shortest incident edge,
 
77
 *                    multiplied by this fraction.
 
78
 *   plane        <-- value of the plane parameter;
 
79
 *                    when subdividing faces, 2 faces are considered
 
80
 *                    coplanar and may be joined if angle between their
 
81
 *                    normals (in degrees) does not exceed this parameter.
 
82
 *   verbosity    <-- level of verbosity required
 
83
 *
 
84
 * The function returns a number (1 to n) associated with the
 
85
 * new joining. This number may optionnally be used to assign advanced
 
86
 * parameters to the joining.
 
87
 *----------------------------------------------------------------------------*/
 
88
 
 
89
void
 
90
cs_user_join(void)
 
91
{
 
92
  int    join_num;
 
93
  int    verbosity = 1, visualization;
 
94
  float  fraction = 0.10, plane = 0.25;
 
95
  return; /* REMOVE_LINE_FOR_USE_OF_SUBROUTINE */
 
96
 
 
97
  fraction = 0.10;
 
98
  plane = 25.0;
 
99
  verbosity = 1; /* debug level if >= 3 */
 
100
  visualization = 1; /* debug level if >= 3 */
 
101
 
 
102
  /* Add a joining operation */
 
103
  /* ----------------------- */
 
104
 
 
105
  join_num = cs_join_add("98 or 99",
 
106
                         fraction,
 
107
                         plane,
 
108
                         verbosity,
 
109
                         visualization);
 
110
 
 
111
  /*--------------------------------------------------------------------------*/
 
112
 
 
113
  /* Example with advanced parameters;
 
114
     Advanced parameters may be modified to solve errors during the
 
115
     joining step or to get a better mesh quality. */
 
116
 
 
117
  {
 
118
    /* Merge tolerance factor:
 
119
     * used to locally modify the tolerance associated to each
 
120
     * vertex BEFORE the merge step.
 
121
     *   = 0 => no vertex merge;
 
122
     *   < 1 => vertex merge is more strict. It may increase the number
 
123
     *          of tolerance reduction and so define smaller subset of
 
124
     *          vertices to merge together but it can drive to loose
 
125
     *          intersections;
 
126
     *   = 1 => no change;
 
127
     *   > 1 => vertex merge is less strict. The subset of vertices able
 
128
     *          to be merged together is greater. */
 
129
 
 
130
     double mtf = 1.00;
 
131
 
 
132
     /* Pre-merge factor:
 
133
      * this parameter is used to define a bound under which two vertices
 
134
      * are merged before the merge step.
 
135
      * Tolerance limit for the pre-merge = pmf * fraction. */
 
136
 
 
137
     double pmf = 0.10;
 
138
 
 
139
     /* Tolerance computation mode:
 
140
      *
 
141
      *   1: (default) tol = min. edge length related to a vertex * fraction
 
142
      *   2: tolerance is computed like in mode 1 with in addition, the
 
143
      *      multiplication by a coefficient equal to the max sin(e1, e2)
 
144
      *      where e1 and e2 are two edges sharing the same vertex V for which
 
145
      *      we want to compute the tolerance.
 
146
      *  11: as 1 but taking into account only the selected faces
 
147
      *  12: as 2 but taking into account only the selected faces */
 
148
 
 
149
     int tcm = 1;
 
150
 
 
151
      /* Intersection computation mode:
 
152
       *  1: (default) Original algorithm.
 
153
       *     Try to snap intersection to extremity.
 
154
       *  2: New intersection algorithm.
 
155
       *     Avoid snapping intersection to extremity. */
 
156
 
 
157
     int icm = 1;
 
158
 
 
159
     /* Maximum number of equivalence breaks which is
 
160
      * enabled during the merge step. */
 
161
 
 
162
     int max_break = 500;
 
163
 
 
164
     /* Maximum number of sub-faces when splitting a selected face. */
 
165
 
 
166
     int max_sub_face = 100;
 
167
 
 
168
     /* tml, tmb and tmr are parameters of the searching algorithm for
 
169
      * face intersections between selected faces (octree structure).
 
170
      * Useful to adjust speed vs. memory consumption. */
 
171
 
 
172
     /* Tree Max Level:
 
173
      * deepest level reachable when building the tree */
 
174
 
 
175
     int tml = 30;
 
176
 
 
177
     /* Tree Max Boxes:
 
178
      * max. number of bounding boxes which can be linked to a leaf of the tree
 
179
      * (not necessary true for the deepest level) */
 
180
 
 
181
     int tmb = 25;
 
182
 
 
183
     /* Tree Max. Ratio:
 
184
      * stop refining the tree structure when
 
185
      * number of bounding boxes > tmr * number of faces to locate.
 
186
      * In parallel, a separate (usually lower) value may be set for
 
187
      * the initial coarse tree used to determine distribution.
 
188
      * Reducing this will help reduce memory consumption. */
 
189
 
 
190
     double tmr = 5.0;
 
191
     double tmr_distrib = 2.0;
 
192
 
 
193
     /* Set advanced parameters */
 
194
 
 
195
     cs_join_set_advanced_param(join_num,
 
196
                                mtf, pmf, tcm, icm,
 
197
                                max_break, max_sub_face,
 
198
                                tml, tmb, tmr, tmr_distrib);
 
199
  }
 
200
}