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

#include <SmartLaplacianSmoother.hpp>

Inheritance diagram for SmartLaplacianSmoother:
Collaboration diagram for SmartLaplacianSmoother:

Public Member Functions

 SmartLaplacianSmoother (ObjectiveFunction *obj_func, MsqError &err)
 
 ~SmartLaplacianSmoother ()
 
 SmartLaplacianSmoother (ObjectiveFunction *obj_func, MsqError &err)
 
 ~SmartLaplacianSmoother ()
 
- 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 Attributes

QualityMetricedgeQM
 
ObjectiveFunctiondefaultObjFunc
 

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

Moves free center vertex to the average of the neighboring vertices if that move does not decrease the given objective function value.

Definition at line 55 of file includeLinks/SmartLaplacianSmoother.hpp.

Constructor & Destructor Documentation

SmartLaplacianSmoother ( ObjectiveFunction obj_func,
MsqError err 
)

Definition at line 56 of file QualityImprover/VertexMover/LaplacianSmoothers/SmartLaplacianSmoother.cpp.

References SmartLaplacianSmoother::defaultObjFunc, SmartLaplacianSmoother::edgeQM, PatchData::ELEMENTS_ON_VERTEX_PATCH, MSQ_ERRRTN, VertexMover::objFunc, QualityImprover::set_name(), and PatchDataUser::set_patch_type().

58  : edgeQM(0), defaultObjFunc(0)
59 {
60  this->set_name("SmartLaplacianSmoother");
61 
63  if(obj_func==NULL){
64  edgeQM = new IdealWeightInverseMeanRatio(err); MSQ_ERRRTN(err);
65  defaultObjFunc = new LInfTemplate(edgeQM);
67  }
68  else{
69  objFunc=obj_func;
70  defaultObjFunc=NULL;
71  }
72 
73 }
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
Sets the Patch Type.
void set_name(msq_std::string name)
provides a name to the QualityImprover (use it in constructor).
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

SmartLaplacianSmoother ( ObjectiveFunction obj_func,
MsqError err 
)

Member Function Documentation

void cleanup ( )
protectedvirtual

Implements VertexMover.

Definition at line 151 of file QualityImprover/VertexMover/LaplacianSmoothers/SmartLaplacianSmoother.cpp.

152 {
153  // cout << "- Executing SmartLaplacianSmoother::iteration_end()\n";
154 }
virtual void cleanup ( )
protectedvirtual

Implements VertexMover.

void initialize ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Definition at line 81 of file QualityImprover/VertexMover/LaplacianSmoothers/SmartLaplacianSmoother.cpp.

82 {
83 
84 }
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 86 of file QualityImprover/VertexMover/LaplacianSmoothers/SmartLaplacianSmoother.cpp.

88 {
89  // cout << "- Executing SmartLaplacianSmoother::iteration_complete()\n";
90 }
void optimize_vertex_positions ( PatchData pd,
MsqError err 
)
protectedvirtual
Todo:
Michael: optimize_vertex_position is probably not implemented in an optimal way. We used to use all of the vertices in the patch as 'adjacent' vertices. Now we call get_adjacent_vertex_indices. We could use a VERTICES_ON_VERTEX type of patch or a global patch?
Todo:
Michael: optimize_vertex_position is probably not implemented in an optimal way. We used to use all of the vertices in the patch as 'adjacent' vertices. Now we call get_adjacent_vertex_indices. We could use a VERTICES_ON_VERTEX type of patch or a global patch?

Implements VertexMover.

Definition at line 97 of file QualityImprover/VertexMover/LaplacianSmoothers/SmartLaplacianSmoother.cpp.

References Mesquite::centroid_smooth_mesh(), ObjectiveFunction::evaluate(), PatchData::get_adjacent_vertex_indices(), PatchData::get_vertex_array(), MSQ_ERRRTN, MsqFreeVertexIndexIterator::next(), VertexMover::objFunc, MsqFreeVertexIndexIterator::reset(), PatchData::snap_vertex_to_domain(), and MsqFreeVertexIndexIterator::value().

99 {
100  //default the laplacian smoother to 3 even for 2-d elements.
101  //int dim = get_mesh_set()->space_dim();
102  size_t dim = 3;
103  MsqVertex* verts=pd.get_vertex_array(err); MSQ_ERRRTN(err);
104  //variables for the function values.
105  double orig_val=0;
106  double mod_val=0;
107  //compute the original function value and check validity
108  bool valid_flag = objFunc->evaluate(pd,orig_val,err); MSQ_ERRRTN(err);
109  // does the Laplacian smoothing
110  MsqFreeVertexIndexIterator free_iter(&pd, err); MSQ_ERRRTN(err);
111  free_iter.reset();
112  free_iter.next();
113  //m is the free vertex.
114  size_t m=free_iter.value();
115  vector<size_t> vert_indices;
116  vert_indices.reserve(25);
117  //get vertices adjacent to vertex m
118  pd.get_adjacent_vertex_indices(m,vert_indices,err); MSQ_ERRRTN(err);
119  //move vertex m
120  //save the original position of the free vertex
121  Vector3D orig_position(verts[m]);
122  //smooth the patch
123  centroid_smooth_mesh(pd, vert_indices.size(), vert_indices,
124  m, dim, err); MSQ_ERRRTN(err);
125  //snap vertex m to domain
126  pd.snap_vertex_to_domain(m,err); MSQ_ERRRTN(err);
127  //if the original function val was invalid, then we allow the move
128  //But, if it wasn valid, we need to decide.
129  if(valid_flag){
130  //compute the new value
131  valid_flag = objFunc->evaluate(pd,mod_val,err); MSQ_ERRRTN(err);
132  //if the new value is worse the original OR if the new value is not
133  //valid (we already know the original value was valid by above) then
134  //we don't allow the move.
135  if(!valid_flag || mod_val>orig_val){
136  //move the vert back to where it was.
137  verts[m]=orig_position;
138  //PRINT_INFO("\norig = %f, new = %f, new valid = %d",orig_val,mod_val,valid_flag);
139  }
140 
141  }
142 
143 }
bool evaluate(PatchData &patch, double &fval, MsqError &err)
NVec< 3, double > Vector3D
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
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)

Here is the call graph for this function:

virtual void optimize_vertex_positions ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

void terminate_mesh_iteration ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Definition at line 145 of file QualityImprover/VertexMover/LaplacianSmoothers/SmartLaplacianSmoother.cpp.

147 {
148  // cout << "- Executing SmartLaplacianSmoother::iteration_complete()\n";
149 }
virtual void terminate_mesh_iteration ( PatchData pd,
MsqError err 
)
protectedvirtual

Implements VertexMover.

Member Data Documentation


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