Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inks/EdgeLengthQualityMetric.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 "EdgeLengthQualityMetric.hpp"
36 #include "Vector3D.hpp"
37 #include "QualityMetric.hpp"
38 #include "MsqVertex.hpp"
39 #include "PatchData.hpp"
40 
41 #include <math.h>
42 #ifdef MSQ_USE_OLD_STD_HEADERS
43 # include <vector.h>
44 #else
45 # include <vector>
46  using std::vector;
47 #endif
48 
49 using namespace Mesquite;
50 
52  double &fval, MsqError &err)
53 {
54  fval=0.0;
55  size_t this_vert = pd.get_vertex_index(vert);
56  size_t other_vert;
57  vector<size_t> adj_verts;
58  Vector3D edg;
59  pd.get_adjacent_vertex_indices(this_vert,adj_verts,err); MSQ_ERRZERO(err);
60  int num_sample_points=adj_verts.size();
61  double *metric_values=new double[num_sample_points];
62  MsqVertex* verts = pd.get_vertex_array(err); MSQ_ERRZERO(err);
63  int point_counter=0;
64  while(!adj_verts.empty()){
65  other_vert=adj_verts.back();
66  adj_verts.pop_back();
67  edg[0]=verts[this_vert][0]-verts[other_vert][0];
68  edg[1]=verts[this_vert][1]-verts[other_vert][1];
69  edg[2]=verts[this_vert][2]-verts[other_vert][2];
70  metric_values[point_counter]=edg.length();
71  ++point_counter;
72  }
73  fval=average_metrics(metric_values,num_sample_points,err); MSQ_ERRZERO(err);
74  delete[] metric_values;
75 
76  return true;
77 
78 }
79 
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
Used to hold the error state and return it to the application.
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
size_t get_vertex_index(MsqVertex *vertex)
void get_adjacent_vertex_indices(size_t vertex_index, msq_std::vector< size_t > &vert_indices, MsqError &err)
bool evaluate_vertex(PatchData &pd, MsqVertex *vert, double &fval, MsqError &err)
Evaluate the metric for a vertex.
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
double average_metrics(const double metric_values[], const int &num_values, MsqError &err)
average_metrics takes an array of length num_values and averages the contents using averaging method ...
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...