Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TargetCalculator/LVQDTargetCalculator.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  ***************************************************************** */
27 
37 #include "LVQDTargetCalculator.hpp"
38 #include "PatchDataUser.hpp"
39 #include "PatchData.hpp"
40 #include "MeshSet.hpp"
41 #include "MsqTimer.hpp"
42 
43 using namespace Mesquite;
44 
45 
46 
50 {
51  MSQ_FUNCTION_TIMER( "LVQDTargetCalculator::compute_target_matrices" );
52 
53  // Gets from the reference mesh a patch ref_pd equivalent to the patch pd of the main mesh.
54  PatchData ref_pd;
55  PatchDataParameters ref_pd_params(this->get_all_parameters());
56  if (refMesh)
57  refMesh->get_next_patch(ref_pd, ref_pd_params, err);
58  else
59  MSQ_SETERR(err)("No reference mesh", MsqError::INVALID_STATE);
60  MSQ_ERRRTN(err);
61  compute_target_matrices(pd, ref_pd, err);
62 }
64  PatchData &ref_pd, MsqError &err)
65 {
66  // Make sure topology of ref_pd and pd are equal
67  size_t num_elements=pd.num_elements();
68  size_t num_vertices=pd.num_vertices();
69  if (num_elements != pd.num_elements() || num_vertices != pd.num_vertices())
70  {
72  return;
73  }
74 
75 
76  MsqMeshEntity* elems = pd.get_element_array(err); MSQ_ERRRTN(err);
77  MsqMeshEntity* elems_ref = ref_pd.get_element_array(err); MSQ_ERRRTN(err);
78 
84  Matrix3D V, Q, Delta;
85  double Lambda=1;
86 
87 // std::map<enum guide_type, Matrix3D[MSQ_MAX_NUM_VERT_PER_ENT]> guides;
88 
89  if (lambdaBase == AVERAGE)
90  Lambda = ref_pd.get_average_Lambda_3d(err); MSQ_ERRRTN(err);
91 
92  for (size_t i=0; i<num_elements; ++i) {
93  unsigned nve = elems[i].vertex_count();
94  if (nve != elems_ref[i].vertex_count())
95  {
97  return;
98  }
99 
100  if (lambdaBase == REGULAR) {
101  compute_guide_matrices(guideLambda, ref_pd, i, L_guides, nve, err);
102  MSQ_ERRRTN(err); }
103  compute_guide_matrices(guideV, ref_pd, i, V_guides, nve, err); MSQ_ERRRTN(err);
104  compute_guide_matrices(guideQ, ref_pd, i, Q_guides, nve, err); MSQ_ERRRTN(err);
105  compute_guide_matrices(guideDelta, ref_pd, i, D_guides, nve, err); MSQ_ERRRTN(err);
106 
107  for (unsigned c=0; c<nve; ++c) {
108  if (lambdaBase == REGULAR) Lambda = compute_Lambda(L_guides[c], err); MSQ_ERRRTN(err);
109  V = compute_V_3D(V_guides[c], err); MSQ_ERRRTN(err);
110  Q = compute_Q_3D(Q_guides[c], err); MSQ_ERRRTN(err);
111  Delta = compute_Delta_3D(D_guides[c], err); MSQ_ERRRTN(err);
112  matrices[c] = Lambda * V * Q * Delta;
113  }
114  pd.targetMatrices.set_element_corner_tags( &pd, i, matrices, err ); MSQ_ERRRTN(err);
115  }
116 }
117 
The Lambda coefficient is the average on the mesh.
CornerTag< TargetMatrix > targetMatrices
Target matrix data.
Used to hold the error state and return it to the application.
PatchDataParameters & get_all_parameters()
Returns the PatchDataParameters object.
void compute_guide_matrices(enum guide_type type, PatchData &ref_pd, size_t elem_ind, Matrix3D A[], int num, MsqError &err)
Computes the guide corner matrices A for a given element index in the reference patch.
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Matrix3D compute_V_3D(const Matrix3D &A, MsqError &err)
Each element has a lambda coefficient.
const int MSQ_MAX_NUM_VERT_PER_ENT
Definition: Mesquite.hpp:120
Matrix3D compute_Q_3D(const Matrix3D &A, MsqError &err)
static double compute_Lambda(const Matrix3D &A, MsqError &err)
Note that this function is static, i.e. it can be used independently of an object.
size_t num_elements() const
number of elements in the Patch.
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.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79
virtual void compute_target_matrices(PatchData &pd, MsqError &err)
double get_average_Lambda_3d(MsqError &err)
Returns average corner determinant over all corners in the patch This information is stored in the pa...
size_t num_vertices() const
number of vertices in the patch.
Matrix3D compute_Delta_3D(const Matrix3D &A, MsqError &err)
Class containing the target corner matrices for the context based smoothing.
object is in an invalid state
const MsqMeshEntity * get_element_array(MsqError &err) const
Returns a pointer to the start of the element array.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
bool get_next_patch(PatchData &pd, PatchDataUser *pd_user, MsqError &err)
Gets the next PatchData.