/
solver_set.jl
117 lines (104 loc) · 2.42 KB
/
solver_set.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""
$(TYPEDEF)
Structure of solver setup
## Fields
$(FIELDS)
"""
struct SolverSet{
TS<:AbstractSetup,
TP<:AbstractPhysicalSpace,
TV<:Union{AbstractVelocitySpace,Nothing},
TG<:AbstractProperty,
TI<:Union{AbstractCondition,Nothing},
TO<:AbstractString,
} <: AbstractSolverSet
# setup
set::TS
# physical space
pSpace::TP
ps::TP
# velocity space
vSpace::TV
vs::TV
# gas property
gas::TG
# initial and boundary condition
ib::TI
# file system
outputFolder::TO
end
function SolverSet(
SET::AbstractSetup,
PS::AbstractPhysicalSpace,
VS::Union{AbstractVelocitySpace,Nothing},
GAS::AbstractProperty,
IB::Union{AbstractCondition,Nothing} = nothing,
DIR::AbstractString = @__DIR__,
)
return SolverSet{typeof(SET),typeof(PS),typeof(VS),typeof(GAS),typeof(IB),typeof(DIR)}(
SET,
PS,
PS,
VS,
VS,
GAS,
IB,
DIR,
)
end
function SolverSet(
SET::AbstractSetup,
PS::AbstractPhysicalSpace,
GAS::AbstractProperty,
IB::Union{AbstractCondition,Nothing} = nothing,
DIR::AbstractString = @__DIR__,
)
return SolverSet{typeof(SET),typeof(PS),Nothing,typeof(GAS),typeof(IB),typeof(DIR)}(
SET,
PS,
PS,
nothing,
nothing,
GAS,
IB,
DIR,
)
end
function SolverSet(file)
# generate configuration
config = begin
if file isa AbstractString
read_cfg(file)
else
file
end
end
# setup
set = set_setup(; config...)
# physical space
ps = set_geometry(; config...)
# velocity space
vs = set_velocity(; config...)
# gas property
gas = set_property(config)
# initial & boundary condition
ib = set_ib(config, set, ps, vs, gas)
# create working directory
identifier = string(Dates.now(), "/")
#outputFolder = string("../out/", replace(identifier, ":"=>"."))
outputFolder = replace(identifier, ":" => ".")
mkdir(outputFolder)
mkdir(string(outputFolder, "data/"))
if file isa AbstractString
cp(file, string(outputFolder, "config.txt"))
else
if file isa NamedTuple
dict = ntuple_dict(file)
else
dict = file
end
CSV.write(string(outputFolder, "config.csv"), dict)
end
# create new struct
return SolverSet(set, ps, vs, gas, ib, outputFolder)
end