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

Computes the maximum quality metric value. More...

#include <MaxTemplate.hpp>

Inheritance diagram for MaxTemplate:
Collaboration diagram for MaxTemplate:

Public Member Functions

 MaxTemplate (QualityMetric *)
 
virtual ~MaxTemplate ()
 
virtual bool concrete_evaluate (PatchData &patch, double &fval, MsqError &err)
 
 MaxTemplate (QualityMetric *)
 
virtual ~MaxTemplate ()
 
virtual bool concrete_evaluate (PatchData &patch, double &fval, MsqError &err)
 
- Public Member Functions inherited from ObjectiveFunction
 ObjectiveFunction ()
 
virtual ~ObjectiveFunction ()
 
bool evaluate (PatchData &patch, double &fval, MsqError &err)
 
void set_gradient_type (GRADIENT_TYPE grad)
 Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT. More...
 
bool compute_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size=0)
 Calls either compute_numerical_gradient or compute_analytical_gradient depending on the value of gradType. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More...
 
bool compute_hessian (PatchData &patch, MsqHessian &hessian, Vector3D *const &grad, double &OF_val, MsqError &err)
 Calls compute_analytical_hessian. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More...
 
QualityMetricget_quality_metric ()
 
virtual msq_std::list
< QualityMetric * > 
get_quality_metric_list ()
 
void set_quality_metric (QualityMetric *qm)
 Set the value of qMetric. More...
 
void set_negate_flag (int neg)
 Set the value of ObjectiveFunction's negateFlag. Unless composite, concrete ObjectiveFunctions should set this flag to to the value of the associated QualityMetric's negateFLag. More...
 
int get_negate_flag ()
 Returns negateFlag. More...
 
 ObjectiveFunction ()
 
virtual ~ObjectiveFunction ()
 
bool evaluate (PatchData &patch, double &fval, MsqError &err)
 
void set_gradient_type (GRADIENT_TYPE grad)
 Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT. More...
 
bool compute_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size=0)
 Calls either compute_numerical_gradient or compute_analytical_gradient depending on the value of gradType. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More...
 
bool compute_hessian (PatchData &patch, MsqHessian &hessian, Vector3D *const &grad, double &OF_val, MsqError &err)
 Calls compute_analytical_hessian. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More...
 
QualityMetricget_quality_metric ()
 
virtual msq_std::list
< QualityMetric * > 
get_quality_metric_list ()
 
void set_quality_metric (QualityMetric *qm)
 Set the value of qMetric. More...
 
void set_negate_flag (int neg)
 Set the value of ObjectiveFunction's negateFlag. Unless composite, concrete ObjectiveFunctions should set this flag to to the value of the associated QualityMetric's negateFLag. More...
 
int get_negate_flag ()
 Returns negateFlag. More...
 

Protected Member Functions

virtual bool compute_analytical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size)
 
virtual bool compute_analytical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size)
 
- Protected Member Functions inherited from ObjectiveFunction
bool compute_numerical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size)
 Non-virtual function which numerically computes the gradient of the Objective Function. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More...
 
virtual bool compute_analytical_hessian (PatchData &, MsqHessian &, Vector3D *const &, double &, MsqError &)
 
double get_eps (PatchData &pd, double &local_val, int k, MsqVertex *vertex, MsqError &err)
 Returns eps used in the numerical gradient calculation. More...
 
void set_use_local_gradient (bool new_bool)
 Sets useLocalGradient This variable determines whether compute_numercial_gradient can use the most efficient gradient calculation. More...
 
bool compute_numerical_gradient (PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size)
 Non-virtual function which numerically computes the gradient of the Objective Function. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'. More...
 
virtual bool compute_analytical_hessian (PatchData &, MsqHessian &, Vector3D *const &, double &, MsqError &)
 
double get_eps (PatchData &pd, double &local_val, int k, MsqVertex *vertex, MsqError &err)
 Returns eps used in the numerical gradient calculation. More...
 
void set_use_local_gradient (bool new_bool)
 Sets useLocalGradient This variable determines whether compute_numercial_gradient can use the most efficient gradient calculation. More...
 

Additional Inherited Members

- Public Types inherited from ObjectiveFunction
enum  GRADIENT_TYPE { NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT, NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT }
 
enum  GRADIENT_TYPE { NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT, NUMERICAL_GRADIENT, ANALYTICAL_GRADIENT }
 

Detailed Description

Computes the maximum quality metric value.

This function is the same as the LInfTemplate except that no absolute values are used.

Definition at line 56 of file includeLinks/MaxTemplate.hpp.

Constructor & Destructor Documentation

MaxTemplate ( QualityMetric qualitymetric)

Definition at line 43 of file ObjectiveFunction/MaxTemplate.cpp.

References ObjectiveFunction::ANALYTICAL_GRADIENT, QualityMetric::get_negate_flag(), ObjectiveFunction::set_gradient_type(), ObjectiveFunction::set_negate_flag(), and ObjectiveFunction::set_quality_metric().

43  {
44  set_quality_metric(qualitymetric);
45  set_negate_flag(qualitymetric->get_negate_flag());
47 }
void set_gradient_type(GRADIENT_TYPE grad)
Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT.
void set_quality_metric(QualityMetric *qm)
Set the value of qMetric.
every differentiable function should have an analytical gradient implemented.
void set_negate_flag(int neg)
Set the value of ObjectiveFunction&#39;s negateFlag. Unless composite, concrete ObjectiveFunctions should...

Here is the call graph for this function:

~MaxTemplate ( )
virtual

Definition at line 50 of file ObjectiveFunction/MaxTemplate.cpp.

50  {
51 
52 }
virtual ~MaxTemplate ( )
virtual

Member Function Documentation

bool compute_analytical_gradient ( PatchData patch,
Vector3D *const &  grad,
double &  OF_val,
MsqError err,
size_t  array_size 
)
protectedvirtual

Fills an array of Vector3D, grad, with the gradient of the objective function computed using the gradient of the quality metric. If the function has not been over-riden in the concrete Objective Function, the base class implementation prints a warning and then defaults to numerical gradient. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'.

Parameters
patchThe PatchData object for which the objective function gradient is computed.
gradAn array of Vector3D, at least the size of the number of vertices in the patch.
OF_valis set to the value of the objective function.
array_sizeis the size of the grad Vector3D[] array and must correspond to the number of vertices in the patch.

Reimplemented from ObjectiveFunction.

Definition at line 115 of file ObjectiveFunction/MaxTemplate.cpp.

References MsqError::INVALID_STATE, and MSQ_SETERR.

120  {
121  MSQ_SETERR(err)("The MaxTemplate is not sufficient for methods requiring\n"
122  " gradient information. If you neeed to try this anyway, \n"
123  " set the gradient type to numerical.\n",
125  return false;
126  }
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state
virtual bool compute_analytical_gradient ( PatchData patch,
Vector3D *const &  grad,
double &  OF_val,
MsqError err,
size_t  array_size 
)
protectedvirtual

Fills an array of Vector3D, grad, with the gradient of the objective function computed using the gradient of the quality metric. If the function has not been over-riden in the concrete Objective Function, the base class implementation prints a warning and then defaults to numerical gradient. Function returns 'false' if the patch is not within a required feasible regeion. Otherwise, it returns 'true'.

Parameters
patchThe PatchData object for which the objective function gradient is computed.
gradAn array of Vector3D, at least the size of the number of vertices in the patch.
OF_valis set to the value of the objective function.
array_sizeis the size of the grad Vector3D[] array and must correspond to the number of vertices in the patch.

Reimplemented from ObjectiveFunction.

virtual bool concrete_evaluate ( PatchData patch,
double &  fval,
MsqError err 
)
virtual

Evaluate the objective function on a given patch.

Implements ObjectiveFunction.

bool concrete_evaluate ( PatchData patch,
double &  fval,
MsqError err 
)
virtual

Evaluate the objective function on a given patch.

Implements ObjectiveFunction.

Definition at line 54 of file ObjectiveFunction/MaxTemplate.cpp.

References QualityMetric::ELEMENT_BASED, QualityMetric::evaluate_element(), QualityMetric::evaluate_vertex(), PatchData::get_element_array(), QualityMetric::get_metric_type(), ObjectiveFunction::get_quality_metric(), PatchData::get_vertex_array(), MsqError::INVALID_STATE, MSQ_CHKERR, MSQ_ERRZERO, MSQ_SETERR, PatchData::num_elements(), PatchData::num_vertices(), and QualityMetric::VERTEX_BASED.

55  {
56 
57  //Total value of objective function
58  fval = 0.0;
59  double temp_value=0;
60  bool obj_bool = true;
61  //For elements in Patch
62  int index;
63  QualityMetric* currentQM = get_quality_metric();
64  if(currentQM->get_metric_type()==QualityMetric::ELEMENT_BASED){
65 
66  int num_elements=patch.num_elements();
67  MsqMeshEntity* elems=patch.get_element_array(err); MSQ_ERRZERO(err);
68 
69  for (index=0; index<num_elements; index++){
70 
71  //evaluate metric for this elem
72  obj_bool = currentQM->evaluate_element(patch, &elems[index],
73  temp_value, err);
74  //if invalid patch
75  if(MSQ_CHKERR(err) || !obj_bool ){
76  fval = 0.0;
77  return false;
78  }
79 
80  if(temp_value>fval )
81  fval=temp_value;
82 
83  }//end loop over elements
84  }//end if not VERTEX
85 
86  else if (currentQM->get_metric_type()==QualityMetric::VERTEX_BASED) {
87 
88  int num_vertices=patch.num_vertices();
89  MsqVertex* vertices=patch.get_vertex_array(err); MSQ_ERRZERO(err);
90 
91  for (index=0; index<num_vertices;index++){
92 
93  //evaluate metric for this vertex
94  obj_bool=currentQM->evaluate_vertex(patch, &vertices[index],
95  temp_value, err);
96  //if invalid patch
97  if(MSQ_CHKERR(err) || !obj_bool ){
98  fval = 0.0;
99  return false;
100  }
101  if(temp_value>fval)
102  fval=temp_value;
103 
104  }//end loop over vertices
105  }//end else VERTEX
106  else {
107  MSQ_SETERR(err)("Make sure MetricType is initialised in concrete "
108  "QualityMetric constructor.", MsqError::INVALID_STATE);
109  return false;
110  }
111 
112  return true;
113 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
Definition: patch.h:74
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state

Here is the call graph for this function:


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