#include <ReorderTool.hpp>
Public Member Functions | |
ReorderTool (Core *moab) | |
ErrorCode | handle_order_from_int_tag (Tag ordering_tag, int ordering_tag_skip_value, Tag &new_handle_tag_out) |
Calculate new handle order by tag value. More... | |
ErrorCode | handle_order_from_int_tag (EntityType type, int vals_per_ent, Tag ordering_tag, int ordering_tag_skip_value, Tag new_handle_tag) |
Calculate new handle order by tag value. More... | |
ErrorCode | handle_order_from_sets_and_adj (const Range &sets, Tag &new_handle_tag_out) |
Calculate new handle order by set containment. More... | |
ErrorCode | reorder_entities (Tag new_handle_tag) |
Do the re-ordering indicated by the passed handle tag. More... | |
Private Member Functions | |
ErrorCode | reorder_tag_data (EntityType type, Tag new_handles, Tag reorder_tag) |
helper function for reorder_entities More... | |
ErrorCode | update_set_contents (Tag new_handles) |
helper function for reorder_entities More... | |
void | get_entities (EntityType t, int vals_per_ent, Range &result) |
Get all entities of specified type and size. More... | |
ErrorCode | get_reordered_handles (Tag tag, const Range &old_handles, std::vector< EntityHandle > &new_handles) |
Get new handles corresponding to old handles. More... | |
ErrorCode | get_reordered_handles (Tag tag, const std::vector< EntityHandle > &old_handles, std::vector< EntityHandle > &new_handles) |
Get new handles corresponding to old handles. More... | |
ErrorCode | get_reordered_handles (Tag tag, const EntityHandle *old_handles, EntityHandle *new_handles, size_t num_handles) |
Get new handles corresponding to old handles. More... | |
ErrorCode | get_new_handles (Tag tag, Range &old_handles, std::vector< EntityHandle > &newhandles) |
Remove any non-ordered handles and return new handles for remaining. More... | |
ErrorCode | int_order_from_sets_and_adj (const Range &sets, Tag order_tag, int skip_val, std::vector< std::vector< EntityHandle > * > &data) |
convert from input for handle_order_from_sets_and_adj to input for handle_order_from_int_tag More... | |
Private Attributes | |
Core * | mMB |
Definition at line 18 of file ReorderTool.hpp.
|
inline |
Definition at line 21 of file ReorderTool.hpp.
|
private |
Get all entities of specified type and size.
t | the type of entity to retreive |
vals_per_ent | entity size (connectivity length for elements, dimension for vertices) |
Definition at line 101 of file ReorderTool.cpp.
References moab::TypeSequenceManager::begin(), moab::TypeSequenceManager::end(), moab::EntitySequence::end_handle(), entities, moab::SequenceManager::entity_map(), mMB, moab::Core::sequence_manager(), moab::EntitySequence::start_handle(), and moab::EntitySequence::values_per_entity().
Referenced by handle_order_from_int_tag(), and reorder_entities().
|
private |
Remove any non-ordered handles and return new handles for remaining.
tag | Tag containing old->new mapping |
Definition at line 372 of file ReorderTool.cpp.
References moab::Range::begin(), CHKERR, moab::Range::erase(), ErrorCode, MB_SUCCESS, mMB, moab::Range::size(), and moab::Core::tag_get_data().
Referenced by reorder_tag_data(), and update_set_contents().
|
private |
Get new handles corresponding to old handles.
tag | Tag containing old->new mapping |
Definition at line 359 of file ReorderTool.cpp.
References CHKERR, ErrorCode, MB_SUCCESS, mMB, and moab::Core::tag_get_data().
|
private |
Get new handles corresponding to old handles.
tag | Tag containing old->new mapping |
Definition at line 336 of file ReorderTool.cpp.
References moab::Range::begin(), CHKERR, moab::Range::end(), ErrorCode, MB_SUCCESS, mMB, moab::Range::size(), and moab::Core::tag_get_data().
Referenced by get_reordered_handles(), reorder_entities(), reorder_tag_data(), and update_set_contents().
|
private |
Get new handles corresponding to old handles.
tag | Tag containing old->new mapping |
Definition at line 351 of file ReorderTool.cpp.
References get_reordered_handles().
ErrorCode moab::ReorderTool::handle_order_from_int_tag | ( | EntityType | type, |
int | vals_per_ent, | ||
Tag | ordering_tag, | ||
int | ordering_tag_skip_value, | ||
Tag | new_handle_tag | ||
) |
Calculate new handle order by tag value.
Given a tag containing integer values, calculate new order for entities in the database (except entity sets) such that all entities with tag value A occur before all entities with tag value B in the handle space where A < B. Ordering will be stable for entities with the same tag value.
type | Entity type for which to calculate re-ordering. |
vals_per_ent | Zero for vertices. Connectivity length for elements. |
ordering_tag | Sinlge integer tag, where value on each entity determines the new position in the handle ordering. Entities may have duplicate values. |
ordering_tag_skip_value | Do not reorder entities with this tag value. This is typically the default value of ordering_tag. Specifying this limits the re-ordering to only those entities for which ordering_tag has been set. |
new_handle_tag | Tag into which to store new handle for each entity. Tag must be defined to store a single entity handle and must have a default value of zero. |
Definition at line 115 of file ReorderTool.cpp.
References moab::check_tag_type(), CHKERR, entities, ErrorCode, get_entities(), MB_SUCCESS, MB_TYPE_HANDLE, MB_TYPE_INTEGER, mMB, moab::Core::tag_get_data(), and moab::Core::tag_set_data().
ErrorCode moab::ReorderTool::handle_order_from_int_tag | ( | Tag | ordering_tag, |
int | ordering_tag_skip_value, | ||
Tag & | new_handle_tag_out | ||
) |
Calculate new handle order by tag value.
Given a tag containing integer values, calculate new order for entities in the database (except entity sets) such that all entities with tag value A occur before all entities with tag value B in the handle space where A < B. Ordering will be stable for entities with the same tag value.
ordering_tag | Sinlge integer tag, where value on each entity determines the new position in the handle ordering. Entities may have duplicate values. |
ordering_tag_skip_value | Do not reorder entities with this tag value. This is typically the default value of ordering_tag. Specifying this limits the re-ordering to only those entities for which ordering_tag has been set. |
new_handle_tag_out | Passed back new tag handle containing the entity mapping. The returned tag will be anonymous. The caller is responsible for releasing the tag. The value of this tag on each handle is the new handle that the entity will will be moved to. The tag value will be zero for entities that were not re-ordered. |
Definition at line 59 of file ReorderTool.cpp.
References moab::TypeSequenceManager::begin(), moab::check_tag_type(), CHKERR, moab::TypeSequenceManager::end(), moab::SequenceManager::entity_map(), moab::error(), ErrorCode, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TAG_EXCL, MB_TYPE_HANDLE, MB_TYPE_INTEGER, MBENTITYSET, MBVERTEX, mMB, moab::Core::sequence_manager(), moab::Core::tag_delete(), moab::Core::tag_get_handle(), and moab::EntitySequence::values_per_entity().
Referenced by handle_order_from_sets_and_adj(), and main().
ErrorCode moab::ReorderTool::handle_order_from_sets_and_adj | ( | const Range & | sets, |
Tag & | new_handle_tag_out | ||
) |
Calculate new handle order by set containment.
Given a list of sets, re-order entities such that handles are grouped contiguously by set. Will also group all adjacent mesh entities, such that entities that are are adjacent to members of two or more of the input sets will ge grouped by the combined list of sets (e.g. if the input sets contain elements then all vertices that are adjacent to only elements in the first two sets will be grouped together).
sets | Entity sets by which to group entities. |
new_handle_tag_out | Passed back new tag handle containing the entity mapping. The returned tag will be anonymous. The caller is responsible for releasing the tag. The value of this tag on each handle is the new handle that the entity will will be moved to. The tag value will be zero for entities that were not re-ordered. |
Definition at line 193 of file ReorderTool.cpp.
References moab::Range::all_of_type(), moab::error(), ErrorCode, handle_order_from_int_tag(), int_order_from_sets_and_adj(), MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TAG_EXCL, MB_TYPE_INTEGER, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, mMB, moab::Core::tag_delete(), and moab::Core::tag_get_handle().
Referenced by main().
|
private |
convert from input for handle_order_from_sets_and_adj
to input
for handle_order_from_int_tag
Definition at line 249 of file ReorderTool.cpp.
References moab::Range::all_of_type(), moab::Range::begin(), moab::check_tag_type(), CHKERR, moab::Range::clear(), dim, moab::Range::end(), ErrorCode, moab::Core::get_adjacencies(), moab::Core::get_entities_by_dimension(), MB_SUCCESS, MB_TYPE_INTEGER, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, moab::Range::merge(), mMB, moab::Core::tag_get_data(), moab::Core::tag_set_data(), and moab::Interface::UNION.
Referenced by handle_order_from_sets_and_adj().
Do the re-ordering indicated by the passed handle tag.
The specified re-ordering must be a permutation. Each existing entity must be moved to a new, existing handle such that no two entities are moved to the same new handle.
Given a tag storing handles that define a permution, apply the described re-ordering. The passed tag must contain one entity handle per entity. The value of the tag must be zero for all entities that are not to be re-ordered. For entities to be re-ordered, the tag must contain the new handle that the entity is to be moved to. No two entities may have the same value for this tag (other than a value of zero.)
new_handle_tag | Tag containing new handles for entities to reorder. Typically the output of handle_order_from_int_tag or similar. |
Definition at line 399 of file ReorderTool.cpp.
References moab::TypeSequenceManager::begin(), moab::check_tag_type(), CHKERR, moab::TypeSequenceManager::end(), entities, moab::SequenceManager::entity_map(), moab::error(), ErrorCode, moab::Core::get_connectivity(), moab::Core::get_coords(), get_entities(), get_reordered_handles(), MB_INDEX_OUT_OF_RANGE, MB_SUCCESS, MB_TYPE_HANDLE, MBENTITYSET, MBVERTEX, mMB, reorder_tag_data(), moab::Core::sequence_manager(), moab::Core::set_connectivity(), moab::Core::set_coords(), moab::Core::tag_get_default_value(), moab::Core::tag_get_tags(), UNRECOVERABLE, update_set_contents(), and moab::EntitySequence::values_per_entity().
Referenced by main().
|
private |
helper function for reorder_entities
Reorder tag data for all entities of specified type.
Also updates tag values for MB_TYPE_HANDLE tags.
type | Entity type to reorder |
new_handles | Tag containing old->new handle mapping |
reorder_tag | The tag data to reorder |
Definition at line 487 of file ReorderTool.cpp.
References moab::Range::begin(), buffer, CHKERR, moab::Range::empty(), moab::Range::end(), moab::Range::erase(), moab::error(), ErrorCode, moab::Core::get_entities_by_type_and_tag(), get_new_handles(), get_reordered_handles(), MB_SUCCESS, MB_TYPE_BIT, MB_TYPE_DOUBLE, MB_TYPE_HANDLE, MB_TYPE_INTEGER, MB_TYPE_OPAQUE, MB_TYPE_OUT_OF_RANGE, MB_VARIABLE_DATA_LENGTH, MBENTITYSET, mMB, moab::Range::size(), sizes, moab::Core::tag_delete_data(), moab::Core::tag_get_by_ptr(), moab::Core::tag_get_bytes(), moab::Core::tag_get_data(), moab::Core::tag_get_data_type(), moab::Core::tag_set_by_ptr(), and moab::Core::tag_set_data().
Referenced by reorder_entities().
helper function for reorder_entities
Update set contents for changed handles.
new_handles | Tag containing old->new handle mapping |
Definition at line 633 of file ReorderTool.cpp.
References moab::Core::add_entities(), moab::Range::begin(), CHKERR, moab::Core::clear_meshset(), moab::Range::empty(), moab::Range::end(), ErrorCode, moab::Core::get_entities_by_handle(), moab::Core::get_entities_by_type(), moab::Core::get_meshset_options(), get_new_handles(), get_reordered_handles(), moab::Range::insert(), moab::intersect(), MB_SUCCESS, MBENTITYSET, mMB, moab::Core::remove_entities(), and moab::Range::size().
Referenced by reorder_entities().
|
private |
Definition at line 178 of file ReorderTool.hpp.
Referenced by get_entities(), get_new_handles(), get_reordered_handles(), handle_order_from_int_tag(), handle_order_from_sets_and_adj(), int_order_from_sets_and_adj(), reorder_entities(), reorder_tag_data(), and update_set_contents().