Erivelton's GSoC 2019

Dynamic Analyze - Week 3 and 4

June 17, 2019 — under ,

This post encloses work from weeks 3 and 4 and also presents a summary about these 4 weeks of coding period before the First Evaluation. If you have been following my Google Summer of Code Blog, you know that the purpose of this project is to introduce consistent inertia modeling for beam elements.

The work done with MBDyn since the first week resulted in 5 posts. The first post talks about the Entry Test to be accepted in the program. The following post talks about the community period and the remaining posts were done every week with descriptions of the work I was doing with the help of my mentors Marco Morandini and Paolo Mantegazza. Here is a list of posts in case you wish to go over:

This past week I continued to work with allocating the bodies for the beam. Because it has been a while since I have coded using cpp, my skills were kind of rusty. So, this week I spent a few hours going over casting. I like to think that casting is a way to convert certain types of variables or objects to other types. For example, convert a float variable into an integer as in the following:

#include <iostream>
using namespace std;
int main()
{
   float f = 3.5;
   int a = f;
   int b = static_cast<int>(f);
   cout << b;
}

For MBDyn, there were some casting operations along with the coding that were challenging to me. For MBDyn, it has been using to access some information found on the derived class. For example, for StructNode class and StructDispNode in body.cc (https://github.com/EriveltonGualter/GSoC-MBDyn/blob/master/mbdyn-develop/mbdyn/struct/body.cc#L2134).

const DynamicStructDispNode* pDynamicDispNode = 0;
pDynamicDispNode = dynamic_cast<const DynamicStructDispNode*>(pStrDispNode1);

Another issue I faced in this meantime was related to SAFENEWWITHCONSTRUCTOR macro.

Restating what the mentors said, it dynamically allocates an entity and at the same time, when optionally built with some debug flags enabled, it does some further compile- and run-time checks. Even though its usage is not common anymore, we still use in MBDyn for consistency along the code. This is one of the variety of existent macros in the code which is located at mynewmem.h. For additional information, here is an interesting article about Dynamic Memory Allocation and Fragmentation in C and C++. The following is a description of how it can be used.

SAFENEWWITHCONSTRUCTOR_ (item * pit, item, constructor, clMemMan mm);
   <pit> is a pointer to the type <item> and must be <pit> = NULL
   <item> is a valid type
   <constructor> is the constructor of <item>
   <mm> is an object of the clMemMan class
       if #ifdef DEBUG_MEMMANAGER = TRUE,
       otherwise it is not used

Additionally, this past week a lot of insights were transmitted by the mentors. Even though, MBDyn is able to perform analysis for dynamic and static simulations, the initial goal of the project is to focus on allocating automatically inertia to the beam for dynamic situation. It means, we assume all the nodes are dynamic, and we maintain the current code for static analysis.

Relating to my modifications of the code, I strongly advice for the user and community to download the code I have been working on in order to provide feedback. You will notice that the current branch of the software still are not able to fully allocate the new bodies. However, it is able to parse all the requirements attributed and I was able to use the given macros inherent from body.cc.

By running this cantilever script, the terminal will present the following output:

In conclusion, throughout these four weeks, a lot of reading and debugging code were done in order to understand MBDyn structure. Additionally, feedback from the mentors were pivotal to understand better in order to develop my project goal. The work done in this first period of code resulted in the following: understanding of the code and performing meaningful modifications for debugging; establishing a syntax for native script; making modifications on the ReadBeamElement method to parse the desired inputs; and finally to allocate the new bodies, which still need more intervention. All the modifications can be tracked in the following list of commits:

https://github.com/EriveltonGualter/GSoC-MBDyn/commits/master


Theme created by Jim Crist. Licensed under Creative Commons.

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