LCOV - code coverage report
Current view: top level - src/io - WriteNCDF.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 4 4 100.0 %
Date: 2020-12-16 07:07:30 Functions: 13 13 100.0 %
Branches: 8 16 50.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                 :            : //-------------------------------------------------------------------------
      17                 :            : // Filename      : WriteNCDF.hpp
      18                 :            : //
      19                 :            : // Purpose       : ExodusII writer
      20                 :            : //
      21                 :            : // Special Notes : Lots of code taken from verde implementation
      22                 :            : //
      23                 :            : // Creator       : Corey Ernst
      24                 :            : //
      25                 :            : // Date          : 8/02
      26                 :            : //
      27                 :            : // Owner         : Corey Ernst
      28                 :            : //-------------------------------------------------------------------------
      29                 :            : 
      30                 :            : #ifndef WRITENCDF_HPP
      31                 :            : #define WRITENCDF_HPP
      32                 :            : 
      33                 :            : #ifndef IS_BUILDING_MB
      34                 :            : #error "WriteNCDF.hpp isn't supposed to be included into an application"
      35                 :            : #endif
      36                 :            : 
      37                 :            : #include <vector>
      38                 :            : #include <string>
      39                 :            : 
      40                 :            : #include "moab/Forward.hpp"
      41                 :            : #include "moab/Range.hpp"
      42                 :            : #include "moab/ExoIIInterface.hpp"
      43                 :            : #include "moab/WriterIface.hpp"
      44                 :            : 
      45                 :            : namespace moab
      46                 :            : {
      47                 :            : 
      48                 :            : class WriteUtilIface;
      49                 :            : 
      50                 :            : //! struct used to hold data for each block to be output in Exodus; used by
      51                 :            : //! initialize_exodus_file to initialize the file header for increased speed
      52                 :        300 : struct MaterialSetData
      53                 :            : {
      54                 :            :     int id;
      55                 :            :     int number_elements;
      56                 :            :     int number_nodes_per_element;
      57                 :            :     int number_attributes;
      58                 :            :     ExoIIElementType element_type;
      59                 :            :     Range elements;
      60                 :            : };
      61                 :            : 
      62                 :            : //! struct used to hold data for each nodeset to be output in Exodus; used by
      63                 :            : //! initialize_exodus_file to initialize the file header for increased speed
      64 [ +  - ][ +  - ]:        117 : struct DirichletSetData
      65                 :            : {
      66                 :            :     int id;
      67                 :            :     int number_nodes;
      68                 :            :     std::vector< EntityHandle > nodes;
      69                 :            :     std::vector< double > node_dist_factors;
      70                 :            : };
      71                 :            : 
      72                 :            : //! struct used to hold data for each sideset to be output in Exodus; used by
      73                 :            : //! initialize_exodus_file to initialize the file header for increased speed
      74 [ +  - ][ +  - ]:        180 : struct NeumannSetData
         [ +  - ][ +  - ]
      75                 :            : {
      76                 :            :     int id;
      77                 :            :     int number_elements;
      78                 :            :     std::vector< EntityHandle > elements;
      79                 :            :     std::vector< int > side_numbers;
      80                 :            :     EntityHandle mesh_set_handle;
      81                 :            :     std::vector< double > ss_dist_factors;
      82                 :            : };
      83                 :            : 
      84                 :            : //! Output Exodus File for VERDE
      85                 :            : class WriteNCDF : public WriterIface
      86                 :            : {
      87                 :            : 
      88                 :            :   public:
      89                 :            :     static WriterIface* factory( Interface* );
      90                 :            : 
      91                 :            :     //! Constructor
      92                 :            :     WriteNCDF( Interface* impl );
      93                 :            : 
      94                 :            :     //! Destructor
      95                 :            :     virtual ~WriteNCDF();
      96                 :            : 
      97                 :            :     //! writes out an ExoII file
      98                 :            :     ErrorCode write_file( const char* exodus_file_name, const bool overwrite, const FileOptions& opts,
      99                 :            :                           const EntityHandle* output_list, const int num_sets,
     100                 :            :                           const std::vector< std::string >& qa_records, const Tag* = NULL, int = 0,
     101                 :            :                           int user_dimension = 3 );
     102                 :            : 
     103                 :            :   protected:
     104                 :            :     //! number of dimensions in this exo file
     105                 :            :     // int number_dimensions();
     106                 :            : 
     107                 :            :     //! open an ExoII file for writing
     108                 :            :     ErrorCode open_file( const char* file_name );
     109                 :            : 
     110                 :            :     //! contains the general information about a mesh
     111 [ +  - ][ +  - ]:         27 :     struct ExodusMeshInfo
     112                 :            :     {
     113                 :            :         unsigned int num_dim;
     114                 :            :         unsigned int num_nodes;
     115                 :            :         unsigned int num_elements;
     116                 :            :         unsigned int num_elementblocks;
     117                 :            :         unsigned int num_polyhedra_blocks;
     118                 :            :         std::vector< std::string > qaRecords;
     119                 :            :         Range nodes;
     120                 :            :         Range polyhedronFaces;  // they will accumulate, like nodes
     121                 :            :         // they will be written before any other face blocks, and before polyhedra blocks
     122                 :            :     };
     123                 :            : 
     124                 :            :   private:
     125                 :            :     //! interface instance
     126                 :            :     Interface* mdbImpl;
     127                 :            :     WriteUtilIface* mWriteIface;
     128                 :            : 
     129                 :            :     //! file name
     130                 :            :     std::string exodusFile;
     131                 :            :     int ncFile;
     132                 :            : 
     133                 :            :     //! Meshset Handle for the mesh that is currently being read
     134                 :            :     EntityHandle mCurrentMeshHandle;
     135                 :            : 
     136                 :            :     //! Cached tags for reading.  Note that all these tags are defined when the
     137                 :            :     //! core is initialized.
     138                 :            :     Tag mMaterialSetTag;
     139                 :            :     Tag mDirichletSetTag;
     140                 :            :     Tag mNeumannSetTag;
     141                 :            :     Tag mHasMidNodesTag;
     142                 :            :     Tag mGeomDimensionTag;
     143                 :            :     Tag mDistFactorTag;
     144                 :            :     Tag mGlobalIdTag;
     145                 :            :     Tag mQaRecordTag;
     146                 :            : 
     147                 :            :     Tag mEntityMark;  // used to say whether an entity will be exported
     148                 :            : 
     149                 :            :     int repeat_face_blocks;  // only to make paraview and visit happy
     150                 :            : 
     151                 :            :     ErrorCode gather_mesh_information( ExodusMeshInfo& mesh_info, std::vector< MaterialSetData >& block_info,
     152                 :            :                                        std::vector< NeumannSetData >& sideset_info,
     153                 :            :                                        std::vector< DirichletSetData >& nodeset_info,
     154                 :            :                                        std::vector< EntityHandle >& blocks, std::vector< EntityHandle >& sidesets,
     155                 :            :                                        std::vector< EntityHandle >& nodesets );
     156                 :            : 
     157                 :            :     ErrorCode write_header( ExodusMeshInfo& mesh_info, std::vector< MaterialSetData >& block_info,
     158                 :            :                             std::vector< NeumannSetData >& sideset_info, std::vector< DirichletSetData >& nodeset_info,
     159                 :            :                             const char* filename );
     160                 :            : 
     161                 :            :     ErrorCode initialize_exodus_file( ExodusMeshInfo& mesh_info, std::vector< MaterialSetData >& block_data,
     162                 :            :                                       std::vector< NeumannSetData >& sideset_data,
     163                 :            :                                       std::vector< DirichletSetData >& nodeset_data, const char* title_string,
     164                 :            :                                       bool write_maps = true, bool write_sideset_distribution_factors = true );
     165                 :            : 
     166                 :            :     ErrorCode write_qa_string( const char* string, int record_number, int record_position );
     167                 :            : 
     168                 :            :     ErrorCode write_qa_records( std::vector< std::string >& qa_record_list );
     169                 :            : 
     170                 :            :     ErrorCode write_nodes( int num_nodes, Range& nodes, int dimension );
     171                 :            : 
     172                 :            :     ErrorCode write_poly_faces( ExodusMeshInfo& mesh_info );
     173                 :            :     ErrorCode write_elementblocks( ExodusMeshInfo& mesh_info, std::vector< MaterialSetData >& block_data );
     174                 :            : 
     175                 :            :     ErrorCode write_exodus_integer_variable( const char* variable_name, int* variable_array, int start_position,
     176                 :            :                                              int number_values );
     177                 :            : 
     178                 :            :     ErrorCode write_global_node_order_map( int num_nodes, Range& nodes );
     179                 :            :     ErrorCode write_global_element_order_map( int num_elements );
     180                 :            :     ErrorCode write_element_order_map( int num_elements );
     181                 :            : 
     182                 :            :     ErrorCode write_BCs( std::vector< NeumannSetData >& sidesets, std::vector< DirichletSetData >& nodesets );
     183                 :            : 
     184                 :            :     ErrorCode find_side_element_type( const int element_id, ExoIIElementType& type );
     185                 :            : 
     186                 :            :     /* ErrorCode assign_block_ids_to_ssets(EntityHandle ss_handle,
     187                 :            :                                             MB_MeshSet *ss_mesh_set);
     188                 :            :                                             */
     189                 :            :     //! free up allocated Ranges
     190                 :            :     void reset_block( std::vector< MaterialSetData >& block_info );
     191                 :            : 
     192                 :            :     //! recursive function; given a meshset handle, get the entities and put them
     193                 :            :     //! on the right list, then call recursively for any contained meshsets, first
     194                 :            :     //! checking for sense reversals
     195                 :            :     ErrorCode get_sideset_elems( EntityHandle sideset, int current_sense, Range& forward_elems, Range& reverse_elems );
     196                 :            : 
     197                 :            :     ErrorCode get_valid_sides( Range& elems, ExodusMeshInfo& mesh_info, const int sense, NeumannSetData& sideset_data );
     198                 :            : 
     199                 :            :     //! get the time and date in strings
     200                 :            :     static void time_and_date( char* time_string, char* date_string );
     201                 :            : };
     202                 :            : 
     203                 :            : }  // namespace moab
     204                 :            : 
     205                 :            : #endif

Generated by: LCOV version 1.11