1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 | /* *****************************************************************
MESQUITE -- The Mesh Quality Improvement Toolkit
Copyright 2004 Sandia Corporation and Argonne National
Laboratory. Under the terms of Contract DE-AC04-94AL85000
with Sandia Corporation, the U.S. Government retains certain
rights in this software.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
(lgpl.txt) along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[email protected], [email protected], [email protected],
[email protected], [email protected], [email protected]
***************************************************************** */
// -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3
// -*-
/*! \file ConditionNumberFunctions.hpp
Header file for the MBMesquite::ShapeQualityMetric class
\author Thomas Leurent
\date 2002-09-01
*/
#ifndef ConditionNumberFunctions_hpp
#define ConditionNumberFunctions_hpp
#include "Mesquite.hpp"
#include "MsqError.hpp"
#include "QualityMetric.hpp"
#include "PatchData.hpp"
namespace MBMesquite
{
static inline bool condition_number_2d( const Vector3D temp_vec[],
size_t e_ind,
PatchData& pd,
double& fval,
MsqError& err )
{
// norm squared of J
double term1 = temp_vec[0] % temp_vec[0] + temp_vec[1] % temp_vec[1];<--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
Vector3D unit_surf_norm;
pd.get_domain_normal_at_element( e_ind, unit_surf_norm, err );
MSQ_ERRZERO( err );
unit_surf_norm.normalize();
// det J
double temp_var = unit_surf_norm % ( temp_vec[0] * temp_vec[1] );
// revert to old, non-barrier form
if( temp_var <= 0.0 ) return false;
fval = term1 / ( 2.0 * temp_var );
return true;
/*
double h;
double delta=pd.get_barrier_delta(err); MSQ_ERRZERO(err);
// Note: technically, we want delta=eta*tau-max
// whereas the function above gives delta=eta*alpha-max
//
// Because the only requirement on eta is eta << 1,
// and because tau-max = alpha-max/0.707 we can
// ignore the discrepancy
if (delta==0) {
if (temp_var < MSQ_DBL_MIN ) {
return false;
}
else {
h=temp_var;
}
// Note: when delta=0, the vertex_barrier_function
// formally gives h=temp_var as well.
// We just do it this way to avoid any
// roundoff issues.
// Also: when delta=0, this metric is identical
// to the original condition number with
// the barrier at temp_var=0
}
else {
h = QualityMetric::vertex_barrier_function(temp_var,delta);
if (h<MSQ_DBL_MIN && fabs(temp_var) > MSQ_DBL_MIN ) {
h = delta*delta/fabs(temp_var); }
// Note: Analytically, h is strictly positive, but
// it can be zero numerically if temp_var
// is a large negative number
// In the case h=0, we use a different analytic
// approximation to compute h.
}
if (h<MSQ_DBL_MIN) {
MSQ_SETERR(err)( "Barrier function is zero due to excessively large "
"negative area compared to delta. /n Try to untangle "
"mesh another way. ", MsqError::INVALID_MESH);
return false;
}
fval=term1/(2*h);
if (fval>MSQ_MAX_CAP) {
fval=MSQ_MAX_CAP;
}
return true;
*/
}
//} //namespace
static inline bool condition_number_3d( const Vector3D temp_vec[], PatchData& /*pd*/, double& fval, MsqError& /*err*/ )
{
// norm squared of J
double term1 = temp_vec[0] % temp_vec[0] + temp_vec[1] % temp_vec[1] + temp_vec[2] % temp_vec[2];<--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
// norm squared of adjoint of J
double term2 = ( temp_vec[0] * temp_vec[1] ) % ( temp_vec[0] * temp_vec[1] ) +<--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
( temp_vec[1] * temp_vec[2] ) % ( temp_vec[1] * temp_vec[2] ) +<--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
( temp_vec[2] * temp_vec[0] ) % ( temp_vec[2] * temp_vec[0] );<--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct. <--- Same expression on both sides of '%'. [+]Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
// det of J
double temp_var = temp_vec[0] % ( temp_vec[1] * temp_vec[2] );
// revert to old, non-barrier formulation
if( temp_var <= 0.0 ) return false;
fval = sqrt( term1 * term2 ) / ( 3.0 * temp_var );
return true;
/*
double h;
double delta=pd.get_barrier_delta(err); MSQ_ERRZERO(err);
// Note: technically, we want delta=eta*tau-max
// whereas the function above gives delta=eta*alpha-max
//
// Because the only requirement on eta is eta << 1,
// and because tau-max = alpha-max/0.707 we can
// ignore the discrepancy
if (delta==0) {
if (temp_var < MSQ_DBL_MIN ) {
return false;
}
else {
h=temp_var;
}
// Note: when delta=0, the vertex_barrier_function
// formally gives h=temp_var as well.
// We just do it this way to avoid any
// roundoff issues.
// Also: when delta=0, this metric is identical
// to the original condition number with
// the barrier at temp_var=0
}
else {
h = QualityMetric::vertex_barrier_function(temp_var,delta);
if (h<MSQ_DBL_MIN && fabs(temp_var) > MSQ_DBL_MIN ) {
h = delta*delta/fabs(temp_var); }
// Note: Analytically, h is strictly positive, but
// it can be zero numerically if temp_var
// is a large negative number
// In the h=0, we use a different analytic
// approximation to compute h.
}
if (h<MSQ_DBL_MIN) {
MSQ_SETERR(err)("Barrier function is zero due to excessively large "
"negative area compared to delta. /n Try to untangle "
"mesh another way. ", MsqError::INVALID_MESH);
return false;
}
fval=sqrt(term1*term2)/(3*h);
if (fval>MSQ_MAX_CAP) {
fval=MSQ_MAX_CAP;
}
return true;
*/
}
} // namespace MBMesquite
#endif // ConditionNumberFunctions_hpp
|