(Solved) Compose - Error: invalid input; cannot read file in call to function gettypeindex (T01 file)

Autumn
Autumn Altair Community Member
edited August 2023 in Community Q&A

Hello,

I have been using Compose to analyze data from T01 and .h3d files. I have followed the blog post Extracting and Post-Processing CAE/TEST results in Altair Compose to determine that I want some variables defined as follows

type_rbody = gettypeindex(TH_file, 'Part');
req_rbody = getreqlist(TH_file, type_rbody);
comp_rbody = getcomplist(TH_file, '', type_rbody);
req2_PlasStrain = getreqlist(h3d_file, 'Loadcase 1', 'Plastic Strain (3D)');
req2_Node = getreqindex(h3d_file, 'Loadcase 1', 'Displacement', node);

so that I can then use 'readvector' to get energy, force, etc. data. Note that TH_file and h3d_file are two string variables containing the directory+filename of the T01 and h3d file, respectively (I need to store the .oml file in a separate folder than the T01 and .h3d files).

While it mostly runs smoothly, every so often I am passed the following error:

Error: invalid input; cannot read file in call to function gettypeindex at line number 38 in file script2.oml

which is always related to the T01 file and gettypeindex in the first line of the code pasted above. Sometimes, all it takes is me restarting Compose and the problem is solved (no other changes necessary). Other times, I cannot seem to get anything to run - even if it had been working just fine earlier (with no changes).

I am wondering if there is something I am missing that is causing Compose to fail to read the T01 file occasionally? Is there perhaps a character limit for the directory + filename -- sometimes if I close Compose, change a folder name for the T01 directory (remove a space, for example), and rerun the .oml file, it works - almost as if the TH_file string was too long or wasn't being properly read.

Any suggestions or solutions would be much appreciated.

Thank you in advance for your time.

Answers

  • manoj kandukuri
    manoj kandukuri
    Altair Employee
    edited May 2022

    Hello, 

    Are you using relative path for the filename ('TH_file')? can you please share the portion of the code where you have defined TH_file variable? 

    Thanks,

    Manoj Kandukuri

     

     

     

  • Autumn
    Autumn Altair Community Member
    edited May 2022

    Hello, 

    Are you using relative path for the filename ('TH_file')? can you please share the portion of the code where you have defined TH_file variable? 

    Thanks,

    Manoj Kandukuri

     

     

     

    The path & filename for the T01 and .h3d files end up being the full path (i.e. similar to TH_file = G:\folder\folder\etc\modelT01), though I grab the actual filename with extension using my own Python function ('file_names') as I am looping through my Compose script for many T01 & .h3d files in many different folders.

    Here is the portion of the code which gathers the filename information and defines the TH_file variable:

    ...
    pathname = omlfilename('fullpathext')
    script_filepath = fileparts(pathname)
    [status, errMesg, lists] = evalpythonfunction(python_code, 'file_names', csv_compose)
    %^-- new script, for getting list of h3d and T01 files to process
    %---BEGIN LOOPING FOR DATA COLLECTION---
    index = 1
    while index <= length(lists)/3
         %---GET NAME OF H3D & TH FILES---
         h3d_f = cell2mat(lists(index))
         num = length(lists)/3;
         TH_f = cell2mat(lists(index+num))
         h3d_file = [script_filepath, '\', h3d_f]
         TH_file = [script_filepath, '\', TH_f]
         node = cell2mat(lists(index+2*num))
         ...

     

     

     

  • manoj kandukuri
    manoj kandukuri
    Altair Employee
    edited June 2022
    Autumn said:

    The path & filename for the T01 and .h3d files end up being the full path (i.e. similar to TH_file = G:\folder\folder\etc\modelT01), though I grab the actual filename with extension using my own Python function ('file_names') as I am looping through my Compose script for many T01 & .h3d files in many different folders.

    Here is the portion of the code which gathers the filename information and defines the TH_file variable:

    ...
    pathname = omlfilename('fullpathext')
    script_filepath = fileparts(pathname)
    [status, errMesg, lists] = evalpythonfunction(python_code, 'file_names', csv_compose)
    %^-- new script, for getting list of h3d and T01 files to process
    %---BEGIN LOOPING FOR DATA COLLECTION---
    index = 1
    while index <= length(lists)/3
         %---GET NAME OF H3D & TH FILES---
         h3d_f = cell2mat(lists(index))
         num = length(lists)/3;
         TH_f = cell2mat(lists(index+num))
         h3d_file = [script_filepath, '\', h3d_f]
         TH_file = [script_filepath, '\', TH_f]
         node = cell2mat(lists(index+2*num))
         ...

     

     

     

    Hello,

    By looking at the code, i don't see any issue. can you print the "h3d_file" and "TH_file" and see if its pointing to the right direction? May i know what version of compose you're using?

    Also, Solver (name, version) used to get these h3d and T01 files?

    Have you tried using debugging feature in compose to watch the "h3d_file" and "TH_file" variable value?

     

    here is the short video showing how to use debugging feature in compose

    https://www.youtube.com/watch?v=Ic3-YTi5-10

     

    Thanks,

    Manoj

     

  • Autumn
    Autumn Altair Community Member
    edited June 2022

    Hello,

    By looking at the code, i don't see any issue. can you print the "h3d_file" and "TH_file" and see if its pointing to the right direction? May i know what version of compose you're using?

    Also, Solver (name, version) used to get these h3d and T01 files?

    Have you tried using debugging feature in compose to watch the "h3d_file" and "TH_file" variable value?

     

    here is the short video showing how to use debugging feature in compose

    https://www.youtube.com/watch?v=Ic3-YTi5-10

     

    Thanks,

    Manoj

     

    I print the "h3d_file" and "TH_file" variables with each iteration of the while loop and can confirm that even if the code passes an error reading the data from those files, the path is correct (& the files do exist at that path).

    My Compose version is 2021.2. I created the models in HyperMesh, and ran Radioss 2021.2 as the solver to obtain the .h3d and T01 files.

    I have tried the debugging feature and can confirm that even when the path is correct, there can still be an issue reading the files. I have found that the best solution for me so far is to close and restart Compose once the code cycles through to a path where the files cannot be read. Any attempt to troubleshoot or modify the code won't be nearly as helpful as a simple restart. Then, even without modification, I can sometimes just start the code again and have things work fine (even for the same .h3d and T01 files that had previously passed an error).

  • manoj kandukuri
    manoj kandukuri
    Altair Employee
    edited June 2022
    Autumn said:

    I print the "h3d_file" and "TH_file" variables with each iteration of the while loop and can confirm that even if the code passes an error reading the data from those files, the path is correct (& the files do exist at that path).

    My Compose version is 2021.2. I created the models in HyperMesh, and ran Radioss 2021.2 as the solver to obtain the .h3d and T01 files.

    I have tried the debugging feature and can confirm that even when the path is correct, there can still be an issue reading the files. I have found that the best solution for me so far is to close and restart Compose once the code cycles through to a path where the files cannot be read. Any attempt to troubleshoot or modify the code won't be nearly as helpful as a simple restart. Then, even without modification, I can sometimes just start the code again and have things work fine (even for the same .h3d and T01 files that had previously passed an error).

    Hi,

    is it possible to share the script and sample files?, i can take a look at it.

    Please create a support ticket using below link and attach the files. please add my name in the description.

    https://community.altair.com/community?id=csm_get_help&sys_id=de45c412c312310015519f2974d3ae1b

    thanks,

    Manoj Kandukuri

  • Autumn
    Autumn Altair Community Member
    edited August 2023

    SOLUTION: (error seemed to be related to a memory issue)

    The solution ended up being to include a "releasedata" command after every "readvector" command (it needed to be directly after each one - it did not work by putting all "releasedata" commands after all "readvector" commands), with a sample as follows... "releasefileinfo" commands were also used to help.

    ... {start of code, gettypeindex/getreqlist/etc. commands}

    %---DEFINE INPUT SOURCES---
    ds_Totmass = readvector(TH_file, 'Global Variables', 'Mass', 'MAG');
    releasedata(TH_file, 'Global Variables', 'Mass', 'MAG');
    % to delete read commands (readvector/readcae/readmultvectors from memory 

    ds_IE = readvector(TH_file, 'Global Variables', 'Internal Energy', 'MAG');
    releasedata(TH_file, 'Global Variables', 'Internal Energy', 'MAG');
        
    ds_KE = readvector(TH_file, 'Global Variables', 'Kinetic Energy', 'MAG');
    releasedata(TH_file, 'Global Variables', 'Kinetic Energy', 'MAG');
        
    ... {remainder of readvector/releasedata command pairs}
        
    %---DELETE/RELEASE DATA FROM MEMORY (to help with long list of iterations through Compose)
    % to delete metadata (getsubcaselist/gettypelist/getrequestlist/ etc from memory
    releasefileinfo(TH_file);
    releasefileinfo(h3d_file);

    ... {remainder of code, calculations, outputs, etc.}