177
178
double mesh_functional_distorsion(MTriangle *t, double u, double v)
179
180
// compute uncurved element jacobian d_u x and d_v x
180
181
double mat[3][3];
181
double d1 = t->getPrimaryJacobian(u,v,0,mat);
183
//double d1 = t->getJacobian(u,v,0,mat);
182
t->getPrimaryJacobian(u, v, 0, mat);
183
// t->getJacobian(u,v,0,mat);
184
184
double v1[3] = {mat[0][0], mat[0][1], mat[0][2]};
185
185
double v2[3] = {mat[1][0], mat[1][1], mat[1][2]};
186
186
double normal1[3];
187
187
prodve(v1, v2, normal1);
188
188
double nn = sqrt(normal1[0]*normal1[0] +
189
normal1[1]*normal1[1] +
190
normal1[2]*normal1[2]);
189
normal1[1]*normal1[1] +
190
normal1[2]*normal1[2]);
192
192
// compute uncurved element jacobian d_u x and d_v x
194
double d2 = t->getJacobian(u, v, 0, mat);
194
t->getJacobian(u, v, 0, mat);
196
195
double v1b[3] = {mat[0][0], mat[0][1], mat[0][2]};
197
196
double v2b[3] = {mat[1][0], mat[1][1], mat[1][2]};
198
197
double normal[3];
199
198
prodve(v1b, v2b, normal);
202
201
prosca(normal1, normal, &sign);
203
202
double det = norm3(normal) * (sign > 0 ? 1. : -1.) / nn;
203
//double det = norm3(normal);
205
205
// compute distorsion
206
double dist = std::min(1. / det, det);
206
// double dist = std::min(1. / det, det);
210
double mesh_functional_distorsion_p2(MTriangle *t)
212
double d = mesh_functional_distorsion(t,0.,0.);
213
d = std::min(d,mesh_functional_distorsion(t,1.,0.));
214
d = std::min(d,mesh_functional_distorsion(t,0.,1.));
215
d = std::min(d,mesh_functional_distorsion(t,.5,0.));
216
d = std::min(d,mesh_functional_distorsion(t,0.,0.5));
217
d = std::min(d,mesh_functional_distorsion(t,.5,0.5));
211
221
double qmDistorsionOfMapping (MTriangle *e)
214
if (e->getPolynomialOrder() == 1)return 1.0;
224
if (e->getPolynomialOrder() == 1) return 1.0;
225
// if (e->getPolynomialOrder() == 2) return mesh_functional_distorsion_p2(e);
217
229
e->getIntegrationPoints(e->getPolynomialOrder(),&npts, &pts);
219
for (int i=0;i<npts;i++){
231
for (int i = 0 ; i < npts; i++){
220
232
const double u = pts[i].pt[0];
221
233
const double v = pts[i].pt[1];
222
const double w = pts[i].pt[2];
223
const double di = mesh_functional_distorsion (e,u,v);
224
dmin = (i==0)? di : std::min(dmin,di);
234
const double di = mesh_functional_distorsion (e, u, v);
235
dmin = (i == 0)? di : std::min(dmin, di);
226
237
const gmshMatrix<double>& points = e->getFunctionSpace()->points;
228
for (int i=0;i<e->getNumPrimaryVertices();i++) {
229
const double u = points(i,0);
230
const double v = points(i,1);
231
const double di = mesh_functional_distorsion (e,u,v);
232
dmin = std::min(dmin,di);
239
for (int i = 0; i < e->getNumPrimaryVertices(); i++) {
240
const double u = points(i, 0);
241
const double v = points(i, 1);
242
const double di = mesh_functional_distorsion (e, u, v);
243
dmin = std::min(dmin, di);
239
250
// compute uncurved element jacobian d_u x and d_v x
240
251
double mat[3][3];
241
t->getPrimaryJacobian(u,v,w, mat);
252
t->getPrimaryJacobian(u, v, w, mat);
243
254
const double det1 = det3x3(mat);
245
256
//const double det1 = t->getJacobian(u,v,w,mat);
246
257
// const double det1 = det3x3(mat);
247
t->getJacobian(u,v,w,mat);
258
t->getJacobian(u, v, w, mat);
248
259
const double detN = det3x3(mat);
249
260
// const double detN = det3x3(mat);
251
262
// printf("%g %g %g = %g %g\n",u,v,w,det1,detN);
253
264
if (det1 == 0 || detN == 0) return 0;
254
double dist = std::min(detN/det1, det1/detN);
265
double dist = std::min(detN / det1, det1 / detN);
259
double qmDistorsionOfMapping (MTetrahedron *e)
269
double qmDistorsionOfMapping(MTetrahedron *e)
261
if (e->getPolynomialOrder() == 1)return 1.0;
271
if (e->getPolynomialOrder() == 1) return 1.0;
264
e->getIntegrationPoints(e->getPolynomialOrder(),&npts, &pts);
274
e->getIntegrationPoints(e->getPolynomialOrder(), &npts, &pts);
266
for (int i=0;i<npts;i++){
276
for (int i = 0; i < npts; i++){
267
277
const double u = pts[i].pt[0];
268
278
const double v = pts[i].pt[1];
269
279
const double w = pts[i].pt[2];
270
const double di = mesh_functional_distorsion (e,u,v,w);
271
dmin = (i==0)? di : std::min(dmin,di);
280
const double di = mesh_functional_distorsion(e, u, v, w);
281
dmin = (i == 0) ? di : std::min(dmin, di);
274
284
const gmshMatrix<double>& points = e->getFunctionSpace()->points;
276
for (int i=0;i<e->getNumPrimaryVertices();i++) {
277
const double u = points(i,0);
278
const double v = points(i,1);
279
const double w = points(i,2);
280
const double di = mesh_functional_distorsion (e,u,v,w);
281
dmin = std::min(dmin,di);
286
for (int i = 0; i < e->getNumPrimaryVertices(); i++) {
287
const double u = points(i, 0);
288
const double v = points(i, 1);
289
const double w = points(i, 2);
290
const double di = mesh_functional_distorsion(e, u, v, w);
291
dmin = std::min(dmin, di);
283
// printf("DMIN = %g\n\n",dmin);
285
return dmin< 0 ? 0 :dmin;