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

Combines two quality metrics (qMetric1 and qMetric2 defined in the parent class CompositeQualityMetric) by addition for two- and three-diminsional elements. Note: This function should not be used to combine a node-based metric with an element-based metric. More...

#include <AddQualityMetric.hpp>

Inheritance diagram for AddQualityMetric:
Collaboration diagram for AddQualityMetric:

Public Member Functions

 AddQualityMetric (QualityMetric *qm1, QualityMetric *qm2, MsqError &err)
 
virtual ~AddQualityMetric ()
 
void set_addition_operands (QualityMetric *qm1, QualityMetric *qm2, MsqError &)
 
bool evaluate_element (PatchData &pd, MsqMeshEntity *element, double &value, MsqError &err)
 
bool evaluate_vertex (PatchData &pd, MsqVertex *vertex, double &value, MsqError &err)
 
 AddQualityMetric (QualityMetric *qm1, QualityMetric *qm2, MsqError &err)
 
virtual ~AddQualityMetric ()
 
void set_addition_operands (QualityMetric *qm1, QualityMetric *qm2, MsqError &)
 
bool evaluate_element (PatchData &pd, MsqMeshEntity *element, double &value, MsqError &err)
 Evaluate the metric for an element. More...
 
bool evaluate_vertex (PatchData &pd, MsqVertex *vertex, double &value, MsqError &err)
 Evaluate the metric for a vertex. More...
 
- Public Member Functions inherited from QualityMetric
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...
 
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...
 
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)
 

Private Attributes

QualityMetricqualMetric1
 
QualityMetricqualMetric2
 

Additional Inherited Members

- Public Types inherited from QualityMetric
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 }
 
- Protected Member Functions inherited from QualityMetric
 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 inherited from QualityMetric
AveragingMethod avgMethod
 
int feasible
 
msq_std::string metricName
 

Detailed Description

Combines two quality metrics (qMetric1 and qMetric2 defined in the parent class CompositeQualityMetric) by addition for two- and three-diminsional elements. Note: This function should not be used to combine a node-based metric with an element-based metric.

Definition at line 59 of file includeLinks/AddQualityMetric.hpp.

Constructor & Destructor Documentation

AddQualityMetric ( QualityMetric qm1,
QualityMetric qm2,
MsqError err 
)

Ensures that qm1 and qm2 are not NULL. If either qm1 or qm2 are valid only on a feasible region, then the composite metric's feasibility flag is set to one. If qm1 and qm2 have different negateFlags, then a warning is printed, and the composite metric's negate flag is set to one. Otherwise, the composite metric's negateFlag is set to qm1's negateFlag (and, thus, qm2's negateFlag).

Definition at line 42 of file QualityMetric/AddQualityMetric.cpp.

References QualityMetric::feasible, QualityMetric::get_feasible_constraint(), QualityMetric::get_metric_type(), QualityMetric::get_negate_flag(), MsqError::INVALID_ARG, MsqError::INVALID_STATE, MSQ_DBGOUT, MSQ_SETERR, QualityMetric::set_metric_type(), QualityMetric::set_name(), and QualityMetric::set_negate_flag().

43  : qualMetric1( qm1 ),
44  qualMetric2( qm2 )
45 {
46  if(qm1 == NULL || qm2 == NULL){
47  MSQ_SETERR(err)("AddQualityMetric constructor passed NULL pointer.",
49  return;
50  }
52  if(qm2->get_feasible_constraint())
54  int n_flag=qm1->get_negate_flag();
55  if(n_flag!=qm2->get_negate_flag()){
56  MSQ_DBGOUT(1) << "AddQualityMetric is being used to compose a metric "
57  << "that should be minimized\n with a metric that should be "
58  << "maximized.";
59  set_negate_flag(1);
60  }
61  else{
62  set_negate_flag(n_flag);
63  }
64 
65  // Checks that metrics are of the same type
66  if ( qm1->get_metric_type() != qm2->get_metric_type() ) {
67  MSQ_SETERR(err)("Cannot add a vertex-based QM with an element-based QM.",
69  return;
70  } else {
72  }
73 
74  set_name("Composite Add");
75 }
int get_negate_flag()
Returns negateFlag.
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state
void set_metric_type(MetricType t)
This function should be used in the constructor of every concrete quality metric. ...
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
int get_feasible_constraint()
Returns the feasible flag for this metric.
void set_name(msq_std::string st)
Sets the name of this metric.

Here is the call graph for this function:

virtual ~AddQualityMetric ( )
inlinevirtual

Definition at line 73 of file includeLinks/AddQualityMetric.hpp.

74  { }
AddQualityMetric ( QualityMetric qm1,
QualityMetric qm2,
MsqError err 
)

Ensures that qm1 and qm2 are not NULL. If either qm1 or qm2 are valid only on a feasible region, then the composite metric's feasibility flag is set to one. If qm1 and qm2 have different negateFlags, then a warning is printed, and the composite metric's negate flag is set to one. Otherwise, the composite metric's negateFlag is set to qm1's negateFlag (and, thus, qm2's negateFlag).

virtual ~AddQualityMetric ( )
inlinevirtual

Definition at line 73 of file src/QualityMetric/AddQualityMetric.hpp.

74  { }

Member Function Documentation

bool evaluate_element ( PatchData pd,
MsqMeshEntity element,
double &  value,
MsqError err 
)
virtual

Returns qMetric1->evaluate_element(element, err) plus qMetric2-evaluate_element(element, err)

Reimplemented from QualityMetric.

Definition at line 79 of file QualityMetric/AddQualityMetric.cpp.

References QualityMetric::evaluate_element(), MSQ_ERRZERO, AddQualityMetric::qualMetric1, and AddQualityMetric::qualMetric2.

83 {
84  bool valid_flag;
85  double metric1, metric2;
86  valid_flag=qualMetric1->evaluate_element(pd, element, metric1, err); MSQ_ERRZERO(err);
87  if(!valid_flag)
88  return false;
89  valid_flag=qualMetric2->evaluate_element(pd, element, metric2, err); MSQ_ERRZERO(err);
90  value = metric1+metric2;
91  //if the first metric was invalid we have already returned
92  //so we return whatever the flag was on the second metric.
93  return valid_flag;
94 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
virtual bool evaluate_element(PatchData &, MsqMeshEntity *, double &, MsqError &err)
Evaluate the metric for an element.

Here is the call graph for this function:

bool evaluate_element ( PatchData ,
MsqMeshEntity ,
double &  ,
MsqError err 
)
virtual

Evaluate the metric for an element.

Reimplemented from QualityMetric.

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

Evaluate the metric for a vertex.

Reimplemented from QualityMetric.

bool evaluate_vertex ( PatchData pd,
MsqVertex vert,
double &  value,
MsqError err 
)
virtual

Returns qMetric1->evaluate_vertex(...) plus qMetric2-evaluate_vertex(...)

Reimplemented from QualityMetric.

Definition at line 98 of file QualityMetric/AddQualityMetric.cpp.

References QualityMetric::evaluate_vertex(), MSQ_ERRZERO, AddQualityMetric::qualMetric1, and AddQualityMetric::qualMetric2.

102 {
103  bool valid_flag;
104  double metric1, metric2;
105  valid_flag=qualMetric1->evaluate_vertex(pd, vert, metric1, err); MSQ_ERRZERO(err);
106  if(!valid_flag)
107  return false;
108  valid_flag=qualMetric2->evaluate_vertex(pd, vert, metric2, err); MSQ_ERRZERO(err);
109  value = metric1+metric2;
110  //if the first metric was invalid we have already returned
111  //so we return whatever the flag was on the second metric.
112  return valid_flag;
113 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
virtual bool evaluate_vertex(PatchData &, MsqVertex *, double &, MsqError &err)
Evaluate the metric for a vertex.

Here is the call graph for this function:

void set_addition_operands ( QualityMetric qm1,
QualityMetric qm2,
MsqError  
)
inline
void set_addition_operands ( QualityMetric qm1,
QualityMetric qm2,
MsqError  
)
inline

Member Data Documentation


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