Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
src/QualityMetric/Untangle/UntangleBetaQualityMetric.hpp
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  ***************************************************************** */
27 // -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3 -*-
28 
37 #ifndef UNTANGLE_BETA_QUALITY_METRIC_HPP
38 #define UNTANGLE_BETA_QUALITY_METRIC_HPP
39 
40 #include "Mesquite.hpp"
42 #include "PatchData.hpp"
43 namespace Mesquite
44 {
60  class UntangleBetaQualityMetric : public UntangleQualityMetric
61  {
62  public:
63 
64  UntangleBetaQualityMetric(double bet=0.05);
65 
66  // virtual destructor ensures use of polymorphism during destruction
68  {}
74  bool evaluate_element(PatchData &pd,MsqMeshEntity* element,
75  double &fval,MsqError &err);
76 
79  void set_beta(double beta_in)
80  {mBeta = beta_in;}
82  double get_beta()
83  {return mBeta;}
84 
85  protected:
86  inline void untangle_function_2d(Vector3D temp_vec[],size_t e_ind,
87  PatchData &pd, double &fval,
88  MsqError &err);
89 
90  inline void untangle_function_3d(Vector3D temp_vec[],double &fval,
91  MsqError &err);
92 
93  private:
94  double mBeta;
95  };
96  //************BEGIN INLINE FUNCTIONS**************************
97 
98  inline void UntangleBetaQualityMetric::untangle_function_2d(Vector3D temp_vec[],size_t e_ind,PatchData &pd, double &fval, MsqError &err)
99  {
100  Vector3D surface_normal;
101  pd.get_domain_normal_at_element(e_ind,surface_normal,err); MSQ_ERRRTN(err);
102  Vector3D cross_vec=temp_vec[0]*temp_vec[1];
103  //cout<<"\nsurface_normal "<<surface_normal;
104  //cout<<"\cross_vec "<<cross_vec;
105  double temp_var=cross_vec.length();
106  if(cross_vec%surface_normal<0.0){
107  temp_var*=-1;
108  }
109  temp_var -= mBeta;
110  //cout<<"temp_var == "<<temp_var;
111  fval=0.0;
112  if(temp_var<0.0){
113  fval=fabs(temp_var)-temp_var;
114  }
115  // cout<<"\nfval == "<<fval<<" e_ind "<<e_ind;
116  }
117 
118  inline void UntangleBetaQualityMetric::untangle_function_3d(Vector3D temp_vec[],double &fval, MsqError &/*err*/)
119  {
120  double temp_var=temp_vec[0]%(temp_vec[1]*temp_vec[2]);
121  temp_var-=mBeta;
122  fval=0.0;
123  if(temp_var<0.0){
124  fval=fabs(temp_var)-temp_var;
125  }
126  }
127 
128 } //namespace
129 
130 
131 #endif // UntangleBetaQualityMetric_hpp
132 
133 
Used to hold the error state and return it to the application.
void untangle_function_3d(Vector3D temp_vec[], 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...
UntangleBetaQualityMetric(double bet=0.05)
For untangle beta, the constructor defaults to the SUM averaging method, and to the ELEMENT_VERTICES ...
NVec< 3, double > Vector3D
void untangle_function_2d(Vector3D temp_vec[], size_t e_ind, PatchData &pd, double &fval, MsqError &err)
bool evaluate_element(PatchData &pd, MsqMeshEntity *element, double &fval, MsqError &err)
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.