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

Computes the L_infinity objective function for a given patch, i.e., LInfTemplate::concrete_evaluate returns the maximum absolute value of the quality metric values on 'patch'. More...

#include <LInfTemplate.hpp>

Inheritance diagram for LInfTemplate:
Collaboration diagram for LInfTemplate:

Public Member Functions

 LInfTemplate (QualityMetric *)
 
virtual ~LInfTemplate ()
 
virtual bool concrete_evaluate (PatchData &patch, double &fval, MsqError &err)
 
 LInfTemplate (QualityMetric *)
 
virtual ~LInfTemplate ()
 
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 L_infinity objective function for a given patch, i.e., LInfTemplate::concrete_evaluate returns the maximum absolute value of the quality metric values on 'patch'.

Definition at line 55 of file includeLinks/LInfTemplate.hpp.

Constructor & Destructor Documentation

LInfTemplate ( QualityMetric qualitymetric)

Definition at line 42 of file ObjectiveFunction/LInfTemplate.cpp.

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

42  {
43  set_quality_metric(qualitymetric);
45  set_negate_flag(qualitymetric->get_negate_flag());
46 }
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:

~LInfTemplate ( )
virtual

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

50  {
51 
52 }
virtual ~LInfTemplate ( )
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 105 of file ObjectiveFunction/LInfTemplate.cpp.

References MsqError::INVALID_STATE, and MSQ_SETERR.

110  {
111  MSQ_SETERR(err)("The LInfTemplate is not sufficient for methods requiring\n"
112  " gradient information. If you neeed to try this anyway, \n"
113  " set the gradient type to numerical.\n",
115  return false;
116  }
#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/LInfTemplate.cpp.

References QualityMetric::ELEMENT_BASED, QualityMetric::evaluate_element(), QualityMetric::evaluate_vertex(), PatchData::get_element_array(), QualityMetric::get_metric_type(), ObjectiveFunction::get_quality_metric(), ObjectiveFunction::get_quality_metric_list(), PatchData::get_vertex_array(), MSQ_ERRZERO, PatchData::num_elements(), and PatchData::num_vertices().

55  {
56  //Total value of objective function
57  double temp_value=0;
58  fval=0.0;
59  bool obj_bool=true;
60  //For elements in Patch
61  int index;
62  QualityMetric* currentQM = get_quality_metric();
63  if(currentQM==NULL)
64  currentQM=get_quality_metric_list().front();
65  if(currentQM->get_metric_type()==QualityMetric::ELEMENT_BASED){
66  int num_elements=patch.num_elements();
67  MsqMeshEntity* elems=patch.get_element_array(err); MSQ_ERRZERO(err);
68  //Michael: this may not do what we want
69  //Set currentQM to be the first quality metric* in the list
70  for (index=0; index<num_elements;index++){
71  //evaluate metric for this elem
72  obj_bool=currentQM->evaluate_element(patch, &elems[index], temp_value,
73  err); MSQ_ERRZERO(err);
74  //if invalid patch
75  if(!obj_bool){
76  return false;
77  }
78  temp_value = fabs(temp_value);
79  if(temp_value>fval)
80  fval=temp_value;
81  }//end loop over elements
82  }//end if not VERTEX
83  else {//VERTEX
84  int num_vertices=patch.num_vertices();
85  MsqVertex* vertices=patch.get_vertex_array(err); MSQ_ERRZERO(err);
86  //Michael: this may not do what we want
87  //Set currentQM to be the first quality metric* in the list
88 
89  for (index=0; index<num_vertices;index++){
90  //evaluate metric for this vertex
91  obj_bool=currentQM->evaluate_vertex(patch,&vertices[index],
92  temp_value, err); MSQ_ERRZERO(err);
93  //if invalid patch
94  if(!obj_bool){
95  return false;
96  }
97  temp_value = fabs(temp_value);
98  if(temp_value>fval)
99  fval=temp_value;
100  }//end loop over vertices
101  }//end elseVERTEX
102  return true;
103 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
virtual msq_std::list< QualityMetric * > get_quality_metric_list()
Definition: patch.h:74

Here is the call graph for this function:


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