Ice Sheet System Model  4.18
Code documentation
GeomEdge.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <string.h>
3 #include <cmath>
4 
5 #include "../shared/shared.h"
6 
7 #include "GeomEdge.h"
8 #include "Geometry.h"
9 
10 using namespace std;
11 
12 namespace bamg {
13 
14  /*Constructor/Destructor*/
15 
16  /*Methods*/
17  int GeomEdge::Cracked() const {/*{{{*/
18  return type &1;
19  }/*}}}*/
20  R2 GeomEdge::F(double theta) const{/*{{{*/
21  /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/F)*/
22  // parametrization of the curve edge
23 
24  R2 A=v[0]->r,B=v[1]->r;
25  double ca,cb,cta,ctb;
26 
27  //Check that theta is in [0 1]
28  _assert_(theta>-1e-12 && theta<1+1e-12);
29 
30  if (TgA()){
31  if (TgB()){ //Hermite interpolation
32  cb = theta*theta*(3-2*theta);
33  ca = 1-cb;
34  cta = (1-theta)*(1-theta)*theta;
35  ctb = (theta-1)*theta*theta ;
36  }
37  else {
38  double t = theta;
39  cb = t*t;
40  ca = 1-cb;
41  cta= t-cb;
42  ctb=0;
43  }
44  }
45  else{
46  if (TgB()){
47  double t = 1-theta;
48  ca = t*t;
49  cb = 1-ca;
50  ctb= -t+ca;
51  cta=0;
52  }
53  else { // lagrange P1
54  ca =(1-theta);
55  cb = theta;
56  cta=ctb=0;
57  }
58  }
59  return A*ca + B*cb + tg[0]*cta + tg[1]*ctb;
60  }
61  /*}}}*/
62  int GeomEdge::Mark() const {/*{{{*/
63  return type &16;
64  }/*}}}*/
65  int GeomEdge::Required() {/*{{{*/
66  return type &64;
67  }/*}}}*/
68  void GeomEdge::Set(const GeomEdge & rec,const Geometry & Gh ,Geometry & GhNew){ /*{{{*/
69  *this = rec;
70  v[0] = GhNew.vertices + Gh.GetId(v[0]);
71  v[1] = GhNew.vertices + Gh.GetId(v[1]);
72  if (Adj[0]) Adj[0] = GhNew.edges + Gh.GetId(Adj[0]);
73  if (Adj[1]) Adj[1] = GhNew.edges + Gh.GetId(Adj[1]);
74  }
75  /*}}}*/
76  void GeomEdge::SetCracked() { /*{{{*/
77  type |= 1;/*=>1st digit to 1*/
78  }/*}}}*/
79  void GeomEdge::SetTgA() { /*{{{*/
80  type |=4; /*=>2d digit to 1*/
81  }/*}}}*/
82  void GeomEdge::SetTgB() { /*{{{*/
83  type |=8; /*=> 3d digit to 1*/
84  }/*}}}*/
85  void GeomEdge::SetMark() { /*{{{*/
86  type |=16;/*=> 4th digiy to 1*/
87  }/*}}}*/
88  void GeomEdge::SetUnMark() { /*{{{*/
89  type &= 1007 /* 1023-16 = 000111110111 => 4th digit to 0*/;
90  }/*}}}*/
91  void GeomEdge::SetRequired() { /*{{{*/
92  type |= 64;/*=>6th digit to 1*/
93  }/*}}}*/
94  int GeomEdge::TgA() const {/*{{{*/
95  return type &4;
96  }/*}}}*/
97  int GeomEdge::TgB() const {/*{{{*/
98  return type &8;
99  }/*}}}*/
100 }
GeomEdge.h
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
bamg::Geometry
Definition: Geometry.h:18
bamg
Definition: AdjacentTriangle.cpp:9
bamg::Geometry::edges
GeomEdge * edges
Definition: Geometry.h:28
Geometry.h
bamg::Adj
AdjacentTriangle Adj(const AdjacentTriangle &a)
Definition: Mesh.h:164
bamg::Geometry::vertices
GeomVertex * vertices
Definition: Geometry.h:27
bamg::GeomEdge
Definition: GeomEdge.h:11
bamg::Geometry::GetId
long GetId(const GeomVertex &t) const
Definition: Geometry.cpp:425
bamg::P2< double, double >