~ubuntu-branches/debian/sid/gmsh/sid

« back to all changes in this revision

Viewing changes to Mesh/BackgroundMesh2D.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-08-26 22:45:27 UTC
  • mfrom: (1.3.25)
  • Revision ID: package-import@ubuntu.com-20150826224527-wiqnz3dwz6ap8tty
Tags: 2.10.1+dfsg1-1
* [4c450d1] Update d/watch.
* [90ca918] Imported Upstream version 2.10.1+dfsg1. (Closes: #793245)
* [af26665] Use any-arch instead of list of archs.
* [e94c6d2] Refresh patches.
* [6ab417f] Update d/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
void backgroundMesh2D::create_face_mesh()
62
62
{
63
 
  quadsToTriangles(dynamic_cast<GFace*>(gf), 100000);
 
63
  GFace *face = dynamic_cast<GFace*>(gf);
 
64
  if(!face){
 
65
    Msg::Error("Entity is not a face in background mesh");
 
66
    return;
 
67
  }
 
68
 
 
69
  quadsToTriangles(face, 100000);
64
70
 
65
71
  // storing the initial mesh from GFace
66
72
  tempTR.clear();
67
 
  GFace *face = dynamic_cast<GFace*>(gf);
 
73
 
68
74
  for(unsigned int i = 0; i < face->triangles.size(); i++)
69
 
    tempTR.push_back(new MTriangle(face->triangles[i]->getVertex(0), face->triangles[i]->getVertex(1), face->triangles[i]->getVertex(2)));
 
75
    tempTR.push_back(new MTriangle(face->triangles[i]->getVertex(0),
 
76
                                   face->triangles[i]->getVertex(1),
 
77
                                   face->triangles[i]->getVertex(2)));
70
78
 
71
79
  // avoid computing curvatures on the fly : only on the
72
80
  // BGM computes once curvatures at each node
121
129
  }
122
130
}
123
131
 
124
 
 
125
 
void backgroundMesh2D::unset(){
 
132
void backgroundMesh2D::unset()
 
133
{
126
134
  for (unsigned int i = 0; i < vertices.size(); i++) delete vertices[i];
127
135
  for (unsigned int i = 0; i < getNumMeshElements(); i++) delete elements[i];
128
136
  if (octree)delete octree;
129
137
  octree=NULL;
130
138
}
131
139
 
132
 
 
133
 
void backgroundMesh2D::create_mesh_copy(){
 
140
void backgroundMesh2D::create_mesh_copy()
 
141
{
134
142
  // TODO: useful to extend it to other elements ???
135
143
  //std::set<SPoint2> myBCNodes;
136
144
  GFace *face = dynamic_cast<GFace*>(gf);
 
145
  if(!face){
 
146
    Msg::Error("Entity is not a face in background mesh");
 
147
    return;
 
148
  }
137
149
  for (unsigned int i = 0; i < face->triangles.size(); i++){
138
150
    MTriangle *e = face->triangles[i];
139
151
    MVertex *news[3];
158
170
}
159
171
 
160
172
 
161
 
GPoint backgroundMesh2D::get_GPoint_from_MVertex(const MVertex *v)const{
162
 
  return dynamic_cast<GFace*>(gf)->point(SPoint2(v->x(),v->y()));
 
173
GPoint backgroundMesh2D::get_GPoint_from_MVertex(const MVertex *v)const
 
174
{
 
175
  GFace *face = dynamic_cast<GFace*>(gf);
 
176
  if(!face){
 
177
    Msg::Error("Entity is not a face in background mesh");
 
178
    return GPoint();
 
179
  }
 
180
  return face->point(SPoint2(v->x(),v->y()));
163
181
}
164
182
 
165
183
 
171
189
    // now, the new mesh has been copied in local in backgroundMesh2D, deleting the mesh
172
190
    // from GFace, back to the previous one !
173
191
    GFace *face = dynamic_cast<GFace*>(gf);
174
 
    face->triangles = tempTR;
 
192
    if(!face)
 
193
      Msg::Error("Entity is not a face in background mesh");
 
194
    else
 
195
      face->triangles = tempTR;
175
196
  }
176
197
}
177
198
 
181
202
}
182
203
 
183
204
 
184
 
void backgroundMesh2D::propagateValues(DoubleStorageType &dirichlet, simpleFunction<double> &eval_diffusivity, bool in_parametric_plane){
 
205
void backgroundMesh2D::propagateValues(DoubleStorageType &dirichlet,
 
206
                                       simpleFunction<double> &eval_diffusivity,
 
207
                                       bool in_parametric_plane)
 
208
{
185
209
#if defined(HAVE_SOLVER)
186
210
  linearSystem<double> *_lsys = 0;
187
211
#if defined(HAVE_PETSC) && !defined(HAVE_TAUCS)
207
231
  // Number vertices
208
232
  std::set<MVertex*> vs;
209
233
  GFace *face = dynamic_cast<GFace*>(gf);
 
234
  if(!face){
 
235
    Msg::Error("Entity is not a face in background mesh");
 
236
    delete _lsys;
 
237
    return;
 
238
  }
210
239
  for (unsigned int k = 0; k < face->triangles.size(); k++)
211
240
    for (int j=0;j<3;j++)vs.insert(face->triangles[k]->getVertex(j));
212
241
  for (unsigned int k = 0; k < face->quadrangles.size(); k++)
213
242
    for (int j=0;j<4;j++)vs.insert(face->quadrangles[k]->getVertex(j));
214
243
 
215
 
 
216
244
  std::map<MVertex*,SPoint3> theMap;
217
245
  if ( in_parametric_plane) {
218
246
    for (std::set<MVertex*>::iterator it = vs.begin(); it != vs.end(); ++it){
254
282
#endif
255
283
}
256
284
 
257
 
 
258
 
void backgroundMesh2D::computeSizeField(){
 
285
void backgroundMesh2D::computeSizeField()
 
286
{
259
287
  GFace *face = dynamic_cast<GFace*>(gf);
260
 
  list<GEdge*> e;// = face->edges();
 
288
  if(!face){
 
289
    Msg::Error("Entity is not a face in background mesh");
 
290
    return;
 
291
  }
 
292
 
 
293
  list<GEdge*> e;
261
294
  replaceMeshCompound(face, e);
262
295
  list<GEdge*>::const_iterator it = e.begin();
263
296
  DoubleStorageType sizes;
303
336
}
304
337
 
305
338
 
306
 
void backgroundMesh2D::updateSizes(){
 
339
void backgroundMesh2D::updateSizes()
 
340
{
307
341
  DoubleStorageType::iterator itv = sizeField.begin();
308
342
  for ( ; itv != sizeField.end(); ++itv){
309
343
    SPoint2 p;
319
353
    }
320
354
    else{
321
355
      GFace *face = dynamic_cast<GFace*>(gf);
 
356
      if(!face){
 
357
        Msg::Error("Entity is not a face in background mesh");
 
358
        return;
 
359
      }
322
360
      reparamMeshVertexOnFace(v, face, p);
323
361
      lc = sizeFactor * BGM_MeshSize(face, p.x(), p.y(), v->x(), v->y(), v->z());
324
362
    }
363
401
  // now, the new mesh has been copied in local in backgroundMesh2D, deleting the mesh
364
402
  // from GFace, back to the previous one !
365
403
  GFace *face = dynamic_cast<GFace*>(gf);
366
 
  face->triangles = tempTR;
 
404
  if(!face)
 
405
    Msg::Error("Entity is not a face in background mesh");
 
406
  else
 
407
    face->triangles = tempTR;
367
408
}
368
409
 
369
410
frameFieldBackgroundMesh2D::~frameFieldBackgroundMesh2D(){}
437
478
 
438
479
  list<GEdge*> e;
439
480
  GFace *face = dynamic_cast<GFace*>(gf);
 
481
  if(!face){
 
482
    Msg::Error("Entity is not a face in background mesh");
 
483
    return;
 
484
  }
 
485
 
440
486
  replaceMeshCompound(face, e);
441
487
 
442
488
  list<GEdge*>::const_iterator it = e.begin();
523
569
{
524
570
  SPoint2 parampoint;
525
571
  GFace *face = dynamic_cast<GFace*>(gf);
 
572
  if(!face){
 
573
    Msg::Error("Entity is not a face in background mesh");
 
574
    return;
 
575
  }
526
576
  reparamMeshVertexOnFace(vert, face, parampoint);
527
577
  return eval_crossfield(parampoint[0], parampoint[1], cf);
528
578
}
596
646
}
597
647
 
598
648
// returns the cross field as a pair of othogonal vectors (NOT in parametric coordinates, but real 3D coordinates)
599
 
Pair<SVector3, SVector3> frameFieldBackgroundMesh2D::compute_crossfield_directions(double u,double v, double angle_current)
 
649
Pair<SVector3, SVector3> frameFieldBackgroundMesh2D::compute_crossfield_directions(double u, double v,
 
650
                                                                                   double angle_current)
600
651
{
601
652
  // get the unit normal at that point
602
653
  GFace *face = dynamic_cast<GFace*>(gf);
 
654
  if(!face){
 
655
    Msg::Error("Entity is not a face in background mesh");
 
656
    return Pair<SVector3,SVector3>(SVector3(), SVector3());
 
657
  }
 
658
 
603
659
  Pair<SVector3, SVector3> der = face->firstDer(SPoint2(u,v));
604
660
  SVector3 s1 = der.first();
605
661
  SVector3 s2 = der.second();
623
679
 
624
680
bool frameFieldBackgroundMesh2D::compute_RK_infos(double u,double v, double x, double y, double z, RK_form &infos)
625
681
{
626
 
 
627
682
  // check if point is in domain
628
683
  if (!inDomain(u,v)) return false;
629
684
 
635
690
 
636
691
  // get the unit normal at that point
637
692
  GFace *face = dynamic_cast<GFace*>(gf);
 
693
  if(!face){
 
694
    Msg::Error("Entity is not a face in background mesh");
 
695
    return false;
 
696
  }
 
697
 
638
698
  Pair<SVector3, SVector3> der = face->firstDer(SPoint2(u,v));
639
699
  SVector3 s1 = der.first();
640
700
  SVector3 s2 = der.second();