MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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>
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:
Definition at line 76 of file InstructionQueue.hpp.
Definition at line 56 of file InstructionQueue.cpp.
: autoQualAssess( true ), vertexSlaverCount( 0 ), nbPreConditionners( 0 ), isMasterSet( false ), masterInstrIndex( 0 ) { }
MESQUITE_EXPORT MBMesquite::InstructionQueue::InstructionQueue | ( | const Settings & | settings | ) |
InstructionQueue::~InstructionQueue | ( | ) | [virtual] |
Definition at line 62 of file InstructionQueue.cpp.
{}
void InstructionQueue::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 124 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_STATE, isMasterSet, MSQ_SETERR, and nbPreConditionners.
Referenced by main(), smooth_mixed_mesh(), and VertexCullingRegressionTest::test_laplacian_smoothing_with_cull().
{ if( isMasterSet ) { MSQ_SETERR( err ) ( "Cannot add preconditioners once the master " "QualityImprover has been set.", MsqError::INVALID_STATE ); return; } instructions.push_back( instr ); nbPreConditionners++; }
void InstructionQueue::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 214 of file InstructionQueue.cpp.
References instructions.
Referenced by BCDTest::compare_bcd(), ParShapeImprover::count_invalid_elements(), do_smoother(), main(), run(), run_global_smoother(), run_local_smoother(), run_local_smoother2(), run_quality_optimizer(), run_solution_mesh_optimizer(), MBMesquite::SizeAdaptShapeWrapper::run_wrapper(), MBMesquite::PaverMinEdgeLengthWrapper::run_wrapper(), MBMesquite::ViscousCFDTetShapeWrapper::run_wrapper(), MBMesquite::ShapeImprover::run_wrapper(), MBMesquite::ShapeImprovementWrapper::run_wrapper(), MBMesquite::LaplaceWrapper::run_wrapper(), MBMesquite::UntangleWrapper::run_wrapper(), ParShapeImprover::ParShapeImprovementWrapper::run_wrapper(), MBMesquite::DeformingDomainWrapper::run_wrapper(), smooth_mesh(), smooth_mixed_mesh(), QualityAssessorTest::test_free_only(), and VertexCullingRegressionTest::test_laplacian_smoothing_with_cull().
{ instructions.push_back( instr ); }
void InstructionQueue::add_tag_vertex_mesh | ( | TagVertexMesh * | m, |
MsqError & | err | ||
) |
Definition at line 94 of file InstructionQueue.cpp.
References instructions, isMasterSet, and masterInstrIndex.
Referenced by MBMesquite::SizeAdaptShapeWrapper::run_wrapper(), MBMesquite::DeformingDomainWrapper::store_initial_mesh(), and TagVertexMeshTest::test_reference_mesh().
{ instructions.push_front( vs ); if( isMasterSet ) ++masterInstrIndex; }
void InstructionQueue::add_target_calculator | ( | TargetWriter * | tc, |
MsqError & | err | ||
) |
Definition at line 64 of file InstructionQueue.cpp.
References instructions.
Referenced by run_test().
{ instructions.push_back( tc ); }
void InstructionQueue::add_vertex_slaver | ( | VertexSlaver * | slaver, |
MsqError & | err | ||
) |
Add a tool mark higher-order nodes as slaved. Note: Implies set_slaved_ho_node_mode( Settings::SLAVE_CALCULATED )
Definition at line 69 of file InstructionQueue.cpp.
References instructions, isMasterSet, masterInstrIndex, MBMesquite::Settings::set_slaved_ho_node_mode(), MBMesquite::Settings::SLAVE_CALCULATED, and vertexSlaverCount.
Referenced by main(), and InstructionQueueTest::test_add_remove_vertex_slaver().
{ instructions.push_front( vs ); if( isMasterSet ) ++masterInstrIndex; ++vertexSlaverCount; set_slaved_ho_node_mode( Settings::SLAVE_CALCULATED ); }
void InstructionQueue::clear | ( | ) |
Definition at line 358 of file InstructionQueue.cpp.
References autoQualAssess, instructions, isMasterSet, and masterInstrIndex.
{ instructions.clear(); autoQualAssess = true; isMasterSet = false; masterInstrIndex = 0; }
std::list< Instruction * >::iterator InstructionQueue::clear_master | ( | MsqError & | err | ) | [private] |
Definition at line 366 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_STATE, isMasterSet, masterInstrIndex, and MSQ_SETERR.
Referenced by set_master_quality_improver().
{ std::list< Instruction* >::iterator instr_iter; std::list< Instruction* >::iterator master_pos; if( !isMasterSet ) { MSQ_SETERR( err )( "No master quality improver to clear.", MsqError::INVALID_STATE ); return instr_iter; } // position the instruction iterator over the master quality improver master_pos = instructions.begin(); std::advance( master_pos, masterInstrIndex ); // erases the master quality improver instr_iter = instructions.erase( master_pos ); isMasterSet = false; // returns the position where the Master was return instr_iter; }
MESQUITE_EXPORT void MBMesquite::InstructionQueue::disable_automatic_quality_assessment | ( | ) | [inline] |
Definition at line 124 of file InstructionQueue.hpp.
References autoQualAssess.
{ autoQualAssess = false; }
Definition at line 129 of file InstructionQueue.hpp.
References autoQualAssess.
{ autoQualAssess = true; }
void InstructionQueue::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.
index | is 0-based. An error is set if the index does not correspond to a valid position in the queue. |
Definition at line 183 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_ARG, MBMesquite::MsqError::INVALID_STATE, isMasterSet, masterInstrIndex, MSQ_SETERR, and nbPreConditionners.
{ // checks index is valid if( isMasterSet == true && index > masterInstrIndex ) { MSQ_SETERR( err ) ( "Cannot add a preconditioner after the master " "QualityImprover.", MsqError::INVALID_STATE ); return; } if( index >= instructions.size() ) { MSQ_SETERR( err )( "index", MsqError::INVALID_ARG ); return; } // position the instruction iterator std::list< Instruction* >::iterator pos; pos = instructions.begin(); std::advance( pos, index ); // adds the preconditioner instructions.insert( pos, instr ); nbPreConditionners++; }
void InstructionQueue::insert_quality_assessor | ( | QualityAssessor * | instr, |
size_t | index, | ||
MsqError & | err | ||
) |
QualityAssessors can be inserted at any position in the instruction queue.
index | is 0-based. An error is set if the index is past the end of the queue. |
Definition at line 256 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_ARG, and MSQ_SETERR.
{ // checks index is valid if( index > instructions.size() ) { MSQ_SETERR( err ) ( "index points two positions beyond end of list.", MsqError::INVALID_ARG ); return; } // position the instruction iterator std::list< Instruction* >::iterator pos; pos = instructions.begin(); std::advance( pos, index ); // adds the QualityAssessor instructions.insert( pos, instr ); }
void InstructionQueue::remove_preconditioner | ( | size_t | index, |
MsqError & | err | ||
) |
removes a QualityImprover* from the instruction queue
index | is 0-based. An error is set if the index does not correspond to a valid element in the queue. |
Definition at line 145 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_ARG, isMasterSet, masterInstrIndex, MSQ_SETERR, and nbPreConditionners.
{ // checks index is valid if( isMasterSet && index == masterInstrIndex ) { MSQ_SETERR( err )( "cannot remove master QualityImprover.", MsqError::INVALID_ARG ); return; } else if( index >= instructions.size() ) { MSQ_SETERR( err )( "Index points beyond end of list.", MsqError::INVALID_ARG ); return; } // position the instruction iterator over the preconditioner to delete std::list< Instruction* >::iterator pos; pos = instructions.begin(); std::advance( pos, index ); if( !dynamic_cast< QualityImprover* >( *pos ) ) { MSQ_SETERR( err )( "Index does not point to a QualityImprover.", MsqError::INVALID_ARG ); return; } std::string name = ( *pos )->get_name(); instructions.erase( pos ); nbPreConditionners--; }
void InstructionQueue::remove_quality_assessor | ( | size_t | index, |
MsqError & | err | ||
) |
removes a QualityAssessor* from the instruction queue
index | is 0-based. An error is set if the index does not correspond to a valid element in the queue. |
Definition at line 225 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_ARG, and MSQ_SETERR.
Referenced by MBMesquite::ViscousCFDTetShapeWrapper::run_wrapper().
{ // checks index is valid if( index >= instructions.size() ) { MSQ_SETERR( err )( "index", MsqError::INVALID_ARG ); return; } // position the instruction iterator over the QualityAssessor to delete std::list< Instruction* >::iterator pos; pos = instructions.begin(); std::advance( pos, index ); if( !dynamic_cast< QualityAssessor* >( *pos ) ) { MSQ_SETERR( err )( "Index does not point to a QualityImprover.", MsqError::INVALID_ARG ); return; } std::string name = ( *pos )->get_name(); instructions.erase( pos ); }
void InstructionQueue::remove_tag_vertex_mesh | ( | TagVertexMesh * | m, |
MsqError & | err | ||
) |
Definition at line 100 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_ARG, isMasterSet, masterInstrIndex, and MSQ_SETERR.
{ size_t idx = 0; for( std::list< Instruction* >::iterator i = instructions.begin(); i != instructions.end(); ++i, ++idx ) { if( *i == vs ) { instructions.erase( i ); if( isMasterSet && masterInstrIndex > idx ) --masterInstrIndex; return; } } MSQ_SETERR( err )( "Not found", MsqError::INVALID_ARG ); }
void InstructionQueue::remove_vertex_slaver | ( | VertexSlaver * | slaver, |
MsqError & | err | ||
) |
Remove a tool mark higher-order nodes as slaved. Note: Implies set_slaved_ho_node_mode( Settings::SLAVE_ALL )
Definition at line 77 of file InstructionQueue.cpp.
References instructions, MBMesquite::MsqError::INVALID_ARG, isMasterSet, masterInstrIndex, MSQ_SETERR, MBMesquite::Settings::set_slaved_ho_node_mode(), MBMesquite::Settings::SLAVE_ALL, and vertexSlaverCount.
Referenced by main(), and InstructionQueueTest::test_add_remove_vertex_slaver().
{ size_t idx = 0; for( std::list< Instruction* >::iterator i = instructions.begin(); i != instructions.end(); ++i, ++idx ) { if( *i == vs ) { instructions.erase( i ); if( isMasterSet && masterInstrIndex > idx ) --masterInstrIndex; if( --vertexSlaverCount == 0 ) set_slaved_ho_node_mode( Settings::SLAVE_ALL ); return; } } MSQ_SETERR( err )( "Not found", MsqError::INVALID_ARG ); }
void InstructionQueue::run_common | ( | MeshDomainAssoc * | mesh_and_domain, |
ParallelMesh * | pmesh, | ||
Settings * | settings, | ||
MsqError & | err | ||
) | [virtual] |
Exectute the instruction queue.
Execute all operations in the instruction queue.
mesh | The mesh to run each instruction on. |
domain | The domain of the mesh -- may be NULL if no domain. |
Implements MBMesquite::IQInterface.
Definition at line 295 of file InstructionQueue.cpp.
References MBMesquite::MeshDomainAssoc::get_domain(), MBMesquite::MeshDomainAssoc::get_mesh(), instructions, MBMesquite::MsqInterrupt::interrupt(), MBMesquite::MsqError::INTERRUPTED, MBMesquite::MsqError::INVALID_STATE, isMasterSet, mesh, MSQ_DBGOUT, MSQ_ERRRTN, MSQ_SETERR, nbPreConditionners, MBMesquite::Settings::trap_floating_point_exception(), and MBMesquite::version_string().
Referenced by ParShapeImprover::count_invalid_elements(), MBMesquite::PaverMinEdgeLengthWrapper::run_wrapper(), MBMesquite::SizeAdaptShapeWrapper::run_wrapper(), MBMesquite::ViscousCFDTetShapeWrapper::run_wrapper(), MBMesquite::ShapeImprover::run_wrapper(), MBMesquite::ShapeImprovementWrapper::run_wrapper(), MBMesquite::LaplaceWrapper::run_wrapper(), MBMesquite::UntangleWrapper::run_wrapper(), ParShapeImprover::ParShapeImprovementWrapper::run_wrapper(), and MBMesquite::DeformingDomainWrapper::run_wrapper().
{ MSQ_DBGOUT( 1 ) << version_string( false ) << "\n"; if( nbPreConditionners != 0 && isMasterSet == false ) { MSQ_SETERR( err ) ( "no pre-conditionners allowed if master QualityImprover " "is not set.", MsqError::INVALID_STATE ); return; } #ifdef ENABLE_INTERRUPT // Register SIGINT handler MsqInterrupt msq_interrupt; #endif Mesh* mesh = mesh_and_domain->get_mesh(); MeshDomain* domain = mesh_and_domain->get_domain(); // Generate SIGFPE on floating point errors MsqFPE fpe_trap( settings->trap_floating_point_exception() ); std::list< Instruction* >::const_iterator instr; // Initialize each instruction for( instr = instructions.begin(); instr != instructions.end(); ++instr ) { if( MsqInterrupt::interrupt() ) { MSQ_SETERR( err )( MsqError::INTERRUPTED ); return; } ( *instr )->initialize_queue( mesh_and_domain, settings, err );MSQ_ERRRTN( err ); } // Run each instruction for( instr = instructions.begin(); instr != instructions.end(); ++instr ) { if( MsqInterrupt::interrupt() ) { MSQ_SETERR( err )( MsqError::INTERRUPTED ); return; } if( pmesh ) { assert( !mesh || pmesh == mesh ); ( *instr )->loop_over_mesh( pmesh, domain, settings, err ); } else { ( *instr )->loop_over_mesh( mesh_and_domain, settings, err ); } MSQ_ERRRTN( err ); } }
void InstructionQueue::set_master_quality_improver | ( | QualityImprover * | instr, |
MsqError & | err | ||
) |
Definition at line 274 of file InstructionQueue.cpp.
References clear_master(), instructions, isMasterSet, masterInstrIndex, MSQ_DBGOUT, and MSQ_ERRRTN.
Referenced by BCDTest::compare_bcd(), create_instruction_queue(), do_smoother(), main(), run(), run_global_smoother(), run_local_smoother(), run_local_smoother2(), run_quality_optimizer(), run_smoother(), run_solution_mesh_optimizer(), run_test(), MBMesquite::PaverMinEdgeLengthWrapper::run_wrapper(), MBMesquite::SizeAdaptShapeWrapper::run_wrapper(), MBMesquite::ViscousCFDTetShapeWrapper::run_wrapper(), MBMesquite::ShapeImprover::run_wrapper(), MBMesquite::ShapeImprovementWrapper::run_wrapper(), MBMesquite::LaplaceWrapper::run_wrapper(), MBMesquite::UntangleWrapper::run_wrapper(), ParShapeImprover::ParShapeImprovementWrapper::run_wrapper(), MBMesquite::DeformingDomainWrapper::run_wrapper(), smooth_mesh(), smooth_mixed_mesh(), TerminationCriterionTest::test_abs_vtx_movement_culling(), SphericalGeometryTest::test_cg_mesh_cond_sphere(), SphericalGeometryTest::test_lapl_geo_sphere(), VertexCullingRegressionTest::test_laplacian_smoothing_with_cull(), PlanarGeometryTest::test_plane_quad_tangled(), PlanarGeometryTest::test_plane_tri_tangled(), PlanarGeometryTest::test_plane_tri_xz(), and SphericalGeometryTest::test_smart_lapl_sphere().
{ if( isMasterSet ) { MSQ_DBGOUT( 1 ) << "InstructionQueue::set_master_quality_improver():\n" << "\tOverwriting previously specified master quality improver.\n"; // if master is already set, clears it and insert the new one at the same position. std::list< Instruction* >::iterator master_pos; master_pos = this->clear_master( err );MSQ_ERRRTN( err ); instructions.insert( master_pos, instr ); isMasterSet = true; } else { // if master is not set, add it at the end of the queue. instructions.push_back( instr ); isMasterSet = true; masterInstrIndex = instructions.size() - 1; } }
bool MBMesquite::InstructionQueue::autoQualAssess [private] |
Definition at line 153 of file InstructionQueue.hpp.
Referenced by clear(), disable_automatic_quality_assessment(), and enable_automatic_quality_assessment().
std::list< Instruction* > MBMesquite::InstructionQueue::instructions [private] |
Definition at line 151 of file InstructionQueue.hpp.
Referenced by add_preconditioner(), add_quality_assessor(), add_tag_vertex_mesh(), add_target_calculator(), add_vertex_slaver(), clear(), clear_master(), insert_preconditioner(), insert_quality_assessor(), remove_preconditioner(), remove_quality_assessor(), remove_tag_vertex_mesh(), remove_vertex_slaver(), run_common(), and set_master_quality_improver().
bool MBMesquite::InstructionQueue::isMasterSet [private] |
Definition at line 157 of file InstructionQueue.hpp.
Referenced by add_preconditioner(), add_tag_vertex_mesh(), add_vertex_slaver(), clear(), clear_master(), insert_preconditioner(), remove_preconditioner(), remove_tag_vertex_mesh(), remove_vertex_slaver(), run_common(), and set_master_quality_improver().
size_t MBMesquite::InstructionQueue::masterInstrIndex [private] |
0-based. Keeping an index instead of an iterator in case list is reallocated
Definition at line 158 of file InstructionQueue.hpp.
Referenced by add_tag_vertex_mesh(), add_vertex_slaver(), clear(), clear_master(), insert_preconditioner(), remove_preconditioner(), remove_tag_vertex_mesh(), remove_vertex_slaver(), and set_master_quality_improver().
size_t MBMesquite::InstructionQueue::nbPreConditionners [private] |
Definition at line 156 of file InstructionQueue.hpp.
Referenced by add_preconditioner(), insert_preconditioner(), remove_preconditioner(), and run_common().
int MBMesquite::InstructionQueue::vertexSlaverCount [private] |
Definition at line 155 of file InstructionQueue.hpp.
Referenced by add_vertex_slaver(), and remove_vertex_slaver().