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

Plotting max aspect ratio with time

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 9, 2024, 07:58
Default Plotting max aspect ratio with time
  #1
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 79
Rep Power: 6
2538sukham is on a distinguished road
Hello Foamers.

I am running a dynamic simulation with a moving wall and velocity laplacian. I want to check the motion before the actual simulation and so moveDynamicMesh is performed. I have the mesh quality information for the time steps.



1. How do I plot the max aspect ratio with time for the mesh motion? I want to find at which timestep, the max aspect ratio is at a peak. I am at a lost.

2. checkMesh -writeAllFields have given me the required data and can be visualised via paraView. Is there a way to generate the plot from paraView?



I hope someone can point me to a right direction for the plot. Meanwhile if I come up with a solution, I will be happy to share it here


An instance of the simulation is attached.



With regards
Attached Images
File Type: png mesh quality.png (95.8 KB, 10 views)
2538sukham is offline   Reply With Quote

Old   January 9, 2024, 08:22
Default
  #2
Senior Member
 
NotOverUnderated's Avatar
 
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5
NotOverUnderated is on a distinguished road
According to your screenshot, the mesh quality fields including aspect ratio are written to disk every time step. You can open them in Paraview, and plot the maximum aspect ratio over time.

If you save the output from your screenshot to a log file you can use grep command to find the maximum aspect ratio. save it to a file and plot it.
__________________
Don't keep making the same mistakes. Try to make new mistakes.
NotOverUnderated is offline   Reply With Quote

Old   January 9, 2024, 09:55
Default
  #3
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 79
Rep Power: 6
2538sukham is on a distinguished road
Quite right. I got it by following the following instruction given on
HTML Code:
https://docs.paraview.org/en/latest/Tutorials/ClassroomTutorials/beginningPlotting.html
Here is an image attached for the graph. Although it is a bit heavy on the system considering paraView have to look into every cell and write out the selection over time.



Thanks!
Attached Images
File Type: png maxAspectRatio.png (25.2 KB, 11 views)
2538sukham is offline   Reply With Quote

Old   January 9, 2024, 10:25
Default
  #4
Senior Member
 
NotOverUnderated's Avatar
 
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5
NotOverUnderated is on a distinguished road
Nice

You can also use grep command to extract those values from the log file and plot them later using Gnuplot or any other software.
__________________
Don't keep making the same mistakes. Try to make new mistakes.
NotOverUnderated is offline   Reply With Quote

Old   January 9, 2024, 10:48
Default
  #5
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 79
Rep Power: 6
2538sukham is on a distinguished road
I will do that and post the commands here after I successfully plot using grep.
Cheers. 🙂
2538sukham is offline   Reply With Quote

Old   January 10, 2024, 06:40
Default
  #6
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 79
Rep Power: 6
2538sukham is on a distinguished road
Here is the use of grep but then how to set the x axis as time and not iterations? The time was from 1s so the graph looks a bit different but then the plotting way would remain same.
Code:
set border lw 1
set logscale y
set title "Residuals" font "arial,16"
set ylabel "Aspect Ratio" font "arial,12"
set xlabel "Iterations" font "arial,12"
set key width 1
plot "< cat log | grep 'Max aspect ratio' | cut -d' ' -f9 | tr -d ','" title 'AspectRatio' with lines lw 1,
pause 1
reread
gnuplot Residuals.txt


How to get x axis as time??? hmmm.
Attached Images
File Type: png AspectRatioGNU.png (30.3 KB, 7 views)
2538sukham is offline   Reply With Quote

Old   January 10, 2024, 07:02
Default
  #7
Senior Member
 
NotOverUnderated's Avatar
 
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5
NotOverUnderated is on a distinguished road
Quote:
Originally Posted by 2538sukham View Post
Here is the use of grep but then how to set the x axis as time and not iterations? The time was from 1s so the graph looks a bit different but then the plotting way would remain same.
Code:
set border lw 1
set logscale y
set title "Residuals" font "arial,16"
set ylabel "Aspect Ratio" font "arial,12"
set xlabel "Iterations" font "arial,12"
set key width 1
plot "< cat log | grep 'Max aspect ratio' | cut -d' ' -f9 | tr -d ','" title 'AspectRatio' with lines lw 1,
pause 1
reread
gnuplot Residuals.txt


How to get x axis as time??? hmmm.
Nice!

I have some comments:

1) Do not cat to grep! Most commands accept filenames as arguments. So instead of:

Code:
cat filename | grep 'foo'
You should do this:

Code:
grep 'foo' filename

2) Instead of using the command inside gnuplot script, you can proceed like this:
  • use grep to extract Time from the file and save the result to a temporary file time.txt
  • use grep to extract the maximum aspect ratio from the file and save the result to a temporary file maxAspectRatio.txt
  • Use another tool to combine the two files into single file

To combine the two files time.txt and maxAspectRatio.txt you can use many tools: LibreOffice calc, Microsoft Excel, or a command with the name 'paste':

Code:
paste -d " " time.txt maxAspectRatio.txt > result.txt
The output file result.txt will have two columns: time and maxAspectRatio. Use that file in Gnuplot to plot it.


I know there are better ways to do that, but I hope this helps
__________________
Don't keep making the same mistakes. Try to make new mistakes.
NotOverUnderated is offline   Reply With Quote

Old   January 10, 2024, 07:06
Default
  #8
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 79
Rep Power: 6
2538sukham is on a distinguished road
okay now I think I can accomplish this. I will post the result once this is done for other users if they need it. And Thank you for the input!! Really appreciated.
P.S. I am also looking into swak4Foam and pyFoam so if I get the alternatives, I will post here for other users. Cheers!
2538sukham is offline   Reply With Quote

Old   January 12, 2024, 21:10
Default
  #9
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 79
Rep Power: 6
2538sukham is on a distinguished road
So pyFoamPlotRunner.py can be used. or run the moveDynamicMesh > log and use
Code:
pyFoamPlotWatcher.py log --hardcopy --format-of-hardcopy=png
It prints out the non-orthogonality and aspect ratio with time.


I consider my thread closed. Thanks!
Attached Images
File Type: png custom0000_nonorhogonalitydynamicmesh.png (10.7 KB, 7 views)
2538sukham 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
LES, Courant Number, Crash, Sudden Alhasan OpenFOAM Running, Solving & CFD 5 November 22, 2019 02:05
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 07:56
Force can not converge colopolo CFX 13 October 4, 2011 22:03
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 21:14
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58


All times are GMT -4. The time now is 11:17.