LCOV - code coverage report
Current view: top level - src/moab - ReorderTool.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1 1 100.0 %
Date: 2020-12-16 07:07:30 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       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                 :          2 :     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, int vals_per_ent, Tag ordering_tag,
      73                 :            :                                          int ordering_tag_skip_value, Tag new_handle_tag );
      74                 :            : 
      75                 :            :     /**\brief Calculate new handle order by set containment
      76                 :            :      *
      77                 :            :      * Given a list of sets, re-order entities such that handles are
      78                 :            :      * grouped contiguously by set.  Will also group all adjacent mesh
      79                 :            :      * entities, such that entities that are are adjacent to members of
      80                 :            :      * two or more of the input sets will ge grouped by the combined
      81                 :            :      * list of sets (e.g. if the input sets contain elements then all
      82                 :            :      * vertices that are adjacent to only elements in the first two sets
      83                 :            :      * will be grouped together).
      84                 :            :      *
      85                 :            :      *\param sets          Entity sets by which to group entities.
      86                 :            :      *\param new_handle_tag_out  Passed back new tag handle containing the
      87                 :            :      *                     entity mapping.  The returned tag will be anonymous.
      88                 :            :      *                     The caller is responsible for releasing the tag.
      89                 :            :      *                     The value of this tag on each handle is the new
      90                 :            :      *                     handle that the entity will will be moved to. The
      91                 :            :      *                     tag value will be zero for entities that were not
      92                 :            :      *                     re-ordered.
      93                 :            :      */
      94                 :            :     ErrorCode handle_order_from_sets_and_adj( const Range& sets, Tag& new_handle_tag_out );
      95                 :            : 
      96                 :            :     /**\brief Do the re-ordering indicated by the passed handle tag.
      97                 :            :      *
      98                 :            :      * The specified re-ordering must be a permutation.  Each existing
      99                 :            :      * entity must be moved to a new, existing handle such that no
     100                 :            :      * two entities are moved to the same new handle.
     101                 :            :      *
     102                 :            :      * Given a tag storing handles that define a permution, apply the
     103                 :            :      * described re-ordering.  The passed tag must contain one entity
     104                 :            :      * handle per entity.  The value of the tag must be zero for all
     105                 :            :      * entities that are not to be re-ordered.  For entities to be
     106                 :            :      * re-ordered, the tag must contain the new handle that the entity
     107                 :            :      * is to be moved to.  No two entities may have the same value for
     108                 :            :      * this tag (other than a value of zero.)
     109                 :            :      *
     110                 :            :      *\param new_handle_tag Tag containing new handles for entities to
     111                 :            :      *                      reorder.  Typically the output of
     112                 :            :      *                      handle_order_from_int_tag or similar.
     113                 :            :      */
     114                 :            :     ErrorCode reorder_entities( Tag new_handle_tag );
     115                 :            : 
     116                 :            :   private:
     117                 :            :     /**\brief helper function for reorder_entities
     118                 :            :      *
     119                 :            :      * Reorder tag data for all entities of specified type.
     120                 :            :      *
     121                 :            :      * Also updates tag values for MB_TYPE_HANDLE tags.
     122                 :            :      *\param type  Entity type to reorder
     123                 :            :      *\param new_handles Tag containing old->new handle mapping
     124                 :            :      *\param reorder_tag The tag data to reorder
     125                 :            :      */
     126                 :            :     ErrorCode reorder_tag_data( EntityType type, Tag new_handles, Tag reorder_tag );
     127                 :            : 
     128                 :            :     /**\brief helper function for reorder_entities
     129                 :            :      *
     130                 :            :      * Update set contents for changed handles.
     131                 :            :      *\param new_handles Tag containing old->new handle mapping
     132                 :            :      */
     133                 :            :     ErrorCode update_set_contents( Tag new_handles );
     134                 :            : 
     135                 :            :     /**\brief Get all entities of specified type and size
     136                 :            :      *\param t the type of entity to retreive
     137                 :            :      *\param vals_per_ent entity size (connectivity length for elements,
     138                 :            :      *         dimension for vertices)
     139                 :            :      */
     140                 :            :     void get_entities( EntityType t, int vals_per_ent, Range& result );
     141                 :            : 
     142                 :            :     /**\brief Get new handles corresponding to old handles
     143                 :            :      *\param tag Tag containing old->new mapping
     144                 :            :      */
     145                 :            :     ErrorCode get_reordered_handles( Tag tag, const Range& old_handles, std::vector< EntityHandle >& new_handles );
     146                 :            : 
     147                 :            :     /**\brief Get new handles corresponding to old handles
     148                 :            :      *\param tag Tag containing old->new mapping
     149                 :            :      */
     150                 :            :     ErrorCode get_reordered_handles( Tag tag, const std::vector< EntityHandle >& old_handles,
     151                 :            :                                      std::vector< EntityHandle >& new_handles );
     152                 :            : 
     153                 :            :     /**\brief Get new handles corresponding to old handles
     154                 :            :      *\param tag Tag containing old->new mapping
     155                 :            :      */
     156                 :            :     ErrorCode get_reordered_handles( Tag tag, const EntityHandle* old_handles, EntityHandle* new_handles,
     157                 :            :                                      size_t num_handles );
     158                 :            : 
     159                 :            :     /**\brief Remove any non-ordered handles and return new handles for remaining
     160                 :            :      *\param tag Tag containing old->new mapping
     161                 :            :      */
     162                 :            :     ErrorCode get_new_handles( Tag tag, Range& old_handles, std::vector< EntityHandle >& newhandles );
     163                 :            : 
     164                 :            :     /**\brief convert from input for \c handle_order_from_sets_and_adj to
     165                 :            :      *        \c input for handle_order_from_int_tag
     166                 :            :      */
     167                 :            :     ErrorCode int_order_from_sets_and_adj( const Range& sets, Tag order_tag, int skip_val,
     168                 :            :                                            std::vector< std::vector< EntityHandle >* >& data );
     169                 :            : 
     170                 :            :     Core* mMB;
     171                 :            : };
     172                 :            : 
     173                 :            : }  // namespace moab
     174                 :            : 
     175                 :            : #endif  // moab_REORDER_TOOL_HPP

Generated by: LCOV version 1.11