Skip to content

Commit

Permalink
Convert a special type of OPERATE to MULTX/Y/Z
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Jun 13, 2024
1 parent 4152d25 commit 87feeee
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/InputParser/keywords/special.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,43 @@ function parse_keyword!(data, outer_data, units, cfg, f, ::Val{:OPERATE})
op_prm2 = parsed[11]

IJK = get_box_indices(outer_data, il, iu, jl, ju, kl, ku)
operation_target = get_operation_section(outer_data, target)
operation_source = get_operation_section(outer_data, source)
if ismissing(operation_target)
data[target] = zeros(dims)
operation_target = data[target]
if target == source && op == "MULTX" && startswith(target, "TRAN")
handle_multxyz_as_operate!(outer_data, target, IJK, op_prm1)
else
operation_target = get_operation_section(outer_data, target)
operation_source = get_operation_section(outer_data, source)
if ismissing(operation_target)
data[target] = zeros(dims)
operation_target = data[target]
end
apply_operate!(operation_target, operation_source, IJK, op, op_prm1, op_prm2)
end
apply_operate!(operation_target, operation_source, IJK, op, op_prm1, op_prm2)
# On to the next one.
rec = read_record(f)
end
end

function handle_multxyz_as_operate!(outer_data, target, IJK, val)
# A special fix to handle the fact that we don't really initialize
# TRANX/TRANY/TRANZ arrays and this special case operation can be
# reformulated as MULTX/MULTY/MULTZ.
# TODO: Make a bit more general.
grid = outer_data["GRID"]
dir = target[end]
alternative_key = "MULT$dir"
if !haskey(grid, alternative_key)
grid[alternative_key] = ones(Float64, grid["cartDims"]...)
end
I, J, K = IJK
for i in I
for j in J
for k in K
grid[alternative_key][i, j, k] *= val
end
end
end
end

function apply_operate!(target, source, IJK, op, prm1, prm2)
I, J, K = IJK
op = lowercase(op)
Expand Down

0 comments on commit 87feeee

Please sign in to comment.