Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Godoy, William
jexio
Commits
cc6f2128
Commit
cc6f2128
authored
Jun 24, 2020
by
William F Godoy
Browse files
Getting file sizes
parent
8d81850e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/extractor/Amrex.jl
View file @
cc6f2128
...
...
@@ -13,7 +13,7 @@ mutable struct Amrex <: AbstractAmrex
outputPrefix
,
[
"max_step"
,
"amr.check_int"
,
"amr.plot_int"
,
"amr.n_cell"
,
"amr.max_level"
],
[
"plots_size"
,
"checkpoints_size"
],
runlogFile
runlogFile
,
)
end
...
...
src/extractor/AmrexCastro.jl
View file @
cc6f2128
...
...
@@ -22,43 +22,45 @@ struct AmrexCastro <: AbstractAmrex
"castro.cfl"
,
"castro.max_grid_size"
,
],
Dict
{
String
,
Array
{
String
}}(
"plots_size"
=>
[
"max_step"
,
"amr.plot_int"
,
"amr.n_cell"
,
"amr.max_level"
]),
runlogFile
Dict
{
String
,
Array
{
String
}}(
"plots_size"
=>
[
"max_step"
,
"amr.plot_int"
,
"amr.n_cell"
,
"amr.max_level"
],
),
runlogFile
,
)
end
# runs the linear models for each entry in outputs
function
run_linear_models
(
extractor
::
AmrexCastro
)
X
::
DataFrames
.
DataFrame
=
_get_linear_model_X
(
extractor
)
for
key
in
keys
(
extractor
.
outputs
)
if
(
key
==
"plots_size"
)
_run_linear_model_plots_size
(
extractor
,
X
)
end
if
(
key
==
"plots_size"
)
_run_linear_model_plots_size
(
extractor
,
X
)
end
end
end
function
_get_input_file
(
extractor
::
AmrexCastro
,
outputDir
::
String
)
::
String
# hardcoded input...find out if this is always the case with Castro
inputFiles
::
Array
{
String
}
=
helper_get_prefix_files
(
"input"
,
outputDir
)
if
isempty
(
inputFiles
)
throw
(
NoSuchFieldException
(
"jexio AmrexCastro: Can't find Castro input files in directories:"
,
outputDirs
,
))
throw
(
NoSuchFieldException
(
"jexio AmrexCastro: Can't find Castro input files in directories:"
,
outputDirs
,
))
# use length, instead of size as it returns tuples
elseif
length
(
inputFiles
)
!=
1
print
(
"Number of files: "
,
size
(
inputFiles
))
throw
(
DimensionMismatch
(
"jexio AmrexCastro: found more than one input file"
))
else
end
elseif
length
(
inputFiles
)
!=
1
print
(
"Number of files: "
,
size
(
inputFiles
))
throw
(
DimensionMismatch
(
"jexio AmrexCastro: found more than one input file"
))
else
end
return
inputFiles
[
1
]
end
return
inputFiles
[
1
]
end
...
...
@@ -71,7 +73,6 @@ function _get_linear_model_X(extractor::AmrexCastro)::DataFrames.DataFrame
isXInit
::
Bool
=
false
for
outputDir
in
outputDirs
inputFile
::
String
=
_get_input_file
(
extractor
,
outputDir
)
# get relevant input parameters
parameters
=
_input_parser
(
extractor
,
inputFile
)
...
...
@@ -91,31 +92,38 @@ end
function
_run_linear_model_plots_size
(
extractor
::
AmrexCastro
,
X
::
DataFrames
.
DataFrame
)
XColumns
::
Array
{
String
}
=
extractor
.
outputs
[
"plots_size"
]
outputDirs
=
helper_get_prefix_directories
(
extractor
.
outputPrefix
)
for
outputDir
in
outputDirs
# TODO refactor this later
inputFile
::
String
=
_get_input_file
(
extractor
,
outputDir
)
parameters
=
_input_parser
(
extractor
,
inputFile
)
rootPlotName
=
get
(
parameters
,
"amr.plot_file"
,
""
)
# find all directories with rootPlotName and get its size
plotFileDirs
=
helper_get_prefix_directories
(
string
(
outputDir
,
"/"
,
rootPlotName
))
println
(
plotFileDirs
)
# todo add nprocs to the X matrix
# extractor.runlogFile
end
end
XColumns
::
Array
{
String
}
=
extractor
.
outputs
[
"plots_size"
]
outputDirs
=
helper_get_prefix_directories
(
extractor
.
outputPrefix
)
for
outputDir
in
outputDirs
# TODO refactor this later
inputFile
::
String
=
_get_input_file
(
extractor
,
outputDir
)
parameters
=
_input_parser
(
extractor
,
inputFile
)
rootPlotName
=
get
(
parameters
,
"amr.plot_file"
,
""
)
# find all directories with rootPlotName and get its size
plotFileDirs
=
helper_get_prefix_directories
(
string
(
outputDir
,
"/"
,
rootPlotName
))
plotsSize
::
Int64
=
0
for
plotFileDir
in
plotFileDirs
sizeDir
::
Int64
=
helper_get_directory_size
(
plotFileDir
)
plotsSize
+=
sizeDir
println
(
plotFileDir
,
" size: "
,
sizeDir
)
end
println
(
"plots_size: "
,
plotsSize
)
# println(plotFileDirs)
# todo add nprocs to the X matrix
# extractor.runlogFile
end
end
src/helper/helperSystem.jl
View file @
cc6f2128
import
Glob
"""
Gets the list of directories with a certain absolute prefix
Example:
/my/absolute/path/prefix
returns:
/my/absolute/path/prefix.1
/my/absolute/path/prefix.2
/my/absolute/path/prefix.3
"""
function
helper_get_prefix_directories
(
prefix
::
String
)
::
Array
{
String
}
findDelimiter
=
findlast
(
"/"
,
prefix
)
searchDirectory
::
String
=
prefix
[
1
:
findDelimiter
[
1
]
-
1
]
...
...
@@ -30,3 +39,13 @@ function helper_get_prefix_files(prefix::String, path::String)::Array{String}
pattern
::
String
=
string
(
prefix
,
"*"
)
files
=
Glob
.
glob
(
pattern
,
path
)
end
function
helper_get_directory_size
(
directory
::
String
)
::
Int64
size
::
Int64
=
0
for
(
root
,
dirs
,
files
)
in
walkdir
(
directory
)
size
+=
sum
(
map
(
filesize
,
joinpath
.
(
root
,
files
)))
end
return
size
end
test/test_AmrexCastro.jl
View file @
cc6f2128
...
...
@@ -19,7 +19,7 @@ function test_AmrexCastro()
exio
=
Exio
.
exio_init
(
"AmrexCastro"
,
"./test/data/AmrexCastro/hydro_tests/Sedov/2d.cyl_in_cartcoords/case"
,
"run.log"
"run.log"
,
)
@test
typeof
(
exio
)
==
Exio
.
ExioH
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment