Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ReorderTool.hpp
Go to the documentation of this file.
1 /** \file ReorderTool.hpp 2  * \author Jason Kraftcheck 3  * \date 2011-05-23 4  */ 5  6 #ifndef moab_REORDER_TOOL_HPP 7 #define moab_REORDER_TOOL_HPP 8  9 #include "moab/Types.hpp" 10 #include <vector> 11  12 namespace moab 13 { 14  15 class Core; 16 class Range; 17  18 class ReorderTool 19 { 20  public: 21  ReorderTool( Core* moab ) : mMB( moab ) {} 22  23  /**\brief Calculate new handle order by tag value. 24  * 25  * Given a tag containing integer values, calculate new order for entities 26  * in the database (except entity sets) such that all entities 27  * with tag value A occur before all entities with tag value B 28  * in the handle space where A < B. Ordering will be stable for 29  * entities with the same tag value. 30  * 31  *\param ordering_tag Sinlge integer tag, where value on each entity 32  * determines the new position in the handle ordering. 33  * Entities may have duplicate values. 34  *\param ordering_tag_skip_value Do not reorder entities with this tag 35  * value. This is typically the default value of 36  * ordering_tag. Specifying this limits the re-ordering 37  * to only those entities for which ordering_tag has 38  * been set. 39  *\param new_handle_tag_out Passed back new tag handle containing the 40  * entity mapping. The returned tag will be anonymous. 41  * The caller is responsible for releasing the tag. 42  * The value of this tag on each handle is the new 43  * handle that the entity will will be moved to. The 44  * tag value will be zero for entities that were not 45  * re-ordered. 46  */ 47  ErrorCode handle_order_from_int_tag( Tag ordering_tag, int ordering_tag_skip_value, Tag& new_handle_tag_out ); 48  49  /**\brief Calculate new handle order by tag value. 50  * 51  * Given a tag containing integer values, calculate new order for entities 52  * in the database (except entity sets) such that all entities 53  * with tag value A occur before all entities with tag value B 54  * in the handle space where A < B. Ordering will be stable for 55  * entities with the same tag value. 56  * 57  *\param type Entity type for which to calculate re-ordering. 58  *\param vals_per_ent Zero for vertices. Connectivity length for elements. 59  *\param ordering_tag Sinlge integer tag, where value on each entity 60  * determines the new position in the handle ordering. 61  * Entities may have duplicate values. 62  *\param ordering_tag_skip_value Do not reorder entities with this tag 63  * value. This is typically the default value of 64  * ordering_tag. Specifying this limits the re-ordering 65  * to only those entities for which ordering_tag has 66  * been set. 67  *\param new_handle_tag Tag into which to store new handle for each 68  * entity. Tag must be defined to store a single 69  * entity handle and must have a default value of 70  * zero. 71  */ 72  ErrorCode handle_order_from_int_tag( EntityType type, 73  int vals_per_ent, 74  Tag ordering_tag, 75  int ordering_tag_skip_value, 76  Tag new_handle_tag ); 77  78  /**\brief Calculate new handle order by set containment 79  * 80  * Given a list of sets, re-order entities such that handles are 81  * grouped contiguously by set. Will also group all adjacent mesh 82  * entities, such that entities that are are adjacent to members of 83  * two or more of the input sets will ge grouped by the combined 84  * list of sets (e.g. if the input sets contain elements then all 85  * vertices that are adjacent to only elements in the first two sets 86  * will be grouped together). 87  * 88  *\param sets Entity sets by which to group entities. 89  *\param new_handle_tag_out Passed back new tag handle containing the 90  * entity mapping. The returned tag will be anonymous. 91  * The caller is responsible for releasing the tag. 92  * The value of this tag on each handle is the new 93  * handle that the entity will will be moved to. The 94  * tag value will be zero for entities that were not 95  * re-ordered. 96  */ 97  ErrorCode handle_order_from_sets_and_adj( const Range& sets, Tag& new_handle_tag_out ); 98  99  /**\brief Do the re-ordering indicated by the passed handle tag. 100  * 101  * The specified re-ordering must be a permutation. Each existing 102  * entity must be moved to a new, existing handle such that no 103  * two entities are moved to the same new handle. 104  * 105  * Given a tag storing handles that define a permution, apply the 106  * described re-ordering. The passed tag must contain one entity 107  * handle per entity. The value of the tag must be zero for all 108  * entities that are not to be re-ordered. For entities to be 109  * re-ordered, the tag must contain the new handle that the entity 110  * is to be moved to. No two entities may have the same value for 111  * this tag (other than a value of zero.) 112  * 113  *\param new_handle_tag Tag containing new handles for entities to 114  * reorder. Typically the output of 115  * handle_order_from_int_tag or similar. 116  */ 117  ErrorCode reorder_entities( Tag new_handle_tag ); 118  119  private: 120  /**\brief helper function for reorder_entities 121  * 122  * Reorder tag data for all entities of specified type. 123  * 124  * Also updates tag values for MB_TYPE_HANDLE tags. 125  *\param type Entity type to reorder 126  *\param new_handles Tag containing old->new handle mapping 127  *\param reorder_tag The tag data to reorder 128  */ 129  ErrorCode reorder_tag_data( EntityType type, Tag new_handles, Tag reorder_tag ); 130  131  /**\brief helper function for reorder_entities 132  * 133  * Update set contents for changed handles. 134  *\param new_handles Tag containing old->new handle mapping 135  */ 136  ErrorCode update_set_contents( Tag new_handles ); 137  138  /**\brief Get all entities of specified type and size 139  *\param t the type of entity to retreive 140  *\param vals_per_ent entity size (connectivity length for elements, 141  * dimension for vertices) 142  */ 143  void get_entities( EntityType t, int vals_per_ent, Range& result ); 144  145  /**\brief Get new handles corresponding to old handles 146  *\param tag Tag containing old->new mapping 147  */ 148  ErrorCode get_reordered_handles( Tag tag, const Range& old_handles, std::vector< EntityHandle >& new_handles ); 149  150  /**\brief Get new handles corresponding to old handles 151  *\param tag Tag containing old->new mapping 152  */ 153  ErrorCode get_reordered_handles( Tag tag, 154  const std::vector< EntityHandle >& old_handles, 155  std::vector< EntityHandle >& new_handles ); 156  157  /**\brief Get new handles corresponding to old handles 158  *\param tag Tag containing old->new mapping 159  */ 160  ErrorCode get_reordered_handles( Tag tag, 161  const EntityHandle* old_handles, 162  EntityHandle* new_handles, 163  size_t num_handles ); 164  165  /**\brief Remove any non-ordered handles and return new handles for remaining 166  *\param tag Tag containing old->new mapping 167  */ 168  ErrorCode get_new_handles( Tag tag, Range& old_handles, std::vector< EntityHandle >& newhandles ); 169  170  /**\brief convert from input for \c handle_order_from_sets_and_adj to 171  * \c input for handle_order_from_int_tag 172  */ 173  ErrorCode int_order_from_sets_and_adj( const Range& sets, 174  Tag order_tag, 175  int skip_val, 176  std::vector< std::vector< EntityHandle >* >& data ); 177  178  Core* mMB; 179 }; 180  181 } // namespace moab 182  183 #endif // moab_REORDER_TOOL_HPP