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

#include <ShapeQualityMetric.hpp>

Inheritance diagram for ShapeQualityMetric:
Collaboration diagram for ShapeQualityMetric:

Public Member Functions

virtual ~ShapeQualityMetric ()
 virtual destructor ensures use of polymorphism during destruction More...
 
virtual ~ShapeQualityMetric ()
 virtual destructor ensures use of polymorphism during destruction 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...
 
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

bool condition_number_2d (Vector3D temp_vec[], size_t v_ind, PatchData &pd, double &fval, MsqError &err)
 Given the 2-d jacobian matrix, compute the condition number, fval. More...
 
bool condition_number_3d (Vector3D temp_vec[], PatchData &pd, double &fval, MsqError &err)
 Given the 3-d jacobian matrix, compute the condition number, fval. More...
 
bool condition_number_2d (Vector3D temp_vec[], size_t v_ind, PatchData &pd, double &fval, MsqError &err)
 Given the 2-d jacobian matrix, compute the condition number, fval. More...
 
bool condition_number_3d (Vector3D temp_vec[], PatchData &pd, double &fval, MsqError &err)
 Given the 3-d jacobian matrix, compute the condition number, fval. More...
 
- 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)
 

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 Attributes inherited from QualityMetric
AveragingMethod avgMethod
 
int feasible
 
msq_std::string metricName
 

Detailed Description

Definition at line 48 of file includeLinks/ShapeQualityMetric.hpp.

Constructor & Destructor Documentation

virtual ~ShapeQualityMetric ( )
inlinevirtual

virtual destructor ensures use of polymorphism during destruction

Definition at line 57 of file includeLinks/ShapeQualityMetric.hpp.

58  {};
virtual ~ShapeQualityMetric ( )
inlinevirtual

virtual destructor ensures use of polymorphism during destruction

Definition at line 57 of file src/QualityMetric/Shape/ShapeQualityMetric.hpp.

58  {};

Member Function Documentation

bool condition_number_2d ( Vector3D  temp_vec[],
size_t  v_ind,
PatchData pd,
double &  fval,
MsqError err 
)
inlineprotected

Given the 2-d jacobian matrix, compute the condition number, fval.

Definition at line 109 of file includeLinks/ShapeQualityMetric.hpp.

References PatchData::domain_set(), PatchData::get_barrier_delta(), PatchData::get_domain_normal_at_vertex(), MsqError::INVALID_MESH, Mesquite::MSQ_DBL_MIN, MSQ_ERRZERO, Mesquite::MSQ_MAX_CAP, MSQ_SETERR, and QualityMetric::vertex_barrier_function().

Referenced by ConditionNumberQualityMetric::evaluate_element(), and VertexConditionNumberQualityMetric::evaluate_vertex().

114  {
115  //norm squared of J
116  double term1=temp_vec[0]%temp_vec[0]+temp_vec[1]%temp_vec[1];
117 
118  Vector3D unit_surf_norm;
119  if ( pd.domain_set() ) {
120  pd.get_domain_normal_at_vertex(v_ind,true,unit_surf_norm,err);MSQ_ERRZERO(err);
121  }
122  else {
123  return false;
124  }
125 
126  // det J
127  double temp_var=unit_surf_norm%(temp_vec[0]*temp_vec[1]);
128 
129  double h;
130  double delta=pd.get_barrier_delta(err); MSQ_ERRZERO(err);
131 
132  // Note: technically, we want delta=eta*tau-max
133  // whereas the function above gives delta=eta*alpha-max
134  //
135  // Because the only requirement on eta is eta << 1,
136  // and because tau-max = alpha-max/0.707 we can
137  // ignore the discrepancy
138 
139  if (delta==0) {
140  if (temp_var < MSQ_DBL_MIN ) {
141  return false;
142  }
143  else {
144  h=temp_var;
145  }
146 
147  // Note: when delta=0, the vertex_barrier_function
148  // formally gives h=temp_var as well.
149  // We just do it this way to avoid any
150  // roundoff issues.
151  // Also: when delta=0, this metric is identical
152  // to the original condition number with
153  // the barrier at temp_var=0
154  }
155  else {
156  h = vertex_barrier_function(temp_var,delta);
157 
158  if (h<MSQ_DBL_MIN && fabs(temp_var) > MSQ_DBL_MIN ) {
159  h = delta*delta/fabs(temp_var); }
160  // Note: Analytically, h is strictly positive, but
161  // it can be zero numerically if temp_var
162  // is a large negative number
163  // In the case h=0, we use a different analytic
164  // approximation to compute h.
165  }
166 
167  if (h<MSQ_DBL_MIN) {
168  MSQ_SETERR(err)( "Barrier function is zero due to excessively large "
169  "negative area compared to delta. /n Try to untangle "
170  "mesh another way. ", MsqError::INVALID_MESH);
171  return false;
172  }
173 
174  fval=term1/(2*h);
175 
176  if (fval>MSQ_MAX_CAP) {
177  fval=MSQ_MAX_CAP;
178  }
179  return true;
180 
181  }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
const double MSQ_DBL_MIN
Definition: Mesquite.hpp:158
const double MSQ_MAX_CAP
Definition: Mesquite.hpp:173
double vertex_barrier_function(double det, double delta)
Escobar Barrier Function for Shape and Other Metrics.
NVec< 3, double > Vector3D
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.

Here is the call graph for this function:

Here is the caller graph for this function:

bool condition_number_2d ( Vector3D  temp_vec[],
size_t  v_ind,
PatchData pd,
double &  fval,
MsqError err 
)
protected

Given the 2-d jacobian matrix, compute the condition number, fval.

bool condition_number_3d ( Vector3D  temp_vec[],
PatchData pd,
double &  fval,
MsqError err 
)
protected

Given the 3-d jacobian matrix, compute the condition number, fval.

bool condition_number_3d ( Vector3D  temp_vec[],
PatchData pd,
double &  fval,
MsqError err 
)
inlineprotected

Given the 3-d jacobian matrix, compute the condition number, fval.

Definition at line 186 of file includeLinks/ShapeQualityMetric.hpp.

References PatchData::get_barrier_delta(), MsqError::INVALID_MESH, Mesquite::MSQ_DBL_MIN, MSQ_ERRZERO, Mesquite::MSQ_MAX_CAP, MSQ_SETERR, sqrt(), and QualityMetric::vertex_barrier_function().

Referenced by ConditionNumberQualityMetric::evaluate_element(), and VertexConditionNumberQualityMetric::evaluate_vertex().

190  {
191  //norm squared of J
192  double term1=temp_vec[0]%temp_vec[0]+
193  temp_vec[1]%temp_vec[1]+
194  temp_vec[2]%temp_vec[2];
195  //norm squared of adjoint of J
196  double term2=(temp_vec[0]*temp_vec[1])%
197  (temp_vec[0]*temp_vec[1])+
198  (temp_vec[1]*temp_vec[2])%
199  (temp_vec[1]*temp_vec[2])+
200  (temp_vec[2]*temp_vec[0])%
201  (temp_vec[2]*temp_vec[0]);
202  //det of J
203  double temp_var=temp_vec[0]%(temp_vec[1]*temp_vec[2]);
204 
205  double h;
206  double delta=pd.get_barrier_delta(err); MSQ_ERRZERO(err);
207 
208  // Note: technically, we want delta=eta*tau-max
209  // whereas the function above gives delta=eta*alpha-max
210  //
211  // Because the only requirement on eta is eta << 1,
212  // and because tau-max = alpha-max/0.707 we can
213  // ignore the discrepancy
214 
215  if (delta==0) {
216  if (temp_var < MSQ_DBL_MIN ) {
217  return false;
218  }
219  else {
220  h=temp_var;
221  }
222 
223  // Note: when delta=0, the vertex_barrier_function
224  // formally gives h=temp_var as well.
225  // We just do it this way to avoid any
226  // roundoff issues.
227  // Also: when delta=0, this metric is identical
228  // to the original condition number with
229  // the barrier at temp_var=0
230 
231  }
232  else {
233  h = vertex_barrier_function(temp_var,delta);
234 
235  if (h<MSQ_DBL_MIN && fabs(temp_var) > MSQ_DBL_MIN ) {
236  h = delta*delta/fabs(temp_var); }
237 
238  // Note: Analytically, h is strictly positive, but
239  // it can be zero numerically if temp_var
240  // is a large negative number
241  // In the h=0, we use a different analytic
242  // approximation to compute h.
243  }
244  if (h<MSQ_DBL_MIN) {
245  MSQ_SETERR(err)("Barrier function is zero due to excessively large "
246  "negative area compared to delta. /n Try to untangle "
247  "mesh another way. ", MsqError::INVALID_MESH);
248  return false;
249  }
250 
251  fval=sqrt(term1*term2)/(3*h);
252 
253  if (fval>MSQ_MAX_CAP) {
254  fval=MSQ_MAX_CAP;
255  }
256  return true;
257 
258  }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
const double MSQ_DBL_MIN
Definition: Mesquite.hpp:158
const double MSQ_MAX_CAP
Definition: Mesquite.hpp:173
double vertex_barrier_function(double det, double delta)
Escobar Barrier Function for Shape and Other Metrics.
double sqrt(double d)
Definition: double.h:73
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.

Here is the call graph for this function:

Here is the caller graph for this function:


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