Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QualityMetric Class Reference

Base class for concrete quality metrics. More...

#include <QualityMetric.hpp>

Inheritance diagram for QualityMetric:

Public Types

enum  MetricType {
  MT_UNDEFINED, VERTEX_BASED, ELEMENT_BASED, VERTEX_BASED_FREE_ONLY,
  MT_UNDEFINED, VERTEX_BASED, ELEMENT_BASED, VERTEX_BASED_FREE_ONLY
}
 
enum  ElementEvaluationMode {
  EEM_UNDEFINED, ELEMENT_VERTICES, LINEAR_GAUSS_POINTS, QUADRATIC_GAUSS_POINTS,
  CUBIC_GAUSS_POINTS, EEM_UNDEFINED, ELEMENT_VERTICES, LINEAR_GAUSS_POINTS,
  QUADRATIC_GAUSS_POINTS, CUBIC_GAUSS_POINTS
}
 
enum  AveragingMethod {
  NONE, LINEAR, RMS, HMS,
  MINIMUM, MAXIMUM, HARMONIC, GEOMETRIC,
  SUM, SUM_SQUARED, GENERALIZED_MEAN, STANDARD_DEVIATION,
  MAX_OVER_MIN, MAX_MINUS_MIN, SUM_OF_RATIOS_SQUARED, NONE,
  LINEAR, RMS, HMS, MINIMUM,
  MAXIMUM, HARMONIC, GEOMETRIC, SUM,
  SUM_SQUARED, GENERALIZED_MEAN, STANDARD_DEVIATION, MAX_OVER_MIN,
  MAX_MINUS_MIN, SUM_OF_RATIOS_SQUARED
}
 
enum  GRADIENT_TYPE { NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT, NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT }
 
enum  HESSIAN_TYPE { NUMERICAL_HESSIAN, ANALYTICAL_HESSIAN, NUMERICAL_HESSIAN, ANALYTICAL_HESSIAN }
 
enum  MetricType {
  MT_UNDEFINED, VERTEX_BASED, ELEMENT_BASED, VERTEX_BASED_FREE_ONLY,
  MT_UNDEFINED, VERTEX_BASED, ELEMENT_BASED, VERTEX_BASED_FREE_ONLY
}
 
enum  ElementEvaluationMode {
  EEM_UNDEFINED, ELEMENT_VERTICES, LINEAR_GAUSS_POINTS, QUADRATIC_GAUSS_POINTS,
  CUBIC_GAUSS_POINTS, EEM_UNDEFINED, ELEMENT_VERTICES, LINEAR_GAUSS_POINTS,
  QUADRATIC_GAUSS_POINTS, CUBIC_GAUSS_POINTS
}
 
enum  AveragingMethod {
  NONE, LINEAR, RMS, HMS,
  MINIMUM, MAXIMUM, HARMONIC, GEOMETRIC,
  SUM, SUM_SQUARED, GENERALIZED_MEAN, STANDARD_DEVIATION,
  MAX_OVER_MIN, MAX_MINUS_MIN, SUM_OF_RATIOS_SQUARED, NONE,
  LINEAR, RMS, HMS, MINIMUM,
  MAXIMUM, HARMONIC, GEOMETRIC, SUM,
  SUM_SQUARED, GENERALIZED_MEAN, STANDARD_DEVIATION, MAX_OVER_MIN,
  MAX_MINUS_MIN, SUM_OF_RATIOS_SQUARED
}
 
enum  GRADIENT_TYPE { NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT, NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT }
 
enum  HESSIAN_TYPE { NUMERICAL_HESSIAN, ANALYTICAL_HESSIAN, NUMERICAL_HESSIAN, ANALYTICAL_HESSIAN }
 

Public Member Functions

virtual ~QualityMetric ()
 
MetricType get_metric_type ()
 
void set_element_evaluation_mode (ElementEvaluationMode mode, MsqError &err)
 Sets the evaluation mode for the ELEMENT_BASED metrics. More...
 
ElementEvaluationMode get_element_evaluation_mode ()
 Returns the evaluation mode for the metric. More...
 
void set_averaging_method (AveragingMethod method, MsqError &err)
 
void set_feasible_constraint (int alpha)
 
int get_feasible_constraint ()
 Returns the feasible flag for this metric. More...
 
void set_name (msq_std::string st)
 Sets the name of this metric. More...
 
msq_std::string get_name ()
 Returns the name of this metric (as a string). More...
 
double vertex_barrier_function (double det, double delta)
 Escobar Barrier Function for Shape and Other Metrics. More...
 
virtual bool evaluate_vertex (PatchData &, MsqVertex *, double &, MsqError &err)
 Evaluate the metric for a vertex. More...
 
virtual bool evaluate_element (PatchData &, MsqMeshEntity *, double &, MsqError &err)
 Evaluate the metric for an element. More...
 
void set_gradient_type (GRADIENT_TYPE grad)
 Sets gradType for this metric. More...
 
void set_hessian_type (HESSIAN_TYPE ht)
 Sets hessianType for this metric. More...
 
bool compute_vertex_gradient (PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
 Calls compute_vertex_numerical_gradient if gradType equals NUMERCIAL_GRADIENT. Calls compute_vertex_analytical_gradient if gradType equals ANALYTICAL_GRADIENT;. More...
 
bool compute_element_gradient (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_gradient() or compute_element_analytical_gradient() for gradType equal NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT, respectively. More...
 
bool compute_element_gradient_expanded (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 
bool compute_element_hessian (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
 For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_hessian() or compute_element_analytical_hessian() for hessianType equal NUMERICAL_HESSIAN or ANALYTICAL_HESSIAN, respectively. More...
 
void set_negate_flag (int neg)
 
int get_negate_flag ()
 Returns negateFlag. More...
 
virtual void change_metric_type (MetricType t, MsqError &err)
 
virtual ~QualityMetric ()
 
MetricType get_metric_type ()
 
void set_element_evaluation_mode (ElementEvaluationMode mode, MsqError &err)
 Sets the evaluation mode for the ELEMENT_BASED metrics. More...
 
ElementEvaluationMode get_element_evaluation_mode ()
 Returns the evaluation mode for the metric. More...
 
void set_averaging_method (AveragingMethod method, MsqError &err)
 
void set_feasible_constraint (int alpha)
 
int get_feasible_constraint ()
 Returns the feasible flag for this metric. More...
 
void set_name (msq_std::string st)
 Sets the name of this metric. More...
 
msq_std::string get_name ()
 Returns the name of this metric (as a string). More...
 
double vertex_barrier_function (double det, double delta)
 Escobar Barrier Function for Shape and Other Metrics. More...
 
virtual bool evaluate_vertex (PatchData &, MsqVertex *, double &, MsqError &err)
 Evaluate the metric for a vertex. More...
 
virtual bool evaluate_element (PatchData &, MsqMeshEntity *, double &, MsqError &err)
 Evaluate the metric for an element. More...
 
void set_gradient_type (GRADIENT_TYPE grad)
 Sets gradType for this metric. More...
 
void set_hessian_type (HESSIAN_TYPE ht)
 Sets hessianType for this metric. More...
 
bool compute_vertex_gradient (PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
 
bool compute_element_gradient (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_gradient() or compute_element_analytical_gradient() for gradType equal NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT, respectively. More...
 
bool compute_element_gradient_expanded (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 
bool compute_element_hessian (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
 For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_hessian() or compute_element_analytical_hessian() for hessianType equal NUMERICAL_HESSIAN or ANALYTICAL_HESSIAN, respectively. More...
 
void set_negate_flag (int neg)
 
int get_negate_flag ()
 Returns negateFlag. More...
 
virtual void change_metric_type (MetricType t, MsqError &err)
 

Protected Member Functions

 QualityMetric ()
 
void set_metric_type (MetricType t)
 This function should be used in the constructor of every concrete quality metric. More...
 
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 data member avgMethod . More...
 
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 and write into the passed metric_values array the the value weight/count to use when averaging gradient vectors for the metric. More...
 
double weighted_average_metrics (const double coef[], const double metric_values[], const int &num_values, MsqError &err)
 takes an array of coefficients and an array of metrics (both of length num_value) and averages the contents using averaging method 'method'. More...
 
bool compute_vertex_numerical_gradient (PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
 
bool compute_element_numerical_gradient (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 Non-virtual function which numerically computes the gradient of a QualityMetric of a given element for a given set of free vertices on that element. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() . More...
 
virtual bool compute_vertex_analytical_gradient (PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
 Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is VERTEX_BASED. More...
 
virtual bool compute_element_analytical_gradient (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() . More...
 
bool compute_element_numerical_hessian (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
 
virtual bool compute_element_analytical_hessian (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
 
 QualityMetric ()
 
void set_metric_type (MetricType t)
 This function should be used in the constructor of every concrete quality metric. More...
 
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 data member avgMethod . More...
 
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 and write into the passed metric_values array the the value weight/count to use when averaging gradient vectors for the metric. More...
 
double weighted_average_metrics (const double coef[], const double metric_values[], const int &num_values, MsqError &err)
 takes an array of coefficients and an array of metrics (both of length num_value) and averages the contents using averaging method 'method'. More...
 
bool compute_vertex_numerical_gradient (PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
 
bool compute_element_numerical_gradient (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 Non-virtual function which numerically computes the gradient of a QualityMetric of a given element for a given set of free vertices on that element. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() . More...
 
virtual bool compute_vertex_analytical_gradient (PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)
 Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is VERTEX_BASED. More...
 
virtual bool compute_element_analytical_gradient (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
 Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() . More...
 
bool compute_element_numerical_hessian (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
 
virtual bool compute_element_analytical_hessian (PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
 

Protected Attributes

AveragingMethod avgMethod
 
int feasible
 
msq_std::string metricName
 

Private Attributes

ElementEvaluationMode evalMode
 
MetricType mType
 
GRADIENT_TYPE gradType
 
HESSIAN_TYPE hessianType
 
int negateFlag
 

Friends

class MsqMeshEntity
 

Detailed Description

Base class for concrete quality metrics.

Definition at line 64 of file includeLinks/QualityMetric.hpp.

Member Enumeration Documentation

AveragingMethod allows you to set how the quality metric values attained at each sample point will be averaged together to produce a single metric value for an element.

Enumerator
NONE 
LINEAR 
RMS 
HMS 
MINIMUM 
MAXIMUM 
HARMONIC 
GEOMETRIC 
SUM 
SUM_SQUARED 
GENERALIZED_MEAN 
STANDARD_DEVIATION 
MAX_OVER_MIN 
MAX_MINUS_MIN 
SUM_OF_RATIOS_SQUARED 
NONE 
LINEAR 
RMS 
HMS 
MINIMUM 
MAXIMUM 
HARMONIC 
GEOMETRIC 
SUM 
SUM_SQUARED 
GENERALIZED_MEAN 
STANDARD_DEVIATION 
MAX_OVER_MIN 
MAX_MINUS_MIN 
SUM_OF_RATIOS_SQUARED 

Definition at line 131 of file includeLinks/QualityMetric.hpp.

AveragingMethod allows you to set how the quality metric values attained at each sample point will be averaged together to produce a single metric value for an element.

Enumerator
NONE 
LINEAR 
RMS 
HMS 
MINIMUM 
MAXIMUM 
HARMONIC 
GEOMETRIC 
SUM 
SUM_SQUARED 
GENERALIZED_MEAN 
STANDARD_DEVIATION 
MAX_OVER_MIN 
MAX_MINUS_MIN 
SUM_OF_RATIOS_SQUARED 
NONE 
LINEAR 
RMS 
HMS 
MINIMUM 
MAXIMUM 
HARMONIC 
GEOMETRIC 
SUM 
SUM_SQUARED 
GENERALIZED_MEAN 
STANDARD_DEVIATION 
MAX_OVER_MIN 
MAX_MINUS_MIN 
SUM_OF_RATIOS_SQUARED 

Definition at line 131 of file src/QualityMetric/QualityMetric.hpp.

is for metrics of type ELEMENT_BASED only. It allows you to indicate whether we are evaluating the metric based on element vertices, or element gauss points.

Enumerator
EEM_UNDEFINED 
ELEMENT_VERTICES 
LINEAR_GAUSS_POINTS 
QUADRATIC_GAUSS_POINTS 
CUBIC_GAUSS_POINTS 
EEM_UNDEFINED 
ELEMENT_VERTICES 
LINEAR_GAUSS_POINTS 
QUADRATIC_GAUSS_POINTS 
CUBIC_GAUSS_POINTS 

Definition at line 111 of file includeLinks/QualityMetric.hpp.

Enumerator
EEM_UNDEFINED 
ELEMENT_VERTICES 
LINEAR_GAUSS_POINTS 
QUADRATIC_GAUSS_POINTS 
CUBIC_GAUSS_POINTS 
EEM_UNDEFINED 
ELEMENT_VERTICES 
LINEAR_GAUSS_POINTS 
QUADRATIC_GAUSS_POINTS 
CUBIC_GAUSS_POINTS 

Definition at line 111 of file src/QualityMetric/QualityMetric.hpp.

Sets to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT

Enumerator
NUMERICAL_GRADIENT 
ANALYTICAL_GRADIENT 
NUMERICAL_GRADIENT 
ANALYTICAL_GRADIENT 

Definition at line 205 of file includeLinks/QualityMetric.hpp.

Enumerator
NUMERICAL_GRADIENT 
ANALYTICAL_GRADIENT 
NUMERICAL_GRADIENT 
ANALYTICAL_GRADIENT 

Definition at line 205 of file src/QualityMetric/QualityMetric.hpp.

Sets to either NUMERICAL_HESSIAN or ANALYTICAL_HESSIAN

Enumerator
NUMERICAL_HESSIAN 
ANALYTICAL_HESSIAN 
NUMERICAL_HESSIAN 
ANALYTICAL_HESSIAN 

Definition at line 217 of file includeLinks/QualityMetric.hpp.

Enumerator
NUMERICAL_HESSIAN 
ANALYTICAL_HESSIAN 
NUMERICAL_HESSIAN 
ANALYTICAL_HESSIAN 

Definition at line 217 of file src/QualityMetric/QualityMetric.hpp.

enum MetricType

is a property of the metric. It should be set correctly in the constructor of the concrete QualityMetric. An example of a (mediocre) VERTEX_BASED metric is the smallest edge connected to a vertex. An example of a (mediocre) ELEMENT_BASED metric is the aspect ratio of an element.

Enumerator
MT_UNDEFINED 
VERTEX_BASED 
ELEMENT_BASED 
VERTEX_BASED_FREE_ONLY 
MT_UNDEFINED 
VERTEX_BASED 
ELEMENT_BASED 
VERTEX_BASED_FREE_ONLY 

Definition at line 97 of file includeLinks/QualityMetric.hpp.

enum MetricType
Enumerator
MT_UNDEFINED 
VERTEX_BASED 
ELEMENT_BASED 
VERTEX_BASED_FREE_ONLY 
MT_UNDEFINED 
VERTEX_BASED 
ELEMENT_BASED 
VERTEX_BASED_FREE_ONLY 

Definition at line 97 of file src/QualityMetric/QualityMetric.hpp.

Constructor & Destructor Documentation

virtual ~QualityMetric ( )
inlinevirtual

Definition at line 86 of file includeLinks/QualityMetric.hpp.

87  {};
virtual ~QualityMetric ( )
inlinevirtual

Definition at line 86 of file src/QualityMetric/QualityMetric.hpp.

87  {};

Member Function Documentation

double average_metric_and_weights ( double  metric_values[],
int  num_metric_values,
MsqError err 
)
protected

Given a list of metric values, calculate the average metric valude according to the current avgMethod and write into the passed metric_values array the the value weight/count to use when averaging gradient vectors for the metric.

Parameters
metric_values: As input, a set of quality metric values to average. As output, the fraction of the corresponding gradient vector that contributes to the average gradient.
num_metric_valuesThe number of values in the passed array.

Definition at line 495 of file QualityMetric/QualityMetric.cpp.

References cimg_library::exp(), i, MsqError::INVALID_STATE, cimg_library::log(), MAXIMUM, Mesquite::MSQ_MIN, MSQ_SETERR, and sqrt().

Referenced by IdealWeightInverseMeanRatio::compute_element_analytical_gradient(), and IdealWeightMeanRatio::compute_element_analytical_gradient().

498 {
499  double avg = 0.0;
500  int i, tmp_count;
501  double f;
502 
503  switch (avgMethod)
504  {
505 
506  case MINIMUM:
507  avg = metrics[0];
508  for (i = 1; i < count; ++i)
509  if (metrics[i] < avg)
510  avg = metrics[i];
511 
512  tmp_count = 0;
513  for (i = 0; i < count; ++i)
514  {
515  if( metrics[i] - avg <= MSQ_MIN )
516  {
517  metrics[i] = 1.0;
518  ++tmp_count;
519  }
520  else
521  {
522  metrics[i] = 0.0;
523  }
524  }
525 
526  f = 1.0 / tmp_count;
527  for (i = 0; i < count; ++i)
528  metrics[i] *= f;
529 
530  break;
531 
532 
533  case MAXIMUM:
534  avg = metrics[0];
535  for (i = 1; i < count; ++i)
536  if (metrics[i] > avg)
537  avg = metrics[i];
538 
539  tmp_count = 0;
540  for (i = 0; i < count; ++i)
541  {
542  if( avg - metrics[i] <= MSQ_MIN )
543  {
544  metrics[i] = 1.0;
545  ++tmp_count;
546  }
547  else
548  {
549  metrics[i] = 0.0;
550  }
551  }
552 
553  f = 1.0 / tmp_count;
554  for (i = 0; i < count; ++i)
555  metrics[i] *= f;
556 
557  break;
558 
559 
560  case SUM:
561  for (i = 0; i < count; ++i)
562  {
563  avg += metrics[i];
564  metrics[i] = 1.0;
565  }
566 
567  break;
568 
569 
570  case SUM_SQUARED:
571  for (i = 0; i < count; ++i)
572  {
573  avg += (metrics[i]*metrics[i]);
574  metrics[i] *= 2;
575  }
576 
577  break;
578 
579 
580  case LINEAR:
581  f = 1.0 / count;
582  for (i = 0; i < count; ++i)
583  {
584  avg += metrics[i];
585  metrics[i] = f;
586  }
587  avg *= f;
588 
589  break;
590 
591 
592  case GEOMETRIC:
593  for (i = 0; i < count; ++i)
594  avg += log(metrics[i]);
595  avg = exp( avg/count );
596 
597  f = avg / count;
598  for (i = 0; i < count; ++i)
599  metrics[i] = f / metrics[i];
600 
601  break;
602 
603 
604  case RMS:
605  for (i = 0; i < count; ++i)
606  avg += metrics[i] * metrics[i];
607  avg = sqrt( avg / count );
608 
609  f = 1. / (avg*count);
610  for (i = 0; i < count; ++i)
611  metrics[i] *= f;
612 
613  break;
614 
615 
616  case HARMONIC:
617  for (i = 0; i < count; ++i)
618  avg += 1.0 / metrics[i];
619  avg = count / avg;
620 
621  for (i = 0; i < count; ++i)
622  metrics[i] = (avg * avg) / (count * metrics[i] * metrics[i]);
623 
624  break;
625 
626 
627  case HMS:
628  for (i = 0; i < count; ++i)
629  avg += 1. / (metrics[i] * metrics[i]);
630  avg = sqrt( count / avg );
631 
632  f = avg*avg*avg / count;
633  for (i = 0; i < count; ++i)
634  metrics[i] = f / (metrics[i] * metrics[i] * metrics[i]);
635 
636  break;
637 
638 
639  default:
640  MSQ_SETERR(err)("averaging method not available.",MsqError::INVALID_STATE);
641  }
642 
643  return avg;
644 }
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
double sqrt(double d)
Definition: double.h:73
CImg< _cimg_Tfloat > log(const CImg< T > &instance)
Definition: CImg.h:6021
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79
object is in an invalid state
const double MSQ_MIN
Definition: Mesquite.hpp:160

Here is the call graph for this function:

Here is the caller graph for this function:

double average_metric_and_weights ( double  metric_values[],
int  num_metric_values,
MsqError err 
)
protected

Given a list of metric values, calculate the average metric valude according to the current avgMethod and write into the passed metric_values array the the value weight/count to use when averaging gradient vectors for the metric.

Parameters
metric_values: As input, a set of quality metric values to average. As output, the fraction of the corresponding gradient vector that contributes to the average gradient.
num_metric_valuesThe number of values in the passed array.
double average_metrics ( const double  metric_values[],
const int &  num_values,
MsqError err 
)
inlineprotected

average_metrics takes an array of length num_values and averages the contents using averaging method data member avgMethod .

average_metrics takes an array of length num_value and averages the contents using averaging method 'method'.

Definition at line 524 of file includeLinks/QualityMetric.hpp.

References QualityMetric::avgMethod, QualityMetric::GEOMETRIC, QualityMetric::HARMONIC, QualityMetric::HMS, i, MsqError::INVALID_ARG, j, QualityMetric::LINEAR, QualityMetric::MAX_MINUS_MIN, QualityMetric::MAX_OVER_MIN, QualityMetric::MAXIMUM, QualityMetric::MINIMUM, Mesquite::MSQ_MAX_CAP, Mesquite::MSQ_MIN, MSQ_SETERR, QualityMetric::NONE, MsqError::NOT_IMPLEMENTED, Mesquite::pow(), QualityMetric::RMS, sqrt(), QualityMetric::STANDARD_DEVIATION, QualityMetric::SUM, QualityMetric::SUM_OF_RATIOS_SQUARED, and QualityMetric::SUM_SQUARED.

Referenced by ConditionNumberQualityMetric::evaluate_element(), ASMQualityMetric::evaluate_element(), UntangleBetaQualityMetric::evaluate_element(), IdealWeightInverseMeanRatio::evaluate_element(), IdealWeightMeanRatio::evaluate_element(), VertexConditionNumberQualityMetric::evaluate_vertex(), EdgeLengthQualityMetric::evaluate_vertex(), LocalSizeQualityMetric::evaluate_vertex(), and EdgeLengthRangeQualityMetric::evaluate_vertex().

526  {
527  //MSQ_MAX needs to be made global?
528  //double MSQ_MAX=1e10;
529  double total_value=0.0;
530  double temp_value=0.0;
531  int i=0;
532  int j=0;
533  //if no values, return zero
534  if (num_values<=0){
535  return 0.0;
536  }
537 
538  switch(avgMethod){
539  case GEOMETRIC:
540  total_value=1.0;
541  for (i=0;i<num_values;++i){
542  total_value*=(metric_values[i]);
543  }
544  total_value=pow(total_value, (1/((double) num_values)));
545  break;
546 
547  case HARMONIC:
548  //ensure no divide by zero, return zero
549  for (i=0;i<num_values;++i){
550  if(metric_values[i]<MSQ_MIN){
551  if(metric_values[i]>MSQ_MIN){
552  return 0.0;
553  }
554  }
555  total_value+=(1/metric_values[i]);
556  }
557  //ensure no divide by zero, return MSQ_MAX_CAP
558  if(total_value<MSQ_MIN){
559  if(total_value>MSQ_MIN){
560  return MSQ_MAX_CAP;
561  }
562  }
563  total_value=num_values/total_value;
564  break;
565 
566  case LINEAR:
567  for (i=0;i<num_values;++i){
568  total_value+=metric_values[i];
569  }
570  total_value/= (double) num_values;
571  break;
572 
573  case MAXIMUM:
574  total_value = metric_values[0];
575  for (i = 1; i < num_values; ++i){
576  if (metric_values[i] > total_value){
577  total_value = metric_values[i];
578  }
579  }
580  break;
581 
582  case MINIMUM:
583  total_value = metric_values[0];
584  for (i = 1; i < num_values; ++i){
585  if (metric_values[i] < total_value) {
586  total_value = metric_values[i];
587  }
588  }
589  break;
590 
591  case NONE:
592  MSQ_SETERR(err)("Averaging method set to NONE", MsqError::INVALID_ARG);
593  break;
594 
595  case RMS:
596  for (i=0;i<num_values;++i){
597  total_value+=(metric_values[i]*metric_values[i]);
598  }
599  total_value/= (double) num_values;
600  total_value=sqrt(total_value);
601  break;
602 
603  case HMS:
604  //ensure no divide by zero, return zero
605  for (i=0;i<num_values;++i){
606  if (metric_values[i]*metric_values[i] < MSQ_MIN) {
607  return 0.0;
608  }
609  total_value += (1.0/(metric_values[i]*metric_values[i]));
610  }
611 
612  //ensure no divide by zero, return MSQ_MAX_CAP
613  if (total_value < MSQ_MIN) {
614  return MSQ_MAX_CAP;
615  }
616  total_value = sqrt(num_values/total_value);
617  break;
618 
619  case STANDARD_DEVIATION:
620  total_value=0;
621  temp_value=0;
622  for (i=0;i<num_values;++i){
623  temp_value+=metric_values[i];
624  total_value+=(metric_values[i]*metric_values[i]);
625  }
626  temp_value/= (double) num_values;
627  temp_value*=temp_value;
628  total_value/= (double) num_values;
629  total_value-=temp_value;
630  break;
631 
632  case SUM:
633  for (i=0;i<num_values;++i){
634  total_value+=metric_values[i];
635  }
636  break;
637 
638  case SUM_SQUARED:
639  for (i=0;i<num_values;++i){
640  total_value+= (metric_values[i]*metric_values[i]);
641  }
642  break;
643 
644  case MAX_MINUS_MIN:
645  //total_value used to store the maximum
646  //temp_value used to store the minimum
647  temp_value=MSQ_MAX_CAP;
648  for (i=0;i<num_values;++i){
649  if(metric_values[i]<temp_value){
650  temp_value=metric_values[i];
651  }
652  if(metric_values[i]>total_value){
653  total_value=metric_values[i];
654  }
655  }
656 
657  //ensure no divide by zero, return MSQ_MAX_CAP
658  if (temp_value < MSQ_MIN) {
659  return MSQ_MAX_CAP;
660  }
661  total_value-=temp_value;
662  break;
663 
664  case MAX_OVER_MIN:
665  //total_value used to store the maximum
666  //temp_value used to store the minimum
667  temp_value=MSQ_MAX_CAP;
668  for (i=0;i<num_values;++i){
669  if(metric_values[i]<temp_value){
670  temp_value=metric_values[i];
671  }
672  if(metric_values[i]>total_value){
673  total_value=metric_values[i];
674  }
675  }
676 
677  //ensure no divide by zero, return MSQ_MAX_CAP
678  if (temp_value < MSQ_MIN) {
679  return MSQ_MAX_CAP;
680  }
681  total_value/=temp_value;
682  break;
683 
685  for (j=0;j<num_values;++j){
686  //ensure no divide by zero, return MSQ_MAX_CAP
687  if (metric_values[j] < MSQ_MIN) {
688  return MSQ_MAX_CAP;
689  }
690  for (i=0;i<num_values;++i){
691  total_value+=((metric_values[i]/metric_values[j])*
692  (metric_values[i]/metric_values[j]));
693  }
694  }
695  total_value/=(double)(num_values*num_values);
696  break;
697 
698  default:
699  //Return error saying Averaging Method mode not implemented
700  MSQ_SETERR(err)("Requested Averaging Method Not Implemented", MsqError::NOT_IMPLEMENTED);
701  return 0;
702  }
703  return total_value;
704  }
const double MSQ_MAX_CAP
Definition: Mesquite.hpp:173
requested functionality is not (yet) implemented
double sqrt(double d)
Definition: double.h:73
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
double pow(double value, const Exponent &exp)
const double MSQ_MIN
Definition: Mesquite.hpp:160

Here is the call graph for this function:

Here is the caller graph for this function:

double average_metrics ( const double  metric_values[],
const int &  num_values,
MsqError err 
)
protected

average_metrics takes an array of length num_values and averages the contents using averaging method data member avgMethod .

void change_metric_type ( MetricType  t,
MsqError err 
)
virtual

This function is user accessible and virtual. The base class implementation sets an error, because many metrics will only be defined as Element_based or Vertex_based, and this function will not be needed. Some concrete metrics will have both Element_based and Vertex_based definintions, and those metrics will re-implement this function to the MetricType to be changed to either QualityMetric::VERTEX_BASED or QualityMetric::ELEMENT_BASED.

Definition at line 151 of file QualityMetric/QualityMetric.cpp.

References MSQ_SETERR, and MsqError::NOT_IMPLEMENTED.

152 {
153  MSQ_SETERR(err)("This QualityMetric's MetricType can not be changed.",
155 }
requested functionality is not (yet) implemented
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
virtual void change_metric_type ( MetricType  t,
MsqError err 
)
virtual

This function is user accessible and virtual. The base class implementation sets an error, because many metrics will only be defined as Element_based or Vertex_based, and this function will not be needed. Some concrete metrics will have both Element_based and Vertex_based definintions, and those metrics will re-implement this function to the MetricType to be changed to either QualityMetric::VERTEX_BASED or QualityMetric::ELEMENT_BASED.

bool compute_element_analytical_gradient ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protectedvirtual

Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() .

If that function is not over-riden in the concrete class, the base

Parameters description, see QualityMetric::compute_element_gradient() .

Returns
true if the element is valid, false otherwise.

Reimplemented in I_DFT, I_DFT, IdealWeightMeanRatio, IdealWeightMeanRatio, IdealWeightInverseMeanRatio, IdealWeightInverseMeanRatio, RI_DFT, and RI_DFT.

Definition at line 164 of file QualityMetric/QualityMetric.cpp.

References MSQ_CHKERR, and MSQ_PRINT.

Referenced by QualityMetric::compute_element_gradient().

169 {
170  MSQ_PRINT(1)("QualityMetric has no analytical gradient defined. "
171  "Defaulting to numerical gradient.\n");
173  bool b = compute_element_numerical_gradient(pd, element, free_vtces, grad_vec, num_free_vtx, metric_value, err);
174  return !MSQ_CHKERR(err) && b;
175 }
bool compute_element_numerical_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
Non-virtual function which numerically computes the gradient of a QualityMetric of a given element fo...
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.
void set_gradient_type(GRADIENT_TYPE grad)
Sets gradType for this metric.

Here is the caller graph for this function:

virtual bool compute_element_analytical_gradient ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protectedvirtual

Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() .

Reimplemented in I_DFT, I_DFT, IdealWeightMeanRatio, IdealWeightMeanRatio, IdealWeightInverseMeanRatio, IdealWeightInverseMeanRatio, RI_DFT, and RI_DFT.

bool compute_element_analytical_hessian ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
Matrix3D  hessian[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protectedvirtual

If that function is not over-riden in the concrete class, the base class function makes it default to a numerical hessian.

For parameters description, see QualityMetric::compute_element_hessian() .

Returns
true if the element is valid, false otherwise.

Reimplemented in I_DFT, I_DFT, IdealWeightMeanRatio, IdealWeightMeanRatio, IdealWeightInverseMeanRatio, IdealWeightInverseMeanRatio, RI_DFT, and RI_DFT.

Definition at line 185 of file QualityMetric/QualityMetric.cpp.

References MSQ_CHKERR, and MSQ_PRINT.

191 {
192  MSQ_PRINT(1)("QualityMetric has no analytical hessian defined. "
193  "Defaulting to numerical hessian.\n");
195  bool b = compute_element_numerical_hessian(pd, element, free_vtces, grad_vec,
196  hessian, num_free_vtx, metric_value, err);
197  return !MSQ_CHKERR(err) && b;
198 }
bool compute_element_numerical_hessian(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
void set_hessian_type(HESSIAN_TYPE ht)
Sets hessianType for this metric.
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.
virtual bool compute_element_analytical_hessian ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
Matrix3D  hessian[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protectedvirtual
bool compute_element_gradient ( PatchData pd,
MsqMeshEntity el,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
inline

For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_gradient() or compute_element_analytical_gradient() for gradType equal NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT, respectively.

Parameters
free_vtcesbase address of an array of pointers to the element vertices which are considered free for purposes of computing the gradient. The quality metric gradient relative to each of those vertices is computed and stored in grad_vec.
grad_vecbase address of an array of Vector3D where the gradient is stored, in the order specified by the free_vtces array.
num_free_vtxThis is the size of the vertices and gradient arrays.
metric_valueSince the metric is computed, we return it.
Returns
true if the element is valid, false otherwise.

Definition at line 494 of file includeLinks/QualityMetric.hpp.

References QualityMetric::ANALYTICAL_GRADIENT, QualityMetric::compute_element_analytical_gradient(), QualityMetric::compute_element_numerical_gradient(), QualityMetric::gradType, MSQ_CHKERR, and QualityMetric::NUMERICAL_GRADIENT.

Referenced by LPtoPTemplate::compute_analytical_gradient().

501  {
502  bool ret=false;
503  switch(gradType)
504  {
505  case NUMERICAL_GRADIENT:
506  ret = compute_element_numerical_gradient(pd, el, free_vtces, grad_vec,
507  num_free_vtx, metric_value, err);
508  MSQ_CHKERR(err);
509  break;
510  case ANALYTICAL_GRADIENT:
511  ret = compute_element_analytical_gradient(pd, el, free_vtces, grad_vec,
512  num_free_vtx, metric_value, err);
513  MSQ_CHKERR(err);
514  break;
515  }
516  return ret;
517  }
bool compute_element_numerical_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
Non-virtual function which numerically computes the gradient of a QualityMetric of a given element fo...
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
virtual bool compute_element_analytical_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
Virtual function that computes the gradient of the QualityMetric analytically. The base class impleme...

Here is the call graph for this function:

Here is the caller graph for this function:

bool compute_element_gradient ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)

For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_gradient() or compute_element_analytical_gradient() for gradType equal NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT, respectively.

bool compute_element_gradient_expanded ( PatchData pd,
MsqMeshEntity el,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)

same as compute_element_gradient(), but fills fixed vertices spots with zeros instead of not returning values for fixed vertices. Also, the vertices are now ordered according to the element vertices array.

Note that for this function, grad_vec should be an array of size the number of vertices in el, not of size num_free_vtx.

Definition at line 205 of file QualityMetric/QualityMetric.cpp.

References PatchData::get_vertex_index(), MsqMeshEntity::get_vertex_indices(), i, and MSQ_CHKERR.

212 {
213  int i, g, e;
214  bool ret;
215  Vector3D* grad_vec_nz = new Vector3D[num_free_vtx];
216  ret = compute_element_gradient(pd, el, free_vtces, grad_vec_nz,
217  num_free_vtx, metric_value, err);
218  if (MSQ_CHKERR(err)) {
219  delete [] grad_vec_nz;
220  return false;
221  }
222 
223  vector<size_t> gv_i;
224  gv_i.reserve(num_free_vtx);
225  i=0;
226  for (i=0; i<num_free_vtx; ++i) {
227  gv_i.push_back( pd.get_vertex_index(free_vtces[i]) );
228  }
229 
230  vector<size_t> ev_i;
231  el->get_vertex_indices(ev_i);
232 
233  bool inc;
234  vector<size_t>::iterator ev;
235  vector<size_t>::iterator gv;
236  for (ev=ev_i.begin(), e=0; ev!=ev_i.end(); ++ev, ++e) {
237  inc = false; g=0;
238  gv = gv_i.begin();
239  while (gv!=gv_i.end()) {
240  if (*ev == *gv) {
241  inc = true;
242  break;
243  }
244  ++gv; ++g;
245  }
246  if (inc == true)
247  grad_vec[e] = grad_vec_nz[g];
248  else
249  grad_vec[e] = 0;
250  }
251 
252  delete []grad_vec_nz;
253  return ret;
254 }
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
void get_vertex_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
gets the vertices of the mesh entity
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
bool compute_element_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_gradient() or compute_element...
size_t get_vertex_index(MsqVertex *vertex)
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

bool compute_element_gradient_expanded ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)

same as compute_element_gradient(), but fills fixed vertices spots with zeros instead of not returning values for fixed vertices. Also, the vertices are now ordered according to the element vertices array.

bool compute_element_hessian ( PatchData pd,
MsqMeshEntity el,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
Matrix3D  hessian[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)

For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_hessian() or compute_element_analytical_hessian() for hessianType equal NUMERICAL_HESSIAN or ANALYTICAL_HESSIAN, respectively.

Parameters
pd,:PatchData that contains the element which Hessian we want.
el,:this is the element for which the Hessian will be returned.
free_vtces,:base address of an array of pointers to the element vertices which are considered free for purposes of computing the hessian. The vertices within this array must be ordered in the same order as the vertices within the element, el. Only the Hessian entries corresponding to a pair of free vertices will be non-zero.
grad_vec,:this is an array of nve Vector3D, where nve is the total number of vertices in the element. Only the entries corresponding to free vertices specified in free_vtces will be non-zero. The order is the same as the order of the vertices in el.
hessian,:this is a 1D array of Matrix3D that will contain the upper triangular part of the Hessian. It has size nve*(nve+1)/2, i.e. the number of entries in the upper triangular part of a nve*nve matrix.
num_free_vtx,:is the number df free vertices in the element. Essentially, this gives the size of free_vtces[]. The gradient array has the size of the number of vertices in the element, regardless.
metric_value,:Since the metric is computed, we return it.
Returns
true if the element is valid, false otherwise.

Definition at line 81 of file QualityMetric/QualityMetric.cpp.

References PatchData::get_vertex_index(), MsqMeshEntity::get_vertex_indices(), i, MsqError::INTERNAL_ERROR, MSQ_ERRZERO, MSQ_SETERR, and v.

Referenced by LPtoPTemplate::compute_analytical_hessian().

89 {
90  // first, checks that free vertices order is consistent with the
91  // element order.
92  vector<size_t> elem_vtx_indices;
93  vector<size_t>::const_iterator v;
94  el->get_vertex_indices(elem_vtx_indices);
95  int i;
96  v=elem_vtx_indices.begin();
97  for (i=0; i<num_free_vtx; ++i) {
98  while ( v!=elem_vtx_indices.end() &&
99  *v != pd.get_vertex_index(free_vtces[i]) ) {
100  ++v;
101  }
102  if ( v==elem_vtx_indices.end() ) {
103  MSQ_SETERR(err)("free vertices cannot be given in a different"
104  "order than the element's.", MsqError::INTERNAL_ERROR);
105  return false;
106  }
107  }
108 
109 
110  bool ret=false;
111  switch(hessianType)
112  {
113  case NUMERICAL_HESSIAN:
114  ret = compute_element_numerical_hessian(pd, el, free_vtces, grad_vec, hessian,
115  num_free_vtx, metric_value, err);
116  MSQ_ERRZERO(err);
117  break;
118  case ANALYTICAL_HESSIAN:
119  ret = compute_element_analytical_hessian(pd, el, free_vtces, grad_vec, hessian,
120  num_free_vtx, metric_value, err);
121  MSQ_ERRZERO(err);
122  break;
123  }
124  return ret;
125 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
bool compute_element_numerical_hessian(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
void get_vertex_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
gets the vertices of the mesh entity
virtual bool compute_element_analytical_hessian(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
*********************************************************************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
Definition: roccomf90.h:20
size_t get_vertex_index(MsqVertex *vertex)
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

Here is the caller graph for this function:

bool compute_element_hessian ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
Matrix3D  hessian[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)

For MetricType == ELEMENT_BASED. Calls either compute_element_numerical_hessian() or compute_element_analytical_hessian() for hessianType equal NUMERICAL_HESSIAN or ANALYTICAL_HESSIAN, respectively.

bool compute_element_numerical_gradient ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protected

Non-virtual function which numerically computes the gradient of a QualityMetric of a given element for a given set of free vertices on that element. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() .

bool compute_element_numerical_gradient ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protected

Non-virtual function which numerically computes the gradient of a QualityMetric of a given element for a given set of free vertices on that element. This is used by metric which mType is ELEMENT_BASED. For parameters, see compute_element_gradient() .

Parameters description, see QualityMetric::compute_element_gradient() .

Returns
true if the element is valid, false otherwise.

TODO: (MICHAEL) Try to inline this function (currenlty conflicts with MsqVertex.hpp).

Definition at line 262 of file QualityMetric/QualityMetric.cpp.

References MsqError::INTERNAL_ERROR, j, MSQ_CHKERR, MSQ_FUNCTION_TIMER, MSQ_PRINT, MSQ_SETERR, and v.

Referenced by RI_DFT::compute_element_analytical_gradient(), and QualityMetric::compute_element_gradient().

268 {
269  MSQ_FUNCTION_TIMER( "QualityMetric::compute_element_numerical_gradient" );
272  MSQ_PRINT(3)("Computing Numerical Gradient\n");
273 
274  bool valid=this->evaluate_element(pd, element, metric_value, err);
275  if (MSQ_CHKERR(err) || !valid)
276  return false;
277 
278  const double delta_C = 10e-6;
279  double delta = delta_C;
280  const double delta_inv_C = 1. / delta; // avoids division in the loop.
281  double delta_inv = delta_inv_C;
282  int counter=0;
283  double pos=0.0;
284  double metric_value1=0;
285  const int reduction_limit = 15;
286  for (int v=0; v<num_free_vtx; ++v)
287  {
288  /* gradient in the x, y, z direction */
289  for (int j=0;j<3;++j)
290  {
291  //re-initialize variables.
292  valid=false;
293  delta = delta_C;
294  delta_inv = delta_inv_C;
295  counter=0;
296  //perturb the node and calculate gradient. The while loop is a
297  //safety net to make sure the epsilon perturbation does not take
298  //the element out of the feasible region.
299  while(!valid && counter<reduction_limit){
300  //save the original coordinate before the perturbation
301  pos=(*free_vtces[v])[j];
302  // perturb the coordinates of the free vertex in the j direction
303  // by delta
304  (*free_vtces[v])[j]+=delta;
305  //compute the function at the perturbed point location
306  valid=this->evaluate_element(pd, element, metric_value1, err);
307  MSQ_CHKERR(err);
308  //compute the numerical gradient
309  grad_vec[v][j]=(metric_value1-metric_value)*delta_inv;
310  // put the coordinates back where they belong
311  (*free_vtces[v])[j] = pos;
312  ++counter;
313  delta*=0.1;
314  delta_inv*=10.;
315  }
316  if(counter>=reduction_limit){
317  MSQ_SETERR(err)("Perturbing vertex by delta caused an inverted element.",
319  return false;
320  }
321 
322  }
323  }
324  return true;
325 }
*********************************************************************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
Definition: roccomf90.h:20
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
virtual bool evaluate_element(PatchData &, MsqMeshEntity *, double &, MsqError &err)
Evaluate the metric for an element.
j indices j
Definition: Indexing.h:6
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.

Here is the caller graph for this function:

bool compute_element_numerical_hessian ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
Matrix3D  hessian[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protected
bool compute_element_numerical_hessian ( PatchData pd,
MsqMeshEntity element,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
Matrix3D  hessian[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protected

Note that for this function, grad_vec should be an array of size the number of vertices in el, not of size num_free_vtx. Entries that do not correspond with the vertices argument array will be null.

For parameters description, see QualityMetric::compute_element_hessian() .

Returns
true if the element is valid, false otherwise.

Definition at line 337 of file QualityMetric/QualityMetric.cpp.

References free_vertex(), PatchData::get_vertex_index(), MsqMeshEntity::get_vertex_indices(), i, j, k, MSQ_CHKERR, MSQ_FUNCTION_TIMER, MSQ_PRINT, v, and MsqMeshEntity::vertex_count().

Referenced by RI_DFT::compute_element_analytical_hessian().

344 {
345  MSQ_FUNCTION_TIMER( "QualityMetric::compute_element_numerical_hessian" );
346  MSQ_PRINT(3)("Computing Numerical Hessian\n");
347 
348  bool valid=this->compute_element_gradient_expanded(pd, element, free_vtces, grad_vec,
349  num_free_vtx, metric_value, err);
350  if (MSQ_CHKERR(err) || !valid)
351  return false;
352 
353  double delta = 10e-6;
354  double delta_inv = 1./delta;
355  double vj_coord;
356  short nve = element->vertex_count();
357  Vector3D* grad_vec1 = new Vector3D[nve];
358  Vector3D fd;
359  vector<size_t> ev_i;
360  element->get_vertex_indices(ev_i);
361  short w, v, i, j, sum_w, mat_index, k;
362 
363  int fv_ind=0; // index in array free_vtces .
364 
365  // loop over all vertices in element.
366  for (v=0; v<nve; ++v) {
367 
368  // finds out whether vertex v in the element is fixed or free,
369  // as according to argument free_vtces[]
370  bool free_vertex = false;
371  for (k=0; k<num_free_vtx; ++k) {
372  if ( ev_i[v] == pd.get_vertex_index(free_vtces[k]) )
373  free_vertex = true;
374  }
375 
376  // If vertex is fixed, enters null blocks for that column.
377  // Note that null blocks for the row will be taken care of by
378  // the gradient null entries.
379  if (free_vertex==false) {
380  for (w=0; w<nve; ++w) {
381  if (v>=w) {
382  sum_w = w*(w+1)/2; // 1+2+3+...+w
383  mat_index = w*nve+v-sum_w;
384  hessian[mat_index] = 0.;
385  }
386  }
387  }
388  else {
389  // If vertex is free, use finite difference on the gradient to find the Hessian.
390  for (j=0;j<3;++j) {
391  // perturb the coordinates of the vertex v in the j direction by delta
392  vj_coord = (*free_vtces[fv_ind])[j];
393  (*free_vtces[fv_ind])[j]+=delta;
394  //compute the gradient at the perturbed point location
395  valid = this->compute_element_gradient_expanded(pd, element, free_vtces,
396  grad_vec1, num_free_vtx, metric_value, err); MSQ_CHKERR(err);
397  assert(valid);
398  //compute the numerical Hessian
399  for (w=0; w<nve; ++w) {
400  if (v>=w) {
401  //finite difference to get some entries of the Hessian
402  fd = (grad_vec1[w]-grad_vec[w])*delta_inv;
403  // For the block at position w,v in a matrix, we need the corresponding index
404  // (mat_index) in a 1D array containing only upper triangular blocks.
405  sum_w = w*(w+1)/2; // 1+2+3+...+w
406  mat_index = w*nve+v-sum_w;
407 
408  for (i=0; i<3; ++i)
409  hessian[mat_index][i][j] = fd[i];
410 
411  }
412  }
413  // put the coordinates back where they belong
414  (*free_vtces[fv_ind])[j] = vj_coord;
415  }
416  ++fv_ind;
417  }
418  }
419 
420  delete[] grad_vec1;
421 
422  return true;
423 }
j indices k indices k
Definition: Indexing.h:6
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
void get_vertex_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
gets the vertices of the mesh entity
*********************************************************************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
Definition: roccomf90.h:20
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
size_t get_vertex_index(MsqVertex *vertex)
blockLoc i
Definition: read.cpp:79
void free_vertex(T_Vertex *v)
j indices j
Definition: Indexing.h:6
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.
bool compute_element_gradient_expanded(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool compute_vertex_analytical_gradient ( PatchData pd,
MsqVertex vertex,
MsqVertex vertices[],
Vector3D  grad_vec[],
int  num_vtx,
double &  metric_value,
MsqError err 
)
protectedvirtual

Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is VERTEX_BASED.

bool compute_vertex_analytical_gradient ( PatchData pd,
MsqVertex vertex,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protectedvirtual

Virtual function that computes the gradient of the QualityMetric analytically. The base class implementation of this function simply prints a warning and calls compute_numerical_gradient to calculate the gradient. This is used by metric which mType is VERTEX_BASED.

If that function is not over-riden in the concrete class, the base class function makes it default to a numerical gradient.

Parameters
vertexVertex which is considered free for purposes of computing the gradient.
grad_vecVector where the gradient is stored.
metric_valueSince the metric is computed, we return it.
Returns
true if the element is valid, false otherwise.

Definition at line 135 of file QualityMetric/QualityMetric.cpp.

References MSQ_CHKERR, and MSQ_PRINT.

Referenced by QualityMetric::compute_vertex_gradient().

142 {
143  MSQ_PRINT(1)("QualityMetric has no analytical gradient defined. "
144  "Defaulting to numerical gradient.\n");
146  bool b = compute_vertex_numerical_gradient(pd, vertex, free_vtces, grad_vec,
147  num_free_vtx, metric_value, err);
148  return !MSQ_CHKERR(err) && b;
149 }
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.
void set_gradient_type(GRADIENT_TYPE grad)
Sets gradType for this metric.
bool compute_vertex_numerical_gradient(PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)

Here is the caller graph for this function:

bool compute_vertex_gradient ( PatchData pd,
MsqVertex vertex,
MsqVertex vertices[],
Vector3D  grad_vec[],
int  num_vtx,
double &  metric_value,
MsqError err 
)

For MetricType == VERTEX_BASED. Calls either compute_vertex_numerical_gradient or compute_vertex_analytical_gradient for gradType equal NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT, respectively.

Returns
true if the element is valid, false otherwise.
bool compute_vertex_gradient ( PatchData pd,
MsqVertex vertex,
MsqVertex vertices[],
Vector3D  grad_vec[],
int  num_vtx,
double &  metric_value,
MsqError err 
)
inline

Calls compute_vertex_numerical_gradient if gradType equals NUMERCIAL_GRADIENT. Calls compute_vertex_analytical_gradient if gradType equals ANALYTICAL_GRADIENT;.

For MetricType == VERTEX_BASED. Calls either compute_vertex_numerical_gradient or compute_vertex_analytical_gradient for gradType equal NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT, respectively.

Returns
true if the element is valid, false otherwise.

Definition at line 456 of file includeLinks/QualityMetric.hpp.

References QualityMetric::ANALYTICAL_GRADIENT, QualityMetric::compute_vertex_analytical_gradient(), QualityMetric::compute_vertex_numerical_gradient(), QualityMetric::gradType, MSQ_CHKERR, and QualityMetric::NUMERICAL_GRADIENT.

Referenced by LPtoPTemplate::compute_analytical_gradient().

463  {
464  bool ret=false;;
465  switch(gradType)
466  {
467  case NUMERICAL_GRADIENT:
468  ret = compute_vertex_numerical_gradient(pd, vertex, vertices,
469  grad_vec, num_vtx,
470  metric_value, err);
471  MSQ_CHKERR(err);
472  break;
473  case ANALYTICAL_GRADIENT:
474  ret = compute_vertex_analytical_gradient(pd, vertex, vertices,
475  grad_vec,num_vtx,
476  metric_value, err);
477  MSQ_CHKERR(err);
478  break;
479  }
480  return ret;
481  }
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
virtual bool compute_vertex_analytical_gradient(PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], 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 compute_vertex_numerical_gradient(PatchData &pd, MsqVertex &vertex, MsqVertex *vertices[], Vector3D grad_vec[], int num_vtx, double &metric_value, MsqError &err)

Here is the call graph for this function:

Here is the caller graph for this function:

bool compute_vertex_numerical_gradient ( PatchData pd,
MsqVertex vertex,
MsqVertex free_vtces[],
Vector3D  grad_vec[],
int  num_free_vtx,
double &  metric_value,
MsqError err 
)
protected

Non-virtual function which numerically computes the gradient of a QualityMetric of a given free vertex. This is used by metric which mType is VERTEX_BASED.

Returns
true if the element is valid, false otherwise.

Numerically calculates the gradient of a vertex-based QualityMetric value on the given free vertex. The metric is evaluated at MsqVertex 'vertex', and the gradient is calculated with respect to the degrees of freedom associated with MsqVertices in the 'vertices' array.

TODO: (MICHAEL) Try to inline this function (currenlty conflicts with MsqVertex.hpp).

Definition at line 431 of file QualityMetric/QualityMetric.cpp.

References j, MSQ_CHKERR, MSQ_ERRZERO, MSQ_PRINT, and v.

Referenced by QualityMetric::compute_vertex_gradient().

438 {
441  MSQ_PRINT(2)("Computing Gradient (QualityMetric's numeric, vertex based.\n");
442 
443  bool valid=this->evaluate_vertex(pd, &(vertex), metric_value, err);
444  if (MSQ_CHKERR(err) || !valid)
445  return false;
446 
447  const double delta = 10e-6;
448  const double delta_inv = 1./delta;
449  double metric_value1=0;
450  double pos;
451  int v=0;
452  for (v=0; v<num_free_vtx; ++v)
453  {
454  /* gradient in the x, y, z direction */
455  int j=0;
456  for (j=0;j<3;++j)
457  {
458  //save the original coordinate before the perturbation
459  pos=(*free_vtces[v])[j];
460  // perturb the coordinates of the free vertex in the j direction by delta
461  (*free_vtces[v])[j]+=delta;
462  //compute the function at the perturbed point location
463  this->evaluate_vertex(pd, &(vertex), metric_value1, err); MSQ_ERRZERO(err);
464  //compute the numerical gradient
465  grad_vec[v][j]=(metric_value1-metric_value)*delta_inv;
466  // put the coordinates back where they belong
467  (*free_vtces[v])[j] = pos;
468  }
469  }
470  return true;
471 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
*********************************************************************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
Definition: roccomf90.h:20
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
virtual bool evaluate_vertex(PatchData &, MsqVertex *, double &, MsqError &err)
Evaluate the metric for a vertex.
j indices j
Definition: Indexing.h:6
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.

Here is the caller graph for this function:

bool compute_vertex_numerical_gradient ( PatchData pd,
MsqVertex vertex,
MsqVertex vertices[],
Vector3D  grad_vec[],
int  num_vtx,
double &  metric_value,
MsqError err 
)
protected

Non-virtual function which numerically computes the gradient of a QualityMetric of a given free vertex. This is used by metric which mType is VERTEX_BASED.

Returns
true if the element is valid, false otherwise.
bool evaluate_element ( PatchData ,
MsqMeshEntity ,
double &  ,
MsqError err 
)
virtual

Evaluate the metric for an element.

Reimplemented in I_DFT, I_DFT, IdealWeightMeanRatio, IdealWeightMeanRatio, AddQualityMetric, AddQualityMetric, IdealWeightInverseMeanRatio, IdealWeightInverseMeanRatio, MultiplyQualityMetric, MultiplyQualityMetric, AspectRatioGammaQualityMetric, AspectRatioGammaQualityMetric, CornerJacobianQualityMetric, UntangleBetaQualityMetric, UntangleBetaQualityMetric, CornerJacobianQualityMetric, GeneralizedConditionNumberQualityMetric, GeneralizedConditionNumberQualityMetric, ASMQualityMetric, ASMQualityMetric, PowerQualityMetric, PowerQualityMetric, RI_DFT, RI_DFT, ConditionNumberQualityMetric, sI_DFT, sRI_DFT, sI_DFT, sRI_DFT, ConditionNumberQualityMetric, ScalarAddQualityMetric, ScalarMultiplyQualityMetric, ScalarAddQualityMetric, and ScalarMultiplyQualityMetric.

Definition at line 485 of file QualityMetric/QualityMetric.cpp.

References MSQ_SETERR, and MsqError::NOT_IMPLEMENTED.

Referenced by NonSmoothSteepestDescent::compute_function(), LInfTemplate::concrete_evaluate(), MaxTemplate::concrete_evaluate(), LPtoPTemplate::concrete_evaluate(), ScalarAddQualityMetric::evaluate_element(), ScalarMultiplyQualityMetric::evaluate_element(), PowerQualityMetric::evaluate_element(), MultiplyQualityMetric::evaluate_element(), and AddQualityMetric::evaluate_element().

488  {
489  MSQ_SETERR(err)("No implementation for a element-version of this "
490  "metric.", MsqError::NOT_IMPLEMENTED);
491  return false;
492  }
requested functionality is not (yet) implemented
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.

Here is the caller graph for this function:

bool evaluate_vertex ( PatchData ,
MsqVertex ,
double &  ,
MsqError err 
)
virtual
ElementEvaluationMode get_element_evaluation_mode ( )
inline

Returns the evaluation mode for the metric.

Definition at line 124 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::evalMode.

125  { return evalMode; }
ElementEvaluationMode get_element_evaluation_mode ( )
inline

Returns the evaluation mode for the metric.

Definition at line 124 of file includeLinks/QualityMetric.hpp.

References QualityMetric::evalMode.

125  { return evalMode; }
int get_feasible_constraint ( )
inline

Returns the feasible flag for this metric.

Definition at line 177 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::feasible.

int get_feasible_constraint ( )
inline
MetricType get_metric_type ( )
inline

Definition at line 105 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::mType.

105 { return mType; }
msq_std::string get_name ( )
inline

Returns the name of this metric (as a string).

Definition at line 185 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::metricName.

186  { return metricName; }
msq_std::string get_name ( )
inline

Returns the name of this metric (as a string).

Definition at line 185 of file includeLinks/QualityMetric.hpp.

References QualityMetric::metricName.

186  { return metricName; }
int get_negate_flag ( )
inline

Returns negateFlag.

Definition at line 274 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::negateFlag.

void set_averaging_method ( AveragingMethod  method,
MsqError err 
)
inline

Set the averaging method for the quality metric. Current options are NONE: the values are not averaged, GEOMETRIC: the geometric average, HARMONIC: the harmonic average, LINEAR: the linear average, MAXIMUM: the maximum value, MINIMUM: the minimum value, RMS: the root-mean-squared average, HMS: the harmonic-mean-squared average, SUM: the sum of the values, SUM_SQUARED: the sum of the squares of the values, GENERALIZED_MEAN: self explainatory, STANDARD_DEVIATION: the standard deviation squared of the values, MAX_MINUS_MIN: the maximum value minus the minum value, MAX_OVER_MIN: the maximum value divided by the minimum value, SUM_OF_RATIOS_SQUARED: (1/(N^2))*(SUM (SUM (v_i/v_j)^2))

Definition at line 424 of file includeLinks/QualityMetric.hpp.

References QualityMetric::avgMethod, QualityMetric::GEOMETRIC, QualityMetric::HARMONIC, QualityMetric::HMS, QualityMetric::LINEAR, QualityMetric::MAX_MINUS_MIN, QualityMetric::MAX_OVER_MIN, QualityMetric::MAXIMUM, QualityMetric::MINIMUM, MSQ_SETERR, QualityMetric::NONE, MsqError::NOT_IMPLEMENTED, QualityMetric::RMS, QualityMetric::STANDARD_DEVIATION, QualityMetric::SUM, QualityMetric::SUM_OF_RATIOS_SQUARED, and QualityMetric::SUM_SQUARED.

Referenced by I_DFT::I_DFT(), LaplacianSmoother::LaplacianSmoother(), RI_DFT::RI_DFT(), ShapeImprovementWrapper::ShapeImprovementWrapper(), sI_DFT::sI_DFT(), and sRI_DFT::sRI_DFT().

425  {
426  switch(method)
427  {
428  case(NONE):
429  case(GEOMETRIC):
430  case(HARMONIC):
431  case(LINEAR):
432  case(MAXIMUM):
433  case(MINIMUM):
434  case(RMS):
435  case(HMS):
436  case(STANDARD_DEVIATION):
437  case(SUM):
438  case(SUM_SQUARED):
439  case(MAX_OVER_MIN):
440  case(MAX_MINUS_MIN):
441  case(SUM_OF_RATIOS_SQUARED):
442  avgMethod=method;
443  break;
444  default:
445  MSQ_SETERR(err)("Requested Averaging Method Not Implemented", MsqError::NOT_IMPLEMENTED);
446  };
447  return;
448  }
requested functionality is not (yet) implemented
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.

Here is the caller graph for this function:

void set_averaging_method ( AveragingMethod  method,
MsqError err 
)
inline

Set the averaging method for the quality metric. Current options are NONE: the values are not averaged, GEOMETRIC: the geometric average, HARMONIC: the harmonic average, LINEAR: the linear average, MAXIMUM: the maximum value, MINIMUM: the minimum value, RMS: the root-mean-squared average, HMS: the harmonic-mean-squared average, SUM: the sum of the values, SUM_SQUARED: the sum of the squares of the values, GENERALIZED_MEAN: self explainatory, STANDARD_DEVIATION: the standard deviation squared of the values, MAX_MINUS_MIN: the maximum value minus the minum value, MAX_OVER_MIN: the maximum value divided by the minimum value, SUM_OF_RATIOS_SQUARED: (1/(N^2))*(SUM (SUM (v_i/v_j)^2))

void set_element_evaluation_mode ( ElementEvaluationMode  mode,
MsqError err 
)

Sets the evaluation mode for the ELEMENT_BASED metrics.

void set_element_evaluation_mode ( ElementEvaluationMode  mode,
MsqError err 
)
inline

Sets the evaluation mode for the ELEMENT_BASED metrics.

Definition at line 402 of file includeLinks/QualityMetric.hpp.

References QualityMetric::CUBIC_GAUSS_POINTS, QualityMetric::ELEMENT_VERTICES, QualityMetric::evalMode, MsqError::INVALID_STATE, QualityMetric::LINEAR_GAUSS_POINTS, MSQ_SETERR, QualityMetric::mType, MsqError::NOT_IMPLEMENTED, QualityMetric::QUADRATIC_GAUSS_POINTS, and QualityMetric::VERTEX_BASED.

Referenced by ASMQualityMetric::ASMQualityMetric(), AspectRatioGammaQualityMetric::AspectRatioGammaQualityMetric(), ConditionNumberQualityMetric::ConditionNumberQualityMetric(), CornerJacobianQualityMetric::CornerJacobianQualityMetric(), IdealWeightInverseMeanRatio::IdealWeightInverseMeanRatio(), IdealWeightMeanRatio::IdealWeightMeanRatio(), and UntangleBetaQualityMetric::UntangleBetaQualityMetric().

403  {
404  if (mType == VERTEX_BASED) {
405  MSQ_SETERR(err)("function must only be used for ELEMENT_BASED metrics.", MsqError::INVALID_STATE);
406  return;
407  }
408 
409  switch(mode)
410  {
411  case(ELEMENT_VERTICES):
412  case(LINEAR_GAUSS_POINTS):
414  case(CUBIC_GAUSS_POINTS):
415  evalMode=mode;
416  break;
417  default:
418  MSQ_SETERR(err)("Requested mode not implemented", MsqError::NOT_IMPLEMENTED);
419  }
420  return;
421  }
requested functionality is not (yet) implemented
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state

Here is the caller graph for this function:

void set_feasible_constraint ( int  alpha)
inline

Set feasible flag (i.e., does this metric have a feasible region that the mesh must maintain.)

Definition at line 173 of file includeLinks/QualityMetric.hpp.

References QualityMetric::feasible.

void set_feasible_constraint ( int  alpha)
inline

Set feasible flag (i.e., does this metric have a feasible region that the mesh must maintain.)

Definition at line 173 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::feasible.

void set_gradient_type ( GRADIENT_TYPE  grad)
inline

Sets gradType for this metric.

Definition at line 212 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::gradType.

213  { gradType=grad; }
void set_hessian_type ( HESSIAN_TYPE  ht)
inline

Sets hessianType for this metric.

Definition at line 224 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::hessianType.

void set_metric_type ( MetricType  t)
inlineprotected

This function should be used in the constructor of every concrete quality metric.

Errors will result if type is left to MT_UNDEFINED.

Definition at line 291 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::mType.

void set_name ( msq_std::string  st)
inline

Sets the name of this metric.

Definition at line 181 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::metricName.

182  { metricName=st; }
void set_negate_flag ( int  neg)
inline

Set the value of QualityMetric's negateFlag. Concrete QualityMetrics should set this flag to -1 if the QualityMetric needs to be maximized.

Definition at line 270 of file src/QualityMetric/QualityMetric.hpp.

References QualityMetric::negateFlag.

double vertex_barrier_function ( double  det,
double  delta 
)
inline

Escobar Barrier Function for Shape and Other Metrics.

Definition at line 191 of file includeLinks/QualityMetric.hpp.

References sqrt().

Referenced by ShapeQualityMetric::condition_number_2d(), and ShapeQualityMetric::condition_number_3d().

192  { return 0.5*(det+sqrt(det*det+4*delta*delta)); }
double sqrt(double d)
Definition: double.h:73
double det(const Matrix3D &A)

Here is the call graph for this function:

Here is the caller graph for this function:

double vertex_barrier_function ( double  det,
double  delta 
)
inline

Escobar Barrier Function for Shape and Other Metrics.

Definition at line 191 of file src/QualityMetric/QualityMetric.hpp.

References sqrt().

192  { return 0.5*(det+sqrt(det*det+4*delta*delta)); }
double sqrt(double d)
Definition: double.h:73
double det(const Matrix3D &A)

Here is the call graph for this function:

double weighted_average_metrics ( const double  coef[],
const double  metric_values[],
const int &  num_values,
MsqError err 
)
protected

takes an array of coefficients and an array of metrics (both of length num_value) and averages the contents using averaging method 'method'.

double weighted_average_metrics ( const double  coef[],
const double  metric_values[],
const int &  num_values,
MsqError err 
)
inlineprotected

takes an array of coefficients and an array of metrics (both of length num_value) and averages the contents using averaging method 'method'.

Definition at line 708 of file includeLinks/QualityMetric.hpp.

References QualityMetric::avgMethod, i, QualityMetric::LINEAR, MSQ_SETERR, and MsqError::NOT_IMPLEMENTED.

Referenced by sI_DFT::evaluate_element(), and sRI_DFT::evaluate_element().

711  {
712  //MSQ_MAX needs to be made global?
713  //double MSQ_MAX=1e10;
714  double total_value=0.0;
715  int i=0;
716  //if no values, return zero
717  if (num_values<=0){
718  return 0.0;
719  }
720 
721  switch(avgMethod){
722 
723  case LINEAR:
724  for (i=0;i<num_values;++i){
725  total_value += coef[i]*metric_values[i];
726  }
727  total_value /= (double) num_values;
728  break;
729 
730  default:
731  //Return error saying Averaging Method mode not implemented
732  MSQ_SETERR(err)("Requested Averaging Method Not Implemented",MsqError::NOT_IMPLEMENTED);
733  return 0;
734  }
735  return total_value;
736  }
requested functionality is not (yet) implemented
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

Friends And Related Function Documentation

MsqMeshEntity
friend

Definition at line 387 of file includeLinks/QualityMetric.hpp.

Member Data Documentation

HESSIAN_TYPE hessianType
private

Definition at line 397 of file includeLinks/QualityMetric.hpp.

Referenced by QualityMetric::set_hessian_type().

msq_std::string metricName
protected
int negateFlag
private

The documentation for this class was generated from the following files: