~ubuntu-branches/ubuntu/karmic/gmsh/karmic

« back to all changes in this revision

Viewing changes to Post/AdaptiveViews.h

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Daniel Leidert
  • Date: 2008-05-18 12:46:05 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080518124605-716xqbqeo07o497k
Tags: 2.2.0-2
[Christophe Prud'homme]
* Bug fix: "gmsh ships no .desktop", thanks to Vassilis Pandis (Closes:
  #375770). Applied the Ubuntu patch.

[Daniel Leidert]
* debian/control (Vcs-Svn): Fixed.
  (Build-Depends): Use texlive instead of tetex-bin.
* debian/gmsh.doc-base (Section): Fixed accordingly to doc-base (>= 0.8.10).
* debian/rules: Removed some variable declarations, that lead to double
  configuration and seem to be useless.
  (build/gmsh): Try to avoid multiple runs by using a stamp.
  (orig-tarball): Renamed to get-orig-source and changed to use uscan.
* debian/watch: Added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef _ADAPTIVE_VIEWS_H_
2
2
#define _ADAPTIVE_VIEWS_H_
3
3
 
4
 
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 
4
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
5
5
//
6
6
// This program is free software; you can redistribute it and/or modify
7
7
// it under the terms of the GNU General Public License as published by
21
21
// Please report all bugs and problems to <gmsh@geuz.org>.
22
22
 
23
23
#include <list>
 
24
#include <set>
24
25
#include "List.h"
25
26
#include "GmshMatrix.h"
26
27
 
27
 
#define MAX_LEVEL_OF_ZOOM 8
28
 
 
29
 
class Post_View;
 
28
class PViewDataList;
30
29
class GMSH_Post_Plugin;
31
30
 
32
31
// On a triangle, we suppose that there exists an interpolation scheme
36
35
 
37
36
class adapt_point
38
37
{
39
 
public :
40
 
  double x,y,z;
41
 
  double X,Y,Z,val,valx,valy,valz;
 
38
 public:
 
39
  double x, y, z;
 
40
  double X, Y, Z, val, valx, valy, valz;
42
41
  double shape_functions[128];
43
 
  static adapt_point * New (double x, double y, double z, 
44
 
                            Double_Matrix *coeffs, Double_Matrix *eexps); 
45
 
  void print () const
46
 
  {
47
 
    printf("p %g %g\n" ,x,y);
48
 
  }
49
 
  bool operator < (const adapt_point & other) const
 
42
  static adapt_point *New(double x, double y, double z, 
 
43
                          Double_Matrix *coeffs, Double_Matrix *eexps);
 
44
  bool operator < (const adapt_point &other) const
50
45
  {
51
46
    if(other.x < x) return true;
52
47
    if(other.x > x) return false;
60
55
 
61
56
class adapt_edge
62
57
{
63
 
public:
64
 
  adapt_edge (adapt_point *p1,adapt_point *p2)
 
58
 public:
 
59
  adapt_edge(adapt_point *p1, adapt_point *p2)
65
60
    : visible(false)
66
61
  {
67
62
    p[0] = p1;
68
63
    p[1] = p2;
69
64
    e[0] = e[1] = 0;
70
65
  } 
71
 
  inline double V () const
72
 
  {
73
 
    return (p[0]->val + p[1]->val)/2.;    
74
 
  }
75
 
  inline static void GSF (const double u, const double v, double w, double sf[]) 
76
 
  {
77
 
    sf[0] = (1-u)/2.;
78
 
    sf[1] = (1+u)/2.;
79
 
  }
80
 
  void print ()
81
 
  {
82
 
    printf("p1 %g %g p2 %g %g\n", p[0]->x, p[0]->y, p[1]->x, p[1]->y);
83
 
  }
84
 
  static void Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps) ;
85
 
  static void Recur_Create (adapt_edge *e, int maxlevel, int level, 
86
 
                            Double_Matrix *coeffs, Double_Matrix *eexps);
87
 
  static void Error (double AVG , double tol );
88
 
  static void Recur_Error (adapt_edge *e, double AVG, double tol);
 
66
  inline double V() const
 
67
  {
 
68
    return (p[0]->val + p[1]->val) / 2.;
 
69
  }
 
70
  inline static void GSF(const double u, const double v, double w, double sf[])
 
71
  {
 
72
    sf[0] = (1 - u) / 2.;
 
73
    sf[1] = (1 + u) / 2.;
 
74
  }
 
75
  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
 
76
  static void Recur_Create(adapt_edge *e, int maxlevel, int level, 
 
77
                           Double_Matrix *coeffs, Double_Matrix *eexps);
 
78
  static void Error(double AVG, double tol);
 
79
  static void Recur_Error(adapt_edge *e, double AVG, double tol);
89
80
  bool visible;
90
81
  adapt_point *p[2];
91
 
  adapt_edge  *e[2];
 
82
  adapt_edge *e[2];
92
83
  static std::list<adapt_edge*> all_elems;
93
84
  static int nbNod;
94
85
};
95
86
 
96
87
class adapt_triangle
97
88
{
98
 
public:
99
 
  adapt_triangle (adapt_point *p1, adapt_point *p2, adapt_point *p3)
100
 
    : visible (false)
 
89
 public:
 
90
  adapt_triangle(adapt_point *p1, adapt_point *p2, adapt_point *p3)
 
91
    : visible(false)
101
92
  {
102
93
    p[0] = p1;
103
94
    p[1] = p2;
104
95
    p[2] = p3;
105
96
    e[0] = e[1] = e[2] = e[3] = 0;
106
97
  }
107
 
  inline double V () const
108
 
  {
109
 
    return (p[0]->val + p[1]->val + p[2]->val)/3.;    
110
 
  }
111
 
  static void GSF (const double u, const double v, double w, double sf[]); 
112
 
  void print ()
113
 
  {
114
 
    printf("p1 %g %g p2 %g %g p3 %g %g\n", 
115
 
           p[0]->x, p[0]->y, p[1]->x, p[1]->y, p[2]->x, p[2]->y);
116
 
  }
117
 
  static void Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
118
 
  static void Recur_Create (adapt_triangle *t, int maxlevel, int level,
119
 
                            Double_Matrix *coeffs, Double_Matrix *eexps);
120
 
  static void Error (double AVG, double tol);
121
 
  static void Recur_Error (adapt_triangle *t, double AVG, double tol);
 
98
  inline double V() const
 
99
  {
 
100
    return (p[0]->val + p[1]->val + p[2]->val) / 3.;
 
101
  }
 
102
  static void GSF(const double u, const double v, double w, double sf[])
 
103
  {
 
104
    sf[0] = 1. - u - v;
 
105
    sf[1] = u;
 
106
    sf[2] = v;
 
107
  }
 
108
  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
 
109
  static void Recur_Create(adapt_triangle *t, int maxlevel, int level,
 
110
                           Double_Matrix *coeffs, Double_Matrix *eexps);
 
111
  static void Error(double AVG, double tol);
 
112
  static void Recur_Error(adapt_triangle *t, double AVG, double tol);
122
113
  bool visible;
123
114
  adapt_point *p[3];
124
115
  adapt_triangle *e[4];
126
117
  static int nbNod;
127
118
};
128
119
 
129
 
 
130
 
 
131
 
 
132
 
 
133
120
class adapt_quad
134
121
{
135
 
public:
136
 
  adapt_quad (adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4)    
137
 
    : visible (false)
 
122
 public:
 
123
  adapt_quad(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4)    
 
124
    : visible(false)
138
125
  {
139
126
    p[0] = p1;
140
127
    p[1] = p2;
142
129
    p[3] = p4;
143
130
    e[0] = e[1] = e[2] = e[3] = 0;
144
131
  }
145
 
  inline double V () const
 
132
  inline double V() const
146
133
  {
147
 
    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val)/4.;    
 
134
    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val) / 4.;
148
135
  }
149
 
  inline static void GSF (const double u, const double v, double w, double sf[]) 
 
136
  inline static void GSF(const double u, const double v, double w, double sf[])
150
137
  {
151
138
    sf[0] = 0.25 * (1. - u) * (1. - v);
152
139
    sf[1] = 0.25 * (1. + u) * (1. - v);
153
140
    sf[2] = 0.25 * (1. + u) * (1. + v);
154
141
    sf[3] = 0.25 * (1. - u) * (1. + v);
155
142
  }
156
 
  void print ()
157
 
  {
158
 
    printf("p1 %g %g p2 %g %g p3 %g %g\n",
159
 
           p[0]->x, p[0]->y, p[1]->x, p[1]->y, p[2]->x, p[2]->y);
160
 
  }
161
 
  static void Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
162
 
  static void Recur_Create (adapt_quad *q, int maxlevel, int level,
163
 
                            Double_Matrix *coeffs, Double_Matrix *eexps);
164
 
  static void Error (double AVG, double tol);
165
 
  static void Recur_Error (adapt_quad *q, double AVG, double tol);
 
143
  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
 
144
  static void Recur_Create(adapt_quad *q, int maxlevel, int level,
 
145
                           Double_Matrix *coeffs, Double_Matrix *eexps);
 
146
  static void Error(double AVG, double tol);
 
147
  static void Recur_Error(adapt_quad *q, double AVG, double tol);
166
148
  bool visible;
167
149
  adapt_point *p[4];
168
150
  adapt_quad *e[4];
172
154
 
173
155
class adapt_tet
174
156
{
175
 
public:
176
 
  adapt_tet (adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4)    
177
 
    : visible (false)
 
157
 public:
 
158
  adapt_tet(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4)
 
159
    : visible(false)
178
160
  {
179
161
    p[0] = p1;
180
162
    p[1] = p2;
183
165
    e[0] = e[1] = e[2] = e[3] = 0;
184
166
    e[4] = e[5] = e[6] = e[7] = 0;
185
167
  }
186
 
  inline static void GSF (const double u, const double v, double w, double sf[])
 
168
  inline static void GSF(const double u, const double v, double w, double sf[])
187
169
  {
188
170
    sf[0] = 1. - u - v - w;
189
171
    sf[1] = u;
190
172
    sf[2] = v;
191
173
    sf[3] = w;
192
174
  }
193
 
  inline double V () const
194
 
  {
195
 
    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val)/4.;    
196
 
  }
197
 
  void print ()
198
 
  {
199
 
    printf("p1 %g %g p2 %g %g p3 %g %g\n",
200
 
           p[0]->x, p[0]->y, p[1]->x, p[1]->y, p[2]->x, p[2]->y);
201
 
  }
202
 
  static void Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
203
 
  static void Recur_Create (adapt_tet *t, int maxlevel, int level, 
204
 
                            Double_Matrix *coeffs, Double_Matrix *eexps);
205
 
  static void Error (double AVG, double tol);
206
 
  static void Recur_Error (adapt_tet *t, double AVG, double tol);
 
175
  inline double V() const
 
176
  {
 
177
    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val) / 4.;
 
178
  }
 
179
  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
 
180
  static void Recur_Create(adapt_tet *t, int maxlevel, int level, 
 
181
                           Double_Matrix *coeffs, Double_Matrix *eexps);
 
182
  static void Error(double AVG, double tol);
 
183
  static void Recur_Error(adapt_tet *t, double AVG, double tol);
207
184
  bool visible;
208
185
  adapt_point *p[4];
209
186
  adapt_tet *e[8];
213
190
 
214
191
class adapt_hex
215
192
{
216
 
public:
217
 
  adapt_hex (adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4,
218
 
             adapt_point *p5, adapt_point *p6, adapt_point *p7, adapt_point *p8)    
219
 
    : visible (false)
 
193
 public:
 
194
  adapt_hex(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4,
 
195
            adapt_point *p5, adapt_point *p6, adapt_point *p7, adapt_point *p8)    
 
196
    : visible(false)
220
197
  {
221
198
    p[0] = p1;
222
199
    p[1] = p2;
229
206
    e[0] = e[1] = e[2] = e[3] = 0;
230
207
    e[4] = e[5] = e[6] = e[7] = 0;
231
208
  }
232
 
  inline static void GSF (const double u, const double v, double w, double sf[])
 
209
  inline static void GSF(const double u, const double v, double w, double sf[])
233
210
  {
234
211
    sf[0] = 0.125 * (1 - u) * (1 - v) * (1 - w);
235
212
    sf[1] = 0.125 * (1 + u) * (1 - v) * (1 - w);
240
217
    sf[6] = 0.125 * (1 + u) * (1 + v) * (1 + w);
241
218
    sf[7] = 0.125 * (1 - u) * (1 + v) * (1 + w);
242
219
  }
243
 
  inline double V () const
 
220
  inline double V() const
244
221
  {
245
222
    return (p[0]->val + p[1]->val + p[2]->val+ p[3]->val +
246
 
            p[4]->val + p[5]->val + p[6]->val+ p[7]->val)/8.;    
247
 
  }
248
 
  void print ()
249
 
  {
250
 
    printf("p1 %g %g p2 %g %g p3 %g %g\n",
251
 
           p[0]->x, p[0]->y, p[1]->x, p[1]->y, p[2]->x, p[2]->y);
252
 
  }
253
 
  static void Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
254
 
  static void Recur_Create (adapt_hex *h, int maxlevel, int level,
255
 
                            Double_Matrix *coeffs, Double_Matrix *eexps);
256
 
  static void Error (double AVG, double tol);
257
 
  static void Recur_Error (adapt_hex *h, double AVG, double tol);
 
223
            p[4]->val + p[5]->val + p[6]->val+ p[7]->val) / 8.;
 
224
  }
 
225
  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
 
226
  static void Recur_Create(adapt_hex *h, int maxlevel, int level,
 
227
                           Double_Matrix *coeffs, Double_Matrix *eexps);
 
228
  static void Error(double AVG, double tol);
 
229
  static void Recur_Error(adapt_hex *h, double AVG, double tol);
258
230
  bool visible;
259
231
  adapt_point *p[8];
260
232
  adapt_hex *e[8];
268
240
  double minval, maxval;
269
241
  int presentZoomLevel;
270
242
  double presentTol;
271
 
  Double_Matrix * _eexps;
272
 
  Double_Matrix * _coefs;
273
 
  Double_Matrix * _coefsGeom;
274
 
  Double_Matrix * _eexpsGeom;
275
 
  Double_Matrix * _STposX;
276
 
  Double_Matrix * _STposY;
277
 
  Double_Matrix * _STposZ;
278
 
  Double_Matrix * _STval;
 
243
  Double_Matrix *_eexps;
 
244
  Double_Matrix *_coefs;
 
245
  Double_Matrix *_coefsGeom;
 
246
  Double_Matrix *_eexpsGeom;
 
247
  Double_Matrix *_STposX;
 
248
  Double_Matrix *_STposY;
 
249
  Double_Matrix *_STposZ;
 
250
  Double_Matrix *_STval;
279
251
  // for vectors
280
 
  Double_Matrix * _STvalX;
281
 
  Double_Matrix * _STvalY;
282
 
  Double_Matrix * _STvalZ;
283
 
  Double_Matrix * _Interpolate;
284
 
  Double_Matrix * _Geometry;
 
252
  Double_Matrix *_STvalX;
 
253
  Double_Matrix *_STvalY;
 
254
  Double_Matrix *_STvalZ;
 
255
  Double_Matrix *_Interpolate;
 
256
  Double_Matrix *_Geometry;
285
257
public:
286
 
  Adaptive_Post_View (Post_View *view, List_T *_coeffs, List_T *_eexps, List_T *_coeffsGeom=0, List_T *_eexpsGeom=0);
287
 
  ~Adaptive_Post_View ();
288
 
  int getGlobalResolutionLevel () const { return presentZoomLevel; }
289
 
  void setGlobalResolutionLevel (Post_View * view, int level)
 
258
  Adaptive_Post_View(PViewDataList *data, List_T *_coeffs, List_T *_eexps, 
 
259
                     List_T *_coeffsGeom=0, List_T *_eexpsGeom=0);
 
260
  ~Adaptive_Post_View();
 
261
  int getGlobalResolutionLevel() const { return presentZoomLevel; }
 
262
  void setGlobalResolutionLevel(PViewDataList *data, int level)
290
263
  {
291
 
    setAdaptiveResolutionLevel(view, level);
 
264
    setAdaptiveResolutionLevel(data, level);
292
265
  }
293
 
  template <class ELEM>
294
 
  void setAdaptiveResolutionLevel_TEMPL(Post_View * view, int level, int lemvelmax,
295
 
                                        GMSH_Post_Plugin *plug, List_T **myList,
296
 
                                        int *counter, int *done);
297
 
  void setAdaptiveResolutionLevel (Post_View * view , int levelmax, 
298
 
                                   GMSH_Post_Plugin *plug = 0);
299
 
  void initWithLowResolution (Post_View *view);
300
 
  void setTolerance (const double eps) { tol=eps; }
301
 
  double getTolerance () const { return tol; }
302
 
  template <class ELEM>
303
 
  int zoomElement (Post_View * view, int ielem, int level, int levelmax, 
304
 
                   GMSH_Post_Plugin *plug, List_T *theList, int *counter);
 
266
  void setAdaptiveResolutionLevel(PViewDataList *data, int levelmax, 
 
267
                                  GMSH_Post_Plugin *plug=0);
 
268
  template <class ELEM>
 
269
  void setAdaptiveResolutionLevel_TEMPL(int level, int lemvelmax,
 
270
                                        GMSH_Post_Plugin *plug, List_T **myList,
 
271
                                        int *counter, int *done);
 
272
  void initWithLowResolution(PViewDataList *data);
 
273
  void setTolerance(const double eps) { tol = eps; }
 
274
  double getTolerance() const { return tol; }
 
275
  template <class ELEM>
 
276
  int zoomElement(int ielem, int level, int levelmax, 
 
277
                  GMSH_Post_Plugin *plug, List_T *theList, int *counter);
305
278
};
306
279
 
307
280
template <class ELEM>
308
 
void cleanElement ()
 
281
void cleanElement()
309
282
{  
310
 
  typename std::list<ELEM*>::iterator it =  ELEM::all_elems.begin();
311
 
  typename std::list<ELEM*>::iterator ite =  ELEM::all_elems.end();
312
 
  for (; it != ite; ++it){
 
283
  typename std::list<ELEM*>::iterator it = ELEM::all_elems.begin();
 
284
  typename std::list<ELEM*>::iterator ite = ELEM::all_elems.end();
 
285
  for(; it != ite; ++it){
313
286
    delete *it;
314
287
  }
315
288
  ELEM::all_elems.clear();