Kratos GiD Graphical User Interface Guide

From KratosWiki
Jump to: navigation, search


How to: Write the MDPA file

Any kratos application must write it's data in a mdpa file that follows the structure defined Input_Data. In order to write this file, the application must define the tcl procedure: writeModelPartEvent, on it's write tcl file

Let's see different ways to write each of the main blocks:

The easy way

There are some common implemented procedures for writing easily the mdpa, defined in /scripts/Writing.tcl. Let's see the Solid app as an example:


In the solid app, on the init tcl procedure, we initialize some variables, used later on the "conditions" functions; a list of valid apps, used in the app inheritance, and a variable that defines if we want to print all the nodes in the GiD mesh (0) or just the nodes of the groups assigned to a part(1), when writing the nodal coordinates block.

proc Solid::write::Init { } {
    # Namespace variables inicialization
    variable ConditionsDictGroupIterators
    variable NodalConditionsGroup
    set ConditionsDictGroupIterators [dict create]
    set NodalConditionsGroup [list ]
    variable validApps
    set validApps [list "Solid"]
    variable writeCoordinatesByGroups
    set writeCoordinatesByGroups 0

Write event

As said ut supra , the current application receives an event for writing, that must be implemented in the write tcl file. In our example:

proc Solid::write::writeModelPartEvent { } {
    variable writeCoordinatesByGroups
    variable validApps

    # Init data, so we tell the system where the materials are used in our tree
    write::initWriteData "SLParts" "SLMaterials"
    # Common functions
    write::WriteString "Begin Properties 0"
    write::WriteString "End Properties"
    write::writeMaterials $validApps
    if {$writeCoordinatesByGroups} {write::writeNodalCoordinatesOnParts} {write::writeNodalCoordinates}
    # Customized functions

  • The first we do is to call the initWriteData function, to inform the system where are we using the materials in our tree.
  • Then we write some headers with writeModelPartData and WriteString
  • Using write::writeMaterials the Properties block is written. We specify the valid apps whose materials must be written. This allows us to write a different and independent mdpa in a multiple app inheritance (FSI).
  • As $writeCoordinatesByGroups value is 0, all the nodes coordinates in the GiD mesh are written in the Nodal Coordinates block
  • writeElementConnectivities prints the element connectivities specified in the initWriteData first argument.

Then we find some custom implementations, such as the Conditions and the Meshes or subModelParts

Personal tools