How to use the GidIO
This is a tutotial on how to use the Kratos GiD interface (GidIO).
The HowTo describes the measures to be taken in order to read input from input files using the GidIO interface and how to write results that can be post-processed in GiD.
Generating an instance of GidIO
The GidIO interface can only be used, if an instance of the GidIO class has been created. This GidIO instance knows the path of the current problem.gid directory and automatically opens the respective input and output files in the problem.gid directory.
For the instantiation of the GidIO interface there are two Constructors available:
- GidIO( NodeDatafilename, PropertiesDatafilename, ElementDatafilename, ConditionDatafilename, InitialValueDatafilename, ResultFilename, GiD_PostMode ) where the names of each input file and the output file may be given separately, and
- GidIO( Filename, GiD_PostMode ), where the file names are determined automatically according to the given problem name
The flag GiD_PostMode determines whether the output should be written in plain text (GiD_PostASCII) or binary (Gid_PostBinary) file format. The ASCII format is only recommended for debugging, where the user needs to manually access and read the output data. In general, the binary format should be preferred as it yields much smaller output files and can be read and written much faster.
In the Python script of the problem to be solved with Kratos, the GidIO instance can be, for example, initialised by the following command:
gid_io = GidIO("problem_name",GiDPostMode.GiD_PostBinary)
the resulting Python object can then be used to read the input and write the output of the current problem.
Once a ModelPart object has been created, the actual content of the model can be read from the input files by means of the GidIO. The following command creates a ModelPart object and reads all the input files and automatically creates the respective model data:
model_part = ModelPart("Name")
After this, the ModelPart is ready to use.
Writing output that can be post-processed by GiD is written by means of the gidpost library. The GidIO interface provides several functions that allow for a convenient usage of this library in order to easily generate suitable output files. The following sections describe the different features available in the GidIO interface:
- writing normal mesh
- using mesh groups
- Writing conditions meshes
- Writing nodal meshes