Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inks/PowerQualityMetric.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  ***************************************************************** */
35 #include "PowerQualityMetric.hpp"
36 #include "QualityMetric.hpp"
37 #include "Vector3D.hpp"
38 #include "MsqDebug.hpp"
39 
40 using namespace Mesquite;
41 
43  double pow_factor,
44  MsqError &err)
45  : qualMetric( qm1 ), mPower( pow_factor )
46 {
47  if(qm1 == NULL){
48  MSQ_SETERR(err)("PowerQualityMetric constructor passed NULL pointer.",
50  return;
51  }
53  int n_flag=qm1->get_negate_flag();
54  //If the power is negative, then negate flag needs
55  //to be (-n_flag). If the power is very, very small
56  //then we just set an error.
57  if(fabs(pow_factor)<MSQ_MIN)
58  {
59  MSQ_SETERR(err)("PowerQualityMetric passed a double smaller than "
60  "Mesquite's minimum.", MsqError::INVALID_ARG);
61  return;
62  }
63  else if(pow_factor<0)
64  {
65  n_flag=(-n_flag);
66  }
67 
68  set_negate_flag(n_flag);
69 
71 
72  set_name("Composite Power");
73 }
74 
78  MsqMeshEntity *element,
79  double &value,
80  MsqError &err)
81 {
82  bool valid_flag;
83  double metric1;
84  valid_flag=qualMetric->evaluate_element(pd, element, metric1, err); MSQ_ERRZERO(err);
85  if(!valid_flag)
86  return false;
87  value = pow(metric1,mPower);
88  return valid_flag;
89 }
90 
94  MsqVertex* vert,
95  double &value,
96  MsqError& err)
97 {
98  bool valid_flag;
99  double metric1;
100  valid_flag=qualMetric->evaluate_vertex(pd, vert, metric1, err); MSQ_ERRZERO(err);
101  if(!valid_flag)
102  return false;
103  value = pow(metric1,mPower);
104  return valid_flag;
105 }
106 
107 
108 
bool evaluate_vertex(PatchData &pd, MsqVertex *vertex, double &value, MsqError &err)
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
int get_negate_flag()
Returns negateFlag.
Used to hold the error state and return it to the application.
Base class for concrete quality metrics.
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
PowerQualityMetric(QualityMetric *qm1, double pow_double, MsqError &err)
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
bool evaluate_element(PatchData &pd, MsqMeshEntity *element, double &value, MsqError &err)
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.
void set_metric_type(MetricType t)
This function should be used in the constructor of every concrete quality metric. ...
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
int get_feasible_constraint()
Returns the feasible flag for this metric.
void set_name(msq_std::string st)
Sets the name of this metric.
double pow(double value, const Exponent &exp)
const double MSQ_MIN
Definition: Mesquite.hpp:160