CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Post Process of negative time steps folders (https://www.cfd-online.com/Forums/openfoam-post-processing/237564-post-process-negative-time-steps-folders.html)

MisterAceituna July 23, 2021 15:47

Post Process of negative time steps folders
 
1 Attachment(s)
Hi everyone,

I have a pretty straightforward question.
Due to how the solver works, the solutions of a case i am running are stored in folder going from -180 to 540, with a time step of 2. This is due to the fact that the name of the folders doesn't indicate the time but the crank angle of an engine.

When I try to post process, I can smoothly achieve my results for the positive angles (from 0 to 540) but I can't for the negative ones, since OF tells me:

Code:

Cannot find file "faces" in directory "polyMesh" in times "-150" down to constant
Notice that the contents I have inside every folder is the same (i.e. polyMesh/points, uniform/time and all the computed fields).

I attach a picture of the directories I have in my case.

Thank you!

Tobermory July 28, 2021 12:21

A simple solution would be to write a bash script to rename each of the folders, adding say 1000 to the folder number. Your time folders would then all be positive and would retain their correct order.

It's made slightly harder by the fact that bash is picky about filenames starting with a "-", but here's a script you could use:

For example:
Code:

#!/bin/bash
for oldFolder in $(ls); do
        if [[ $oldFolder =~ ^[+-]?[0-9]+$ ]]; then  #check if folder name is an integer
                newFolder=$(expr $oldFolder + 1000)
                mv -- $oldFolder $newFolder
        fi
done


Tobermory July 28, 2021 12:24

Can I suggest that if you are going to try this, do a "dry run" first by getting it to print the mv command to screen, rather than to actually execute it. You can then check that the syntax is right. For example change
Code:

                mv -- $oldFolder $newFolder
to

Code:

                echo mv -- $oldFolder $newFolder
You can also generate an "antidote" script if you need it, to revert back to the original folder names - just change the + to a - in the newFolder expression. Good luck!


All times are GMT -4. The time now is 03:49.