Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjectiveFunction/LInfTemplate.cpp
Go to the documentation of this file.
1 /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Sandia Corporation and Argonne National
5  Laboratory. Under the terms of Contract DE-AC04-94AL85000
6  with Sandia Corporation, the U.S. Government retains certain
7  rights in this software.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  (lgpl.txt) along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
24  pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
25 
26  ***************************************************************** */
36 #include <math.h>
37 #include "LInfTemplate.hpp"
38 
39 namespace Mesquite {
40 
41 
43  set_quality_metric(qualitymetric);
45  set_negate_flag(qualitymetric->get_negate_flag());
46 }
47 
48 
49 //Michael: need to clean up here
51 
52 }
53 
55  MsqError &err){
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();
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 }
104 
106  Vector3D *const &grad,
107  double &OF_val,
108  MsqError &err,
109  size_t array_size)
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  }
117 
118 
119 } // namespace Mesquite
120 
void set_gradient_type(GRADIENT_TYPE grad)
Set gradType to either NUMERICAL_GRADIENT or ANALYTICAL_GRADIENT.
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
void set_quality_metric(QualityMetric *qm)
Set the value of qMetric.
int get_negate_flag()
Returns negateFlag.
Used to hold the error state and return it to the application.
Base class for concrete quality metrics.
virtual bool concrete_evaluate(PatchData &patch, double &fval, MsqError &err)
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
every differentiable function should have an analytical gradient implemented.
virtual msq_std::list< QualityMetric * > get_quality_metric_list()
size_t num_elements() const
number of elements in the Patch.
Definition: patch.h:74
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void set_negate_flag(int neg)
Set the value of ObjectiveFunction&#39;s negateFlag. Unless composite, concrete ObjectiveFunctions should...
size_t num_vertices() const
number of vertices in the patch.
virtual bool evaluate_element(PatchData &, MsqMeshEntity *, double &, MsqError &err)
Evaluate the metric for an element.
virtual bool evaluate_vertex(PatchData &, MsqVertex *, double &, MsqError &err)
Evaluate the metric for a vertex.
virtual bool compute_analytical_gradient(PatchData &patch, Vector3D *const &grad, double &OF_val, MsqError &err, size_t array_size)
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
object is in an invalid state
const MsqMeshEntity * get_element_array(MsqError &err) const
Returns a pointer to the start of the element array.
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...