Erivelton's GSoC 2019

Parsing Input - week 2

June 08, 2019 — under ,

Time flies when you are solving problems or at least trying. After the feedback from my mentors regarding the first week, I was able to go deeper into the code and understand more day after day. My mentors have been really helpful with fast feedback. This second week, long emails were exchange in order to get more information about the tool and the tasks.

The following is a description what I have done.

Beam problem

The final goal of the project is to automatically add masses for the beam element. As stated by Marco Morandini, the roadmap to add this feature for MBDyn is composed by:

  1. Parsing Input: The MBDyn should be able to read from Input file the beam elements and for such case, it is desired to add automatically the masses and the input parameter "automatic mass" should be on the element block. The following contains an Input File structure example:
beam3:
  all the required data already specified for a beam,
  automatic mass,
  value_of_density_per_unit_length, mass offset (a vector), # node 1
  value_of_density_per_unit_length, mass offset (a vector), # node 2
  value_of_density_per_unit_length, mass offset (a vector); # node 3

or

beam3:
  all the required data already specified for a beam,
  automatic mass,
  value_of_density_per_unit_length, mass offset (a vector), # node 1
  same, # node 2
  same; # node 3
  1. Allocate new bodies to ElemData: Currently, all the elements are allocated according with its type (i.e. BODY, FORCE, INERTIA, BEAM and etc.) and it happens during the parsing. Therefore, after identifying if the input file contains the "automatic mass" parameter, it needs to be stored. So far, two approaches can be made. First, a number for each AUTOMATIC_INERTIA can be generated. Otherwise, it could be delayed for the end.
  2. Add new bodies: Then, after identifying that the element contains the parameter "automatic mass", it needs to create the body using the additional provided parameters, such as the value of density per unit length and mass offset.

So far this week, I have completed the parsing inputs (which is located at beam.cc). I am able to read the input file (modified cantilever1 example) and have extracted the expected information. This coming week I will continue on adding the new body. For achieving this task, I will be studying the body.c file. So far, I have already obtained several information from Marco, which will make it easier to adapt this code for the beam.

Code repository

As already mentioned in previous posts, I created a repository for gathering software, files and materials used in this coding period. This week I added the fresh repository and I already pushed the working modifications I have worked on this week.

To get the latest updates as they come, download my current software from git. To download the repository execute the following from the command line:

git clone git@github.com:EriveltonGualter/GSoC-MBDyn.git

To update to the latest version, go into your repository and execute:

git pull origin master

The code is located under the folder mbdyn-develop.

Editing and Debugging Code

As mentioned in the last post, I have been using gdb debugger. It was really useful in the beginning. However, Rafael Mudafort, one of the users of MBDyn, shared his launch configuration for VSCode here: https://public.gitlab.polimi.it/DAER/mbdyn/issues/19. I was able to modify it for my specifications. The following corresponds to the launch configuration for Visual Studio Code on Ubuntu 18.04:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "g++ build and debug active file",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceRoot}/mbdyn/mbdyn",
      "args": [],
      "stopAtEntry": false,
      "cwd": "/home/erivelton/GSoC2019/GSoC-MBDyn/Beam Scripts/",
      "args": ["-fcantilever1.mbd"],
      "stopAtEntry": false,
      "externalConsole": false,
      "MIMode": "gdb"
    }
  ]
}

and here is the task launch:

{
    "tasks": [
        {
            "type": "shell",
            "label": "cpp build active file",
            "command": "/usr/bin/cpp",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            }
        },
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            }
        }
    ],
    "version": "2.0.0"
}

More information about configuring the launch file can be found here: https://github.com/microsoft/vscode-cpptools/blob/master/launch.md/.


Theme created by Jim Crist. Licensed under Creative Commons.

Find me on Twitter, GitHub, old personal webpage, or shoot me an email.