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

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
       3                 :            :  * storing and accessing finite element mesh data.
       4                 :            :  *
       5                 :            :  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
       6                 :            :  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
       7                 :            :  * retains certain rights in this software.
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  */
      15                 :            : 
      16                 :            : #ifndef AENTITY_FACTORY_HPP
      17                 :            : #define AENTITY_FACTORY_HPP
      18                 :            : 
      19                 :            : #ifndef IS_BUILDING_MB
      20                 :            : #error "AEntityFactory.hpp isn't supposed to be included into an application"
      21                 :            : #endif
      22                 :            : 
      23                 :            : #include "moab/Forward.hpp"
      24                 :            : #include <vector>
      25                 :            : 
      26                 :            : namespace moab
      27                 :            : {
      28                 :            : 
      29                 :            : typedef std::vector< EntityHandle > AdjacencyVector;
      30                 :            : class Core;
      31                 :            : 
      32                 :            : //! class AEntityFactory
      33                 :            : class AEntityFactory
      34                 :            : {
      35                 :            :   public:
      36                 :            :     //! require an Interface object in order to access tags on that interface
      37                 :            :     AEntityFactory( Core* mdb );
      38                 :            : 
      39                 :            :     //! destructor
      40                 :            :     ~AEntityFactory();
      41                 :            : 
      42                 :            :     //! add an adjacency from from_ent to to_ent; if both_ways is true, add one
      43                 :            :     //! in reverse too
      44                 :            :     //! NOTE: this function is defined even though we may only be implementing
      45                 :            :     //! vertex-based up-adjacencies
      46                 :            :     ErrorCode add_adjacency( EntityHandle from_ent, EntityHandle to_ent, const bool both_ways = false );
      47                 :            : 
      48                 :            :     //! remove an adjacency from from the base_entity.
      49                 :            :     ErrorCode remove_adjacency( EntityHandle base_entity, EntityHandle adjacency_to_remove );
      50                 :            : 
      51                 :            :     //! remove all adjacencies from from the base_entity.
      52                 :            :     ErrorCode remove_all_adjacencies( EntityHandle base_entity, const bool delete_adj_list = false );
      53                 :            : 
      54                 :            :     /**\brief Get adjacencies for a single source entity.
      55                 :            :      *
      56                 :            :      * Get adjacent entities.
      57                 :            :      *
      58                 :            :      *\param source_entity    The entity for which to retrieve the adjacencies.
      59                 :            :      *\param target_dimension Retrieve adjacent entities of this dimension.  Must
      60                 :            :      *                        be in the range [1,3], where 4 is used to indicated entity sets.
      61                 :            :      *\param target_entities  Requested adjacent entities will be appended to this list.
      62                 :            :      *\param create_if_missing If true, adjacent elements of the specified dimension will
      63                 :            :      *                        be created if they do not already exist.  If the target dimension
      64                 :            :      *                        is less than the dimension of the input entity and greater than zero,
      65                 :            :      *the elements will be created as required to represent the "sides" of the source element.  If
      66                 :            :      *the target dimension is greater than that of the source entity and less than 3, then sides of
      67                 :            :      *the specified dimension on that are a) of greater dimension and b) adjacent to the input
      68                 :            :      *entity will be created. \param create_adjacency_option If create_adjacency_option is >= 0,
      69                 :            :      *adjacencies from entities of that dimension to each target_entity are created (this function
      70                 :            :      *uses AEntityFactory::get_element for each element)
      71                 :            :      */
      72                 :            :     ErrorCode get_elements( EntityHandle source_entity, const unsigned int target_dimension,
      73                 :            :                             std::vector< EntityHandle >& target_entities, const bool create_if_missing,
      74                 :            :                             const int create_adjacency_option = -1 );
      75                 :            : 
      76                 :            :     //! get the vertices for a polyhedron (special implementation because for polyhedra
      77                 :            :     //! connectivity array stores faces)
      78                 :            :     ErrorCode get_polyhedron_vertices( const EntityHandle source_entity, std::vector< EntityHandle >& target_entities );
      79                 :            : 
      80                 :            :     //! get the meshsets that are in source_entitiy's adjacency vector
      81                 :            :     ErrorCode get_associated_meshsets( EntityHandle source_entity, std::vector< EntityHandle >& target_entities );
      82                 :            : 
      83                 :            :     //! get the element defined by the vertices in vertex_list, of the
      84                 :            :     //! type target_type, passing back in target_entity; if create_if_missing
      85                 :            :     //! is true and no entity is found, one is created; if create_adjacency_option
      86                 :            :     //! is >= 0, adjacencies from entities of that dimension to target_entity
      87                 :            :     //! are created (only create_adjacency_option=0 is supported right now,
      88                 :            :     //! so that never creates other ancillary entities); explicitly require
      89                 :            :     //! the vertex_list_size for consistency, even though we could probably get
      90                 :            :     //! it from target_type
      91                 :            :     ErrorCode get_element( const EntityHandle* vertex_list, const int vertex_list_size, const EntityType target_type,
      92                 :            :                            EntityHandle& target_entity, const bool create_if_missing,
      93                 :            :                            const EntityHandle source_entity = 0, const int create_adjacency_option = -1 );
      94                 :            : 
      95                 :            :     /**\brief Get adjacent entities
      96                 :            :      *
      97                 :            :      *\param entity            The source entity for which to retrieve adjacent entities.
      98                 :            :      *\param to_dimension      The adjacent entities to retrieve, specified by dimension.
      99                 :            :      *\param create_if_missing Create adjacent entities that do not already exist.
     100                 :            :      *\param adjacent_entities The resulting adjacent entities are appended to this
     101                 :            :      *                         list.
     102                 :            :      */
     103                 :            :     ErrorCode get_adjacencies( const EntityHandle entity, const unsigned int to_dimension, bool create_if_missing,
     104                 :            :                                std::vector< EntityHandle >& adjacent_entities );
     105                 :            : 
     106                 :            :     //! return const array * for adjacencies
     107                 :            :     ErrorCode get_adjacencies( EntityHandle entity, const EntityHandle*& adjacent_entities, int& num_entities ) const;
     108                 :            : 
     109                 :            :     ErrorCode get_adjacencies( EntityHandle entity, std::vector< EntityHandle >*& adj_vec_ptr_out,
     110                 :            :                                bool create_if_missing = false );
     111                 :            : 
     112                 :            :     //! returns the entities in sorted order
     113                 :            :     ErrorCode get_adjacencies( EntityHandle entity, std::vector< EntityHandle >& adjacent_entities ) const;
     114                 :            : 
     115                 :            :     //! creates vertex to element adjacency information
     116                 :            :     ErrorCode create_vert_elem_adjacencies();
     117                 :            : 
     118                 :            :     //! returns whether vertex to element adjacencies are being stored
     119                 :     501751 :     bool vert_elem_adjacencies() const
     120                 :            :     {
     121                 :     501751 :         return mVertElemAdj;
     122                 :            :     }
     123                 :            : 
     124                 :            :     //! calling code notifying this that an entity is getting deleted
     125                 :            :     ErrorCode notify_delete_entity( EntityHandle entity );
     126                 :            : 
     127                 :            :     //! calling code notifying this that to update connectivity of 'entity'
     128                 :            :     ErrorCode notify_create_entity( const EntityHandle entity, const EntityHandle* node_array, const int number_nodes );
     129                 :            : 
     130                 :            :     //! calling code notifying that an entity changed its connectivity
     131                 :            :     ErrorCode notify_change_connectivity( EntityHandle entity, const EntityHandle* old_array,
     132                 :            :                                           const EntityHandle* new_array, int number_nodes );
     133                 :            : 
     134                 :            :     //! return true if 2 entities are explicitly adjacent
     135                 :            :     bool explicitly_adjacent( const EntityHandle ent1, const EntityHandle ent2 );
     136                 :            : 
     137                 :            :     //! in preparation for merging two entities, adjust adjacencies so that
     138                 :            :     //! entity_to_keep will be adjacent to the "right" entities after merge
     139                 :            :     //! (also checks for potential formation of equivalent entities and
     140                 :            :     //! creates explicit adjacencies accordingly)
     141                 :            :     ErrorCode merge_adjust_adjacencies( EntityHandle entity_to_keep, EntityHandle entity_to_remove );
     142                 :            : 
     143                 :            :     void get_memory_use( unsigned long long& total_entity_storage, unsigned long long& total_storage );
     144                 :            :     ErrorCode get_memory_use( const Range& entities, unsigned long long& total_entity_storage,
     145                 :            :                               unsigned long long& total_amortized_storage );
     146                 :            : 
     147                 :            :   private:
     148                 :            :     ErrorCode get_adjacency_ptr( EntityHandle, std::vector< EntityHandle >*& );
     149                 :            :     ErrorCode get_adjacency_ptr( EntityHandle, const std::vector< EntityHandle >*& ) const;
     150                 :            :     ErrorCode set_adjacency_ptr( EntityHandle, std::vector< EntityHandle >* );
     151                 :            : 
     152                 :            :     ErrorCode get_vertices( EntityHandle h, const EntityHandle*& vect_out, int& count_out,
     153                 :            :                             std::vector< EntityHandle >& storage );
     154                 :            : 
     155                 :            :     //! private constructor to prevent the construction of a default one
     156                 :            :     AEntityFactory();
     157                 :            : 
     158                 :            :     //! interface associated with this tool
     159                 :            :     Core* thisMB;
     160                 :            : 
     161                 :            :     //! whether vertex to element adjacencies are begin done
     162                 :            :     bool mVertElemAdj;
     163                 :            : 
     164                 :            :     //! compare vertex_list to the vertices in this_entity,
     165                 :            :     //!  and return true if they contain the same vertices
     166                 :            :     bool entities_equivalent( const EntityHandle this_entity, const EntityHandle* vertex_list,
     167                 :            :                               const int vertex_list_size, const EntityType target_type );
     168                 :            : 
     169                 :            :     ErrorCode get_zero_to_n_elements( EntityHandle source_entity, const unsigned int target_dimension,
     170                 :            :                                       std::vector< EntityHandle >& target_entities, const bool create_if_missing,
     171                 :            :                                       const int create_adjacency_option = -1 );
     172                 :            : 
     173                 :            :     ErrorCode get_down_adjacency_elements( EntityHandle source_entity, const unsigned int target_dimension,
     174                 :            :                                            std::vector< EntityHandle >& target_entities, const bool create_if_missing,
     175                 :            :                                            const int create_adjacency_option = -1 );
     176                 :            : 
     177                 :            :     ErrorCode get_down_adjacency_elements_poly( EntityHandle source_entity, const unsigned int target_dimension,
     178                 :            :                                                 std::vector< EntityHandle >& target_entities,
     179                 :            :                                                 const bool create_if_missing, const int create_adjacency_option = -1 );
     180                 :            : 
     181                 :            :     ErrorCode get_up_adjacency_elements( EntityHandle source_entity, const unsigned int target_dimension,
     182                 :            :                                          std::vector< EntityHandle >& target_entities, const bool create_if_missing,
     183                 :            :                                          const int create_adjacency_option = -1 );
     184                 :            : 
     185                 :            :     //! check for equivalent entities that may be formed when merging two entities, and
     186                 :            :     //! create explicit adjacencies accordingly
     187                 :            :     ErrorCode check_equiv_entities( EntityHandle entity_to_keep, EntityHandle entity_to_remove );
     188                 :            : 
     189                 :            :     //! create explicit adjacencies between this_ent and all adjacent entities of higher
     190                 :            :     //! dimension
     191                 :            :     ErrorCode create_explicit_adjs( EntityHandle this_ent );
     192                 :            : };
     193                 :            : 
     194                 :            : }  // namespace moab
     195                 :            : 
     196                 :            : #endif

Generated by: LCOV version 1.11