Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
includeLinks/LaplacianSmoother.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  ***************************************************************** */
38 #ifndef Mesquite_LaplacianSmoother_hpp
39 #define Mesquite_LaplacianSmoother_hpp
40 
41 #include "Mesquite.hpp"
42 #include "VertexMover.hpp"
44 
45 #ifdef MSQ_USE_OLD_STD_HEADERS
46 # include <vector.h>
47 #else
48 # include <vector>
49 #endif
50 
51 namespace Mesquite
52 {
53 
58  {
59  public:
62  protected:
63  virtual void initialize(PatchData &pd, MsqError &err);
64  virtual void optimize_vertex_positions(PatchData &pd,
65  MsqError &err);
66  virtual void initialize_mesh_iteration(PatchData &pd, MsqError &err);
67  virtual void terminate_mesh_iteration(PatchData &pd, MsqError &err);
68  virtual void cleanup();
69 
70  private:
72 
73  };
74 
75 
76  inline void centroid_smooth_mesh(PatchData &pd, size_t num_adj_vtx,
77  msq_std::vector<size_t> adj_vtx_ind,
78  size_t free_ind,
79  size_t dimension, MsqError &err)
80  {
81  MsqVertex* verts=pd.get_vertex_array(err);
82  msq_std::vector<size_t>::iterator iter;
83 
84  size_t j;
85  double scale_val=1.0;
86  if (num_adj_vtx==0) {
87  MSQ_SETERR(err)("Number of incident vertices is zero",MsqError::INVALID_ARG);
88  return;
89  }
90  else
91  scale_val=1.0/((double) num_adj_vtx);
92  double avg[3];
93  //loop over the two or three dimensions
94  for(j=0;j<dimension;++j) {
95  //set the iterator to the beginning ob adj_vtx_ind
96  iter=adj_vtx_ind.begin();
97  avg[j] = 0.;
98  while(iter != adj_vtx_ind.end()){
99  avg[j]+=verts[*iter][j];
100  ++iter;
101  }
102  //divide the average by the number of adj. verts
103  verts[free_ind][j] = avg[j]*scale_val;
104  }
105 
106  return;
107  }
108 
109 
110 }
111 
112 #endif
Used to hold the error state and return it to the application.
Base class for concrete quality metrics.
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
j indices j
Definition: Indexing.h:6
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
void centroid_smooth_mesh(PatchData &pd, size_t num_adj_vtx, msq_std::vector< size_t > adj_vtx_ind, size_t free_ind, size_t dimension, MsqError &err)