Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QualityImprover/VertexMover/Randomize/Randomize.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  ***************************************************************** */
39 #include "Randomize.hpp"
40 
41 using namespace Mesquite;
42 
43 
45 {
46  this->set_name("Randomize");
47  mPercent=.05;
48 }
49 
50 Randomize::Randomize(double percent)
51 {
52  this->set_name("Randomize");
53  mPercent=percent;
54 }
55 
57 {
59 }
60 
62 {
63  // cout << "- Executing Randomize::iteration_complete()\n";
64 }
65 
67  MsqError &err)
68 {
69  //cout << "- Executing Randomize::optimize_vertex_position()\n";
70 
71  int num_local_vertices = pd.num_vertices();
72  // gets the array of coordinates for the patch and print it
73  MsqVertex *patch_coords = pd.get_vertex_array(err); MSQ_ERRRTN(err);
74  // does the randomize smooth
75  MsqFreeVertexIndexIterator free_iter(&pd, err); MSQ_ERRRTN(err);
76  free_iter.reset();
77  free_iter.next();
78  //find the free vertex.
79  int m=free_iter.value();
80  randomize_vertex(pd, num_local_vertices,
81  patch_coords[m], err); MSQ_ERRRTN(err);
82  pd.snap_vertex_to_domain(m,err); MSQ_ERRRTN(err);
83 }
84 
86 {
87  // cout << "- Executing Randomize::iteration_complete()\n";
88 }
89 
91 {
92  // cout << "- Executing Randomize::iteration_end()\n";
93 }
94 
95 
size_t value()
Returns an index corresponding to a free vertex.
Randomize()
Constructor defaulting mPercent to .05.
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
Sets the Patch Type.
virtual void terminate_mesh_iteration(PatchData &pd, MsqError &err)
Used to hold the error state and return it to the application.
void set_name(msq_std::string name)
provides a name to the QualityImprover (use it in constructor).
bool next()
Increments the iterator. returns false if there is no more free vertex.
void snap_vertex_to_domain(size_t vertex_index, MsqError &err)
Adjust the position of the specified vertex so that it lies on its constraining domain.
virtual void initialize_mesh_iteration(PatchData &pd, MsqError &err)
size_t num_vertices() const
number of vertices in the patch.
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
virtual void optimize_vertex_positions(PatchData &pd, MsqError &err)
iterates over indexes of free vetices in a PatchData.
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
virtual void initialize(PatchData &pd, MsqError &err)
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
void randomize_vertex(PatchData &pd, size_t num_vtx, MsqVertex &free_vtx, MsqError &err)
Perturbs the free vertex randomly.