跳转至

CGNS

Article link

CGNS and HDF5 compiling and linking

CGNS From Beginner to Master

Tcl/Tk 系列链接整理

code example

cg_dataclass_read

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    DataClass_t dclass;
    cg_goto(this->fileId, 1, "end");
    cg_dataclass_read(&dclass);

    std::cout << "dclass = " << dclass << " dclass name = " << DataClassName[dclass] << "\n";

    CGNS_ENUMT(MassUnits_t) mass;
    CGNS_ENUMT(LengthUnits_t) length;
    CGNS_ENUMT(TimeUnits_t) time;
    CGNS_ENUMT(TemperatureUnits_t) temp;
    CGNS_ENUMT(AngleUnits_t) angle;
    CGNS_ENUMT(ElectricCurrentUnits_t) current;
    CGNS_ENUMT(SubstanceAmountUnits_t) amount;
    CGNS_ENUMT(LuminousIntensityUnits_t) intensity;

    CGNS_ENUMT(MassUnits_t) im;
    CGNS_ENUMT(LengthUnits_t) il;
    CGNS_ENUMT(TimeUnits_t) it;
    CGNS_ENUMT(TemperatureUnits_t) ix;
    CGNS_ENUMT(AngleUnits_t) ia;

    cg_units_read(&im,&il,&it,&ix,&ia);

    std::printf("\nUnits=\n    %s\n    %s\n    %s\n    %s\n    %s\n",
           MassUnitsName[im],LengthUnitsName[il],TimeUnitsName[it],
           TemperatureUnitsName[ix],AngleUnitsName[ia]);

    int nunits = -1;
    cg_nunits(&nunits);

    std::cout << "   CGNS nunits = " << nunits << "\n";

    cg_unitsfull_read(&mass, &length, &time, &temp, &angle, &current, &amount, &intensity);
    std::cout << "mass = " << mass << " MassUnitsName[mass] = " << MassUnitsName[mass]<<"\n";
    std::cout << "length = " << length << " LengthUnitsName[length] = " << LengthUnitsName[length]<<"\n";
    std::cout << "time = " << time << " TimeUnitsName[time] = " << TimeUnitsName[time]<<"\n";
    std::cout << "temp = " << temp << " TemperatureUnitsName[temp] = " << TemperatureUnitsName[temp]<<"\n";
    std::cout << "angle = " << angle<< " AngleUnitsName[angle] = " << AngleUnitsName[angle]<<"\n";
    std::cout << "current = " << current<< " ElectricCurrentUnitsName[current] = " << ElectricCurrentUnitsName[current]<<"\n";
    std::cout << "amount = " << amount<< " SubstanceAmountUnitsName[amount] = " << SubstanceAmountUnitsName[amount]<<"\n";
    std::cout << "intensity = " << intensity << " LuminousIntensityUnitsName[intensity] = " << LuminousIntensityUnitsName[intensity]<<"\n";

recurse_nodes

recurse_nodes

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
static int recurse_nodes (int input, double InputID,
    int output, double OutputID, int follow_links, int depth)
{
    int n, nchild, cnt, name_len, file_len;
    char name[CGIO_MAX_NAME_LENGTH+1];
    char *link_name, *link_file;
    double childID, newID;

    /* Copy the data from the current input node to the output node */

    if (depth && cgio_copy_node(input, InputID, output, OutputID))
        return CG_ERROR;

    /* Loop through the children of the current node */

    if (cgio_number_children(input, InputID, &nchild))
        return CG_ERROR;
    for (n = 1; n <= nchild; n++) {
        if (cgio_children_ids(input, InputID, n, 1, &cnt, &childID) ||
            cgio_get_name(input, childID, name) ||
            cgio_is_link(input, childID, &name_len))
            return CG_ERROR;
        if (name_len) {
            if (cgio_link_size(input, childID, &file_len, &name_len))
                return CG_ERROR;
        }
        if (name_len && (file_len == 0 || follow_links == 0)) {
            link_file = (char *) malloc (file_len + name_len + 2);
            if (link_file == NULL) {
                set_error(CGIO_ERR_MALLOC);
                return CG_ERROR;
            }
            link_name = link_file + file_len + 1;
            if (cgio_get_link(input, childID, link_file, link_name)) {
                free (link_file);
                return CG_ERROR;
            }
            link_file[file_len] = 0;
            link_name[name_len] = 0;
            if (cgio_create_link(output, OutputID, name, link_file,
                    link_name, &newID)) {
                free (link_file);
                return CG_ERROR;
            }
            free (link_file);
        }
        else {
            if (cgio_create_node(output, OutputID, name, &newID) ||
                recurse_nodes(input, childID, output, newID,
                    follow_links, ++depth))
                return CG_ERROR;
        }
    }
    return CG_OK;
}

CGIOsize

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
static int CGIOsize (ClientData data, Tcl_Interp *interp,
    int argc, char **argv)
{
    cgsize_t np;
    char str[65];
    double node_id;
    struct DataType *type;

    Tcl_ResetResult (interp);
    if (argc != 2) {
        Tcl_AppendResult (interp, "wrong # args: should be \"",
            argv[0], " node\"", NULL);
        return TCL_ERROR;
    }
    if (cgioNum == 0) {
        Tcl_AppendResult (interp, "no database is open", NULL);
        return TCL_ERROR;
    }

    if (get_node (interp, argv[1], &node_id))
        return TCL_ERROR;

    np = data_size (interp, node_id);
    if (np == -1)
        return TCL_ERROR;
    type = data_type (interp, node_id);
    if (NULL == type)
        return TCL_ERROR;
    sprintf (str, "%u", (unsigned)np * (unsigned)type->bytes);
    Tcl_AppendResult (interp, str, NULL);
    return TCL_OK;
}

Complex

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
typedef struct _C_double_complex
{
    double _Val[2];
} _C_double_complex;

typedef struct _C_float_complex
{
    float _Val[2];
} _C_float_complex;

typedef struct _C_ldouble_complex
{
    long double _Val[2];
} _C_ldouble_complex;

typedef _C_double_complex  _Dcomplex;
typedef _C_float_complex   _Fcomplex;
typedef _C_ldouble_complex _Lcomplex;

Compile

ifmodintr.lib

Text Only
1
8>LINK : fatal error LNK1104: 无法打开文件“ifmodintr.lib”
version 1
Text Only
1
2
3
cd d:\work\cgns_work\CGNS-4.4.0-Modified\build\
$env:path += ";c:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\compiler\lib\intel64\"
& .\cgns.sln

version 2

Text Only
1
2
3
cd d:\work\cgns_work\CGNS-4.4.0-Modified\build\
$env:path += ";c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\"
& .\cgns.sln

Text Only
1
2
3
4
5
6
7
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\ifmodintr.lib
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\ifconsol.lib
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\libifcoremd.lib
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\libifportmd.lib
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\libmmd.lib
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\libirc.lib
c:\Program Files (x86)\Intel\oneAPI\compiler\latest\lib\svml_dispmd.lib

ZoneType_t

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
typedef enum {
  CGNS_ENUMV( ZoneTypeNull ) =CG_Null,
  CGNS_ENUMV( ZoneTypeUserDefined ) =CG_UserDefined,
  CGNS_ENUMV( Structured ) =2,
  CGNS_ENUMV( Unstructured ) =3
} CGNS_ENUMT( ZoneType_t );

#define NofValidZoneTypes 4

extern CGNSDLL const char * ZoneTypeName[NofValidZoneTypes];

PointSetType_t

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
typedef enum {
  CGNS_ENUMV( PointSetTypeNull ) =CG_Null,
  CGNS_ENUMV( PointSetTypeUserDefined ) =CG_UserDefined,
  CGNS_ENUMV( PointList ) =2,
  CGNS_ENUMV( PointListDonor ) =3,
  CGNS_ENUMV( PointRange ) =4,
  CGNS_ENUMV( PointRangeDonor ) =5,
  CGNS_ENUMV( ElementRange ) =6,
  CGNS_ENUMV( ElementList ) =7,
  CGNS_ENUMV( CellListDonor ) =8
} CGNS_ENUMT( PointSetType_t );

cgns_ptset

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
typedef struct {            /* IndexArray/Range_t Node      */
    char_33 name;           /* name of ADF node                     */
    double id;              /* ADF ID number (address) of node      */
    cgns_link *link;        /* link information         */  /* V2.1 */
    int in_link;            /* set if child of a linked node        */
    CGNS_ENUMT(PointSetType_t) type;  /* PointList, PointRange, ...       */
    char_33 data_type;      /* type of data                         */
    cgsize_t npts;          /* number of points to define the patch */
    cgsize_t size_of_patch; /* nr of nodes or elements in patch     */
    void *data;             /* data (only loaded in MODE_MODIFY     */
} cgns_ptset;