Commit 2a138c08 authored by William F Godoy's avatar William F Godoy
Browse files

More setup

added scripts:
requirements
formatter

tests passing for AmrexCastro
parent b9141834
......@@ -3,15 +3,13 @@ name = "Exio"
uuid = "0525473d-17b7-4fd3-beb1-bf17216ddbac"
version = "0.0.1"
[deps]
Test
Filesystem
[compat]
julia = "1"
JuliaFormatter = "0.6.2"
[extras]
Test = "eaa6fafa-8011-46e2-b288-c2f1e2a8ee56"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
[targets]
test = ["Test"]
......
# Usage run from root project
# julia ./scripts/formatter.jl
# Requires the JuliaFormatter package see scripts/requirements.jl
using JuliaFormatter
format(".")
# Use to install dependencies for this project
# Run:
# > julia scripts/requirements.jl
using Pkg
Pkg.add("JuliaFormatter")
exit()
......@@ -2,7 +2,7 @@ module Exio
export ExioH, exio_init, input_parser
include("extractor/extractor.jl")
include("extractor/Extractor.jl")
mutable struct ExioH
extractor::AbstractExtractor
......
......@@ -4,7 +4,7 @@ abstract type AbstractAmrex <: AbstractExtractor end
mutable struct Amrex <: AbstractAmrex
app::String
outputPrefix::String
degreesOfFreedom
degreesOfFreedom::Any
Amrex() = new()
end
......@@ -18,13 +18,8 @@ end
function init!(extractor::Amrex, outputPrefix::String)
extractor.app = "Amrex"
extractor.outputPrefix = outputPrefix
extractor.degreesOfFreedom = [
"max_step",
"amr.check_int",
"amr.plot_int",
"amr.n_cell",
"amr.max_level"
]
extractor.degreesOfFreedom =
["max_step", "amr.check_int", "amr.plot_int", "amr.n_cell", "amr.max_level"]
end
"""
......@@ -41,7 +36,6 @@ function input_parser(extractor::AbstractAmrex, inputFile::String)::Dict{String,
# go through each line
for line in fileContents
if isempty(line)
continue
end
......@@ -50,13 +44,13 @@ function input_parser(extractor::AbstractAmrex, inputFile::String)::Dict{String,
result = findfirst("#", line)
if isnothing(result) == false
line = SubString(line, 1, result[1]-1)
line = SubString(line, 1, result[1] - 1)
if isempty(line)
continue
end
end
parameter = split(line,"=")
parameter = split(line, "=")
parameters[strip(parameter[1])] = strip(parameter[2])
end
......
mutable struct AmrexCastro <: AbstractAmrex
app::String
degreesOfFreedom
degreesOfFreedom::Any
outputPrefix::String
AmrexCastro() = new()
......@@ -22,7 +22,7 @@ function init!(extractor::AmrexCastro, outputPrefix::String)
"amr.n_cell",
"amr.max_level",
"castro.cfl",
"castro.max_grid_size"
"castro.max_grid_size",
]
extractor.outputPrefix = outputPrefix
end
abstract type AbstractExtractor end
include("amrex.jl")
include("amrexCastro.jl")
include("Amrex.jl")
include("AmrexCastro.jl")
......@@ -4,7 +4,7 @@ using Test, Base.Filesystem
import Exio
@testset "test_amrexCastro" begin
include("test_amrexCastro.jl")
include("test_AmrexCastro.jl")
end;
@testset "test_Exio.input_parser_docstring" begin
......
"""
workaround function to update counter if scalar
Julia doesn't pass values by reference "address"
"""
function test_value(
counter,
parameters::Dict{String,String},
key::String,
test_value::String,
)
value = parameters[key]
@test value == test_value
counter += 1
return counter
end
function test_AmrexCastro()
exio = Exio.exio_init("AmrexCastro", ".")
@test typeof(exio) == Exio.ExioH
println("Current directory: ", Filesystem.pwd())
inputFile = string(
Filesystem.pwd(),
"/test/data/amrexCastro/test_data_AmrexCastro_inputs.2d.cyl_in_cartcoords",
)
println("Input file: ", inputFile)
parameters = Exio.input_parser(exio.extractor, inputFile)
# keys counter
counter = 0
counter = test_value(counter, parameters, "max_step", "20")
counter = test_value(counter, parameters, "stop_time", "0.1")
counter = test_value(counter, parameters, "geometry.is_periodic", "0 0")
counter = test_value(counter, parameters, "geometry.coord_sys", "0")
counter = test_value(counter, parameters, "geometry.prob_lo", "0 0")
counter = test_value(counter, parameters, "geometry.prob_hi", "1 1")
counter = test_value(counter, parameters, "amr.n_cell", "16 16")
counter = test_value(counter, parameters, "castro.lo_bc", "2 2")
counter = test_value(counter, parameters, "castro.hi_bc", "2 2")
counter = test_value(counter, parameters, "castro.do_hydro", "1")
counter = test_value(counter, parameters, "castro.do_react", "0")
counter = test_value(counter, parameters, "castro.cfl", "0.5")
counter = test_value(counter, parameters, "castro.init_shrink", "0.01")
counter = test_value(counter, parameters, "castro.change_max", "1.1")
counter = test_value(counter, parameters, "castro.sum_interval", "1")
counter = test_value(counter, parameters, "castro.v", "1")
counter = test_value(counter, parameters, "amr.v", "1")
counter = test_value(counter, parameters, "amr.max_level", "2")
counter = test_value(counter, parameters, "amr.ref_ratio", "2 2 2 2")
counter = test_value(counter, parameters, "amr.regrid_int", "2")
counter = test_value(counter, parameters, "amr.blocking_factor", "8")
counter = test_value(counter, parameters, "amr.max_grid_size", "128")
counter = test_value(counter, parameters, "amr.check_file", "sedov_2d_cyl_in_cart_chk")
counter = test_value(counter, parameters, "amr.check_int", "20")
counter = test_value(counter, parameters, "amr.plot_file", "sedov_2d_cyl_in_cart_plt")
counter = test_value(counter, parameters, "amr.derive_plot_vars", "ALL")
counter =
test_value(counter, parameters, "amr.probin_file", "probin.2d.cyl_in_cartcoords")
@test counter == 27
end
test_AmrexCastro()
exio = Exio.exio_init("AmrexCastro", ".")
@test typeof(exio) == Exio.ExioH
println("Current directory: ", Filesystem.pwd() )
inputFile = string(Filesystem.pwd(),"/test/data/amrexCastro/test_data_AmrexCastro_inputs.2d.cyl_in_cartcoords")
println( "Input file: ", inputFile )
parameters = Exio.input_parser(exio.extractor, inputFile)
# keys counter
n = 0
for parameter in parameters
key = parameter[1]
value = parameter[2]
if isequal(key, "amr.regrid_int") global n += 1; @test isequal(value, "2")
elseif isequal(key, "amr.plot_file") global n += 1; @test isequal(value,"sedov_2d_cyl_in_cart_plt")
elseif isequal(key, "amr.max_level") global n += 1; @test isequal(value, "2")
elseif isequal(key, "amr.plot_int") global n += 1; @test isequal(value, "20")
elseif isequal(key, "amr.n_cell") global n += 1; @test isequal(value, "16 16")
end
println(parameter[1], "...", parameter[2])
end
# @test n == 5
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment