Pointwise Plugin SDK
apiCAEPUtils.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Pointwise Plugin utility functions
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #ifndef _APICAEPUTILS_H_
10 #define _APICAEPUTILS_H_
11 
12 #include <stdio.h>
13 #include <time.h>
14 
15 #include "apiCAEP.h"
16 #include "apiPWP.h"
17 #include "apiPWPUtils.h"
18 #include "apiGridModel.h"
19 
20 extern "C" {
21 
22 /************************************************************************/
49 // include impl-defined cae instance runtime data types.
50 // Must also define the macro CAEP_RUNTIME_INSTDATADECL
51 #include "rtCaepInstanceData.h"
52 
62 #if !defined(CAEP_RUNTIME_INSTDATADECL)
63 # define CAEP_RUNTIME_INSTDATADECL
64 #endif
65 
66 
67 /***********************************************************/
68 /***********************************************************/
80 //***************************************************************************
81 //***************************************************************************
109  /* add new group enum values before this line */
110 
113  CAEPU_CLKS_SIZE,
115  CAEPU_CLKS_LAST = CAEPU_CLKS_SIZE-1
117  // sdkINTERNALS
118 };
119 
120 
121 /************************************************************************/
124 struct CAEP_RTITEM {
130 
134 
141 
147 
154 
161 
167  const char **pFileExt;
168 
174 
180  PWP_BOOL elemType[PWGM_ELEMTYPE_SIZE];
181 
199  FILE *fp;
200 
211 
217 
223 
231  PWP_UINT32 progTotal;
232 
238  PWP_UINT32 progComplete;
239 
245  clock_t clocks[CAEPU_CLKS_SIZE];
246 
252  PWP_BOOL opAborted;
253  // sdkINTERNALS
255 
265 };
266 
267 
268 /************************************************************************/
282 extern CAEP_RTITEM caepRtItem[];
283 
284 
285 /************************************************************************/
292  /* DOXGRP_APICAEP_UTILS_DATA */
294 
295 
296 
297 //***************************************************************************
298 //***************************************************************************
306 /************************************************************************/
317 
318 
319 /************************************************************************/
329 CAEP_RTITEM* caeuFindFormatByName (const char name[]);
330  /* DOXGRP_APICAEP_UTILS_SDKCAEP */
332 
333 
334 
335 //***************************************************************************
336 //***************************************************************************
348 /************************************************************************/
394 
395 
396 /************************************************************************/
410 
411 
412 /************************************************************************/
423 
424 
425 /************************************************************************/
436 
437 
438 /************************************************************************/
452 void caeuProgressEnd(CAEP_RTITEM *pRti, PWP_BOOL ok);
453  /* DOXGRP_APICAEP_UTILS_PROGRESS */
455 
456 
457 
458 //***************************************************************************
459 //***************************************************************************
468 /************************************************************************/
483 int caeuFileClose(CAEP_RTITEM* pRti, const CAEP_WRITEINFO *pWriteInfo);
484 
485 /************************************************************************/
507 int caeuFileOpen(CAEP_RTITEM* pRti, const CAEP_WRITEINFO *pWriteInfo);
508  /* DOXGRP_APICAEP_UTILS_FILEIO */
510 
511 
512 //***************************************************************************
513 //***************************************************************************
522 /************************************************************************/
531 const char * caeuEncodeToText(PWP_ENUM_ENCODING enc);
532 
533 /************************************************************************/
542 const char * caeuPrecisionToText(PWP_ENUM_PRECISION prec);
543 
544 /************************************************************************/
553 const char * caeuDimensionToText(PWP_ENUM_DIMENSION dim);
554  /* DOXGRP_APICAEP_UTILS_TOTEXT */
556 
557 
558 //***************************************************************************
559 //***************************************************************************
572 //-------------------------------------------------------------------------
579 void caeuSendDebugMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
580 
581 //-------------------------------------------------------------------------
588 void caeuSendInfoMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
589 
590 //-------------------------------------------------------------------------
597 void caeuSendWarningMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
598 
599 //-------------------------------------------------------------------------
606 void caeuSendErrorMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
607  /* DOXGRP_APICAEP_UTILS_MSGS */
609 
610 
611 //***************************************************************************
612 //***************************************************************************
622 //-------------------------------------------------------------------------
649  const char value[], const char access[], const char desc[],
650  const char range[]);
651 
652 //-------------------------------------------------------------------------
667 PWP_BOOL caeuAssignInfoValue(const char key[], const char value[],
668  bool createIfNotExists = true);
669 
681 PWP_BOOL
682 caeuPublishHighOrderValueDefinitions(const PWP_UINT32 maxPolynomialDegree);
683 
701 PWP_BOOL
702 caeuPublishMeshLinkValueDefinitions(const char *indexScheme);
703 
713 
722 PWP_BOOL
724 
734 
744 
753 PWP_BOOL
755  /* DOXGRP_APICAEP_UTILS_VARS */
757 
758 
759 
760 //***************************************************************************
761 //***************************************************************************
769 /************************************************************************/
772 #define CAEPU_RT_DIM(rti) (rti)->pWriteInfo->dimension
773 
774 /************************************************************************/
778 #define CAEPU_RT_DIM_TEXT(rti) \
779  caeuDimensionToText((rti)->pWriteInfo->dimension)
780 
781 /************************************************************************/
784 #define CAEPU_RT_DIM_IS(rti, d) PWP_CAST_BOOL((d) == CAEPU_RT_DIM(rti))
785 
786 /************************************************************************/
789 #define CAEPU_RT_DIM_3D(rti) CAEPU_RT_DIM_IS(rti, PWP_DIMENSION_3D)
790 
791 /************************************************************************/
794 #define CAEPU_RT_DIM_2D(rti) CAEPU_RT_DIM_IS(rti, PWP_DIMENSION_2D)
795 
796 
797 /************************************************************************/
800 #define CAEPU_RT_PREC(rti) (rti)->pWriteInfo->precision
801 
802 /************************************************************************/
806 #define CAEPU_RT_PREC_TEXT(rti) \
807  caeuPrecisionToText((rti)->pWriteInfo->precision)
808 
809 /************************************************************************/
812 #define CAEPU_RT_PREC_IS(rti, prec) PWP_CAST_BOOL((prec) == CAEPU_RT_PREC(rti))
813 
814 /************************************************************************/
817 #define CAEPU_RT_PREC_SINGLE(rti) CAEPU_RT_PREC_IS(rti, PWP_PRECISION_SINGLE)
818 
819 /************************************************************************/
822 #define CAEPU_RT_PREC_DOUBLE(rti) CAEPU_RT_PREC_IS(rti, PWP_PRECISION_DOUBLE)
823 
824 
825 /************************************************************************/
828 #define CAEPU_RT_ENCODING(rti) (rti)->pWriteInfo->encoding
829 
830 /************************************************************************/
834 #define CAEPU_RT_ENCODING_TEXT(rti) \
835  caeuEncodeToText((rti)->pWriteInfo->encoding)
836 
837 /************************************************************************/
840 #define CAEPU_RT_ENC_IS(rti, e) PWP_CAST_BOOL((e) == CAEPU_RT_ENCODING(rti))
841 
842 /************************************************************************/
845 #define CAEPU_RT_ENC_ASCII(rti) CAEPU_RT_ENC_IS(rti, PWP_ENCODING_ASCII)
846 
847 /************************************************************************/
850 #define CAEPU_RT_ENC_BINARY(rti) CAEPU_RT_ENC_IS(rti, PWP_ENCODING_BINARY)
851 
852 /************************************************************************/
855 #define CAEPU_RT_ENC_UNFORMATTED(rti) \
856  CAEPU_RT_ENC_IS(rti, PWP_ENCODING_UNFORMATTED)
857 
858 
859 /************************************************************************/
863 #define CAEPU_RT_IS_ABORTED(rti) PWP_CAST_BOOL((rti)->opAborted)
864 
865 /************************************************************************/
868 #define CAEPU_RT_ABORT(rti) ((rti)->opAborted = PWP_TRUE)
869 
870 /************************************************************************/
910 #define CAEPU_RT_TRY(rti, theOp) \
911  ((rti)->opAborted ? PWP_FALSE : \
912  (((rti)->opAborted = !(theOp)), !CAEPU_RT_IS_ABORTED(rti)))
913 
914 
915 /************************************************************************/
918 #define CAEPU_IS_CLKS_ID(id) \
919  PWP_CAST_BOOL(((id) >= 0) && ((id) <= CAEPU_CLKS_LAST))
920 
921 /************************************************************************/
924 #define CAEPU_RT_CLKS_ID(rti, id) (CAEPU_IS_CLKS_ID(id)? (rti)->clocks[id]: 0)
925 
926 /************************************************************************/
930 #define CAEPU_RT_CLKS_DIFF(rti, startId, endId) \
931  ((CAEPU_IS_CLKS_ID(startId) && CAEPU_IS_CLKS_ID(endId)) ? \
932  ((rti)->clocks[endId] - (rti)->clocks[startId]) : 0)
933 
934 /************************************************************************/
938 #define CAEPU_RT_CLKS_POLL(rti, id) \
939  CAEPU_RT_CLKS_DIFF(rti, id, CAEPU_CLKS_PROGINCR)
940 
941 /************************************************************************/
945 #define CAEPU_RT_CLKS_POLL_STEP(rti) \
946  CAEPU_RT_CLKS_POLL(rti, CAEPU_CLKS_BEGSTEP)
947 
948 /************************************************************************/
952 #define CAEPU_RT_CLKS_DIFF_STEP(rti) \
953  CAEPU_RT_CLKS_DIFF(rti, CAEPU_CLKS_BEGSTEP, CAEPU_CLKS_ENDSTEP)
954 
955 /************************************************************************/
959 #define CAEPU_RT_CLKS_POLL_TOTAL(rti) \
960  CAEPU_RT_CLKS_POLL(rti, CAEPU_CLKS_PROGINIT)
961 
962 /************************************************************************/
966 #define CAEPU_RT_CLKS_DIFF_TOTAL(rti) \
967  CAEPU_RT_CLKS_DIFF(rti, CAEPU_CLKS_PROGINIT, CAEPU_CLKS_PROGEND)
968 
969 /************************************************************************/
973 #define CAEPU_CLKS_TO_MSECS(c) ((PWP_INT32)((c) * 1000) / CLOCKS_PER_SEC)
974 
975 /************************************************************************/
979 #define CAEPU_CLKS_TO_SECS(c) ((PWP_INT32)(c) / CLOCKS_PER_SEC)
980 
981 /************************************************************************/
985 #define CAEPU_CLKS_TO_MINS(c) (CAEPU_CLKS_TO_SECS(c) / 60)
986 
987 /************************************************************************/
991 #define CAEPU_CLKS_TO_HOURS(c) (CAEPU_CLKS_TO_MINS(c) / 60)
992 
993 /************************************************************************/
998 #define CAEPU_CLKS_TO_HMS(c, h, m, s) \
999  (s = CAEPU_CLKS_TO_SECS(c)), \
1000  (h = s / 3600), (s -= h * 3600), \
1001  (m = s / 60), \
1002  (s -= m * 60)
1003 
1004 /************************************************************************/
1007 #define CAEPU_CLKS_TO_FSECS(c) ((PWP_FLOAT)(c) / (PWP_FLOAT)CLOCKS_PER_SEC)
1008 
1015 } /* extern "C" */
1016 
1017 #endif /* _APICAEPUTILS_H_ */
caeuExportStructuredAsUnstructured
PWP_BOOL caeuExportStructuredAsUnstructured(PWGM_HGRIDMODEL model)
Get the user-requested structured grid handling.
Definition: apiCAEPUtils.cxx:378
caeuDimensionToText
const char * caeuDimensionToText(PWP_ENUM_DIMENSION dim)
Converts a PWP_ENUM_DIMENSION value to a text string representation.
Definition: apiCAEPUtils.cxx:513
caeuPrecisionToText
const char * caeuPrecisionToText(PWP_ENUM_PRECISION prec)
Converts a PWP_ENUM_PRECISION value to a text string representation.
Definition: apiCAEPUtils.cxx:500
caeuFilePrecision
PWP_ENUM_PRECISION caeuFilePrecision(PWGM_HGRIDMODEL model)
Get the user-requested file precision.
Definition: apiCAEPUtils.cxx:359
CAEP_RTITEM::elemType
PWP_BOOL elemType[PWGM_ELEMTYPE_SIZE]
Array of supported element-type flags.
Definition: apiCAEPUtils.h:180
rtCaepInstanceData.h
Customizes the typedef CAEP_RTITEM declaration.
PWP_ENUM_VALTYPE
PWP_ENUM_VALTYPE
Supported PWP-API getValue() transfer types.
Definition: apiPWP.h:696
CAEP_RTITEM::pBCInfo
CAEP_BCINFO * pBCInfo
Pointer to an array of supported BC definitions.
Definition: apiCAEPUtils.h:140
CAEPU_CLKS_PROGINIT
@ CAEPU_CLKS_PROGINIT
Definition: apiCAEPUtils.h:104
CAEP_RTITEM::unfData
PWU_UNFDATA unfData
Unformatted file I/O data.
Definition: apiCAEPUtils.h:210
caepRtItem
CAEP_RTITEM caepRtItem[]
The runtime array of CAEP_RTITEM items.
Definition: apiCAEP.cxx:30
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
CAEPU_CLKS_PROGEND
@ CAEPU_CLKS_PROGEND
Definition: apiCAEPUtils.h:108
PWU_RTITEM
The runtime data representing a PWP-API suported by a plugin.
Definition: apiPWPUtils.h:42
CAEP_RTITEM::pApiData
PWU_RTITEM * pApiData
Pointer to the associated PWU_RTITEM structure.
Definition: apiCAEPUtils.h:133
CAEP_RTITEM
The data representing a CAE exporter instance.
Definition: apiCAEPUtils.h:124
caeuFindFormatByName
CAEP_RTITEM * caeuFindFormatByName(const char name[])
Find an item in caepRtItem[] by it's name.
Definition: apiCAEPUtils.cxx:38
caeuPublishMeshLinkValueDefinitions
PWP_BOOL caeuPublishMeshLinkValueDefinitions(const char *indexScheme)
Enables support for the export of MeshLink data and publishes all needed value definitions.
Definition: apiCAEPUtils.cxx:292
CAEP_FORMATINFO
The information returned for each supported CAEP exporter.
Definition: apiCAEP.h:98
caeuProgressIncr
PWP_BOOL caeuProgressIncr(CAEP_RTITEM *pRti)
Completes a progress tracking sub-step.
Definition: apiCAEPUtils.cxx:89
PWGM_HGRIDMODEL
An opaque handle to a grid model.
Definition: apiGridModel.h:326
caeuProgressEndStep
PWP_BOOL caeuProgressEndStep(CAEP_RTITEM *pRti)
Completes a progress tracking major step.
Definition: apiCAEPUtils.cxx:146
CAEPU_CLKS_ENDSTEP
@ CAEPU_CLKS_ENDSTEP
Definition: apiCAEPUtils.h:107
caeuSendInfoMsg
void caeuSendInfoMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an info text message (PWP_MSGID_INFO) to the framework.
Definition: apiCAEPUtils.cxx:224
caeuSendDebugMsg
void caeuSendDebugMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a debug text message (PWP_MSGID_DEBUG) to the framework.
Definition: apiCAEPUtils.cxx:215
CAEP_RTITEM::BCCnt
PWP_UINT32 BCCnt
The number of BC definitions.
Definition: apiCAEPUtils.h:146
apiGridModel.h
Pointwise Grid Model API Specification (PWGM-API)
CAEP_RTITEM::VCCnt
PWP_UINT32 VCCnt
The number of VC definitions.
Definition: apiCAEPUtils.h:160
PWP_ENUM_ENCODING
PWP_ENUM_ENCODING
File encoding values.
Definition: apiPWP.h:782
CAEP_RTITEM::pFileExt
const char ** pFileExt
Pointer to an array of valid file extensions.
Definition: apiCAEPUtils.h:167
caeuProgressBeginStep
PWP_BOOL caeuProgressBeginStep(CAEP_RTITEM *pRti, PWP_UINT32 total)
Begins a progress tracking step.
Definition: apiCAEPUtils.cxx:70
caeuSendErrorMsg
void caeuSendErrorMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an error text message (PWP_MSGID_ERROR) to the framework.
Definition: apiCAEPUtils.cxx:242
caeuAssignInfoValue
PWP_BOOL caeuAssignInfoValue(const char key[], const char value[], bool createIfNotExists=true)
Creates a key/value pair that defines a CAE info attribute.
Definition: apiCAEPUtils.cxx:262
CAEP_RUNTIME_INSTDATADECL
#define CAEP_RUNTIME_INSTDATADECL
Implementation defined CAE runtime instance data macro.
Definition: apiCAEPUtils.h:63
caeuFileEncoding
PWP_ENUM_ENCODING caeuFileEncoding(PWGM_HGRIDMODEL model)
Get the user-requested file encoding.
Definition: apiCAEPUtils.cxx:337
CAEPU_CLKS_PROGINCR
@ CAEPU_CLKS_PROGINCR
Definition: apiCAEPUtils.h:106
caeuEncodeToText
const char * caeuEncodeToText(PWP_ENUM_ENCODING enc)
Converts a PWP_ENUM_ENCODING value to a text string representation.
Definition: apiCAEPUtils.cxx:486
apiCAEP.h
Pointwise CAE Plugin API (CAEP-API)
caeuProgressInit
PWP_BOOL caeuProgressInit(CAEP_RTITEM *pRti, PWP_UINT32 cnt)
Initializes a progress tracking session.
Definition: apiCAEPUtils.cxx:53
CAEP_RTITEM::pVCInfo
CAEP_VCINFO * pVCInfo
Pointer to an array of supported VC definitions.
Definition: apiCAEPUtils.h:153
caepFormatCnt
PWP_UINT32 caepFormatCnt
The number of entries in caepRtItem[] array.
Definition: apiCAEP.cxx:36
caeuSendWarningMsg
void caeuSendWarningMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a warning text message (PWP_MSGID_WARNING) to the framework.
Definition: apiCAEPUtils.cxx:233
CAEPU_CLKS_PROGUPDATE
@ CAEPU_CLKS_PROGUPDATE
Definition: apiCAEPUtils.h:103
caeuPublishValueDefinition
PWP_BOOL caeuPublishValueDefinition(const char key[], PWP_ENUM_VALTYPE type, const char value[], const char access[], const char desc[], const char range[])
Creates a collection of key/value pairs that represent a published CAE attribute definition.
Definition: apiCAEPUtils.cxx:252
caeuExportBndryConditionsOnly
PWP_BOOL caeuExportBndryConditionsOnly(PWGM_HGRIDMODEL model)
Get the user-requested bc export option.
Definition: apiCAEPUtils.cxx:328
caeuFileOpen
int caeuFileOpen(CAEP_RTITEM *pRti, const CAEP_WRITEINFO *pWriteInfo)
Prepare pRti for file I/O as specified by pWriteInfo.
Definition: apiCAEPUtils.cxx:438
PWP_ENDIANNESS
PWP_ENDIANNESS
Flags used to indicate endianness or control endian behaviors in functions.
Definition: apiPWP.h:822
CAEPU_ENUM_CLOCKS
CAEPU_ENUM_CLOCKS
Supported CAEPU clock id values.
Definition: apiCAEPUtils.h:102
PWP_BOOL
int PWP_BOOL
logical value
Definition: apiPWP.h:303
caeuPublishHighOrderValueDefinitions
PWP_BOOL caeuPublishHighOrderValueDefinitions(const PWP_UINT32 maxPolynomialDegree)
Enables support for the export of high order meshes and publishes all needed value definitions.
Definition: apiCAEPUtils.cxx:271
CAEP_VCINFO
Volume condition definition information.
Definition: apiCAEP.h:166
CAEP_RTITEM::model
PWGM_HGRIDMODEL model
Runtime grid model handle to export.
Definition: apiCAEPUtils.h:216
caeuFindFormatById
CAEP_RTITEM * caeuFindFormatById(PWP_UINT32 id)
Find an item in caepRtItem[] by it's id.
Definition: apiCAEPUtils.cxx:23
CAEP_WRITEINFO
CAE export write control information.
Definition: apiCAEP.h:184
caeuFileClose
int caeuFileClose(CAEP_RTITEM *pRti, const CAEP_WRITEINFO *pWriteInfo)
Closes pRti for file I/O as specified by pWriteInfo.
Definition: apiCAEPUtils.cxx:176
CAEP_BCINFO
Boundary condition definition information.
Definition: apiCAEP.h:67
CAEP_RTITEM::pWriteInfo
const CAEP_WRITEINFO * pWriteInfo
Runtime export CAEP_WRITEINFO data.
Definition: apiCAEPUtils.h:222
CAEP_RTITEM::ExtCnt
PWP_UINT32 ExtCnt
The number of valid file extensions.
Definition: apiCAEPUtils.h:173
apiPWPUtils.h
Data and functions useful to PWP-API compliant plugins.
apiPWP.h
Pointwise Plugin API (PWP-API)
CAEPU_CLKS_BEGSTEP
@ CAEPU_CLKS_BEGSTEP
Definition: apiCAEPUtils.h:105
CAEP_RTITEM::FormatInfo
CAEP_FORMATINFO FormatInfo
The CAE Plugin format data.
Definition: apiCAEPUtils.h:129
PWP_ENUM_DIMENSION
PWP_ENUM_DIMENSION
Supported dimensionality values.
Definition: apiPWP.h:763
caeuFileByteOrder
PWP_ENDIANNESS caeuFileByteOrder(PWGM_HGRIDMODEL model)
Get the user-requested file byte order.
Definition: apiCAEPUtils.cxx:307
caeuProgressEnd
void caeuProgressEnd(CAEP_RTITEM *pRti, PWP_BOOL ok)
Ends all progress tracking.
Definition: apiCAEPUtils.cxx:161
CAEP_RTITEM::fp
FILE * fp
Runtime FILE pointer.
Definition: apiCAEPUtils.h:199
PWP_ENUM_PRECISION
PWP_ENUM_PRECISION
File precision values.
Definition: apiPWP.h:802
PWU_UNFDATA
Unformatted file data block.
Definition: apiPWPUtils.h:344