Versions Compared

Key

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

Table of Contents

Create a problemtype

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

...

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.

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 example: the cmas2d_customlib problemtype. You can see it's files on the example's problemtype folder (GiD 14.0\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 -> Examples -> cmas2d_customlib. The first you can see is a window like this:

This window helps you to generate a random 4 sided surface. For this example let's click Random surface and get an autogenerated 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:

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.

...


Your tree should look like this:

Writing the calculation files

Once created a geometry and assigned properties in the tree, it is time to write the input file.
For this example we will need to write the following information in a file:

...


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 process opening the file {modelname}.dat on the model folder.

Solver execution

At this point, we have generated a .dat file, containing the input data for the solver. It's time to launch it. In order to do it, we should have a .bat file (One for Windows and another for Unix based systems.
This script should delete the output files of previous executions (if exist) and launch the solver executable.
Check cmas2d_customlib.win.bat and cmas2d_customlib.unix.bat for more information.
The solver is located in the exec folder of the problem type. For this example, you can access to de cmas2d.c source file, and there are some compiled versions, for the common architectures.

Results

After the execution, the solver has generated some files:

...


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 > MC-DISTANCE
You should see something like this, but adapted to your generated geometry:


Extra: Wizard problemtype example

The current course focuses on a 'tree distribution' of the information. There is another example that implements a 'wizard distribution', based on this tree one. You can find the wizard one on our Github site.

...