#!/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

# create volume fields                                                                                                        
cp -rf origin.0 0

exec 3>&2 # file descriptor 3 to stderr
exec 2>&1 # stderr to stdout

# generate meshes                                                                                                            
blockMesh
splitMeshRegions -cellZones -overwrite

exec 2>&3 # stderr to file descriptor 3

# run                                                                                                                        
PATOx

# convert results in VTK format and open paraview                                                                                                                                   
#paraFoam -builtin

# probe scalar fields (temperature, pressure, density, etc) at desired locations - chosen in system/sampleDict
postProcess -func sampleDict -region demiseMat                      
postProcess -func sampleDict -region porousMat

# grab probed fields and copy them into files   
# processSetsName | input file | output file base name | -npf : number of probed fields | -option: allow moving probes (1/0)                  
processSetsName plot_Ta.xy plot_demiseMat -npf 1 -region demiseMat 
processSetsName plot_Ta.xy plot_porousMat -npf 1 -region porousMat
