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

Computes the ASM (Area Smoothness Metric) of the given element. More...

#include <ASMQualityMetric.hpp>

Inheritance diagram for ASMQualityMetric:
Collaboration diagram for ASMQualityMetric:

Public Member Functions

 ASMQualityMetric ()
 
virtual ~ASMQualityMetric ()
 virtual destructor ensures use of polymorphism during destruction More...
 
bool evaluate_element (PatchData &pd, MsqMeshEntity *element, double &fval, MsqError &err)
 evaluate using mesquite objects More...
 
 ASMQualityMetric ()
 
virtual ~ASMQualityMetric ()
 virtual destructor ensures use of polymorphism during destruction More...
 
bool evaluate_element (PatchData &pd, MsqMeshEntity *element, double &fval, MsqError &err)
 evaluate using mesquite objects More...
 
- Public Member Functions inherited from SmoothnessQualityMetric
virtual ~SmoothnessQualityMetric ()
 
virtual ~SmoothnessQualityMetric ()
 
- 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...
 
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...
 
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)
 

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 SmoothnessQualityMetric
void compute_scalar_weights (int num_scalar_weights, double scalar_weights[], MsqError &err)
 
void compute_scalar_weights (int num_scalar_weights, double scalar_weights[], MsqError &err)
 
- 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

Computes the ASM (Area Smoothness Metric) of the given element.

The metric does not use the sample point functionality or the compute_weighted_jacobian. It computes the unsigned area or volume (a_0)of the element and of neighboring elements (a_i). In 2-d, elements are considered neighbors if they share an edge. In 3-d, elements are considered neighbors if they share a face. The metric is then taken to be the average (default is MAXIMUM) of abs(a_i-a_0)/(a_i+a_0) , and the metric needs to be minimized. The ideal metic value is zero which occurs when an element and its neighbors have the same unsigned area (or volume in three-dimensions).

Definition at line 61 of file includeLinks/ASMQualityMetric.hpp.

Constructor & Destructor Documentation

Definition at line 49 of file QualityMetric/Smoothness/ASMQualityMetric.cpp.

References QualityMetric::avgMethod, QualityMetric::ELEMENT_BASED, QualityMetric::ELEMENT_VERTICES, QualityMetric::feasible, QualityMetric::MAXIMUM, MSQ_CHKERR, QualityMetric::set_element_evaluation_mode(), QualityMetric::set_metric_type(), and QualityMetric::set_name().

50 {
51  MsqError err;
54  MSQ_CHKERR(err);
56  feasible=0;
57  set_name("Area Smoothness");
58 }
Used to hold the error state and return it to the application.
void set_element_evaluation_mode(ElementEvaluationMode mode, MsqError &err)
Sets the evaluation mode for the ELEMENT_BASED metrics.
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
void set_metric_type(MetricType t)
This function should be used in the constructor of every concrete quality metric. ...
void set_name(msq_std::string st)
Sets the name of this metric.

Here is the call graph for this function:

virtual ~ASMQualityMetric ( )
inlinevirtual

virtual destructor ensures use of polymorphism during destruction

Definition at line 67 of file includeLinks/ASMQualityMetric.hpp.

68  {}
virtual ~ASMQualityMetric ( )
inlinevirtual

virtual destructor ensures use of polymorphism during destruction

Definition at line 67 of file src/QualityMetric/Smoothness/ASMQualityMetric.hpp.

68  {}

Member Function Documentation

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

evaluate using mesquite objects

Reimplemented from QualityMetric.

Definition at line 60 of file QualityMetric/Smoothness/ASMQualityMetric.cpp.

References QualityMetric::average_metrics(), MsqMeshEntity::compute_unsigned_area(), MsqMeshEntity::compute_unsigned_volume(), PatchData::get_adjacent_entities_via_n_dim(), PatchData::get_element_array(), PatchData::get_element_index(), MsqMeshEntity::get_element_type(), Mesquite::HEXAHEDRON, i, MSQ_ERRZERO, Mesquite::MSQ_MIN, MSQ_SETERR, MsqError::NOT_IMPLEMENTED, Mesquite::QUADRILATERAL, Mesquite::TETRAHEDRON, and Mesquite::TRIANGLE.

64 {
65  double temp_double;
66  size_t elem_ind=pd.get_element_index(element);
67  vector<size_t> adj_elems;
68 
69  MsqMeshEntity *elems = pd.get_element_array(err);
70  switch(element->get_element_type()){
71  case TRIANGLE:
72  case QUADRILATERAL:
73  pd.get_adjacent_entities_via_n_dim(1,elem_ind,adj_elems,err); MSQ_ERRZERO(err);
74  break;
75  case TETRAHEDRON:
76  case HEXAHEDRON:
77  pd.get_adjacent_entities_via_n_dim(2,elem_ind,adj_elems,err); MSQ_ERRZERO(err);
78  break;
79  default:
80  MSQ_SETERR(err)("ASM quality metric not implemented for this "
81  "element type.", MsqError::NOT_IMPLEMENTED);
82  return false;
83  };
84  int num_samp=adj_elems.size();
85  if(num_samp < 1){
86  fval=0.0;
87  }
88  else{
89  double* met_vals = new double [num_samp];
90  int i=0;
91  switch(element->get_element_type()){
92  case TRIANGLE:
93  case QUADRILATERAL:
94  temp_double=element->compute_unsigned_area(pd,err); MSQ_ERRZERO(err);
95  //PRINT_INFO("\nunsigned area = %f",temp_double);
96  for(i=0;i<num_samp;++i){
97  met_vals[i]=elems[adj_elems[i]].compute_unsigned_area(pd,err); MSQ_ERRZERO(err);
98  //PRINT_INFO("neighboring nunsigned area = %f",met_vals[i]);
99  if((temp_double+met_vals[i])>MSQ_MIN){
100  met_vals[i]=fabs((temp_double-met_vals[i])/(temp_double+
101  met_vals[i]));
102  }
103  else
104  met_vals[i]=0.0;
105  }
106  break;
107 
108  case TETRAHEDRON:
109  case HEXAHEDRON:
110  temp_double=element->compute_unsigned_volume(pd,err); MSQ_ERRZERO(err);
111  for(i=0;i<num_samp;++i){
112  met_vals[i]=elems[adj_elems[i]].compute_unsigned_volume(pd,err); MSQ_ERRZERO(err);
113  if((temp_double+met_vals[i])>MSQ_MIN){
114  met_vals[i]=fabs((temp_double-met_vals[i])/(temp_double+
115  met_vals[i]));
116  }
117  else
118  met_vals[i]=0.0;
119  }
120  break;
121  default:
122  MSQ_SETERR(err)("ASM quality metric not implemented for this "
123  "element type.", MsqError::NOT_IMPLEMENTED);
124  return false;
125  };
126  fval=average_metrics(met_vals,num_samp,err); MSQ_ERRZERO(err);
127  //PRINT_INFO("\nRETURNING %f \n",fval);
128  delete []met_vals;
129  }
130  return true;
131 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
requested functionality is not (yet) implemented
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
double compute_unsigned_volume(PatchData &pd, MsqError &err)
Computes the volume of the element.
void get_adjacent_entities_via_n_dim(int n, size_t ent_ind, msq_std::vector< size_t > &adj_ents, MsqError &err)
Get the indices of entities attached to entity (given by ent_ind). adj_ents is filled with the indice...
size_t get_element_index(MsqMeshEntity *element)
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79
double compute_unsigned_area(PatchData &pd, MsqError &err)
Computes the area of the element.
EntityTopology get_element_type() const
Returns element type.
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 ...
const MsqMeshEntity * get_element_array(MsqError &err) const
Returns a pointer to the start of the element array.
const double MSQ_MIN
Definition: Mesquite.hpp:160

Here is the call graph for this function:

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

evaluate using mesquite objects

Reimplemented from QualityMetric.


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