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

           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 MOAB_READ_UTIL_IFACE_HPP
      17                 :            : #define MOAB_READ_UTIL_IFACE_HPP
      18                 :            : 
      19                 :            : #include <vector>
      20                 :            : #include <string>
      21                 :            : #include "moab/Types.hpp"
      22                 :            : #include "moab/Compiler.hpp"
      23                 :            : 
      24                 :            : namespace moab
      25                 :            : {
      26                 :            : 
      27                 :            : class Range;
      28                 :            : 
      29                 :            : //! Interface implemented in MOAB which provides memory for mesh reading utilities
      30                 :            : class ReadUtilIface
      31                 :            : {
      32                 :            :   public:
      33                 :            :     //! Constructor
      34                 :        170 :     ReadUtilIface() {}
      35                 :            : 
      36                 :            :     //! Destructor
      37         [ -  + ]:        334 :     virtual ~ReadUtilIface() {}
      38                 :            : 
      39                 :            :     //! Given a requested number of vertices and number of coordinates, returns
      40                 :            :     //! memory space which will be used to store vertex coordinates and information
      41                 :            :     //! about what handles those new vertices are assigned; allows direct read of
      42                 :            :     //! coordinate data into memory
      43                 :            :     //! \param num_arrays Number of node position arrays requested
      44                 :            :     //! \param num_nodes Number of nodes
      45                 :            :     //! \param preferred_start_id Preferred integer id starting value
      46                 :            :     //! \param actual_start_handle Actual starting id value
      47                 :            :     //! \param arrays STL vector of double*'s, point to memory storage to be used for
      48                 :            :     //!     these vertices
      49                 :            :     //! \param sequence_size If specified, allocate this sequence size instead of
      50                 :            :     //!      SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE
      51                 :            :     //! \return status Success/failure of this call
      52                 :            :     virtual ErrorCode get_node_coords( const int num_arrays, const int num_nodes, const int preferred_start_id,
      53                 :            :                                        EntityHandle& actual_start_handle, std::vector< double* >& arrays,
      54                 :            :                                        const int sequence_size = -1 ) = 0;
      55                 :            : 
      56                 :            :     //! Given requested number of elements, element type, and number of
      57                 :            :     //! elements, returns pointer to memory space allocated to store connectivity
      58                 :            :     //! of those elements; allows direct read of connectivity data into memory
      59                 :            :     //! \param num_elements Number of elements being requested
      60                 :            :     //! \param verts_per_element Number of vertices per element (incl. higher-order nodes)
      61                 :            :     //! \param mdb_type Element type
      62                 :            :     //! \param preferred_start_id Preferred integer id for first element
      63                 :            :     //! \param actual_start_handle Actual integer id for first element (returned)
      64                 :            :     //! \param array Pointer to memory allocated for storing connectivity for these elements
      65                 :            :     //! \param sequence_size If specified, allocate this sequence size instead of
      66                 :            :     //!      SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE
      67                 :            :     //! \return status Success/failure of this call
      68                 :            :     virtual ErrorCode get_element_connect( const int num_elements, const int verts_per_element,
      69                 :            :                                            const EntityType mdb_type, const int preferred_start_id,
      70                 :            :                                            EntityHandle& actual_start_handle, EntityHandle*& array,
      71                 :            :                                            int sequence_size = -1 ) = 0;
      72                 :            : 
      73                 :            :     /**
      74                 :            :      *\brief Gather entities related to those in the partition
      75                 :            :      * Gather entities related to those in the input partition. Related
      76                 :            :      * means down-adjacent to, contained in, etc.
      77                 :            :      * \param partition Entities for which to gather related entities
      78                 :            :      * \param related_ents Related entities
      79                 :            :      * \param file_set If non-NULL, entity sets contained in this set will be checked;
      80                 :            :      *        otherwise, all sets in the instance will be checked
      81                 :            :      */
      82                 :            :     virtual ErrorCode gather_related_ents( Range& partition, Range& related_ents, EntityHandle* file_set = NULL ) = 0;
      83                 :            : 
      84                 :            :     virtual ErrorCode create_entity_sets( EntityID num_sets, const unsigned* set_flags, EntityID preffered_start_id,
      85                 :            :                                           EntityHandle& actual_start_handle ) = 0;
      86                 :            : 
      87                 :            :     //! Update adjacencies
      88                 :            :     //! Given information about new elements, adjacency information will be updated
      89                 :            :     //! in MOAB. Think of this function as a way of Readers telling MOAB what elements are
      90                 :            :     //! new because we aren't using the Interface to create elements.
      91                 :            :     //! \param start_handle Handle of first new element
      92                 :            :     //! \param number_elements Number of new elements
      93                 :            :     //! \param number_vertices_per_element Number of vertices in each new element
      94                 :            :     //! \param conn_array Connectivity of new elements
      95                 :            :     //! \return status Success/failure of this call
      96                 :            :     virtual ErrorCode update_adjacencies( const EntityHandle start_handle, const int number_elements,
      97                 :            :                                           const int number_vertices_per_element, const EntityHandle* conn_array ) = 0;
      98                 :            : 
      99                 :            :     /**\brief Re-order incoming element connectivity
     100                 :            :      *
     101                 :            :      * Permute the connectivity of each element such that the node
     102                 :            :      * order is that of MBCN rather than the target file format.
     103                 :            :      *\param order The permutation to use.  Must be an array of 'node_per_elem'
     104                 :            :      *             integers and be a permutation of the values [0..node_per_elem-1].
     105                 :            :      *             Such that for a single element:
     106                 :            :      *             mbcn_conn[order[i]] == target_conn[i]
     107                 :            :      *\param conn  The connectivity array to re-order
     108                 :            :      *\param num_elem  The number of elements in the connectivity array
     109                 :            :      *\param node_per_elem The number of nodes in each element's connectivity list.
     110                 :            :      */
     111                 :            :     static inline void reorder( const int* order, EntityHandle* conn, int num_elem, int node_per_elem );
     112                 :            : 
     113                 :            :     //! Given an ordered list of bounding entities and the sense of
     114                 :            :     //! those entities, return an ordered list of vertices
     115                 :            :     virtual ErrorCode get_ordered_vertices( EntityHandle* bound_ents, int* sense, int num_bound, int dim,
     116                 :            :                                             EntityHandle* bound_verts, EntityType& etype ) = 0;
     117                 :            : 
     118                 :            :     //! Assign sequential IDS to entities in range and store IDs in tag
     119                 :            :     virtual ErrorCode assign_ids( Tag id_tag, const Range& ents, int start = 0 ) = 0;
     120                 :            : 
     121                 :            :     //! Assign to each entity in an array the ID that is its position
     122                 :            :     //! in the array plus the value of 'start'.  For any non-zero handles
     123                 :            :     //! in the array, store the ID value in the passed tag.
     124                 :            :     virtual ErrorCode assign_ids( Tag id_tag, const EntityHandle* ents, size_t num_ents, int start = 0 ) = 0;
     125                 :            : 
     126                 :            :     //! Create a new gather set with tag GATHER_SET
     127                 :            :     virtual ErrorCode create_gather_set( EntityHandle& gather_set ) = 0;
     128                 :            : 
     129                 :            :     //! Get entity handle of an existing gather set
     130                 :            :     virtual ErrorCode get_gather_set( EntityHandle& gather_set ) = 0;
     131                 :            : };
     132                 :            : 
     133                 :          4 : inline void ReadUtilIface::reorder( const int* order, EntityHandle* conn, int num_elem, int node_per_elem )
     134                 :            : {
     135         [ +  - ]:          4 :     std::vector< EntityHandle > elem( node_per_elem );
     136                 :          4 :     EntityHandle* const end = conn + num_elem * node_per_elem;
     137         [ +  + ]:         64 :     while( conn != end )
     138                 :            :     {
     139         [ +  - ]:         60 :         std::copy( conn, conn + node_per_elem, elem.begin() );
     140         [ +  + ]:        976 :         for( int j = 0; j < node_per_elem; ++j )
     141         [ +  - ]:        916 :             conn[order[j]] = elem[j];
     142                 :         60 :         conn += node_per_elem;
     143                 :          4 :     }
     144                 :          4 : }
     145                 :            : 
     146                 :            : }  // namespace moab
     147                 :            : 
     148                 :            : #endif

Generated by: LCOV version 1.11