CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Post Process of negative time steps folders

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 23, 2021, 15:47
Default Post Process of negative time steps folders
  #1
New Member
 
Marco
Join Date: Jul 2021
Posts: 4
Rep Power: 4
MisterAceituna is on a distinguished road
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!
Attached Images
File Type: jpg Immagine 2021-07-23 214659.jpg (106.9 KB, 5 views)
MisterAceituna is offline   Reply With Quote

Old   July 28, 2021, 12:21
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
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 is offline   Reply With Quote

Old   July 28, 2021, 12:24
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
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!
Tobermory is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
laplacianFoam with source term Herwig OpenFOAM Running, Solving & CFD 17 November 19, 2019 13:47
Stuck in a Rut- interDyMFoam! xoitx OpenFOAM Running, Solving & CFD 14 March 25, 2016 07:09
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
InterFoam negative alpha karasa03 OpenFOAM 7 December 12, 2013 03:41
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 07:56


All times are GMT -4. The time now is 22:07.