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

A QualityAssessor instance can be inserted into an InstructionQueue to calculate and summarize registered QualityMetrics for the mesh. More...

#include <QualityAssessor.hpp>

Inheritance diagram for QualityAssessor:
Collaboration diagram for QualityAssessor:

Classes

class  Assessor
 Per-metric QualityAssessor data. More...
 

Public Types

enum  QAFunction {
  NO_FUNCTION = 0, AVERAGE =1, HISTOGRAM =2, MAXIMUM =4,
  MINIMUM =8, RMS =16, STDDEV =32, ALL_MEASURES =255,
  NO_FUNCTION = 0, AVERAGE =1, HISTOGRAM =2, MAXIMUM =4,
  MINIMUM =8, RMS =16, STDDEV =32, ALL_MEASURES =255
}
 
enum  QAFunction {
  NO_FUNCTION = 0, AVERAGE =1, HISTOGRAM =2, MAXIMUM =4,
  MINIMUM =8, RMS =16, STDDEV =32, ALL_MEASURES =255,
  NO_FUNCTION = 0, AVERAGE =1, HISTOGRAM =2, MAXIMUM =4,
  MINIMUM =8, RMS =16, STDDEV =32, ALL_MEASURES =255
}
 
- 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
}
 

Public Member Functions

 QualityAssessor (msq_std::string name="QualityAssessor")
 Constructor - output to std::cout. More...
 
 QualityAssessor (msq_stdio::ostream &output_stream, msq_std::string name="QualityAssessor")
 Constructor - specified output stream. More...
 
 QualityAssessor (QualityMetric *metric, QAFunction function, msq_stdio::ostream &output_stream, MsqError &err, msq_std::string name="QualityAssessor")
 Constructor - initial stopping assessement and specified output stream. More...
 
 QualityAssessor (QualityMetric *metric, QAFunction function, MsqError &err, msq_std::string name="QualityAssessor")
 Constructor - initial stopping assessement. More...
 
 ~QualityAssessor ()
 Destructor. More...
 
void set_name (msq_std::string name)
 Provides a name to the QualityAssessor (use it for default name in constructor). More...
 
virtual msq_std::string get_name ()
 Retrieves the QualityAssessor 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 add_quality_assessment (QualityMetric *qm, int function_flags, MsqError &err)
 Adds a quality metric and a wrapper function (min, max, ...). More...
 
void set_stopping_assessment (QualityMetric *qm, QAFunction func, MsqError &err)
 
void add_histogram_assessment (QualityMetric *qm, double min, double max, int intervals, MsqError &err)
 Add a quality metric for which the histogram is to be calculated, and set histogram parameters. More...
 
virtual double loop_over_mesh (MeshSet &ms, MsqError &err)
 Does one sweep over the mesh and assess the quality with the metrics previously added. More...
 
void disable_printing_results ()
 Do not print results of assessment. More...
 
void print_summary (msq_stdio::ostream &stream) const
 Print accumulated summary data to specified stream. More...
 
bool invalid_elements () const
 True if any metric evaluated to an invalid value for any element. More...
 
void reset_data ()
 Reset calculated data. More...
 
const Assessorget_results (QualityMetric *metric) const
 Request summary data for a specific QualityMetric This method allows the application to request the summary data for a metric it has registered with the QualityAssessor. More...
 
const msq_std::list< Assessor > & get_all_results () const
 Get list of all summary data. More...
 
 QualityAssessor (msq_std::string name="QualityAssessor")
 Constructor - output to std::cout. More...
 
 QualityAssessor (msq_stdio::ostream &output_stream, msq_std::string name="QualityAssessor")
 Constructor - specified output stream. More...
 
 QualityAssessor (QualityMetric *metric, QAFunction function, msq_stdio::ostream &output_stream, MsqError &err, msq_std::string name="QualityAssessor")
 Constructor - initial stopping assessement and specified output stream. More...
 
 QualityAssessor (QualityMetric *metric, QAFunction function, MsqError &err, msq_std::string name="QualityAssessor")
 Constructor - initial stopping assessement. More...
 
 ~QualityAssessor ()
 Destructor. More...
 
void set_name (msq_std::string name)
 Provides a name to the QualityAssessor (use it for default name in constructor). More...
 
virtual msq_std::string get_name ()
 Retrieves the QualityAssessor 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 add_quality_assessment (QualityMetric *qm, int function_flags, MsqError &err)
 Adds a quality metric and a wrapper function (min, max, ...). More...
 
void set_stopping_assessment (QualityMetric *qm, QAFunction func, MsqError &err)
 
void add_histogram_assessment (QualityMetric *qm, double min, double max, int intervals, MsqError &err)
 Add a quality metric for which the histogram is to be calculated, and set histogram parameters. More...
 
virtual double loop_over_mesh (MeshSet &ms, MsqError &err)
 Does one sweep over the mesh and assess the quality with the metrics previously added. More...
 
void disable_printing_results ()
 Do not print results of assessment. More...
 
void print_summary (msq_stdio::ostream &stream) const
 Print accumulated summary data to specified stream. More...
 
bool invalid_elements () const
 True if any metric evaluated to an invalid value for any element. More...
 
void reset_data ()
 Reset calculated data. More...
 
const Assessorget_results (QualityMetric *metric) const
 Request summary data for a specific QualityMetric This method allows the application to request the summary data for a metric it has registered with the QualityAssessor. More...
 
const msq_std::list< Assessor > & get_all_results () const
 Get list of all summary data. 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...
 

Static Public Member Functions

static msq_std::string get_QAFunction_name (enum QualityAssessor::QAFunction)
 
static msq_std::string get_QAFunction_name (enum QualityAssessor::QAFunction)
 

Private Member Functions

msq_std::list< Assessor >::iterator find_or_add (QualityMetric *qm)
 Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list. More...
 
msq_std::list< Assessor >::iterator find_or_add (QualityMetric *qm)
 Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list. More...
 

Private Attributes

msq_std::string qualityAssessorName
 Name. More...
 
msq_std::list< AssessorassessList
 List of quality metrics and corresponding data. More...
 
msq_stdio::ostream & outputStream
 Stream to which to write summary of metric data. More...
 
bool printSummary
 Disable printing. More...
 
msq_std::list< Assessor >::iterator stoppingMetric
 Metric in assessList to use as return value for loop_over_mesh. More...
 
QAFunction stoppingFunction
 Value to use as return value for loop_over_mesh. More...
 

Additional Inherited Members

- Protected Member Functions inherited from PatchDataUser
 PatchDataUser ()
 
 PatchDataUser ()
 

Detailed Description

A QualityAssessor instance can be inserted into an InstructionQueue to calculate and summarize registered QualityMetrics for the mesh.

The relevant quality assessments are set by the user or automatically (default) by Mesquite when an InstructionQueue object is used. If the mesh has been changed (improved), it is often useful to reuse the same QualityAssessor object to reassess the mesh quality.

The QAFunction flags passed for each metric control the output for that metric. If no QAFuction flags are passed, no results are printed for the metric except the count of invalid vertices/elements reported by that metric, if any.

The "stopping assessor" and "stopping function", if set, determinte the value reported to Mesquite for the overall run of of the QualityAssessor.

All summary data except the histogram is accumulated for all registered metrics, and can be accessed by the calling application. Histogram data is accumulated only if the HISTOGRAM QUFunction output is requested for the metric (which is impled by calling add_histogram_assessment.

Definition at line 97 of file includeLinks/QualityAssessor.hpp.

Member Enumeration Documentation

enum QAFunction

type of function used in conjunction with QualityMetric to compute mesh quality

Enumerator
NO_FUNCTION 
AVERAGE 
HISTOGRAM 
MAXIMUM 
MINIMUM 
RMS 
STDDEV 
ALL_MEASURES 
NO_FUNCTION 
AVERAGE 
HISTOGRAM 
MAXIMUM 
MINIMUM 
RMS 
STDDEV 
ALL_MEASURES 

Definition at line 104 of file includeLinks/QualityAssessor.hpp.

Constructor & Destructor Documentation

QualityAssessor ( msq_std::string  name = "QualityAssessor")

Constructor - output to std::cout.

QualityAssessor ( msq_stdio::ostream &  output_stream,
msq_std::string  name = "QualityAssessor" 
)

Constructor - specified output stream.

QualityAssessor ( QualityMetric metric,
QAFunction  function,
msq_stdio::ostream &  output_stream,
MsqError err,
msq_std::string  name = "QualityAssessor" 
)

Constructor - initial stopping assessement and specified output stream.

QualityAssessor ( QualityMetric metric,
QAFunction  function,
MsqError err,
msq_std::string  name = "QualityAssessor" 
)

Constructor - initial stopping assessement.

Destructor.

Definition at line 117 of file QualityAssessor/QualityAssessor.cpp.

118  { }
QualityAssessor ( msq_std::string  name = "QualityAssessor")

Constructor - output to std::cout.

QualityAssessor ( msq_stdio::ostream &  output_stream,
msq_std::string  name = "QualityAssessor" 
)

Constructor - specified output stream.

QualityAssessor ( QualityMetric metric,
QAFunction  function,
msq_stdio::ostream &  output_stream,
MsqError err,
msq_std::string  name = "QualityAssessor" 
)

Constructor - initial stopping assessement and specified output stream.

QualityAssessor ( QualityMetric metric,
QAFunction  function,
MsqError err,
msq_std::string  name = "QualityAssessor" 
)

Constructor - initial stopping assessement.

Destructor.

Member Function Documentation

void add_histogram_assessment ( QualityMetric qm,
double  min_val,
double  max_val,
int  intervals,
MsqError err 
)

Add a quality metric for which the histogram is to be calculated, and set histogram parameters.

Checks first to see if the QualityMetric, qm, has been added to this QualityAssessor, and if it has not, adds it. It then adds HISTOGRAM as a QAFunciton for that metric. It then sets the minimum and maximum values for the histogram.

Parameters
qmPointer to the QualityMetric to be used in histogram.
min_val(double) Minimum range of histogram.
max_val(double) Maximum range of histogram.
intervalsNumber of histogram intervals

Definition at line 244 of file QualityAssessor/QualityAssessor.cpp.

References MSQ_SETERR.

249 {
250  if (min_val >= max_val || intervals < 1) {
251  MSQ_SETERR(err)("Invalid histogram range.", MsqError::INVALID_ARG );
252  return;
253  }
254 
255  list<Assessor>::iterator assessor = find_or_add( qm );
256  assessor->funcFlags |= QualityAssessor::HISTOGRAM;
257  assessor->histMin = min_val;
258  assessor->histMax = max_val;
259  assessor->histogram.resize( intervals + 2 );
260 }
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
msq_std::list< Assessor >::iterator find_or_add(QualityMetric *qm)
Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list...
void add_histogram_assessment ( QualityMetric qm,
double  min,
double  max,
int  intervals,
MsqError err 
)

Add a quality metric for which the histogram is to be calculated, and set histogram parameters.

void add_quality_assessment ( QualityMetric qm,
int  function_flags,
MsqError err 
)

Adds a quality metric and a wrapper function (min, max, ...).

void add_quality_assessment ( QualityMetric qm,
int  func,
MsqError err 
)

Adds a quality metric and a wrapper function (min, max, ...).

Several QualityMetric objects can be added to a single QualityAssessor object. This allows to perform several quality assessments over a single mesh sweep.

Parameters
qmis the QualityMetric that will be used to evaluate the mesh quality
funcis the wrapper function used over the QualityMetric (min, max, etc..)

Definition at line 167 of file QualityAssessor/QualityAssessor.cpp.

References Mesquite::DEFAULT_HISTOGRAM_INTERVALS.

170 {
171  msq_std::list<Assessor>::iterator iter;
172 
173  iter = find_or_add( qm );
174  iter->funcFlags |= func;
175  if (func&HISTOGRAM)
176  iter->histogram.resize(DEFAULT_HISTOGRAM_INTERVALS+2);
177 }
msq_std::list< Assessor >::iterator find_or_add(QualityMetric *qm)
Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list...
void disable_printing_results ( )
inline

Do not print results of assessment.

Definition at line 170 of file includeLinks/QualityAssessor.hpp.

References QualityAssessor::printSummary.

Referenced by ShapeImprovementWrapper::ShapeImprovementWrapper().

171  {
172  printSummary = false;
173  }

Here is the caller graph for this function:

void disable_printing_results ( )
inline

Do not print results of assessment.

Definition at line 170 of file src/QualityAssessor/QualityAssessor.hpp.

References QualityAssessor::printSummary.

171  {
172  printSummary = false;
173  }
list< QualityAssessor::Assessor >::iterator find_or_add ( QualityMetric qm)
private

Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list.

Definition at line 179 of file QualityAssessor/QualityAssessor.cpp.

References QualityMetric::get_metric_type().

180 {
181  list<Assessor>::iterator iter;
182 
183  // If metric is already in list, find it
184  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
185  if (iter->qualMetric == qm )
186  break;
187 
188  // If metric not found in list, add it
189  if (iter == assessList.end())
190  {
191  if (qm->get_metric_type() == QualityMetric::VERTEX_BASED)
192  {
193  assessList.push_back( Assessor(qm) );
194  iter = --assessList.end();
195  }
196  else
197  {
198  assessList.push_front( Assessor(qm) );
199  iter = assessList.begin();
200  }
201  }
202 
203  return iter;
204 }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.

Here is the call graph for this function:

msq_std::list<Assessor>::iterator find_or_add ( QualityMetric qm)
private

Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list.

virtual AlgorithmType get_algorithm_type ( )
inlinevirtual

Return the algorithm type (to avoid RTTI use).

Implements PatchDataUser.

Definition at line 144 of file includeLinks/QualityAssessor.hpp.

References PatchDataUser::QUALITY_ASSESSOR.

virtual AlgorithmType get_algorithm_type ( )
inlinevirtual

Return the algorithm type (to avoid RTTI use).

Implements PatchDataUser.

Definition at line 144 of file src/QualityAssessor/QualityAssessor.hpp.

References PatchDataUser::QUALITY_ASSESSOR.

const msq_std::list<Assessor>& get_all_results ( ) const
inline

Get list of all summary data.

Return a const reference to the internal list of calculated data.

Definition at line 288 of file includeLinks/QualityAssessor.hpp.

References QualityAssessor::assessList.

289  { return assessList; }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
const msq_std::list<Assessor>& get_all_results ( ) const
inline

Get list of all summary data.

Return a const reference to the internal list of calculated data.

Definition at line 288 of file src/QualityAssessor/QualityAssessor.hpp.

References QualityAssessor::assessList.

289  { return assessList; }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
virtual msq_std::string get_name ( )
inlinevirtual

Retrieves the QualityAssessor name. A default name should be set in the constructor.

Implements PatchDataUser.

Definition at line 142 of file src/QualityAssessor/QualityAssessor.hpp.

References QualityAssessor::qualityAssessorName.

142 { return qualityAssessorName; }
virtual msq_std::string get_name ( )
inlinevirtual

Retrieves the QualityAssessor name. A default name should be set in the constructor.

Implements PatchDataUser.

Definition at line 142 of file includeLinks/QualityAssessor.hpp.

References QualityAssessor::qualityAssessorName.

142 { return qualityAssessorName; }
static msq_std::string get_QAFunction_name ( enum QualityAssessor::QAFunction  )
static
string get_QAFunction_name ( enum QualityAssessor::QAFunction  fun)
static

Definition at line 120 of file QualityAssessor/QualityAssessor.cpp.

References MAXIMUM.

122 {
123  switch(fun){
124  case(AVERAGE):
125  return "Average ";
126  case(HISTOGRAM):
127  return "Histogram of metric values: ";
128  case(MAXIMUM):
129  return "Maximum ";
130  case(MINIMUM):
131  return "Minimum ";
132  case(RMS):
133  return "RMS ";
134  case(STDDEV):
135  return "Stan. Dev.";
136  default:
137  return "DEFAULT ";
138  };
139 }
const Assessor* get_results ( QualityMetric metric) const

Request summary data for a specific QualityMetric This method allows the application to request the summary data for a metric it has registered with the QualityAssessor.

If the passed QualityMetric has not been registered with the QualityAssessor instance, NULL is returned.

const QualityAssessor::Assessor * get_results ( QualityMetric metric) const

Request summary data for a specific QualityMetric This method allows the application to request the summary data for a metric it has registered with the QualityAssessor.

If the passed QualityMetric has not been registered with the QualityAssessor instance, NULL is returned.

Definition at line 518 of file QualityAssessor/QualityAssessor.cpp.

References QualityAssessor::assessList.

519 {
520  msq_std::list<Assessor>::const_iterator iter;
521  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
522  if (iter->get_metric() == metric)
523  return &*iter;
524  return 0;
525 }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
Definition: metric.h:35
bool invalid_elements ( ) const

True if any metric evaluated to an invalid value for any element.

Definition at line 491 of file QualityAssessor/QualityAssessor.cpp.

492 {
493  bool result = false;
494  msq_std::list<Assessor>::const_iterator iter;
495  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
496  if (iter->get_invalid_element_count())
497  result = true;
498  return result;
499 }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
bool invalid_elements ( ) const

True if any metric evaluated to an invalid value for any element.

double loop_over_mesh ( MeshSet ms,
MsqError err 
)
virtual

Does one sweep over the mesh and assess the quality with the metrics previously added.

Computes the quality data for a given MeshSet, ms. What quality information is calculated, depends on what has been requested through the use of the QualityAssessor constructor, add_quality_assessment(), and set_stopping_assessment(). The resulting data is printed in a table unless disable_printing_results() has been called. The double returned depends on the QualityMetric and QAFunction "return" combination, which can be set using set_stopping_assessemnt().

Parameters
ms(const MeshSet &) MeshSet used for quality assessment.

Implements PatchDataUser.

Definition at line 275 of file QualityAssessor/QualityAssessor.cpp.

References PatchData::element_by_index(), MeshSet::get_next_patch(), i, MAXIMUM, MSQ_ERRZERO, MSQ_SETERR, PatchData::num_elements(), PatchData::num_vertices(), and PatchData::vertex_by_index().

Referenced by ShapeImprovementWrapper::run_instructions().

276 {
277  // Clear out any previous data
278  reset_data();
279 
280  // Check for any metrics for which a histogram is to be
281  // calculated and for which the user has not specified
282  // minimum and maximum values.
283  // Element-based metrics are first in list, followed
284  // by vertex-based metrics. Find first vertex-based
285  // metric also such that element metrics go from
286  // assessList.begin() to elem_end and vertex metrics
287  // go from elem_end to assessList.end()
288  list<Assessor>::iterator elem_end = assessList.end();
289  bool need_second_pass_for_elements = false;
290  bool need_second_pass_for_vertices = false;
291  list<Assessor>::iterator iter;
292  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
293  {
294  if (iter->get_metric()->get_metric_type() == QualityMetric::VERTEX_BASED)
295  break;
296 
297  if (iter->funcFlags&HISTOGRAM && !iter->haveHistRange)
298  need_second_pass_for_elements = true;
299  }
300  elem_end = iter;
301  for ( ; iter != assessList.end(); ++iter)
302  {
303  if (iter->funcFlags&HISTOGRAM && !iter->haveHistRange)
304  need_second_pass_for_vertices = true;
305  }
306 
307  list<Assessor> histogramList;
308 
309  // Do element-based metrics
310  if (assessList.begin() != elem_end)
311  {
312  bool first_pass = false;
313  do { // might need to loop twice to calculate histograms
314  first_pass = !first_pass;
315 
316  PatchData* pd;
317  PatchData local_patch;
319  bool more_mesh = true;
320  if (get_global_patch() == 0) {
321  pd = &local_patch;
322  more_mesh=ms.get_next_patch(*pd, this, err); MSQ_ERRZERO(err);
323  }
324  else {
325  pd = get_global_patch();
326  }
327 
328  //until there are no more patches
329  //there is another get_next_patch at
330  //the end of this loop
331  while (more_mesh)
332  {
333  for (unsigned i = 0; i < pd->num_elements(); ++i)
334  {
335  for (iter = assessList.begin(); iter != elem_end; ++iter)
336  {
337  // If first pass, get values for all metrics
338  if (first_pass)
339  {
340  double value;
341  bool valid = iter->get_metric()->evaluate_element( *pd,
342  &pd->element_by_index(i),
343  value, err );
344  MSQ_ERRZERO(err);
345 
346  iter->add_value(value);
347  if (!valid)
348  iter->add_invalid_value();
349  }
350  // If second pass, only do metrics for which the
351  // histogram hasn't been calculated yet.
352  else if (iter->funcFlags&HISTOGRAM && !iter->haveHistRange)
353  {
354  double value;
355  iter->get_metric()->evaluate_element( *pd,
356  &pd->element_by_index(i),
357  value, err );
358  MSQ_ERRZERO(err);
359 
360  iter->add_hist_value(value);
361  }
362  }
363  }
364 
365  // If dealing with local patches, get next element group (PatchData object)
367  more_mesh = ms.get_next_patch(*pd,this, err); MSQ_ERRZERO(err);
368  //Michael:: Since we are doing global right now:
369  //Remove this when no longer doing global
370  more_mesh=false;
371  }
372 
373  // Fix up any histogram ranges which were calculated
374  for (iter = assessList.begin(); iter != elem_end; ++iter)
375  if (iter->funcFlags&HISTOGRAM && !iter->haveHistRange)
376  if (first_pass)
377  iter->calculate_histogram_range();
378 // Uncomment the following to have the QA keep the first
379 // calculated histogram range for all subsequent iterations.
380 // else
381 // iter->haveHistRange = true;
382 
383  } while (first_pass && need_second_pass_for_elements);
384  }
385 
386 
387  // Do vertex-based metrics
388  if (assessList.end() != elem_end)
389  {
390  bool first_pass = false;
391  do { // might need to loop twice to calculate histograms
392  first_pass = !first_pass;
393 
394  //construct the patch we will send to get_next_patch
395  PatchData* pd;
396  PatchData local_patch;
398  bool more_mesh = true;
399  if (get_global_patch() == 0) {
400  pd = &local_patch;
401  more_mesh=ms.get_next_patch(*pd, this, err); MSQ_ERRZERO(err);
402  }
403  else {
404  pd = get_global_patch();
405  }
406 
407  //until there are no more patches
408  //there is another get_next_patch at
409  //the end of this loop
410  while (more_mesh)
411  {
412  for (unsigned i = 0; i < pd->num_vertices(); ++i)
413  {
414  for (iter = elem_end; iter != assessList.end(); ++iter)
415  {
416  // If first pass, get values for all metrics
417  if (first_pass)
418  {
419  double value;
420  bool valid = iter->get_metric()->evaluate_vertex( *pd,
421  &pd->vertex_by_index(i),
422  value, err );
423  MSQ_ERRZERO(err);
424 
425  iter->add_value(value);
426  if (!valid)
427  iter->add_invalid_value();
428  }
429  // If second pass, only do metrics for which the
430  // histogram hasn't been calculated yet.
431  else if (iter->funcFlags&HISTOGRAM && !iter->haveHistRange)
432  {
433  double value;
434  iter->get_metric()->evaluate_vertex( *pd,
435  &pd->vertex_by_index(i),
436  value, err );
437  MSQ_ERRZERO(err);
438 
439  iter->add_hist_value(value);
440  }
441  }
442  }
443 
445  more_mesh = ms.get_next_patch(*pd,this, err); MSQ_ERRZERO(err);
446  //Michael:: Since we are doing global right now:
447  //Remove this when no longer doing global
448  more_mesh=false;
449  }
450 
451  // Fix up any histogram ranges which were calculated
452  for (iter = elem_end; iter != assessList.end(); ++iter)
453  if (iter->funcFlags&HISTOGRAM && !iter->haveHistRange)
454  if (first_pass)
455  iter->calculate_histogram_range();
456 // Uncomment the following to have the QA keep the first
457 // calculated histogram range for all subsequent iterations.
458 // else
459 // iter->haveHistRange = true;
460 
461  } while (first_pass && need_second_pass_for_vertices);
462  }
463 
464 
465  // Print results, if requested
466  if (printSummary)
467  print_summary( this->outputStream );
468 
469  // If no stopping function, just return zero
470  if (!stoppingFunction)
471  return 0.0;
472 
473  // Otherwise return requested value
474  if (stoppingFunction & STDDEV)
475  return stoppingMetric->get_stddev();
476  else if (stoppingFunction & AVERAGE)
477  return stoppingMetric->get_average();
478  else if (stoppingFunction & MAXIMUM)
479  return stoppingMetric->get_maximum();
480  else if (stoppingFunction & MINIMUM)
481  return stoppingMetric->get_minimum();
482  else if (stoppingFunction & RMS)
483  return stoppingMetric->get_rms();
484  else
485  MSQ_SETERR(err)("Invalid stopping function for QualityAssessor",
487 
488  return 0.0;
489 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
void reset_data()
Reset calculated data.
msq_stdio::ostream & outputStream
Stream to which to write summary of metric data.
void print_summary(msq_stdio::ostream &stream) const
Print accumulated summary data to specified stream.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79
PatchData::PatchType get_patch_type()
Returns the Patch Type.
msq_std::list< Assessor >::iterator stoppingMetric
Metric in assessList to use as return value for loop_over_mesh.
PatchData * get_global_patch()
Returns the Global Patch.
void no_culling_method()
Sets off all culling methods.
object is in an invalid state
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
QAFunction stoppingFunction
Value to use as return value for loop_over_mesh.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual double loop_over_mesh ( MeshSet ms,
MsqError err 
)
virtual

Does one sweep over the mesh and assess the quality with the metrics previously added.

Implements PatchDataUser.

void print_summary ( msq_stdio::ostream &  stream) const

Print accumulated summary data to specified stream.

Definition at line 626 of file QualityAssessor/QualityAssessor.cpp.

References QualityAssessor::assessList, QualityAssessor::AVERAGE, QualityAssessor::HISTOGRAM, QualityAssessor::MAXIMUM, QualityAssessor::MINIMUM, QualityAssessor::qualityAssessorName, QualityAssessor::RMS, and QualityAssessor::STDDEV.

627 {
628  const int NAMEW = 19; // Width of name column in table output
629  const int NUMW = 12; // Width of value columns in table output
630 
631  // Print title
632  stream << msq_stdio::endl
633  << "************** "
635  << " Summary **************"
636  << msq_stdio::endl
637  << msq_stdio::endl;
638 
639  // Get union of function flags, and list any metrics with invalid values
640  msq_std::list<Assessor>::const_iterator iter;
641  unsigned flags = 0;
642  int invalid_count = 0;
643  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
644  {
645  flags |= (iter->funcFlags & ~HISTOGRAM);
646 
647  if (iter->get_invalid_element_count())
648  {
649  ++invalid_count;
650 
651  stream << " " << iter->get_invalid_element_count()
652  << " OF " << iter->get_count()
653  << " VALUES ARE INVALID FOR "
654  << iter->get_metric()->get_name()
655  << msq_stdio::endl << msq_stdio::endl;
656  }
657  }
658 
659  if (0 == invalid_count) {
660  stream << " No invalid values for any metric."
661  << msq_stdio::endl << msq_stdio::endl;
662  }
663 
664  // If printing any values
665  if (flags)
666  {
667  // Print table header line
668  stream << msq_stdio::setw(NAMEW) << "metric";
669  if (flags & MINIMUM)
670  stream << msq_stdio::setw(NUMW) << "minimum";
671  if (flags & AVERAGE)
672  stream << msq_stdio::setw(NUMW) << "average";
673  if (flags & RMS)
674  stream << msq_stdio::setw(NUMW) << "rms";
675  if (flags & MAXIMUM)
676  stream << msq_stdio::setw(NUMW) << "maximum";
677  if (flags & STDDEV)
678  stream << msq_stdio::setw(NUMW) << "std.dev.";
679  stream << msq_stdio::endl;
680 
681  // Print out values for each assessor
682  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
683  {
684  // If no output (other than histogram) for this metric, skip it
685  if (!(iter->funcFlags & ~HISTOGRAM))
686  continue;
687 
688  // Name column
689  stream << msq_stdio::setw(NAMEW) << iter->get_metric()->get_name();
690 
691  // Value columns
692  if (flags & MINIMUM)
693  {
694  if (iter->funcFlags & MINIMUM)
695  stream << msq_stdio::setw(NUMW) << iter->get_minimum();
696  else
697  stream << msq_stdio::setw(NUMW) << " ";
698  }
699  if (flags & AVERAGE)
700  {
701  if (iter->funcFlags & AVERAGE)
702  stream << msq_stdio::setw(NUMW) << iter->get_average();
703  else
704  stream << msq_stdio::setw(NUMW) << " ";
705  }
706  if (flags & RMS)
707  {
708  if (iter->funcFlags & RMS)
709  stream << msq_stdio::setw(NUMW) << iter->get_rms();
710  else
711  stream << msq_stdio::setw(NUMW) << " ";
712  }
713  if (flags & MAXIMUM)
714  {
715  if (iter->funcFlags & MAXIMUM)
716  stream << msq_stdio::setw(NUMW) << iter->get_maximum();
717  else
718  stream << msq_stdio::setw(NUMW) << " ";
719  }
720  if (flags & STDDEV)
721  {
722  if (iter->funcFlags & STDDEV)
723  stream << msq_stdio::setw(NUMW) << iter->get_stddev();
724  else
725  stream << msq_stdio::setw(NUMW) << " ";
726  }
727  stream << msq_stdio::endl;
728  } // for (assessList)
729  } // if (flags)
730 
731  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
732  if (iter->funcFlags & HISTOGRAM)
733  iter->print_histogram( stream );
734 }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
void print_summary ( msq_stdio::ostream &  stream) const

Print accumulated summary data to specified stream.

void reset_data ( )

Reset calculated data.

Definition at line 501 of file QualityAssessor/QualityAssessor.cpp.

502 {
503  msq_std::list<Assessor>::iterator iter;
504  for (iter = assessList.begin(); iter != assessList.end(); ++iter)
505  iter->reset_data();
506 }
msq_std::list< Assessor > assessList
List of quality metrics and corresponding data.
void reset_data ( )

Reset calculated data.

void set_name ( msq_std::string  name)
inline

Provides a name to the QualityAssessor (use it for default name in constructor).

Definition at line 140 of file src/QualityAssessor/QualityAssessor.hpp.

References QualityAssessor::qualityAssessorName.

140 { qualityAssessorName = name; };
void set_name ( msq_std::string  name)
inline

Provides a name to the QualityAssessor (use it for default name in constructor).

Definition at line 140 of file includeLinks/QualityAssessor.hpp.

References QualityAssessor::qualityAssessorName.

140 { qualityAssessorName = name; };
void set_stopping_assessment ( QualityMetric qm,
QAFunction  func,
MsqError err 
)

Sets the QualityMetric and QAFunction combination that will be returned when loop_over_mesh is called.

Sets which QualityMetric and QAFunction combination is used to determine the value return from assess_mesh_quality(). It first ensures that the inputed QAFunction was not HISTOGRAM. It then calls add_quality_assessment with the given QualityMetric and QAFunction, to ensure that this combination will be computed. Finally, it sets the stoppingMetric pointer and the stoppingFunction data members.

Parameters
qmPointer to QualityMetric.
func(QAFUNCTION) Wrapper function for qm (e.g. MINIMUM, MAXIMUM,...).

Definition at line 216 of file QualityAssessor/QualityAssessor.cpp.

References MSQ_SETERR.

219 {
220  if(func==HISTOGRAM){
221  MSQ_SETERR(err)("HISTOGRAM DOES NOT GIVE A VALID RETURN VALUE", MsqError::INVALID_ARG);
222  return;
223  }
224  else if (func == NO_FUNCTION) {
225  MSQ_SETERR(err)("No function specified for stopping assessment", MsqError::INVALID_ARG);
226  return;
227  }
228 
229  stoppingMetric = find_or_add( qm );
230  stoppingFunction = func;
231 }
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
msq_std::list< Assessor >::iterator find_or_add(QualityMetric *qm)
Find an Assessor corresponding to the passed QualityMetric, or create it if is not found in the list...
msq_std::list< Assessor >::iterator stoppingMetric
Metric in assessList to use as return value for loop_over_mesh.
QAFunction stoppingFunction
Value to use as return value for loop_over_mesh.
void set_stopping_assessment ( QualityMetric qm,
QAFunction  func,
MsqError err 
)

Sets the QualityMetric and QAFunction combination that will be returned when loop_over_mesh is called.

Member Data Documentation

msq_std::list< Assessor > assessList
private

List of quality metrics and corresponding data.

Definition at line 303 of file includeLinks/QualityAssessor.hpp.

Referenced by QualityAssessor::get_all_results(), QualityAssessor::get_results(), and QualityAssessor::print_summary().

msq_stdio::ostream & outputStream
private

Stream to which to write summary of metric data.

Definition at line 306 of file includeLinks/QualityAssessor.hpp.

bool printSummary
private

Disable printing.

Definition at line 308 of file includeLinks/QualityAssessor.hpp.

Referenced by QualityAssessor::disable_printing_results().

msq_std::string qualityAssessorName
private
QAFunction stoppingFunction
private

Value to use as return value for loop_over_mesh.

Definition at line 313 of file includeLinks/QualityAssessor.hpp.

msq_std::list< Assessor >::iterator stoppingMetric
private

Metric in assessList to use as return value for loop_over_mesh.

Definition at line 311 of file includeLinks/QualityAssessor.hpp.


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