#!/bin/bash
cd ${0%/*} || exit 1 # Run from this directory

# Source PATO run functions
. $PATO_DIR/src/applications/utilities/runFunctions/RunFunctions

# Initialize the script
pato_init

#!/usr/bin/env python3

import patoPlot
from pylab import *

######################################################################################################
#                                            Data reading                                            #
######################################################################################################

# List of data files
PATOFileList_=[]

# Solid temperature Darcy
PATOFileList_.append("./compressibleDarcy/output/porousMat/scalar/Ta_plot")
# Solid temperature Darcy-Forchheimer
PATOFileList_.append("./output/porousMat/scalar/Ta_plot")
# Solid temperature Darcy
PATOFileList_.append("./compressibleDarcy/output/porousMat/scalar/Tg_plot")
# Solid temperature Darcy-Forchheimer
PATOFileList_.append("./output/porousMat/scalar/Tg_plot")
# Gas velocity Darcy
PATOFileList_.append("./compressibleDarcy/output/porousMat/vector/Ux_plot")
# Gas velocity Darcy-Forchheimer
PATOFileList_.append("./output/porousMat/vector/Ux_plot")

# Read data files
data = patoPlot.patoPlot(PATOFileList_)

######################################################################################################
#                                           Set up plot parameters                                   #
######################################################################################################

params = {
    'axes.labelsize': 14,
    'legend.fontsize': 14,
    'xtick.labelsize': 14,
    'ytick.labelsize': 14,
    'text.usetex': False,
    'figure.figsize': [12, 8]
}
rcParams.update(params)

######################################################################################################
#                                          Solid temperature                                         #
######################################################################################################

# Create figure
fig = plt.figure()
ax = fig.add_subplot(2, 2, 1)

# Set labels
ax.set_xlabel('time (s)', fontsize=16)
ax.set_ylabel('Solid temperature (K)', fontsize=16)
tick_params(axis='x', top='off')
tick_params(axis='y', right='off')

# Data reading
Data0=data.dataList[0]
Data1=data.dataList[1]
Xaxis=Data0[:,0]

# Plot
plot(Xaxis,Data0[:,1],ls='solid', color='black', linewidth=2, alpha = 1, label='Darcy, x=0.001')
plot(Xaxis,Data1[:,1],ls='dotted', color='black', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.001')

plot(Xaxis,Data0[:,2],ls='solid', color='red', linewidth=2, alpha = 1, label='Darcy, x=0.005')
plot(Xaxis,Data1[:,2],ls='dotted', color='red', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.005')

plot(Xaxis,Data0[:,3],ls='solid', color='blue', linewidth=2, alpha = 1, label='Darcy, x=0.01')
plot(Xaxis,Data1[:,3],ls='dotted', color='blue', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.01')

# Tight layout
plt.tight_layout()

######################################################################################################
#                                          gas temperature                                           #
######################################################################################################

# Create figure
ax = fig.add_subplot(2, 2, 2)

# Set labels
ax.set_xlabel('time (s)', fontsize=16)
ax.set_ylabel('Gas temperature (K)', fontsize=16)
tick_params(axis='x', top='off')
tick_params(axis='y', right='off')

# Data reading
Data2=data.dataList[2]
Data3=data.dataList[3]

# Plot
plot(Xaxis,Data2[:,1],ls='solid', color='black', linewidth=2, alpha = 1, label='Darcy, x=0.001')
plot(Xaxis,Data3[:,1],ls='dotted', color='black', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.001')

plot(Xaxis,Data2[:,2],ls='solid', color='red', linewidth=2, alpha = 1, label='Darcy, x=0.005')
plot(Xaxis,Data3[:,2],ls='dotted', color='red', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.005')

plot(Xaxis,Data2[:,3],ls='solid', color='blue', linewidth=2, alpha = 1, label='Darcy, x=0.01')
plot(Xaxis,Data3[:,3],ls='dotted', color='blue', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.01')

# Tight layout
plt.tight_layout()

# Put legend
handles, labels = ax.get_legend_handles_labels()
legend = ax.legend(handles,labels, loc=1, fontsize =13)
frame = legend.get_frame()
frame.set_facecolor('1.0')
frame.set_edgecolor('1.0')


######################################################################################################
#                                          Velocity                                                  #
######################################################################################################

# Create figure
ax = fig.add_subplot(2, 2, 3)

# Set labels
ax.set_xlabel('Time (s)', fontsize=16)
ax.set_ylabel('Gas Darcy velocity (m/s)', fontsize=16)
tick_params(axis='x', top='off')
tick_params(axis='y', right='off')

# Data reading
Data4=data.dataList[4]
Data5=data.dataList[5]

# Plot
plot(Xaxis,Data4[:,1],ls='solid', color='black', linewidth=2, alpha = 1, label='Darcy, x=0.001')
plot(Xaxis,Data5[:,1],ls='dotted', color='black', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.001')

plot(Xaxis,Data4[:,2],ls='solid', color='red', linewidth=2, alpha = 1, label='Darcy, x=0.005')
plot(Xaxis,Data5[:,2],ls='dotted', color='red', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.005')

plot(Xaxis,Data4[:,3],ls='solid', color='blue', linewidth=2, alpha = 1, label='Darcy, x=0.01')
plot(Xaxis,Data5[:,3],ls='dotted', color='blue', linewidth=4, alpha = 1, label='Darcy-Forchheimer, x=0.01')

# Tight layout
plt.tight_layout()

######################################################################################################
#                                          Write figure                                              #
######################################################################################################

outputFile_ = "./comparison.pdf"
savefig(outputFile_)
