Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Randomize Class Reference

Randomly perftubs the (un-culled) vertices. More...

#include <Randomize.hpp>

Inheritance diagram for Randomize:
Collaboration diagram for Randomize:

Public Member Functions

 Randomize ()
 Constructor defaulting mPercent to .05. More...
 
 Randomize (double percent)
 Constructor allowing user to set mPercent. More...
 
virtual ~Randomize ()
 
 Randomize ()
 Constructor defaulting mPercent to .05. More...
 
 Randomize (double percent)
 Constructor allowing user to set mPercent. More...
 
virtual ~Randomize ()
 
- Public Member Functions inherited from VertexMover
virtual ~VertexMover ()
 
virtual double loop_over_mesh (MeshSet &ms, MsqError &err)
 Improves the quality of the MeshSet, calling some methods specified in a class derived from VertexMover. More...
 
virtual ~VertexMover ()
 
virtual double loop_over_mesh (MeshSet &ms, MsqError &err)
 This is the "run" function of PatchDataUser. It can do anything really. More...
 
- Public Member Functions inherited from QualityImprover
virtual ~QualityImprover ()
 
void set_name (msq_std::string name)
 provides a name to the QualityImprover (use it in constructor). More...
 
virtual msq_std::string get_name ()
 retrieves the QualityImprover name. A default name should be set in the constructor. More...
 
virtual AlgorithmType get_algorithm_type ()
 Return the algorithm type (to avoid RTTI use). More...
 
void set_inner_termination_criterion (TerminationCriterion *crit)
 Sets in the termination criterion for the concrete solver's optimization. More...
 
void set_outer_termination_criterion (TerminationCriterion *crit)
 Sets in the termination criterion for the outer loop over patches. More...
 
virtual ~QualityImprover ()
 
void set_name (msq_std::string name)
 provides a name to the QualityImprover (use it in constructor). More...
 
virtual msq_std::string get_name ()
 retrieves the QualityImprover name. A default name should be set in the constructor. More...
 
virtual AlgorithmType get_algorithm_type ()
 Return the algorithm type (to avoid RTTI use). More...
 
void set_inner_termination_criterion (TerminationCriterion *crit)
 Sets in the termination criterion for the concrete solver's optimization. More...
 
void set_outer_termination_criterion (TerminationCriterion *crit)
 Sets in the termination criterion for the outer loop over patches. More...
 
- Public Member Functions inherited from PatchDataUser
virtual ~PatchDataUser ()
 
virtual void set_patch_type (PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
 Sets the Patch Type. More...
 
PatchData::PatchType get_patch_type ()
 Returns the Patch Type. More...
 
int get_nb_layers (MsqError &err)
 Returns number of layers (if relevant for partition algorythm). More...
 
void add_culling_method (enum PatchData::culling_method cm)
 Sets on the culling method passed as argument. More...
 
void no_culling_method ()
 Sets off all culling methods. More...
 
void remove_culling_method (enum PatchData::culling_method cm)
 Sets off the culling method passed as argument. More...
 
long unsigned int get_culling_method_bits ()
 Returns the bitset containing culling methods flags. More...
 
void set_all_parameters (PatchDataParameters &params)
 
PatchDataParametersget_all_parameters ()
 Returns the PatchDataParameters object. More...
 
void set_global_patch (PatchData *pd, MsqError &err)
 Sets the Global Patch, so that it can be use by contiguoug PatchDataUser. More...
 
PatchDataget_global_patch ()
 Returns the Global Patch. More...
 
void no_global_patch ()
 Sets the Global Patch pointer to NULL. More...
 
virtual ~PatchDataUser ()
 
virtual void set_patch_type (PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
 Sets the Patch Type. More...
 
PatchData::PatchType get_patch_type ()
 Returns the Patch Type. More...
 
int get_nb_layers (MsqError &err)
 Returns number of layers (if relevant for partition algorythm). More...
 
void add_culling_method (enum PatchData::culling_method cm)
 Sets on the culling method passed as argument. More...
 
void no_culling_method ()
 Sets off all culling methods. More...
 
void remove_culling_method (enum PatchData::culling_method cm)
 Sets off the culling method passed as argument. More...
 
long unsigned int get_culling_method_bits ()
 Returns the bitset containing culling methods flags. More...
 
void set_all_parameters (PatchDataParameters &params)
 
PatchDataParametersget_all_parameters ()
 Returns the PatchDataParameters object. More...
 
void set_global_patch (PatchData *pd, MsqError &err)
 Sets the Global Patch, so that it can be use by contiguoug PatchDataUser. More...
 
PatchDataget_global_patch ()
 Returns the Global Patch. More...
 
void no_global_patch ()
 Sets the Global Patch pointer to NULL. More...
 

Protected Member Functions

virtual void initialize (PatchData &pd, MsqError &err)
 
virtual void optimize_vertex_positions (PatchData &pd, MsqError &err)
 
virtual void initialize_mesh_iteration (PatchData &pd, MsqError &err)
 
virtual void terminate_mesh_iteration (PatchData &pd, MsqError &err)
 
virtual void cleanup ()
 
virtual void initialize (PatchData &pd, MsqError &err)
 
virtual void optimize_vertex_positions (PatchData &pd, MsqError &err)
 
virtual void initialize_mesh_iteration (PatchData &pd, MsqError &err)
 
virtual void terminate_mesh_iteration (PatchData &pd, MsqError &err)
 
virtual void cleanup ()
 
- Protected Member Functions inherited from VertexMover
 VertexMover ()
 
size_t check_feasible (PatchData &pd, MsqError &err)
 CHECK FEASIBLE IS NOT YET IMPLEMENTED. More...
 
 VertexMover ()
 
size_t check_feasible (PatchData &pd, MsqError &err)
 CHECK FEASIBLE IS NOT YET IMPLEMENTED. More...
 
- Protected Member Functions inherited from QualityImprover
 QualityImprover ()
 
const MeshSetget_mesh_set () const
 
MeshSetget_mesh_set ()
 
void set_mesh_set (MeshSet *ms)
 
TerminationCriterionget_outer_termination_criterion ()
 return the outer termination criterion pointer More...
 
TerminationCriterionget_inner_termination_criterion ()
 return the inner termination criterion pointer More...
 
 QualityImprover ()
 
const MeshSetget_mesh_set () const
 
MeshSetget_mesh_set ()
 
void set_mesh_set (MeshSet *ms)
 
TerminationCriterionget_outer_termination_criterion ()
 return the outer termination criterion pointer More...
 
TerminationCriterionget_inner_termination_criterion ()
 return the inner termination criterion pointer More...
 
- Protected Member Functions inherited from PatchDataUser
 PatchDataUser ()
 
 PatchDataUser ()
 

Private Member Functions

void randomize_vertex (PatchData &pd, size_t num_vtx, MsqVertex &free_vtx, MsqError &err)
 Perturbs the free vertex randomly. More...
 
void randomize_vertex (PatchData &pd, size_t num_vtx, MsqVertex &free_vtx, MsqError &err)
 

Private Attributes

double mPercent
 

Additional Inherited Members

- Public Types inherited from PatchDataUser
enum  AlgorithmType {
  QUALITY_IMPROVER, QUALITY_ASSESSOR, MESH_TRANSFORM, TARGET_CALCULATOR,
  QUALITY_IMPROVER, QUALITY_ASSESSOR, MESH_TRANSFORM, TARGET_CALCULATOR
}
 
enum  AlgorithmType {
  QUALITY_IMPROVER, QUALITY_ASSESSOR, MESH_TRANSFORM, TARGET_CALCULATOR,
  QUALITY_IMPROVER, QUALITY_ASSESSOR, MESH_TRANSFORM, TARGET_CALCULATOR
}
 
- Protected Attributes inherited from VertexMover
ObjectiveFunctionobjFunc
 

Detailed Description

Randomly perftubs the (un-culled) vertices.

Definition at line 52 of file includeLinks/Randomize.hpp.

Constructor & Destructor Documentation

Randomize ( )

Constructor defaulting mPercent to .05.

Definition at line 44 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

References Randomize::mPercent, and QualityImprover::set_name().

45 {
46  this->set_name("Randomize");
47  mPercent=.05;
48 }
void set_name(msq_std::string name)
provides a name to the QualityImprover (use it in constructor).

Here is the call graph for this function:

Randomize ( double  percent)

Constructor allowing user to set mPercent.

Definition at line 50 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

References Randomize::mPercent, and QualityImprover::set_name().

51 {
52  this->set_name("Randomize");
53  mPercent=percent;
54 }
void set_name(msq_std::string name)
provides a name to the QualityImprover (use it in constructor).

Here is the call graph for this function:

virtual ~Randomize ( )
inlinevirtual

Definition at line 60 of file includeLinks/Randomize.hpp.

60 { }
Randomize ( )

Constructor defaulting mPercent to .05.

Randomize ( double  percent)

Constructor allowing user to set mPercent.

virtual ~Randomize ( )
inlinevirtual

Definition at line 60 of file src/QualityImprover/VertexMover/Randomize/Randomize.hpp.

60 { }

Member Function Documentation

void cleanup ( )
protectedvirtual

Implements VertexMover.

Definition at line 90 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

91 {
92  // cout << "- Executing Randomize::iteration_end()\n";
93 }
virtual void cleanup ( )
protectedvirtual

Implements VertexMover.

void initialize ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Definition at line 56 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

References PatchData::ELEMENTS_ON_VERTEX_PATCH, and PatchDataUser::set_patch_type().

57 {
59 }
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
Sets the Patch Type.

Here is the call graph for this function:

virtual void initialize ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

virtual void initialize_mesh_iteration ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

void initialize_mesh_iteration ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Definition at line 61 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

62 {
63  // cout << "- Executing Randomize::iteration_complete()\n";
64 }
virtual void optimize_vertex_positions ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

void optimize_vertex_positions ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Definition at line 66 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

References PatchData::get_vertex_array(), MSQ_ERRRTN, MsqFreeVertexIndexIterator::next(), PatchData::num_vertices(), Randomize::randomize_vertex(), MsqFreeVertexIndexIterator::reset(), PatchData::snap_vertex_to_domain(), and MsqFreeVertexIndexIterator::value().

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 }
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.
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.
iterates over indexes of free vetices in a PatchData.
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
#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.

Here is the call graph for this function:

void randomize_vertex ( PatchData pd,
size_t  num_vtx,
MsqVertex free_vtx,
MsqError err 
)
inlineprivate

Function calculates a scale factor for the patch, then moves the incident vertex randomly in each of the three coordinate directions (relative to the scale factor multiplied by mPercent).

void randomize_vertex ( PatchData pd,
size_t  num_vtx,
MsqVertex free_vtx,
MsqError err 
)
inlineprivate

Perturbs the free vertex randomly.

Function calculates a scale factor for the patch, then moves the incident vertex randomly in each of the three coordinate directions (relative to the scale factor multiplied by mPercent).

Definition at line 83 of file includeLinks/Randomize.hpp.

References PatchData::get_vertex_array(), PatchData::get_vertex_index(), i, j, Mesquite::length(), Randomize::mPercent, MSQ_ERRRTN, MSQ_PRINT, and cimg_library::cimg::rand().

Referenced by Randomize::optimize_vertex_positions().

86  {
87  size_t i;
88  short j;
89  MsqVertex* verts = pd.get_vertex_array(err); MSQ_ERRRTN(err);
90  //a scale w.r.t. the patch size
91  double scale_factor=0.0;
92  //a "random" number between -1 and 1
93  double rand_double=0.0;
94  //a "random" int
95  int rand_int=0;
96  if (num_vtx<=1){
97  MSQ_PRINT(1)("WARNING: Number of incident vertex is zero. Returning.\n");
98  return;
99  }
100 
101  size_t free_ind = pd.get_vertex_index(&(free_vtx));
102 
103 
104  for (i=0;i<num_vtx;++i){
105  if(i != free_ind)
106  scale_factor+=(verts[i]-free_vtx).length();
107  }
108  scale_factor/=( (double) num_vtx - 1.0 );
109  for (j=0;j<3;++j){
110  rand_int = rand();
111  //number between 0 and 1000
112  rand_int = rand_int%1000;
113  //number between -1 and 1
114  rand_double = (((double) rand_int)/500.0)-1.0;
115  free_vtx[j] += scale_factor*rand_double*mPercent;
116  }
117 
118  return;
119  }
double length(Vector3D *const v, int n)
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
#define MSQ_PRINT(flag)
Check debug flag and print printf-style formatted output.
double rand()
Return a random variable between [0,1] with respect to an uniform distribution.
Definition: CImg.h:4833
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void terminate_mesh_iteration ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Definition at line 85 of file QualityImprover/VertexMover/Randomize/Randomize.cpp.

86 {
87  // cout << "- Executing Randomize::iteration_complete()\n";
88 }
virtual void terminate_mesh_iteration ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Member Data Documentation

double mPercent
private
Parameters
Thepercentage of the scale factor each vertex will be moved.

Definition at line 71 of file includeLinks/Randomize.hpp.

Referenced by Randomize::Randomize(), and Randomize::randomize_vertex().


The documentation for this class was generated from the following files: