39 #include "MsqTimer.hpp"
40 #include "MsqDebug.hpp"
42 #ifdef MSQ_USE_OLD_STD_HEADERS
83 c3Con=-2.0*pow_dbl/3.0;
100 static const int locs_hex[8][4] = {{0, 1, 3, 4},
109 const Vector3D d_con(1.0, 1.0, 1.0);
114 bool metric_valid =
false;
123 if (!metric_valid)
return false;
129 for (i = 0; i < 4; ++
i) {
130 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
131 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
132 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
135 if (!metric_valid)
return false;
146 if (!metric_valid)
return false;
150 for (i = 0; i < 8; ++
i) {
151 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
152 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
153 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
154 mCoords[3] = vertices[v_i[locs_hex[
i][3]]];
157 if (!metric_valid)
return false;
181 "Minimum and maximum not continuously differentiable.\n"
182 "Element of subdifferential will be returned.\n";
191 static const int locs_hex[8][4] = {{0, 1, 3, 4},
200 const Vector3D d_con(1.0, 1.0, 1.0);
204 bool metric_valid =
false;
205 int vert_per_elem = 0;
224 for (i = 0; i < 4; ++
i) {
227 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
228 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
229 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
235 for (i = 0; i < 4; ++
i) {
250 if (!metric_valid)
return false;
256 for (i = 0; i < 8; ++
i) {
259 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
260 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
261 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
262 mCoords[3] = vertices[v_i[locs_hex[
i][3]]];
268 for (i = 0; i < 8; ++
i) {
285 for (i = 0; i < vert_per_elem; ++
i) {
286 for (j = 0; j < nv; ++
j) {
287 if (vertices + v_i[i] == v[j]) {
312 "Minimum and maximum not continuously differentiable.\n"
313 "Element of subdifferential will be returned.\n"
314 "Who knows what the Hessian is?\n" ;
326 static const int locs_hex[8][4] = {{0, 1, 3, 4},
335 const Vector3D d_con(1.0, 1.0, 1.0);
340 bool metric_valid =
false;
355 for (i = 0; i < 3; ++
i) {
357 if (j<nfv && vertices + v_i[i] == fv[j] )
380 for (i=0; i < 10; ++
i) {
386 for (i = 0; i < 4; ++
i) {
389 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
390 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
391 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
407 for (i = 0; i < 4; ++
i) {
412 for (i = 0; i < 4; ++
i) {
417 for (j = 0; j < 3; ++
j) {
418 for (k = j; k < 3; ++
k) {
423 loc = 4*r - (r*(r+1)/2) + c;
427 loc = 4*c - (c*(c+1)/2) + r;
438 for (i = 0; i < 4; ++
i) {
444 for (i = 0; i < 4; ++
i) {
446 g[locs_hex[
i][1]] +=
mMetrics[
i]*mGradients[3*i+1];
447 g[locs_hex[
i][2]] +=
mMetrics[
i]*mGradients[3*i+2];
449 for (j = 0; j < 3; ++
j) {
450 for (k = j; k < 3; ++
k) {
458 loc = 4*r - (r*(r+1)/2) + c;
462 loc = 4*c - (c*(c+1)/2) + r;
473 for (i = 0; i < 4; ++
i) {
479 for (i = 0; i < 4; ++
i) {
484 for (j = 0; j < 3; ++
j) {
485 for (k = j; k < 3; ++
k) {
490 loc = 4*r - (r*(r+1)/2) + c;
494 loc = 4*c - (c*(c+1)/2) + r;
502 for (i=0; i<10; ++
i) {
531 for (i = 0; i < 4; ++
i) {
542 for (i = 0; i < 4; ++
i) {
544 g[locs_hex[
i][1]] +=
g_factor[
i]*mGradients[3*i+1];
545 g[locs_hex[
i][2]] +=
g_factor[
i]*mGradients[3*i+2];
547 for (j = 0; j < 3; ++
j) {
548 for (k = j; k < 3; ++
k) {
556 loc = 4*r - (r*(r+1)/2) + c;
560 loc = 4*c - (c*(c+1)/2) + r;
568 m =
pow(nm, 1.0 / t);
573 for (i = 0; i < 4; ++
i) {
574 for (j = i; j < 4; ++
j) {
586 for (i=0; i<4; ++
i) {
588 if (ind<nfv && vertices+v_i[i] == fv[ind] )
620 if (!metric_valid)
return false;
624 for (i = 0; i < 4; ++
i) {
626 if (j<nfv && vertices + v_i[i] == fv[j] )
657 for (i = 0; i < 8; ++
i) {
660 mCoords[0] = vertices[v_i[locs_hex[
i][0]]];
661 mCoords[1] = vertices[v_i[locs_hex[
i][1]]];
662 mCoords[2] = vertices[v_i[locs_hex[
i][2]]];
663 mCoords[3] = vertices[v_i[locs_hex[
i][3]]];
679 for (i = 0; i < 8; ++
i) {
684 for (i = 0; i < 8; ++
i) {
690 for (j = 0; j < 4; ++
j) {
691 for (k = j; k < 4; ++
k) {
696 loc = 8*r - (r*(r+1)/2) + c;
700 loc = 8*c - (c*(c+1)/2) + r;
711 for (i = 0; i < 8; ++
i) {
717 for (i = 0; i < 8; ++
i) {
719 g[locs_hex[
i][1]] +=
mMetrics[
i]*mGradients[4*i+1];
720 g[locs_hex[
i][2]] +=
mMetrics[
i]*mGradients[4*i+2];
721 g[locs_hex[
i][3]] +=
mMetrics[
i]*mGradients[4*i+3];
723 for (j = 0; j < 4; ++
j) {
724 for (k = j; k < 4; ++
k) {
732 loc = 8*r - (r*(r+1)/2) + c;
736 loc = 8*c - (c*(c+1)/2) + r;
747 for (i = 0; i < 8; ++
i) {
753 for (i = 0; i < 8; ++
i) {
759 for (j = 0; j < 4; ++
j) {
760 for (k = j; k < 4; ++
k) {
765 loc = 8*r - (r*(r+1)/2) + c;
769 loc = 8*c - (c*(c+1)/2) + r;
805 for (i = 0; i < 8; ++
i) {
816 for (i = 0; i < 8; ++
i) {
818 g[locs_hex[
i][1]] +=
g_factor[
i]*mGradients[4*i+1];
819 g[locs_hex[
i][2]] +=
g_factor[
i]*mGradients[4*i+2];
820 g[locs_hex[
i][3]] +=
g_factor[
i]*mGradients[4*i+3];
822 for (j = 0; j < 4; ++
j) {
823 for (k = j; k < 4; ++
k) {
831 loc = 8*r - (r*(r+1)/2) + c;
835 loc = 8*c - (c*(c+1)/2) + r;
843 m =
pow(nm, 1.0 / t);
848 for (i = 0; i < 8; ++
i) {
849 for (j = i; j < 8; ++
j) {
861 for (i=0; i<8; ++
i) {
863 if (ind<nfv && vertices+v_i[i] == fv[ind] )
int h_fcn_3i(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool g_fcn_2i(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool m_fcn_3e(double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
bool g_fcn_2e(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
void zero()
Sets all entries to zero (more efficient than assignement).
bool g_fcn_3e(double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
Used to hold the error state and return it to the application.
bool m_fcn_3i(double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
Matrix3D transpose(const Matrix3D &A)
requested functionality is not (yet) implemented
Matrix3D & outer_product(const Vector3D &v1, const Vector3D &v2)
Computes .
bool evaluate_element(PatchData &pd, MsqMeshEntity *element, double &fval, MsqError &err)
evaluate using mesquite objects
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
bool m_fcn_2i(double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool g_fcn_3i(double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
double average_metric_and_weights(double metric_values[], int num_metric_values, MsqError &err)
Given a list of metric values, calculate the average metric valude according to the current avgMethod...
void set_hessian_type(HESSIAN_TYPE ht)
Sets hessianType for this metric.
bool compute_element_analytical_hessian(PatchData &pd, MsqMeshEntity *e, MsqVertex *v[], Vector3D g[], Matrix3D h[], int nv, double &m, MsqError &err)
void get_domain_normal_at_element(size_t elem_index, Vector3D &surf_norm, MsqError &err) const
invalid function argument passed
bool h_fcn_3e(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
void set_element_evaluation_mode(ElementEvaluationMode mode, MsqError &err)
Sets the evaluation mode for the ELEMENT_BASED metrics.
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
bool m_fcn_2e(double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void set_negate_flag(int neg)
bool compute_element_analytical_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
Virtual function that computes the gradient of the QualityMetric analytically. The base class impleme...
bool h_fcn_2e(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
IdealWeightInverseMeanRatio(MsqError &err, double pow_dbl=1.0)
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
EntityTopology get_element_type() const
Returns element type.
void set_gradient_type(GRADIENT_TYPE grad)
Sets gradType for this metric.
object is in an invalid state
const msq_stdc::size_t * get_vertex_index_array() const
Very efficient retrieval of vertices indexes (corresponding to the PatchData vertex array)...
void set_metric_type(MetricType t)
This function should be used in the constructor of every concrete quality metric. ...
double average_metrics(const double metric_values[], const int &num_values, MsqError &err)
average_metrics takes an array of length num_values and averages the contents using averaging method ...
void set_metric_power(double pow_dbl, MsqError &err)
Sets the power value in the metric computation.
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
AveragingMethod avgMethod
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
void set_name(msq_std::string st)
Sets the name of this metric.
bool h_fcn_2i(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
double pow(double value, const Exponent &exp)