How to remove files created by result object when analysis input is changed

Hi,
I have ACT Result objects that using OnStartPost callback creates input.json files containing all input needed for calculations - it extracts input from .rst, Excel files and other Ansys objects. And then does all the calculations that are then saved to output.json. During Evaluate it only reads the output from the global dictionary (loaded from output.json) and displays it. It significantly improves overall evaluation time and other post-processing tasks (allowing users to quickly review all input/output data).

In XML I've added a function that clears those .json files using OnRemove, OnSuppress, OnClearData and OnAfterGeometryUpdate. They do work if user:

  • removes result object,
  • suppresses result object,
  • clear generated data on result object or the whole Solution,
  • updates the geometry.

But it does not remove .json if any input to the analysis is changed, like changing the Pressure or Force, adding new support etc. and user clicks Solve. You can see in pic above that the .rst has different date than .json.

Am I missing a callback here? Is this even possible to trigger remove .json with the solution I did for preparing all calculations ?

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 900
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

    @Mateusz Haven't tested it, but I think there are a few possibilities:

    • To delete the json when user clicks solve, I would use the OnStartEval callback.
    • To delete the json when anything in the tree is changed:
      • either use a IsValid callback to check any change of status in any object in Mechanical, return true for the callback but have the method also delete the json ?
      • use one (or several) Python Code object(s) to check for change in the Mechanical object(s) and delete the json file.

    Hope this helps, although these suggestions are just workarounds...

  • Mateusz
    Mateusz Member Posts: 16
    10 Comments First Anniversary Name Dropper
    **

    Hi @Pernelle, thanks for answering.

    I've checked OnStartEval, but it get triggered even when changing the Display Time on a result. Using it to trigger the Remove Json function would remove all json files containing the results forcing the script to re-calculate everything from scratch... making all the effort to store the data useless.

    IsValid seems like a good idea. It gets activated upon every Tree action. I wrote this following function that checks if the Solution status changed to SolveRequired. It seems to do the job. Is going to work in every single scenario? I am not sure though at the moment :(

    def remove_pipe_check_is_valid(obj):
        if obj.Analysis.Solution.Status == SolutionStatusType.SolveRequired:
            remove_pipe_check(obj)
        return True
    

    The issue is I do get an error message when Solving the analysis. It states that the function above takes 1 argument but 2 are given. The whole log gets populated with dozens of such errors. According to the ACT Reference, IsValid should only take 1 argument (as I wrote the code).

    But it seems there is an error in Ansys with that callback. I'm using 24R2.

  • Mateusz
    Mateusz Member Posts: 16
    10 Comments First Anniversary Name Dropper
    **

    Disregard the issue I wrote above. I cannot edit the post to remove it. By mistake I had the same function attached to OnStartEval callback I forgot to remove :#
    Thanks for pointing me in right direction @Pernelle :)