LCOV - code coverage report
Current view: top level - util/cgm - CubitFileSimModel.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 0 11 0.0 %
Date: 2020-06-30 00:58:45 Functions: 0 4 0.0 %
Branches: 0 48 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*******************************************************************************
       2                 :            :     COPYRIGHT 2010 CATERPILLAR INC.  ALL RIGHTS RESERVED
       3                 :            : 
       4                 :            :     This program is the property of Caterpillar Inc., includes Caterpillar's
       5                 :            :     confidential and trade secret information, and is maintained as an
       6                 :            :     unpublished copyrighted work.  It is not to be copied or used by others
       7                 :            :     except under license from Caterpillar.  This program is also protected as an
       8                 :            :     unpublished work in accordance with the copyright act of 1976.  In the event
       9                 :            :     of either inadvertent or deliberate publication, Caterpillar Inc. intends to
      10                 :            :     maintain copyright protection for this work under the relevant copyright
      11                 :            :     laws pertaining to published works.  The inclusion of a copyright notice
      12                 :            :     hereon is precautionary only, and does not imply publication or disclosure.
      13                 :            : 
      14                 :            :  
      15                 :            :  Filename      : CubitFileSimModel.hpp
      16                 :            : 
      17                 :            :  Purpose       : Defines an interface for the reading and writing functionality
      18                 :            :                  for a Simulation model section of a Cubit (*.cub) format file.
      19                 :            :            
      20                 :            :  Special Notes :
      21                 :            : 
      22                 :            :  Creator       : Andrew Rout
      23                 :            : 
      24                 :            :  Creation Date : 02/20/10
      25                 :            : 
      26                 :            :  Owner         : Andrew Rout
      27                 :            : 
      28                 :            : *******************************************************************************/
      29                 :            : 
      30                 :            : #ifndef CubitFileSimModel_HPP
      31                 :            : #define CubitFileSimModel_HPP
      32                 :            : 
      33                 :            : #include "CubitFileMetaData.hpp"
      34                 :            : #include "CGMUtilConfigure.h"
      35                 :            : #include <vector>
      36                 :            : 
      37                 :            : namespace NCubitFile {
      38                 :            : 
      39                 :            : class CUBIT_UTIL_EXPORT CSimModel {
      40                 :            : public:
      41                 :            :     CSimModel();
      42                 :            :     virtual ~CSimModel();
      43                 :            :     
      44                 :            :     UnsignedInt32 InitWrite(FILE* xpFile,
      45                 :            :         UnsignedInt32 xintBCCount, UnsignedInt32 xintICCount,
      46                 :            :         UnsignedInt32 xintBCSetCount, UnsignedInt32 xintMaterialCount,
      47                 :            :         UnsignedInt32 xintAmplitudeCount, UnsignedInt32 xintConstraintCount);
      48                 :            :     void WriteBCSet(UnsignedInt32 xintIndex,
      49                 :            :         UnsignedInt32 xintBCSetID, UnsignedInt32 xintBCSetUniqueID,
      50                 :            :         UnsignedInt32 xintBCSetAnalysisType, UnsignedInt32 xintRestraintTypesCount,
      51                 :            :         UnsignedInt32 xintLoadTypesCount, UnsignedInt32 xintContactPairTypesCount,
      52                 :            :         SBCSetData* xpaBCSetRestraintData, SBCSetData* xpaBCSetLoadData,
      53                 :            :         SBCSetData* xpaBCSetContactPairData);
      54                 :            :     void WriteMaterial(UnsignedInt32 xintIndex,
      55                 :            :         UnsignedInt32 xintMaterialID, UnsignedInt32 xintMaterialUniqueID,
      56                 :            :         UnsignedInt32 xintPropertiesCount, SMaterialData* xpaMaterialData);
      57                 :            :     void WriteConstraint(UnsignedInt32 xintIndex,
      58                 :            :         UnsignedInt32 xintConstraintID, UnsignedInt32 xintConstraintUniqueID,
      59                 :            :         UnsignedInt32 xintConstraintType,
      60                 :            :         UnsignedInt32 xintIndependentTypeCount, SConstraintData* xpaIndependentData,
      61                 :            :         UnsignedInt32 xintDependentTypeCount, SConstraintData* xpaDependentData);
      62                 :            :     UnsignedInt32 EndWrite();
      63                 :            :     
      64                 :            :     void InitRead(FILE* xpFile, UnsignedInt32& xintAbsoluteOffset,
      65                 :            :         UnsignedInt32& xintBCCount, UnsignedInt32& xintICCount,
      66                 :            :         UnsignedInt32& xintBCSetCount, UnsignedInt32& xintMaterialCount,
      67                 :            :         UnsignedInt32& xintAmplitudeCount, UnsignedInt32& xintConstraintCount);
      68                 :            :     void ReadBCSet(UnsignedInt32 xintIndex,
      69                 :            :         UnsignedInt32& xintBCSetID, UnsignedInt32& xintBCSetUniqueID,
      70                 :            :         UnsignedInt32& xintBCSetAnalysisType, UnsignedInt32& xintRestraintTypesCount,
      71                 :            :         UnsignedInt32& xintLoadTypesCount, UnsignedInt32& xintContactPairTypesCount,
      72                 :            :         SBCSetData*& xpaBCSetRestraintData, SBCSetData*& xpaBCSetLoadData,
      73                 :            :         SBCSetData*& xpaBCSetContactPairData);
      74                 :            :     void ReadMaterial(UnsignedInt32 xintIndex,
      75                 :            :         UnsignedInt32& xintMaterialID, UnsignedInt32& xintMaterialUniqueID,
      76                 :            :         UnsignedInt32& xintPropertiesCount, SMaterialData*& xpaMaterialData);
      77                 :            :     void ReadConstraint(UnsignedInt32 xintIndex,
      78                 :            :         UnsignedInt32& xintConstraintID, UnsignedInt32& xintConstraintUniqueID,
      79                 :            :         UnsignedInt32& xintConstraintType,
      80                 :            :         UnsignedInt32& xintIndependentTypeCount, SConstraintData*& xpaIndependentData,
      81                 :            :         UnsignedInt32& xintDependentTypeCount, SConstraintData*& xpaDependentData);
      82                 :            :     void EndRead();
      83                 :            :     
      84                 :            :     CMetaData& GetBCMetaData();
      85                 :            :     CMetaData& GetICMetaData();
      86                 :            :     CMetaData& GetBCSetMetaData();
      87                 :            :     CMetaData& GetMaterialMetaData();
      88                 :            :     CMetaData& GetAmplitudeMetaData();
      89                 :            :     CMetaData& GetConstraintMetaData();
      90                 :            :     
      91                 :            : private:
      92                 :            :     FILE* mpReadFile;
      93                 :            :     FILE* mpWriteFile;
      94                 :            :     UnsignedInt32 mintSimModelOffset;
      95                 :            :     CMetaData mBCMetaData;
      96                 :            :     CMetaData mICMetaData;
      97                 :            :     CMetaData mBCSetMetaData;
      98                 :            :     CMetaData mMaterialMetaData;
      99                 :            :     CMetaData mAmplitudeMetaData;
     100                 :            :     CMetaData mConstraintMetaData;
     101                 :            : 
     102                 :            :     // Data storage structures:
     103                 :            :     // CAUTION: These structures must be 64 bit word aligned!!!
     104                 :            :     struct SCubitFileSimModelHeader {
     105                 :            :         UnsignedInt32 mintSimModelEndian;
     106                 :            :         UnsignedInt32 mintSimModelSchema;
     107                 :            :         UnsignedInt32 mintSimModelCompress;
     108                 :            :         UnsignedInt32 mintSimModelLength;
     109                 :            :         UnsignedInt32 mintBCCount;
     110                 :            :         UnsignedInt32 mintBCTableOffset;
     111                 :            :         UnsignedInt32 mintBCMetaDataOffset;
     112                 :            :         UnsignedInt32 mintICCount;
     113                 :            :         UnsignedInt32 mintICTableOffset;
     114                 :            :         UnsignedInt32 mintICMetaDataOffset;
     115                 :            :         UnsignedInt32 mintBCSetCount;
     116                 :            :         UnsignedInt32 mintBCSetTableOffset;
     117                 :            :         UnsignedInt32 mintBCSetMetaDataOffset;
     118                 :            :         UnsignedInt32 mintMaterialCount;
     119                 :            :         UnsignedInt32 mintMaterialTableOffset;
     120                 :            :         UnsignedInt32 mintMaterialMetaDataOffset;
     121                 :            :         UnsignedInt32 mintAmplitudeCount;
     122                 :            :         UnsignedInt32 mintAmplitudeTableOffset;
     123                 :            :         UnsignedInt32 mintAmplitudeMetaDataOffset;
     124                 :            :         UnsignedInt32 mintFutureTableOffset; // for forwards compatibility
     125                 :            :         //UnsignedInt32 mintPadFor64bitOS; // only if odd number of items in struct
     126                 :            :     } mSimModel;
     127                 :            :     static const UnsignedInt32 mintSizeOfSimModelHeader;
     128                 :            :     //
     129                 :            :     // Continuation from previous table
     130                 :            :     // CAUTION: These structures must be 64 bit word aligned!!!
     131                 :            :     struct SCubitFileSimModelHeader2 {
     132                 :            :         UnsignedInt32 mintConstraintCount;
     133                 :            :         UnsignedInt32 mintConstraintTableOffset;
     134                 :            :         UnsignedInt32 mintConstraintMetaDataOffset;
     135                 :            :         UnsignedInt32 mintFutureTableOffset; // for forwards compatibility
     136                 :            :         //UnsignedInt32 mintPadFor64bitOS; // only if odd number of items in struct
     137                 :            :     } mSimModel2;
     138                 :            :     static const UnsignedInt32 mintSizeOfSimModelHeader2;
     139                 :            : 
     140                 :            :     struct SCubitFileBCSetEntry {
     141                 :            :         UnsignedInt32 mintBCSetID;
     142                 :            :         UnsignedInt32 mintBCSetUniqueID;
     143                 :            :         UnsignedInt32 mintBCSetAnalysisType;
     144                 :            :         UnsignedInt32 mintRestraintTypesCount;
     145                 :            :         UnsignedInt32 mintRestraintMembersCount;
     146                 :            :         UnsignedInt32 mintRestraintsOffset;
     147                 :            :         UnsignedInt32 mintLoadTypesCount;
     148                 :            :         UnsignedInt32 mintLoadMembersCount;
     149                 :            :         UnsignedInt32 mintLoadsOffset;
     150                 :            :         UnsignedInt32 mintContactPairTypesCount;
     151                 :            :         UnsignedInt32 mintContactPairMembersCount;
     152                 :            :         UnsignedInt32 mintContactPairsOffset;
     153                 :            :         UnsignedInt32 mintBCSetLength;
     154                 :            :         UnsignedInt32 mintPadFor64bitOS;
     155                 :            :     } *mpaBCSets;
     156                 :            :     static const UnsignedInt32 mintSizeOfBCSetEntry;
     157                 :            : 
     158                 :            :     struct SCubitFileMaterialEntry {
     159                 :            :         UnsignedInt32 mintMaterialID;
     160                 :            :         UnsignedInt32 mintMaterialUniqueID;
     161                 :            :         UnsignedInt32 mintMaterialPropertiesOffset;
     162                 :            :         UnsignedInt32 mintMaterialPropertiesCount;
     163                 :            :         UnsignedInt32 mintPropertyDataCount; // total num of all property data
     164                 :            :         UnsignedInt32 mintMaterialLength;
     165                 :            :     } *mpaMaterials;
     166                 :            :     static const UnsignedInt32 mintSizeOfMaterialEntry;
     167                 :            : 
     168                 :            :     struct SCubitFileConstraintEntry {
     169                 :            :         UnsignedInt32 mintConstraintID;
     170                 :            :         UnsignedInt32 mintConstraintUniqueID;
     171                 :            :         UnsignedInt32 mintConstraintType;
     172                 :            :         UnsignedInt32 mintIndependentTypeCount; // usually 1 independent node/vertex
     173                 :            :         UnsignedInt32 mintIndependentDataOffset;
     174                 :            :         UnsignedInt32 mintDependentTypeCount;
     175                 :            :         UnsignedInt32 mintDependentDataOffset;
     176                 :            :         UnsignedInt32 mintConstraintLength;
     177                 :            :         //UnsignedInt32 mintPadFor64bitOS;
     178                 :            :     } *mpaConstraints;
     179                 :            :     static const UnsignedInt32 mintSizeOfConstraintEntry;
     180                 :            : 
     181                 :            :     // These structs aren't used yet (12.1), can modify them until they are first used.
     182                 :            :     // Then, they must be locked in.
     183                 :            :     struct SCubitFileBCEntry {
     184                 :            :         UnsignedInt32 mintBCID;
     185                 :            :         UnsignedInt32 mintBCUniqueID;
     186                 :            :         UnsignedInt32 mintBCType;
     187                 :            :         UnsignedInt32 mintDataLength;
     188                 :            :         UnsignedInt32 mintDataOffset;
     189                 :            :         UnsignedInt32 mintBCLength;
     190                 :            :         //UnsignedInt32 mintPadFor64bitOS;
     191                 :            :     } *mpaBCs;
     192                 :            :     static const UnsignedInt32 mintSizeOfBCEntry;
     193                 :            : 
     194                 :            :     struct SCubitFileICEntry {
     195                 :            :         UnsignedInt32 mintICID;
     196                 :            :         UnsignedInt32 mintICUniqueID;
     197                 :            :         UnsignedInt32 mintICType;
     198                 :            :         UnsignedInt32 mintDataLength;
     199                 :            :         UnsignedInt32 mintDataOffset;
     200                 :            :         UnsignedInt32 mintICCLength;
     201                 :            :         //UnsignedInt32 mintPadFor64bitOS;
     202                 :            :     } *mpaICs;
     203                 :            :     static const UnsignedInt32 mintSizeOfICEntry;
     204                 :            : 
     205                 :            :     struct SCubitFileAmplitudeEntry {
     206                 :            :         UnsignedInt32 mintAmplitudeID;
     207                 :            :         UnsignedInt32 mintAmplitudeUniqueID;
     208                 :            :         UnsignedInt32 mintDataLength;
     209                 :            :         UnsignedInt32 mintDataOffset;
     210                 :            :         UnsignedInt32 mintAmplitudeLength;
     211                 :            :         UnsignedInt32 mintPadFor64bitOS;
     212                 :            :     } *mpaAmplitudes;
     213                 :            :     static const UnsignedInt32 mintSizeOfAmplitudeEntry;
     214                 :            :     
     215                 :            :     // Buffers for read operations.
     216                 :            :     struct SBCSetReturnBuffer {
     217                 :            :         //restraints
     218                 :            :         UnsignedInt32 mintNumRestraintTypes;
     219                 :            :         UnsignedInt32 mintNumRestraintMembers;
     220                 :            :         SBCSetData* mpaBCSetRestraintData;
     221                 :            :         UnsignedInt32* mpaintRestraintMemberIDs;
     222                 :            :         //loads
     223                 :            :         UnsignedInt32 mintNumLoadTypes;
     224                 :            :         UnsignedInt32 mintNumLoadMembers;
     225                 :            :         SBCSetData* mpaBCSetLoadData;
     226                 :            :         UnsignedInt32* mpaintLoadMemberIDs;
     227                 :            :         //contact pairs
     228                 :            :         UnsignedInt32 mintNumContactPairTypes;
     229                 :            :         UnsignedInt32 mintNumContactPairMembers;
     230                 :            :         SBCSetData* mpaBCSetContactPairData;
     231                 :            :         UnsignedInt32* mpaintContactPairMemberIDs;
     232                 :            :     } mBCSetBuff;
     233                 :            : 
     234                 :            :     struct SMaterialReturnBuffer {
     235                 :            :         UnsignedInt32 mintNumDataTypes;
     236                 :            :         UnsignedInt32 mintNumDataMembers; //i.e. current size of buffer
     237                 :            :         SMaterialData* mpaMaterialData;
     238                 :            :         double* mpadblData;
     239                 :            :     } mMaterialBuff;
     240                 :            : 
     241                 :            :     struct SConstraintReturnBuffer {
     242                 :            :         UnsignedInt32 mintNumIndependentTypes;
     243                 :            :         UnsignedInt32 mintNumIndependentMembers;
     244                 :            :         SConstraintData* mpaIndependentData;
     245                 :            :         UnsignedInt32* mpaintIndependentIDs;
     246                 :            :         //--
     247                 :            :         UnsignedInt32 mintNumDependentTypes;
     248                 :            :         UnsignedInt32 mintNumDependentMembers;
     249                 :            :         SConstraintData* mpaDependentData;
     250                 :            :         UnsignedInt32* mpaintDependentIDs;
     251                 :            :     } mConstraintBuff;
     252                 :            : 
     253                 :            : 
     254                 :            :     template <class TBuffer>
     255                 :          0 :     TBuffer* AdjustBuffer(UnsignedInt32 xintRequiredSize,
     256                 :            :         UnsignedInt32& xintActualSize, TBuffer*& xpaBuffer)
     257                 :            :     {
     258 [ #  # ][ #  # ]:          0 :         if(!xintRequiredSize)  return NULL;  // Nothing requested, return nothing.
         [ #  # ][ #  # ]
     259                 :            : 
     260 [ #  # ][ #  # ]:          0 :         if(xintActualSize < xintRequiredSize) {
         [ #  # ][ #  # ]
     261 [ #  # ][ #  # ]:          0 :             if(xpaBuffer)
         [ #  # ][ #  # ]
     262 [ #  # ][ #  # ]:          0 :                 delete [] xpaBuffer;
         [ #  # ][ #  # ]
     263                 :          0 :             xintActualSize = xintRequiredSize;
     264 [ #  # ][ #  # ]:          0 :             xpaBuffer = new TBuffer[xintActualSize];
         [ #  # ][ #  # ]
     265   [ #  #  #  #  :          0 :             if(!xpaBuffer) {
             #  #  #  # ]
     266                 :          0 :                 xintActualSize = 0;
     267                 :          0 :                 throw CCubitFile::eMemoryError;
     268                 :            :             }
     269                 :            :         }
     270                 :          0 :         return xpaBuffer;
     271                 :            :     }
     272                 :            : };
     273                 :            : 
     274                 :            : } // namespace NCubitFile
     275                 :            : 
     276                 :            : #endif
     277                 :            : 

Generated by: LCOV version 1.11