Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QualityMetric/DFT/sRI_DFT.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 "sRI_DFT.hpp"
37 
38 using namespace Mesquite;
39 
40 
42  MsqMeshEntity* element,
43  double& value, MsqError &err)
44 {
46  double c_k[MSQ_MAX_NUM_VERT_PER_ENT];
47  double dft[MSQ_MAX_NUM_VERT_PER_ENT];
48  bool return_flag = false;
49  double h, tau, s;
50 
51  size_t num_T = element->vertex_count();
52  compute_T_matrices(*element, pd, T, num_T, c_k, err); MSQ_ERRZERO(err);
53 
54  const double id[] = {1., 0., 0., 0., 1., 0., 0., 0., 1.};
55  const Matrix3D I(id);
56  Matrix3D TT;
57  for (size_t i=0; i<num_T; ++i) {
58  tau = det(T[i]);
59  s = pow(tau, MSQ_ONE_THIRD); // for 3D (tet & hex)
60  TT = transpose(T[i]);
61  TT = TT * T[i];
62  TT -= (s*s)*I;
63  dft[i] = .5 * Frobenius_2(TT);
64  return_flag = get_barrier_function(pd, tau, h, err); MSQ_ERRZERO(err);
65  dft[i] /= pow(h, 4.0/3.0);
66  }
67 
68  value = weighted_average_metrics(c_k, dft, num_T, err); MSQ_ERRZERO(err);
69 
70  return return_flag;
71 }
72 
73 
74 
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
static const double MSQ_ONE_THIRD
Definition: Mesquite.hpp:128
Used to hold the error state and return it to the application.
double s
Definition: blastest.C:80
Matrix3D transpose(const Matrix3D &A)
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
const int MSQ_MAX_NUM_VERT_PER_ENT
Definition: Mesquite.hpp:120
double Frobenius_2(const Matrix3D &A)
Return the square of the Frobenius norm of A, i.e. sum (diag (A&#39; * A))
virtual bool evaluate_element(PatchData &pd, MsqMeshEntity *element, double &value, MsqError &err)
Evaluate the metric for an element.
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
double weighted_average_metrics(const double coef[], const double metric_values[], const int &num_values, MsqError &err)
takes an array of coefficients and an array of metrics (both of length num_value) and averages the co...
blockLoc i
Definition: read.cpp:79
void compute_T_matrices(MsqMeshEntity &elem, PatchData &pd, Matrix3D T[], size_t num_T, double c_k[], MsqError &err)
For a given element, compute each corner matrix A, and given a target corner matrix W...
double det(const Matrix3D &A)
bool get_barrier_function(PatchData &pd, const double &tau, double &h, MsqError &err)
double pow(double value, const Exponent &exp)