Open File.bdf

Asked by jacopo

Hi i need your help. I need to open in yade a file.bdf. It is an airplane built using Nastran. I need to use this surface on yade. The file they gave me is a file.bdf; i searched on internet how can i convert it in file.gts, but nothing is texted. Any advice? i tried also with the code written in trunk file (https://github.com/yade/trunk/blob/master/examples/gts-horse/gts-operators.py) but it doesn't work, it gives me this error :
RuntimeError: expecting an integer (number of vertices)

Infact if i open my file it has this format:

$ NASTRAN input file created by the MSC MSC.Nastran input file
$ translator ( MSC.Patran 13.0.053 ) on May 02, 2007 at 15:10:25.
ASSIGN OUTPUT2 = 'prova.op2', UNIT = 12
$ Direct Text Input for Nastran System Cell Section
$ Direct Text Input for File Management Section
$ Linear Static Analysis, Database
SOL 101
TIME 600
$ Direct Text Input for Executive Control
CEND
$ Elements for group : default_group
SET 1 = 1 THRU 578,580 THRU 845,847,848,850,851,853,854,856,857,859,860,
862,863,865,866,868,869,871,872,874,875,877,878,880,881,883,884,886,887,
889,890,892,893,895,896,898,899,901,902,904,905,907 THRU 932,934,

and so on.... it has more then 1000 lines like this. how can i convert this in vertices??

i need your help , i don't really know how to do. thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Fabio
Solved:
Last query:
Last reply:
Revision history for this message
Fabio (fabiogabri) said :
#1

Hello Jacopo,
the header of you *.bdf file is not very informative and it probably combines geometry info and other "finite element" info that are not useful in your case.

gts format is not as popular as stl format, so I suggest to search for a bdf_to_stl converter.

Surfing on the web i found [1]

Please, try it and let us know

Fabio

[1] https://github.com/SteveDoyle2/pyNastran/blob/master/pyNastran/converters/nastran/nastran_to_stl.py

Revision history for this message
jacopo (varrialeee) said :
#2

i' m trying as you suggest me , but in all the case i write "mp03.bdf or bdf_mp03 and aereo.stl or stl_aereo ( in the script is texted "bdf_filename, stl_filename) it doesn't work. it gives me this error:

Traceback (most recent call last):
  File "/usr/bin/yade", line 182, in runScript
    execfile(script,globals())
  File "convertitore.py", line 11, in <module>
    from pyNastran.bdf import read_bdf
ImportError: No module named pyNastran.bdf ------> at line 11 if i change the script in:" from mp03.bdf import read_bdf"
it gives the same error.

I 'm sorry but i still need your help. Now this is my code where mp03 is the name of my file Nastran ( i have saved it as mp03.bdf in my folder , but if i put in the script the name "mp03.bdf" it gives me syntax error) .
aereo is the name that i would like to give to the generated stl file.

##################################################

Script:
"""
defines:
 - stl = nastran_to_stl_filename(mp03, aereo, is_binary=False,
                                 log=None)
 - stl = nastran_to_stl(mp03, aereo, is_binary=False,
                        log=None, stop_on_failure=False)
"""
from __future__ import print_function
from six import iteritems
import numpy as np
from pyNastran.bdf import read_bdf
from pyNastran.converters.stl import STL

def nastran_to_stl_filename(bdf_mp03, stl_aereo, is_binary=False, log=None):
    """Converts a Nastran model to an STL"""
    return nastran_to_stl(bdf_mp03, stl_aereo, is_binary=is_binary)

def nastran_to_stl(bdf_mp03, stl_aereo, is_binary=False, log=None, stop_on_failure=False):
    """
    Converts a Nastran model to an STL
    Parameters
    ----------
    bdf_mp03 : varies
        str : the path to a BDF input file
        BDF() : a BDF() model object
    stl_aereo : str
        the output STL path
    is_binary : bool; default=False
        should the output file be binary
    log : Logger()
        a Python logging object
    stop_on_failure : bool; default=False
        should the code stop if an error is encountered
    """
    if isinstance(bdf_mp03, str):
        model = read_bdf(bdf_mp03, log=log)
    else:
        model = bdf_mp03

    #log.info('card_count = %s' % model.card_count)

    nnodes = len(model.nodes)
    nodes = np.zeros((nnodes, 3), dtype='float64')
    elements = []

    i = 0
    nodeid_to_i_map = {}
    offset = False
    if offset:
        nid = list(model.nodes.keys())[0]
        xyz0 = model.nodes[nid].get_position()
    else:
        xyz0 = np.zeros(3, dtype='float64')
    for node_id, node in sorted(iteritems(model.nodes)):
        xyz = node.get_position()
        nodes[i, :] = xyz - xyz0
        nodeid_to_i_map[node_id] = i
        i += 1
    assert len(model.nodes) == i, 'model.nodes=%s i=%s' % (len(model.nodes), i)
    for unused_eid, element in sorted(iteritems(model.elements)):
        if element.type in ['CQUADR']:
            continue
        elif element.type in ['CBAR', 'CBEAM', 'CONM2', 'RBE2', 'RBE3',
                              'CBUSH', 'CBUSH1D', 'CBUSH2D',
                              'CONROD', 'CROD',
                              'CELAS1', 'CELAS2', 'CELAS3', 'CELAS4',
                              'CDAMP1', 'CDAMP2', 'CDAMP3', 'CDAMP4',]:
            continue
        elif element.type in ['CQUAD4']:
            n1, n2, n3, n4 = element.node_ids
            i1, i2, i3, i4 = (nodeid_to_i_map[n1], nodeid_to_i_map[n2],
                              nodeid_to_i_map[n3], nodeid_to_i_map[n4])
            elements.append([i1, i2, i3])
            elements.append([i3, i4, i1])
        elif element.type in ['CTRIA3', 'CTRIAR']:
            nids = element.node_ids
            unids = np.unique(nids)
            if len(unids) == 2:
                continue
            n1, n2, n3 = nids
            i1, i2, i3 = nodeid_to_i_map[n1], nodeid_to_i_map[n2], nodeid_to_i_map[n3]
            elements.append([i1, i2, i3])
        else:
            print(element.type)
    elements = np.array(elements, dtype='int32')
    stl = STL(log=model.log)
    stl.nodes = nodes
    #stl.nodes -= nodes[0, :]
    stl.elements = elements
    stl.write_stl(stl_aereo, is_binary=is_binary, stop_on_failure=stop_on_failure)
    return stl

Revision history for this message
Jan Stránský (honzik) said :
#3

Hi,

> ImportError: No module named pyNastran.bdf

python does not know about pyNastran.bdf.. there are two easy ways:
1) "install" the package by running 'python setup.py' from the downloaded directory
2) sudo pip install pyNastran

let us know. In case of troubles, please provide also the bdf file.

cheers
Jan

Revision history for this message
Chareyre (bruno-chareyre-9) said :
#4

Hi Jacopo, I'm affraid the only realistic comming to my mind beyond
decrypting it by yourself is to ask nastran people about conversion to a
more generic format.
Bruno

Le lun. 23 juil. 2018 12:32, jacopo <email address hidden>
a écrit :

> New question #671054 on Yade:
> https://answers.launchpad.net/yade/+question/671054
>
> Hi i need your help. I need to open in yade a file.bdf. It is an airplane
> built using Nastran. I need to use this surface on yade. The file they gave
> me is a file.bdf; i searched on internet how can i convert it in file.gts,
> but nothing is texted. Any advice? i tried also with the code written in
> trunk file (
> https://github.com/yade/trunk/blob/master/examples/gts-horse/gts-operators.py)
> but it doesn't work, it gives me this error :
> RuntimeError: expecting an integer (number of vertices)
>
> Infact if i open my file it has this format:
>
> $ NASTRAN input file created by the MSC MSC.Nastran input file
> $ translator ( MSC.Patran 13.0.053 ) on May 02, 2007 at 15:10:25.
> ASSIGN OUTPUT2 = 'prova.op2', UNIT = 12
> $ Direct Text Input for Nastran System Cell Section
> $ Direct Text Input for File Management Section
> $ Linear Static Analysis, Database
> SOL 101
> TIME 600
> $ Direct Text Input for Executive Control
> CEND
> $ Elements for group : default_group
> SET 1 = 1 THRU 578,580 THRU 845,847,848,850,851,853,854,856,857,859,860,
> 862,863,865,866,868,869,871,872,874,875,877,878,880,881,883,884,886,887,
> 889,890,892,893,895,896,898,899,901,902,904,905,907 THRU 932,934,
>
>
> and so on.... it has more then 1000 lines like this. how can i convert
> this in vertices??
>
> i need your help , i don't really know how to do. thanks.
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>

Revision history for this message
jacopo (varrialeee) said :
#5

Hi. I think i did it. I used FEMAP, 3D software. I downloaded trial version. This software allow you To open file .nas Or .bdf, IT has a lot of format type. Then i export all The created mesh as stl file. Theoretically IT should merged al The vertices outomatically. I didn t open the the stl file yet.
-> Is in yade a procedure that allow me to open IT? As The one with GTI surface?
-> At this point i only imported The geometry.... How about The material? I could read the value set in the original file bdf , But The two softwares probably work with different material values. Do you think i should have To work only on contact? ... Becouse i could set in The beginning of The script the material But in this way i would define only one material for The whole aircraft. What do you suggest me To do?
________________________________
Da: <email address hidden> <email address hidden> per conto di Chareyre <email address hidden>
Inviato: venerdì 27 luglio 2018 21:42:28
A: Jacopo Varriale
Oggetto: Re: [Question #671054]: Open File.bdf

Your question #671054 on Yade changed:
https://answers.launchpad.net/yade/+question/671054

Chareyre proposed the following answer:
Hi Jacopo, I'm affraid the only realistic comming to my mind beyond
decrypting it by yourself is to ask nastran people about conversion to a
more generic format.
Bruno

Le lun. 23 juil. 2018 12:32, jacopo <email address hidden>
a écrit :

> New question #671054 on Yade:
> https://answers.launchpad.net/yade/+question/671054
>
> Hi i need your help. I need to open in yade a file.bdf. It is an airplane
> built using Nastran. I need to use this surface on yade. The file they gave
> me is a file.bdf; i searched on internet how can i convert it in file.gts,
> but nothing is texted. Any advice? i tried also with the code written in
> trunk file (
> https://github.com/yade/trunk/blob/master/examples/gts-horse/gts-operators.py)
> but it doesn't work, it gives me this error :
> RuntimeError: expecting an integer (number of vertices)
>
> Infact if i open my file it has this format:
>
> $ NASTRAN input file created by the MSC MSC.Nastran input file
> $ translator ( MSC.Patran 13.0.053 ) on May 02, 2007 at 15:10:25.
> ASSIGN OUTPUT2 = 'prova.op2', UNIT = 12
> $ Direct Text Input for Nastran System Cell Section
> $ Direct Text Input for File Management Section
> $ Linear Static Analysis, Database
> SOL 101
> TIME 600
> $ Direct Text Input for Executive Control
> CEND
> $ Elements for group : default_group
> SET 1 = 1 THRU 578,580 THRU 845,847,848,850,851,853,854,856,857,859,860,
> 862,863,865,866,868,869,871,872,874,875,877,878,880,881,883,884,886,887,
> 889,890,892,893,895,896,898,899,901,902,904,905,907 THRU 932,934,
>
>
> and so on.... it has more then 1000 lines like this. how can i convert
> this in vertices??
>
> i need your help , i don't really know how to do. thanks.
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/yade/+question/671054/+confirm?answer_id=3

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/yade/+question/671054

You received this question notification because you asked the question.

Revision history for this message
Fabio (fabiogabri) said :
#6

Hello Jacopo,
for importing the surface you may try the direct way by using the stl importer "yade.ymport.stl" (have a look here [1])
or for stl to gts conversion have a look here [2]

for what concern the "materials" I think you get confused: FMAP (as Nastran, I guess) is designed for finite element codes... Yade uses the Discrete Element Method and a different set of material parameters that are mostly "contact parameters".

[1] https://yade-dem.org/doc/yade.ymport.html

[2] https://answers.launchpad.net/yade/+question/406791#comment-6

Revision history for this message
jacopo (varrialeee) said :
#7

Okay, then do I have to set the same material for the whole aircraft and then work on the type of contact until I reach the results i want? ( i can set The material defining IT before importing The stl file) .
> i m working on an airplane crash test And i have To reproduce the results of The real test. I m asking your opinion about what the best way to reach my goals is .
________________________________
Da: <email address hidden> <email address hidden> per conto di Fabio <email address hidden>
Inviato: giovedì 2 agosto 2018 17:23:35
A: Jacopo Varriale
Oggetto: Re: [Question #671054]: Open File.bdf

Your question #671054 on Yade changed:
https://answers.launchpad.net/yade/+question/671054

    Status: Open => Answered

Fabio proposed the following answer:
Hello Jacopo,
for importing the surface you may try the direct way by using the stl importer "yade.ymport.stl" (have a look here [1])
or for stl to gts conversion have a look here [2]

for what concern the "materials" I think you get confused: FMAP (as
Nastran, I guess) is designed for finite element codes... Yade uses the
Discrete Element Method and a different set of material parameters that
are mostly "contact parameters".

[1] https://yade-dem.org/doc/yade.ymport.html

[2] https://answers.launchpad.net/yade/+question/406791#comment-6

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/yade/+question/671054/+confirm?answer_id=5

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/yade/+question/671054

You received this question notification because you asked the question.

Revision history for this message
Best Fabio (fabiogabri) said :
#8

Jacopo,
please, open a new question with a different subject and try to be more specific on what is your goal: the crash test of an aircraft is too general and too vague... on a soil? on a concrete wall? Do you want to simulate the entire aircraft ? (it seems hard to do!)
What is the deformable/crushable object? the impacting wall or the aircraft or both? in the second and third case I think it is hard to simulate with a discrete element code... you have to choose simpler objects and simpler shapes (like a bullet for example).
If the impacting wall is low-strength and/or highly deformable, maybe the aircraft could be represented as a rigid object... but again, what is the model that you are representing? Open a new question.
Regards
Fabio

Revision history for this message
jacopo (varrialeee) said :
#9

Thanks Fabio, that solved my question.