Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

C / C++ language:

Include the file header file gidpost.h to use the libray gidpost

...

  • testpost.c, is provided to show the use of the library from C/C++.
  • testpost_fd.c that use the *f functions where the file handler is explicitly specified (to allow multiple files)
  • IGA_test_1.c, to show the use of OnNurbsSurface isogeometric results

FORTRAN language:


A small example, called testpostfor.f, is provided to show the use of the library with FORTRAN 77
the same case is implemented with FORTRAN 90 in the example testpost.f90, using the gidpost.F90 interface module

...


Note: the hdf5.lib library is only required to write files with HDF5 format.
Note: For Linux platforms the extension of libraries is .a instead of .lib


Python module:

Inside the folder gidpost/gidpost-swig there are a couple of examples on how to use gidpost python module.

Once the module has been built and installed, then you can use it like this:

Code Block
languagepy
titlegidpost_test.py
$ python3
Type "help", "copyright", "credits" or "license" for more information.
>>> import gidpost
gidpost.GiD_PostInit()
gidpost.GiD_OpenPostResultFile( "gidpost-test.post.h5", gidpost.GiD_PostHDF5)

# create connectivity array for each element
# two triangles
elem_connec_1 = gidpost.new_intArray( 3)
elem_connec_2 = gidpost.new_intArray( 3)
# 1 quadrilateral
elem_connec_3 = gidpost.new_intArray( 4)               # Create an array
# id's begin at 1
gidpost.intArray_setitem( elem_connec_1, 0, 1)
gidpost.intArray_setitem( elem_connec_1, 1, 2)
gidpost.intArray_setitem( elem_connec_1, 2, 3)
gidpost.intArray_setitem( elem_connec_2, 0, 1)
gidpost.intArray_setitem( elem_connec_2, 1, 3)
gidpost.intArray_setitem( elem_connec_2, 2, 4)
gidpost.intArray_setitem( elem_connec_3, 0, 2)
gidpost.intArray_setitem( elem_connec_3, 1, 5)
gidpost.intArray_setitem( elem_connec_3, 2, 6)
gidpost.intArray_setitem( elem_connec_3, 3, 3)

gidpost.GiD_BeginMeshColor( "test gp_py triangles", gidpost.GiD_3D, gidpost.GiD_Triangle, 3, 0.6, 0.5, 0.4)
gidpost.GiD_BeginCoordinates()
gidpost.GiD_WriteCoordinates( 1, 0.0, 0.0, 0.0)
gidpost.GiD_WriteCoordinates( 2, 1.0, 0.0, 0.0)
gidpost.GiD_WriteCoordinates( 3, 1.0, 1.0, 0.0)
gidpost.GiD_WriteCoordinates( 4, 0.0, 1.0, 0.0)
# coordinates of other meshes can be written here or at each mesh
gidpost.GiD_WriteCoordinates( 5, 2.0, 0.0, 0.0)
gidpost.GiD_WriteCoordinates( 6, 2.0, 1.0, 0.0)
gidpost.GiD_EndCoordinates()
gidpost.GiD_BeginElements()
gidpost.GiD_WriteElement( 1, elem_connec_1)
gidpost.GiD_WriteElement( 2, elem_connec_2)
gidpost.GiD_EndElements()

gidpost.GiD_BeginMeshColor( "test gp_py quadrilaterals", gidpost.GiD_3D, gidpost.GiD_Quadrilateral, 4, 0.8, 0.2, 0.5)
# coordinates of other meshes can be written in the first mesh or at each mesh
# gidpost.GiD_BeginCoordinates()
# gidpost.GiD_WriteCoordinates( 5, 2.0, 0.0, 0.0)
# gidpost.GiD_WriteCoordinates( 6, 2.0, 1.0, 0.0)
# gidpost.GiD_EndCoordinates()
gidpost.GiD_BeginElements()
gidpost.GiD_WriteElement( 3, elem_connec_3)
gidpost.GiD_EndElements()

# Writing results
gidpost.GiD_BeginResultHeader( "test nodal", "gidpost", 1.0, gidpost.GiD_Scalar, gidpost.GiD_OnNodes, "")
# id's begin at 1
gidpost.GiD_WriteScalar( 1, 10.0)
gidpost.GiD_WriteScalar( 2, 20.0)
gidpost.GiD_WriteScalar( 3, 30.0)
gidpost.GiD_WriteScalar( 4, 40.0)
gidpost.GiD_WriteScalar( 5, 50.0)
gidpost.GiD_WriteScalar( 6, 60.0)
gidpost.GiD_EndResult()

gidpost.GiD_BeginResultHeader( "test elemental", "gidpost", 1.0, gidpost.GiD_Scalar, gidpost.GiD_OnGaussPoints, "GP_ELEMENT_1")
# id's begin at 1
gidpost.GiD_WriteScalar( 1, 11.0)
gidpost.GiD_WriteScalar( 2, 22.0)
gidpost.GiD_WriteScalar( 3, 33.0)
gidpost.GiD_EndResult()

gidpost.GiD_ClosePostResultFile()
gidpost.GiD_PostDone()

gidpost.delete_intArray( elem_connec_1)
gidpost.delete_intArray( elem_connec_2)
gidpost.delete_intArray( elem_connec_3)