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

An InstructionQueue object gathers Mesquite Instructions and ensures that the instruction queue is coherent for mesh improvement and/or mesh quality assessment purposes. More...

#include <InstructionQueue.hpp>

Inheritance diagram for InstructionQueue:
Collaboration diagram for InstructionQueue:

Public Member Functions

 InstructionQueue ()
 
virtual ~InstructionQueue ()
 
void add_target_calculator (TargetCalculator *tc, MsqError &err)
 
void add_preconditioner (QualityImprover *instr, MsqError &err)
 adds a QualityImprover at the end of the instruction list More...
 
void remove_preconditioner (size_t index, MsqError &err)
 removes a QualityImprover* from the instruction queue More...
 
void insert_preconditioner (QualityImprover *instr, size_t index, MsqError &err)
 inserts a QualityImprover* into the instruction queue. More...
 
void add_quality_assessor (QualityAssessor *instr, MsqError &err)
 adds a QualityAssessor to the instruction queue. More...
 
void remove_quality_assessor (size_t index, MsqError &err)
 removes a QualityAssessor* from the instruction queue More...
 
void insert_quality_assessor (QualityAssessor *instr, size_t index, MsqError &err)
 inserts a QualityAssessor* into the instruction queue. More...
 
void set_master_quality_improver (QualityImprover *instr, MsqError &err)
 
void disable_automatic_quality_assessment ()
 
void enable_automatic_quality_assessment ()
 
void disable_automatic_midnode_adjustment ()
 
void enable_automatic_midnode_adjustment ()
 
virtual void run_instructions (MeshSet &msc, MsqError &err)
 This function is virtual so that it may be redefined in the wraper classes. More...
 
void clear ()
 
void trap_floating_point_exception (bool enable)
 Generate SIGFPE whenever a floating point exception occurs. More...
 
bool trap_floating_point_exception () const
 
 InstructionQueue ()
 
virtual ~InstructionQueue ()
 
void add_target_calculator (TargetCalculator *tc, MsqError &err)
 
void add_preconditioner (QualityImprover *instr, MsqError &err)
 
void remove_preconditioner (size_t index, MsqError &err)
 
void insert_preconditioner (QualityImprover *instr, size_t index, MsqError &err)
 
void add_quality_assessor (QualityAssessor *instr, MsqError &err)
 
void remove_quality_assessor (size_t index, MsqError &err)
 
void insert_quality_assessor (QualityAssessor *instr, size_t index, MsqError &err)
 
void set_master_quality_improver (QualityImprover *instr, MsqError &err)
 
void disable_automatic_quality_assessment ()
 
void enable_automatic_quality_assessment ()
 
void disable_automatic_midnode_adjustment ()
 
void enable_automatic_midnode_adjustment ()
 
virtual void run_instructions (MeshSet &msc, MsqError &err)
 This function is virtual so that it may be redefined in the wraper classes. More...
 
void clear ()
 
void trap_floating_point_exception (bool enable)
 Generate SIGFPE whenever a floating point exception occurs. More...
 
bool trap_floating_point_exception () const
 

Private Member Functions

msq_std::list< PatchDataUser * >
::iterator 
clear_master (MsqError &err)
 
msq_std::list< PatchDataUser * >
::iterator 
clear_master (MsqError &err)
 

Private Attributes

msq_std::list< PatchDataUser * > instructions
 
bool autoQualAssess
 
bool autoAdjMidNodes
 
size_t nbPreConditionners
 
bool isMasterSet
 
size_t masterInstrIndex
 0-based. More...
 
PatchDataglobalPatch
 Used to prevent reallocating a global patch for successive global algorithms. More...
 
bool trapFPE
 

Detailed Description

An InstructionQueue object gathers Mesquite Instructions and ensures that the instruction queue is coherent for mesh improvement and/or mesh quality assessment purposes.

The user can instantiate several InstructionQueue objects to be used with various MeshSet objects.

The most commonly used functions are:

  1. add_preconditioner(...)
  2. add_quality_assessor(...)
  3. set_master_quality_improver(...)
  4. run_instructions(...)

Definition at line 73 of file includeLinks/InstructionQueue.hpp.

Constructor & Destructor Documentation

virtual ~InstructionQueue ( )
inlinevirtual

Definition at line 79 of file includeLinks/InstructionQueue.hpp.

79 {};
virtual ~InstructionQueue ( )
inlinevirtual

Definition at line 79 of file src/Control/InstructionQueue.hpp.

79 {};

Member Function Documentation

void add_preconditioner ( QualityImprover instr,
MsqError err 
)

adds a QualityImprover at the end of the instruction list

This function cannot be used once the set_master_quality_improver() function has been used.

See also insert_preconditioner().

Definition at line 91 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions, MsqError::INVALID_STATE, InstructionQueue::isMasterSet, MSQ_SETERR, and InstructionQueue::nbPreConditionners.

93 {
94  if (isMasterSet) {
95  MSQ_SETERR(err)("Cannot add preconditionners once the master "
96  "QualityImprover has been set.", MsqError::INVALID_STATE);
97  return;
98  }
99 
100  instructions.push_back(instr);
102 }
msq_std::list< PatchDataUser * > instructions
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state
void add_preconditioner ( QualityImprover instr,
MsqError err 
)
void add_quality_assessor ( QualityAssessor instr,
MsqError err 
)

adds a QualityAssessor to the instruction queue.

QualityAssessor pointers can be added at any time to the instruction queue.

Definition at line 177 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions.

Referenced by LaplacianIQ::LaplacianIQ().

179 {
180  instructions.push_back(instr);
181 }
msq_std::list< PatchDataUser * > instructions

Here is the caller graph for this function:

void add_quality_assessor ( QualityAssessor instr,
MsqError err 
)
void add_target_calculator ( TargetCalculator tc,
MsqError err 
)
void add_target_calculator ( TargetCalculator tc,
MsqError err 
)

Definition at line 78 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions.

79 {
80  instructions.push_back( tc );
81 }
msq_std::list< PatchDataUser * > instructions
void clear ( )
msq_std::list<PatchDataUser*>::iterator clear_master ( MsqError err)
private
list< PatchDataUser * >::iterator clear_master ( MsqError err)
private

Definition at line 337 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions, MsqError::INVALID_STATE, InstructionQueue::isMasterSet, InstructionQueue::masterInstrIndex, and MSQ_SETERR.

Referenced by InstructionQueue::set_master_quality_improver().

338 {
339  msq_std::list<PatchDataUser*>::iterator instr_iter;
340  msq_std::list<PatchDataUser*>::iterator master_pos;
341 
342  if (!isMasterSet) {
343  MSQ_SETERR(err)("No master quality improver to clear.", MsqError::INVALID_STATE);
344  return instr_iter;
345  }
346 
347  // position the instruction iterator over the master quality improver
348  master_pos = instructions.begin();
349  advance(master_pos, masterInstrIndex);
350 
351  // erases the master quality improver
352  instr_iter = instructions.erase(master_pos);
353  isMasterSet = false;
354 
355  // returns the position where the Master was
356  return instr_iter;
357 }
msq_std::list< PatchDataUser * > instructions
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state

Here is the caller graph for this function:

void disable_automatic_midnode_adjustment ( )
inline
void disable_automatic_midnode_adjustment ( )
inline
void disable_automatic_quality_assessment ( )
inline
void disable_automatic_quality_assessment ( )
inline
void enable_automatic_midnode_adjustment ( )
inline
void enable_automatic_midnode_adjustment ( )
inline
void enable_automatic_quality_assessment ( )
inline
void enable_automatic_quality_assessment ( )
inline
void insert_preconditioner ( QualityImprover instr,
size_t  index,
MsqError err 
)

inserts a QualityImprover* into the instruction queue.

Pre-conditionners can only be inserted before the master QualityImprover.

Parameters
indexis 0-based. An error is set if the index does not correspond to a valid position in the queue.

Definition at line 148 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions, MsqError::INVALID_ARG, MsqError::INVALID_STATE, InstructionQueue::isMasterSet, InstructionQueue::masterInstrIndex, MSQ_SETERR, and InstructionQueue::nbPreConditionners.

150 {
151  // checks index is valid
152  if (isMasterSet==true && index > masterInstrIndex) {
153  MSQ_SETERR(err)("Cannot add a preconditionner after the master "
154  "QualityImprover.", MsqError::INVALID_STATE);
155  return;
156  }
157  if (index >= instructions.size() ) {
158  MSQ_SETERR(err)("index", MsqError::INVALID_ARG);
159  return;
160  }
161 
162  // position the instruction iterator
163  list<PatchDataUser*>::iterator pos;
164  pos = instructions.begin();
165  advance(pos, index);
166  // adds the preconditioner
167  instructions.insert(pos,instr);
169 }
msq_std::list< PatchDataUser * > instructions
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state
void insert_preconditioner ( QualityImprover instr,
size_t  index,
MsqError err 
)
void insert_quality_assessor ( QualityAssessor instr,
size_t  index,
MsqError err 
)

inserts a QualityAssessor* into the instruction queue.

QualityAssessors can be inserted at any position in the instruction queue.

Parameters
indexis 0-based. An error is set if the index is past the end of the queue.

Definition at line 222 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions, MsqError::INVALID_ARG, and MSQ_SETERR.

224 {
225  // checks index is valid
226  if (index > instructions.size()) {
227  MSQ_SETERR(err)("index points two positions beyond end of list.",
229  return;
230  }
231 
232  // position the instruction iterator
233  list<PatchDataUser*>::iterator pos;
234  pos = instructions.begin();
235  advance(pos, index);
236  // adds the QualityAssessor
237  instructions.insert(pos,instr);
238 }
msq_std::list< PatchDataUser * > instructions
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void insert_quality_assessor ( QualityAssessor instr,
size_t  index,
MsqError err 
)
void remove_preconditioner ( size_t  index,
MsqError err 
)
void remove_preconditioner ( size_t  index,
MsqError err 
)

removes a QualityImprover* from the instruction queue

Parameters
indexis 0-based. An error is set if the index does not correspond to a valid element in the queue.

Definition at line 111 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions, MsqError::INVALID_ARG, InstructionQueue::isMasterSet, InstructionQueue::masterInstrIndex, MSQ_SETERR, InstructionQueue::nbPreConditionners, and PatchDataUser::QUALITY_IMPROVER.

112 {
113  // checks index is valid
114  if ( isMasterSet && index == masterInstrIndex ) {
115  MSQ_SETERR(err)("cannot remove master QualityImprover.", MsqError::INVALID_ARG);
116  return;
117  } else if (index >= instructions.size() ) {
118  MSQ_SETERR(err)("Index points beyond end of list.",MsqError::INVALID_ARG);
119  return;
120  }
121 
122  // position the instruction iterator over the preconditionner to delete
123  msq_std::list<PatchDataUser*>::iterator pos;
124  pos = instructions.begin();
125  advance(pos, index);
126 
127  if ( (*pos)->get_algorithm_type() != PatchDataUser::QUALITY_IMPROVER )
128  {
129  MSQ_SETERR(err)("Index does not point to a QualityImprover.",
131  return;
132  }
133 
134  string name = (*pos)->get_name();
135  instructions.erase(pos);
137 }
msq_std::list< PatchDataUser * > instructions
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void remove_quality_assessor ( size_t  index,
MsqError err 
)
void remove_quality_assessor ( size_t  index,
MsqError err 
)

removes a QualityAssessor* from the instruction queue

Parameters
indexis 0-based. An error is set if the index does not correspond to a valid element in the queue.

Definition at line 190 of file Control/InstructionQueue.cpp.

References InstructionQueue::instructions, MsqError::INVALID_ARG, MSQ_SETERR, and PatchDataUser::QUALITY_ASSESSOR.

191 {
192  // checks index is valid
193  if (index >= instructions.size() ) {
194  MSQ_SETERR(err)("index", MsqError::INVALID_ARG);
195  return;
196  }
197 
198  // position the instruction iterator over the QualityAssessor to delete
199  list<PatchDataUser*>::iterator pos;
200  pos = instructions.begin();
201  advance(pos, index);
202 
203  if ( (*pos)->get_algorithm_type() != PatchDataUser::QUALITY_ASSESSOR )
204  {
205  MSQ_SETERR(err)("Index does not point to a QualityImprover.",
207  return;
208  }
209 
210  string name = (*pos)->get_name();
211  instructions.erase(pos);
212 }
msq_std::list< PatchDataUser * > instructions
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
virtual void run_instructions ( MeshSet msc,
MsqError err 
)
virtual

This function is virtual so that it may be redefined in the wraper classes.

Reimplemented in ShapeImprovementWrapper, and ShapeImprovementWrapper.

void run_instructions ( MeshSet msc,
MsqError err 
)
virtual

This function is virtual so that it may be redefined in the wraper classes.

Reimplemented in ShapeImprovementWrapper, and ShapeImprovementWrapper.

Definition at line 260 of file Control/InstructionQueue.cpp.

References InstructionQueue::autoAdjMidNodes, MeshSet::get_next_patch(), PatchData::GLOBAL_PATCH, InstructionQueue::globalPatch, InstructionQueue::instructions, MsqError::INVALID_STATE, InstructionQueue::isMasterSet, MSQ_DBGOUT, MSQ_ERRRTN, MSQ_SETERR, InstructionQueue::nbPreConditionners, InstructionQueue::trapFPE, and Mesquite::version_string().

261 {
262  MSQ_DBGOUT(1) << version_string(false) << "\n";
263 
264  if (nbPreConditionners != 0 && isMasterSet == false ) {
265  MSQ_SETERR(err)("no pre-conditionners allowed if master QualityImprover "
266  "is not set.", MsqError::INVALID_STATE);
267  return;
268  }
269 
270 #ifdef ENABLE_INTERRUPT
271  // Register SIGINT handler
272  MsqInterrupt msq_interrupt;
273 #endif
274 
275  // Generate SIGFPE on floating point errors
276  MsqFPE( this->trapFPE );
277 
278  msq_std::list<PatchDataUser*>::const_iterator instr_iter;
279 
280  if (autoAdjMidNodes)
281  instructions.push_back( new MeanMidNodeMover );
282 
283  // For each instruction in the list
284  for (instr_iter = instructions.begin();
285  !(instr_iter == instructions.end()); ++instr_iter) {
286 
287  // If instruction uses a global patch, creates one or reuse the existing one.
288  if ((*instr_iter)->get_patch_type() == PatchData::GLOBAL_PATCH) {
289  if (globalPatch == 0) {
290  globalPatch = new PatchData;
291  ms.get_next_patch(*globalPatch, (*instr_iter)->get_all_parameters(), err);
292  MSQ_ERRRTN(err);
293  }
294 
295 
296  (*instr_iter)->set_global_patch(globalPatch, err); MSQ_ERRRTN(err);
297  }
298  // If instruction does not use a Global Patch, make sure we discard any existing patch.
299  else {
300  delete globalPatch;
301  globalPatch = 0;
302  (*instr_iter)->no_global_patch();
303  }
304 
305  // applies the QualityImprover/QualityAssessor to the MeshSet
306  (*instr_iter)->loop_over_mesh(ms, err); MSQ_ERRRTN(err);
307 
308  // If this same instruction is reused in this queue, we can't assume the
309  // global patch will still be valid.
310  (*instr_iter)->no_global_patch();
311  }
312 
313  if (autoAdjMidNodes)
314  {
315  delete *instructions.rbegin();
316  instructions.pop_back( );
317  }
318 
319  if (globalPatch != 0)
320  {
321  delete globalPatch; // clean up once all instructions are executed.
322  globalPatch = 0;
323  }
324 }
Class to adjust positions of higher-order nodes.
PatchData * globalPatch
Used to prevent reallocating a global patch for successive global algorithms.
const char * version_string(bool include_build_number=false)
Utility class used by InstructionQueue SIGFPE option.
msq_std::list< PatchDataUser * > instructions
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
object is in an invalid state
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
Class to watch for user-interrupt (SIGINT, ctrl-C)

Here is the call graph for this function:

void set_master_quality_improver ( QualityImprover instr,
MsqError err 
)

Definition at line 241 of file Control/InstructionQueue.cpp.

References InstructionQueue::clear_master(), InstructionQueue::instructions, InstructionQueue::isMasterSet, InstructionQueue::masterInstrIndex, MSQ_DBGOUT, and MSQ_ERRRTN.

Referenced by LaplacianIQ::LaplacianIQ().

243 {
244  if (isMasterSet) {
245  MSQ_DBGOUT(1) << "InstructionQueue::set_master_quality_improver():\n"
246  << "\tOverwriting previously specified master quality improver.\n";
247  // if master is already set, clears it and insert the new one at the same position.
248  list<PatchDataUser*>::iterator master_pos;
249  master_pos = this->clear_master(err); MSQ_ERRRTN(err);
250  instructions.insert(master_pos, instr);
251  isMasterSet = true;
252  } else {
253  // if master is not set, add it at the end of the queue.
254  instructions.push_back(instr);
255  isMasterSet = true;
256  masterInstrIndex = instructions.size()-1;
257  }
258 }
msq_std::list< PatchDataUser * >::iterator clear_master(MsqError &err)
msq_std::list< PatchDataUser * > instructions
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
#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 set_master_quality_improver ( QualityImprover instr,
MsqError err 
)
void trap_floating_point_exception ( bool  enable)
inline

Generate SIGFPE whenever a floating point exception occurs.

Generate a FPE signal when overflow, divbyzero, etc. occur during floating-point arithmatic. This is intended for debugging purposes only, as enabling this will typically result in a crash when such arithmatic errors occur.

If this option is enabled, Mesquite will attempt to set platform-specific flags such that a SIGFPE is generated for floating point errors while the instruction queue is running. If this option ins disabled, Mesquite will not change the flags. There is no option to explicitly disable such flags because that is the default behavior on most platforms, and presumably if the application has enabled such flags it makes little sense to disable them while Mesquite is running.

This functionality may not be supported on all platforms. If it is not supported, this option has no effect.

Definition at line 127 of file includeLinks/InstructionQueue.hpp.

References InstructionQueue::trapFPE.

void trap_floating_point_exception ( bool  enable)
inline

Generate SIGFPE whenever a floating point exception occurs.

Generate a FPE signal when overflow, divbyzero, etc. occur during floating-point arithmatic. This is intended for debugging purposes only, as enabling this will typically result in a crash when such arithmatic errors occur.

If this option is enabled, Mesquite will attempt to set platform-specific flags such that a SIGFPE is generated for floating point errors while the instruction queue is running. If this option ins disabled, Mesquite will not change the flags. There is no option to explicitly disable such flags because that is the default behavior on most platforms, and presumably if the application has enabled such flags it makes little sense to disable them while Mesquite is running.

This functionality may not be supported on all platforms. If it is not supported, this option has no effect.

Definition at line 127 of file src/Control/InstructionQueue.hpp.

References InstructionQueue::trapFPE.

bool trap_floating_point_exception ( ) const
inline
bool trap_floating_point_exception ( ) const
inline

Member Data Documentation

PatchData * globalPatch
private

Used to prevent reallocating a global patch for successive global algorithms.

Definition at line 148 of file includeLinks/InstructionQueue.hpp.

Referenced by InstructionQueue::run_instructions().

size_t masterInstrIndex
private

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