Versions Compared

Key

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

Table of Contents

This tutorial takes you through the steps involved in defining a problem type using GiD. A problem type is a set of files configured by a solver developer so that the program can prepare data to be analyzed.
A simple example was chosen, and takes us through all the associated configuration files while using few lines of code. Particular emphasis is given to the calculation of the centers of mass for two-dimensional surfaces. A simple formulation both conceptually and numerically.
By the end of the example, you should be able to create a calculating module that will interpret the mesh generated in GiD Preprocess. The module will calculate values for each element of the mesh and store the values in a file in such a way as they can be read by GiD Post-process.

Introduction

Our aim is to solve a problem that involves calculating the center of gravity (center of mass) of a 2D object. To do this, we need to develop a calculating module that can interact with GiD.
The problem: calculate the center of mass.
The center of mass (XCM,YCM) of a two-dimensional body is defined as

Image Modified

...

  Image Modified

...

Where ρ(x,y) is the density of the material at point (x,y) and S is the surface of the body; mi are concentrated masses applied on the point (xi,yi).
Each of the N elements is treated as concentrated weight whose mass is defined as the product of the (surface) density and the area of the element.

Interaction of GiD with the calculating module

GiD Preprocess makes a discretization of the object under study and generates a mesh of elements, each one of which is assigned a material and some conditions. This preprocessing information in GiD (mesh, materials, and conditions) enables the calculating module to generate results. For the present example, the calculating module will find the distance of each element relative to the center of mass of the object.
Finally, the results generated by the calculating module will be read and visualized in GiD Post-process.

Image Modified

Diagram of the workflow

GiD must adapt these data to deal with them. Materials, boundary and/or load conditions, and general problem data must be defined.
The calculating module (in this example cmas2d.exe) solves the equations in the problem and saves the results in the results file. This module may be programmed in the language of your choice, 'C' is used in this example
GiD Post-process reads the following files generated by the calculating module:
project_name.post.res: results file.
Each element of the mesh corresponds to a value.
project_name.post.msh: file containing the post-process mesh. If this file does not exist, GiD uses the preprocess mesh also for postprocess.

Example: cmas2d_customlib

Let's see out our example: the cmas2d_customlib problemtype. You can see it's files on the example's problemtype folder (GiD 14.0<GiD>\problemtypes\Examples\cmas2d_customlib.gid)
Inside it's folder, we can find the following files:

...


It's time to load the problemtype. Go to Data-> Problemtype >Problemtype-> Examples >Examples-> cmas2d>cmas2d_customlib. The first you can see is a window like this:Image Removed


Image Added

This window helps you to generate a random 4 sided surface. For this example let's click Random surface and get an

...

auto-generated surface. You can click continue and create your own surface. This is the surface I'll work with:


After this, let's open the properties tree. Go to Data-

...

>Data tree.

Interface definition

In this section, we are going to prepare the interface definition document, called cmas2d_customlib_default.spd.
This is a file in XML format and contains all the definition of all the data necessary for the analysis.
First of all, let's see the final result:

Image Modified

Step by step. The first we see is Units. It's useful to set a global criteria, such as the geometry units, or the default units system.


The next is Point Weight, to assign concentrated mass to a group that contains points. It's spd code is:

...

  • Write '25' in the Weight field
  • Click on 'select' button and select one (or more) point.
  • Press ESC to stop selecting. A group name will be generated.
  • Click OK

...

Image Added

Then we find 'Properties', a folder or 'container', that contains 'Shells' and 'Materials'. It's code is:

...

There is a 'container', another 'condition' called Shells, and a special 'value' called material. In this section, we want to assign a material from the database to a surface (see 'ov' field on the condition). NOTE: As you can see, there is an include to a file. The customLib library allows splitting the spd in different slices. You can find the materials database on that file in the problemtype folder.
By 'double clicking' on Shells, we get a window like this:Image Removed

Image Added

  • Select a material from the list.
  • Select the surface
  • Press ESC
  • Click OK


Your tree should look like this:

Image Modified

Writing the calculation files

...

First we need to do in this function is to call some initialization procedures:


To open the file for writtingwriting:
customlib::InitWriteFile $filename


To initialize the material's database, indicating wich which 'conditions' have materials assigned.
customlib::InitMaterials [list "Shells"] active

...


It is time to write the point weights. To get the number of nodes where we are applying the weights, we need to specify which is the condition we are writtingwriting, and call GetNumberOfNodes:
set condition_list [list "Point_Weight"]
set number_of_conditions [customlib::GetNumberOfNodes $condition_list]


And foreach node with a Point_Weight condition asignedassigned, we need to print the node id and the asigned assigned weight.
set condition_list [list "Point_Weight"]
set condition_formats [list {"%1d" "node" "id"} {"%13.5e" "property" "Weight"}]
customlib::WriteNodes $condition_list $condition_formats


Finally, all we need to do is to close the writting writing file
customlib::EndWriteFile


To test this on your example, you just need to Save your model (ctrl + s), Mesh it (ctrl + g), and calculate (F5). You can see the result of the writting writing process opening the file {modelname}.dat on the model folder.

...


Access the .post.res file to see the format, and check the documentation about the Postprocess data files in the Customization manual.
It's time to change to postprocess and see our results. Go to View results in the menu, contour fill > DISTANCE CENTER
You should see something like this, but adapted to your generated geometry:


Image Modified

Extra: Wizard problemtype example

...