
|
GiDpost: a C / C++ / Fortran library to create postprocess files for GiD
|
|
gidpost is a set of functions (library) for writing postprocess results for GiD in ASCII or binary format.
GiD version 6.1.4b or higher is required to read the ASCII postprocess files.
GiD version 7.2 or higher is required to read the binaries postprocess files.
This software is copyrighted by CIMNE
gid.cimne.upc.es,
(Visit GiD). The software can be used
freely under the terms described in license.terms, all terms described
there apply to all files associated with the software unless
explicitly disclaimed in individual files. Particular terms apply to the third party
code, "cfortran.h", which has its own distribution policy
(please read the "cfortran.doc" for this code). This
description asumes that the readear is familiar with the postprocess
terminology. For futher details please check the online help
available in GiD ( Postprocess
data files chapter).
The library was implemented taking into account two of the must widely
used development environments: C/C++ and FORTRAN.
Here we are going to describe how to compile and use the library. At
the end the reference of the library functions can be found.
- Unix platform:
A makefile is present inside the /unix directory
Inside this file set the value of the variable target to compile the "release" or the "debug"
library version.
To compile, open a console, change the current directory to /gidpost/unix, and write
make
This will create the library /release/gidpost.a ( or /debug/gidpostd.a)
- Micorsoft Windows platform:
A file named Makefile.vc is present to compile with Microsoft Visual C++
Inside this file set the value of the variable CFG to compile the "Release" or the
"Debug" library version.
To compile, open a DOS console, change the current directory to \gidpost\win, and write
nmake -f Makefile.vc
This will create the library gidpost.lib inside the subdirectory \Release
( or \Debug)
- Other platforms:
All the source code to generate the library is included, it can be compiled in other platforms.
The third party code, "cfortran.h", is also provided as a link between C and FORTRAN. It has
its own distribution policy. Please, read the file "cfortran.doc" about the licence terms of
this code.
- C / C++ language:
include the file header file gidpost.h to use the libray gidpost.lib
#include "gidpost.h"
A small example, called testpost.c, is provided to show the use of the library from c/c++.
- FORTRAN language:
A small example, called testpostfor.f, is provided to show the use of the library with FORTRAN
- Mesh file functions
int GiD_OpenPostMeshFile(char* FileName,GiD_PostMode Mode);
Description:
Open a new post mesh file
Parameters:
char* FileName
name of the mesh file (*.flavia.msh)
GiD_PostMode Mode
GiD_PostAscii=0 for ascii output
GiD_PostAsciiZipped=1 for compressed ascii output
GiD_PostBinary=2 for compressed binary output
Example:
c/c++
GiD_OpenPostMeshFile( "testpost.flavia.msh", GiD_PostAscii);
FORTRAN
CALL GID_OPENPOSTMESHFILE('testpost.flavia.msh',0)
int GiD_ClosePostMeshFile();
Description:
Close the current post mesh file
Parameters:
None
Example:
c/c++
GiD_ClosePostMeshFile();
FORTRAN
CALL GID_CLOSEPOSTMESHFILE
int GiD_BeginMesh(char* MeshName,GiD_Dimension Dim,GiD_ElementType EType,
int NNode);
Description:
Begin a new mesh. After that you should write the nodes and the elements.
When writing the elements it is assumed a connectivity of size given in the
paramenter NNode.
Parameters:
char* MeshName
Name of the mesh
GiD_Dimension Dim
GiD_2D=2 for a 2D mesh (is assumed coordinates z=0)
GiD_3D=3 for a 3D mesh
GiD_ElementType EType
GiD_Point=1 for a 1 noded-element
GiD_Linear=2 for a line element
(the number of nodes can be 2 for a linear case or 3 for the quadratic case)
GiD_Triangle=3 for a triangle element
(the number of nodes can be 3 for a linear case or 6 for the quadratic case)
GiD_Quadrilateral=4 for a quadrilateral element
(the number of nodes can be 4 for a linear case and 8 or 9 for the quadratic case)
GiD_Tetrahedra=5 for a tetrahedral element
(the number of nodes can be 4 for a linear case or 10 for the quadratic case)
GiD_Hexahedra=6 for a hexahedral element
(the number of nodes can be 8 for a linear case and 20 or 27 for the quadratic case)
int NNode
Number of nodes of this type of element. The element type an nnods must be constant
for all mesh elements, but it is valid to define more that one mesh.
Example:
c/c++
GiD_BeginMesh("TestMsh",GiD_2D,GiD_Triangle,3);
FORTRAN
CALL GID_BEGINMESH('quadmesh',2,4,4)
int GiD_EndMesh();
Description:
End the current mesh.
Parameters:
None
Example:
c/c++
GiD_EndMesh();
FORTRAN
CALL GID_ENDMESH
int GiD_BeginCoordinates();
Description:
Start a coordinate block in the current mesh. All nodes coordinates must be
written between a to this function and GiD_EndCoordinates().
Parameters:
None
Example:
c/c++
GiD_BeginCoordinates();
FORTRAN
CALL GID_BEGINCOORDINATES
int GiD_EndCoordinates();
Description:
Close the current coordinate block.
Parameters:
None
Example:
c/c++
GiD_EndCoordinates();
FORTRAN
CALL GID_ENDCOORDINATES
int GiD_WriteCoordinates(int id,double x,double y,double z);
Description:
Write a coordinate member at the current Coordinates Block.
Parameters:
int id
Node number identifier (starting from 1, is recommended to avoid jumps in the
numeration)
double x,double y,double z
Cartesian coordinates
Example:
c/c++
int id=1;
double x=3.5,y=1.5e-2,z=0;
GiD_WriteCoordinates(id,x,y,z);
FORTRAN
REAL*8 rx, ry
INTEGER*4 idx
idx=1
rx=3.5
ry=-4.67
CALL GID_WRITECOORDINATES(idx,rx,ry,0.0)
int GiD_BeginElements();
Description:
Start a elements block in the current mesh.
Parameters:
None
Example:
c/c++
GiD_BeginElements();
FORTRAN
CALL GID_BEGINELEMENTS
int GiD_EndElements();
Description:
Close the current elements block.
Parameters:
None
Example:
c/c++
GiD_EndElements();
FORTRAN
CALL GID_ENDELEMENTS
int GiD_WriteElement(int id,int nid[]);
Description:
Write an element member at the current Elements Block.
Parameters:
int id
Element number identifier
int nid[]
connectivities of the element, the vector dimension must be equal to the
NNode parameter given in the previous call to GiD_BeginMesh
Example:
c/c++
int id=2;
int nid[3];
nid[0]=4; nid[1]=7; nid[2]=3;
GiD_WriteElementMat(id,nid);
FORTRAN
INTEGER *4 nid(1:3)
INTEGER*4 idx
idx=2
nid(1)=4
nid(2)=7
nid(3)=3
CALL GID_WRITEELEMENT(idx,nid)
int GiD_WriteElementMat(int id,int nid[]);
Description:
Similar to GiD_WriteElement, but the last aditional integer
on nid correspond to a material number.
- Results file functions
The result groups cannot be written with this library by now. GiD can
read this result groups in the ASCII format from the version 7.2
int GiD_OpenPostResultFile(char* FileName,GiD_PostMode Mode);
Description:
Open a new post result file. All subsequent call to functions write the
information into this file. If there is no mesh file opened then the
output of the mesh is writen into this file also.
Parameters:
char* FileName
name of the mesh file (*.flavia.res)
GiD_PostMode Mode
GiD_PostAscii=0 for ascii output
GiD_PostAsciiZipped=1 for compressed ascii output
GiD_PostBinary=2 for compressed binary output
Note: In binary output, the mesh must be inside the same file of the results,
not call GiD_BeginMesh and GiD_EndMesh on this binary case.
Example:
c/c++
GiD_OpenPostResultFile( "testpost.bin",GiD_PostBinary);
FORTRAN
CALL GID_OPENPOSTRESULTFILE('testfortran.flavia.res',0)
int GiD_ClosePostResultFile();
Description:
Close the current post results file
Parameters:
None
Example:
c/c++
GiD_ClosePostResultFile();
FORTRAN
CALL GID_CLOSEPOSTRESULTFILE
int GiD_BeginGaussPoint(char* name,GiD_ElementType EType,char* MeshName,
int GP_number,int NodesIncluded,int InternalCoord);
Description:
Begin Gauss Points definition. The gauss point definition should have
a name wich may be referenced in futher results blocks. The gauss points
could be internal (InternalCoord=1) or given (InternalCoord=0). If the
gauss points are given then the list of its natural coordinates should be
written using the function GiD_WriteGaussPoint2D or GiD_WriteGaussPoint3D
depending on the dimension of the element type.
Parameters:
char* name
Name to reference this gauss points definition
GiD_ElementType EType
GiD_Point=1 for a 1 noded-element
GiD_Linear=2 for a line element
GiD_Triangle=3 for a triangle element
GiD_Quadrilateral=4 for a quadrilateral element
GiD_Tetrahedra=5 for a tetrahedral element
GiD_Hexahedra=6 for a hexahedral element
char* MeshName
An optional field. If this field is missing, the gauss points are defined
for all the elements of type my_type. If a mesh name is given, the gauss
points are only defined for this mesh.
int GP_number
number of gauss points per element. The GiD internal accepted number
should be:
1, 3, 6 for Triangles;
1, 4, 9 for quadrilaterals;
1, 4 for Tetrahedras;
1, 8, 27 for hexahedras and
1, ... n points equally spaced over lines.
int NodesIncluded
Can be 0 for nodes not included or 1 for included. Only used for gauss
points on Linear elements which indicate whether the end nodes of the
Linear element are included in the number of gauss points per element
count or not.
int InternalCoord
Can be 0 for given coordinates or 1 for internal GiD gauss
points location.
Example:
c/c++
GiD_BeginGaussPoint("GPtria",GiD_Triangle,NULL,1,0,1);
FORTRAN
CHARACTER*4 NULL
NULL = CHAR(0)//CHAR(0)//CHAR(0)//CHAR(0)
CALL GID_BEGINGAUSSPOINT('GPtria',3,NULL,1,0,1);
int GiD_EndGaussPoint();
Description:
End current Gauss Points definition
Parameters:
None
Example:
c/c++
GiD_EndGaussPoint();
FORTRAN
CALL GID_ENDGAUSSPOINT
int GiD_WriteGaussPoint2D(double x,double y);
int GiD_WriteGaussPoint3D(double x,double y,double z);
Description:
Write internal gauss point local coordinates (only required if
InternalCoord=0)
Parameters:
double x,double y,double z
Cartesian gauss points local coordinates
Example:
c/c++
double x=3.5;
double y=-7;
GiD_WriteGaussPoint2D(double x,double y);
FORTRAN
REAL*8 x, y
rx=3.5
ry=-7
CALL GID_WRITEGAUSSPOINT2D(x,y)
int GiD_BeginRangeTable(char* name);
Description:
Begin a Range Table definition. With a range table you can group
the result values into intervals and label each interval with a name.
Inside GiD this can be visualized with a contour range.
Parameters:
char* name
name identifier
Example:
c/c++
GiD_BeginRangeTable("table1");
FORTRAN
CALL GID_BEGINRANGETABLE('table1')
int GiD_EndRangeTable();
Description:
End a Range Table definition.
Parameters:
None
Example:
c/c++
GiD_EndRangeTable();
FORTRAN
CALL GID_ENDRANGETABLE()
int GiD_WriteMinRange(double max,char* name);
int GiD_WriteRange(double min,double max,char* name);
int GiD_WriteMaxRange(double min,char* name);
Description:
Write Range functions. Must be between GiD_BeginRangeTable and
GiD_EndRangeTable.
WriteMinRange : write a range with an implicit minimum value,
the minimum absolute in the result set.
WriteRange : write an explicit range.
WritemaxRange: write a range with an implicit maximum value,
the maximum absolute in the result set.
Parameters:
double min,double max
Values to define a interval
char* name
string asociated to be showed for this interval
Example:
c/c++
GiD_WriteRange(0.0,100.0,"Normal");
FORTRAN
CALL GID_WRITERANGE(0.0,100.0,'Normal')
int GiD_BeginResult(char* Result,char* Analysis,double step,
GiD_ResultType Type,GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
int compc,char* compv[]);
Description:
Begin Result Block. This function open a result block.
Parameters:
char* Result
a name for the Result, which will be used for menus.
char* Analysis
the name of the analysis of this Result, which will be used for menus.
double step
the value of the time step inside the analysis "analysis name".
(for multiple steps results)
GiD_ResultType Type
The type of defined result:
GiD_Scalar=0
GiD_Vector=1
GiD_Matrix=2
GiD_PlainDeformationMatrix=3
GiD_MainMatrix=4
GiD_LocalAxes=5
GiD_ResultLocation Where
The location of the results
GiD_OnNodes=0
GiD_OnGaussPoints=1
char* GaussPointsName
If Where is GiD_OnGaussPoints a "location name" (predefined in
GiD_BeginGaussPoint) should be entered.
char* RangeTable
A valid Range table name or NULL
int compc
The number of component names or 0
char* compv[]
array of 'compc' strings to be used as component names
Note: in FORTRAN, instead use GID_BEGINRESULT, must be used a separate
function foreach result type:
int GiD_BeginScalarResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,
char* RangeTable,char* Comp);
int GiD_BeginVectorResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
char* Comp1,char* Comp2,char* Comp3,char* Comp4);
int GiD_Begin2DMatResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
char* Comp1,char* Comp2,char* Comp3);
int GiD_Begin3DMatResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
char* Comp1,char* Comp2,char* Comp3,
char* Comp4,char* Comp5,char* Comp6);
int GiD_BeginPDMMatResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
char* Comp1,char* Comp2,char* Comp3,
char* Comp4);
int GiD_BeginMainMatResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
char* Comp1,char* Comp2,char* Comp3,
char* Comp4,char* Comp5,char* Comp6,
char* Comp7,char* Comp8,char* Comp9,
char* Comp10,char* Comp11,char* Comp12);
int GiD_BeginLAResult(char* Result,char* Analysis,float step,
GiD_ResultLocation Where,
char* GaussPointsName,char* RangeTable,
char* Comp1,char* Comp2,char* Comp3);
Example:
c/c++
GiD_BeginResult("Result","Static",1.0,GiD_Scalar,GiD_OnNodes,NULL,NULL,0,NULL);
FORTRAN
CHARACTER*4 NULL
NULL = CHAR(0)//CHAR(0)//CHAR(0)//CHAR(0)
CALL GID_BEGINSCALARRESULT('Result','Analy.',1.0,0,0,NULL,NULL)
int GiD_EndResult();
Description:
End Result Block.
Parameters:
None
Example:
c/c++
GiD_EndResult();
FORTRAN
CALL GID_ENDRESULT
int GiD_WriteScalar(int id,double v);
int GiD_WriteVector(int id,double x,double y,double z);
int GiD_WriteVectorModule(int id,double x,double y,double z,double mod);
int GiD_Write2DMatrix(int id,double Sxx,double Syy,double Sxy);
int GiD_Write3DMatrix(int id,double Sxx,double Syy,double Szz,
double Sxy,double Syz,double Sxz);
int GiD_WritePlainDefMatrix(int id,double Sxx,double Syy,double Sxy,double Szz);
int GiD_WriteMainMatrix(int id,
double Si,double Sii,double Siii,
double Vix,double Viy,double Viz,
double Viix,double Viiy,double Viiz,
double Viiix,double Viiiy,double Viiiz);
int GiD_WriteLocalAxes(int id,double euler_1,double euler_2,double euler_3);
Description:
Write result functions. Must be between GiD_BeginResult and GiD_EndResult
Parameters:
None
Example:
c/c++
GiD_WriteScalar(3,4.6);
FORTRAN
INTEGER*4 idx
REAL*8 value
idx=3
value=4.6
CALL GID_WRITESCALAR(idx,value)
|