source: issm/trunk/src/c/objects/Bamg/GeometricalEdge.cpp@ 5447

Last change on this file since 5447 was 5447, checked in by Mathieu Morlighem, 15 years ago

As usual

File size: 4.5 KB
RevLine 
[3913]1#include <cstdio>
2#include <string.h>
3#include <cmath>
4
5#include "../../include/include.h"
6#include "../../shared/Exceptions/exceptions.h"
7
8#include "GeometricalEdge.h"
9#include "Geometry.h"
10
11using namespace std;
12
13namespace bamg {
14
15 /*Constructor/Destructor*/
16
17 /*Methods*/
[5151]18 /*FUNCTION GeometricalEdge::Cracked{{{1*/
19 int GeometricalEdge::Cracked() const {
20 return type &1;
21 }/*}}}*/
22 /*FUNCTION GeometricalEdge::F{{{1*/
23 R2 GeometricalEdge::F(double theta) const{
24 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/F)*/
25 // parametrization of the curve edge
26
27 R2 A=v[0]->r,B=v[1]->r;
28 double ca,cb,cta,ctb;
[5447]29
30 //Check that theta is in [0 1]
31 ISSMASSERT(theta>-1e-12 && theta<1+1e-12);
32
[5151]33 if (TgA())
34 if (TgB()) // interpolation d'hermite
35 { cb = theta*theta*(3-2*theta);
36 ca = 1-cb;
37 cta = (1-theta)*(1-theta)*theta;
38 ctb = (theta-1)*theta*theta ;
39 }
40 else { // 1-t*t, t-t*t, t*t
41 double t = theta;
42 cb = t*t;
43 ca = 1-cb;
44 cta= t-cb;
45 ctb=0;
46 }
47 else
48 if (TgB()){
49 double t = 1-theta;
50 ca = t*t;
51 cb = 1-ca;
52 ctb= -t+ca;
53 cta=0;
54 }
55 else {
56 ca =(1-theta),cb = theta,cta=ctb=0; // lagrange P1
57 }
58 return A*ca + B*cb + tg[0]* cta + tg[1] * ctb;
59 }
60 /*}}}1*/
61 /*FUNCTION GeometricalEdge::Mark{{{1*/
62 int GeometricalEdge::Mark() const {
63 return type &16;
64 }/*}}}*/
[3913]65 /*FUNCTION GeometricalEdge::R1tg{{{1*/
66 double GeometricalEdge::R1tg(double theta,R2 & t) const{
67 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/R1tg)*/
68 // 1/R of radius of cuvature
69
70 R2 A=v[0]->r,B=v[1]->r;
71 double dca,dcb,dcta,dctb;
72 double ddca,ddcb,ddcta,ddctb;
73 double tt = theta*theta;
74
75 //check theta
76 ISSMASSERT(theta>=0 && theta<=1);
77
78 if (TgA()){
79 if (TgB()){
80 // Tangent A and B provided:
81 // interpolation d'hermite
82 dcb = 6*theta*(1-theta);
83 ddcb = 6*(1-2*theta);
84 dca = -dcb;
85 ddca = -ddcb;
86 dcta = (3*theta - 4)*theta + 1;
87 ddcta=6*theta-4;
88 dctb = 3*tt - 2*theta;
89 ddctb = 6*theta-2;
90 }
91 else {
92 //Tangent A provided but tangent B not provided
93 // 1-t*t, t-t*t, t*t
94 double t = theta;
95 dcb = 2*t;
96 ddcb = 2;
97 dca = -dcb;
98 ddca = -2;
99 dcta = 1-dcb;
100 ddcta = -ddcb;
101 dctb=0;
102 ddctb=0;
103 }
104 }
105 else{
106 if (TgB()){
107 //Tangent B provided but tangent A not provided
108 double t = 1-theta;
109 dca = -2*t;
110 ddca = 2;
111 dcb = -dca;
112 ddcb = -2;
113 dctb = 1+dca;
114 ddctb= ddca;
115 dcta =0;
116 ddcta =0;
117 }
118 else {
119 //Neither thangent A nor tangent B provided
120 // lagrange P1
121 t=B-A;
122 return 0;
123 }
124 }
125 R2 d = A*dca + B*dcb + tg[0]* dcta + tg[1] * dctb;
126 R2 dd = A*ddca + B*ddcb + tg[0]* ddcta + tg[1] * ddctb;
127 double d2=(d,d);
128 double sd2 = sqrt(d2);
129 t=d;
130 if(d2>1.0e-20){
131 t/=sd2;
132 return Abs(Det(d,dd))/(d2*sd2);
133 }
134 else return 0;
135 }
136 /*}}}1*/
[5151]137 /*FUNCTION GeometricalEdge::Required{{{1*/
138 int GeometricalEdge::Required() {
139 return type &64;
140 }/*}}}*/
[3913]141 /*FUNCTION GeometricalEdge::Set {{{1*/
142 void GeometricalEdge::Set(const GeometricalEdge & rec,const Geometry & Gh ,Geometry & GhNew){
143 *this = rec;
[5149]144 v[0] = GhNew.vertices + Gh.GetId(v[0]);
145 v[1] = GhNew.vertices + Gh.GetId(v[1]);
146 if (Adj[0]) Adj[0] = GhNew.edges + Gh.GetId(Adj[0]);
147 if (Adj[1]) Adj[1] = GhNew.edges + Gh.GetId(Adj[1]);
[3913]148 }
149 /*}}}*/
[5151]150 /*FUNCTION GeometricalEdge::SetCracked{{{1*/
151 void GeometricalEdge::SetCracked() {
[5397]152 type |= 1;/*=>1st digit to 1*/
[5151]153 }/*}}}*/
154 /*FUNCTION GeometricalEdge::SetTgA{{{1*/
155 void GeometricalEdge::SetTgA() {
[5397]156 type |=4; /*=>2d digit to 1*/
[5151]157 }/*}}}*/
158 /*FUNCTION GeometricalEdge::SetTgB{{{1*/
159 void GeometricalEdge::SetTgB() {
[5397]160 type |=8; /*=> 3d digit to 1*/
[5151]161 }/*}}}*/
162 /*FUNCTION GeometricalEdge::SetMark{{{1*/
163 void GeometricalEdge::SetMark() {
[5397]164 type |=16;/*=> 4th digiy to 1*/
[5151]165 }/*}}}*/
166 /*FUNCTION GeometricalEdge::SetUnMark{{{1*/
167 void GeometricalEdge::SetUnMark() {
[5397]168 type &= 1007 /* 1023-16 = 000111110111 => 4th digit to 0*/;
[5151]169 }/*}}}*/
170 /*FUNCTION GeometricalEdge::SetRequired{{{1*/
171 void GeometricalEdge::SetRequired() {
[5447]172 type |= 64;/*=>6th digit to 1*/
[5151]173 }/*}}}*/
174 /*FUNCTION GeometricalEdge::Tg{{{1*/
175 int GeometricalEdge::Tg(int i) const {
176 return i==0 ? TgA() : TgB();
177 }/*}}}*/
178 /*FUNCTION GeometricalEdge::TgA{{{1*/
179 int GeometricalEdge::TgA() const {
180 return type &4;
181 }/*}}}*/
182 /*FUNCTION GeometricalEdge::TgB{{{1*/
183 int GeometricalEdge::TgB() const {
184 return type &8;
185 }/*}}}*/
[3913]186}
Note: See TracBrowser for help on using the repository browser.