Skip to content

Commit

Permalink
WIP optimized sparse input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
djmaxus committed Oct 11, 2024
1 parent 7a84448 commit b20c167
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions strata_trapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@
num_par_workers (1,1) uint32 = Inf;
end

perm_upscaled = zeros(grid.cells.num, 3);
cells_num = min(length(mask),grid.cells.num);
cell_idxs = 1:cells_num;
mask = mask(cell_idxs);
subset_len = sum(mask);

perm_upscaled = zeros(subset_len, 3);

saturations = linspace(params.sw_resid,1,options.sat_num_points);

cap_pres_upscaled = nan(grid.cells.num,length(saturations));
krw = nan(grid.cells.num,3,length(saturations));
krg = nan(grid.cells.num,3,length(saturations));

cells_num = min(length(mask),grid.cells.num);
mask = mask(1:cells_num);
cap_pres_upscaled = nan(subset_len,length(saturations));
krw = nan(subset_len,3,length(saturations));
krg = nan(subset_len,3,length(saturations));

wb_queue = parallel.pool.DataQueue;
if enable_waitbar
parforWaitbar(0,sum(mask));
afterEach(wb_queue,@parforWaitbar);
end

DR = [grid.DX,grid.DY,grid.DZ];
DR = [grid.DX(mask),grid.DY(mask),grid.DZ(mask)];

parfor (cell_index = 1:cells_num, num_par_workers)
if ~mask(cell_index)
continue;
end
sub_rock = sub_rock(mask);

parfor (cell_index = 1:subset_len, num_par_workers)
sub_porosity = sub_rock(cell_index).poro;
sub_permeability = sub_rock(cell_index).perm;

Expand All @@ -50,16 +50,17 @@
end
end

krw(mask,:,saturations<=params.sw_resid) = 0;
krw(:,:,saturations<=params.sw_resid) = 0;
krg(krg<0) = 0;
krg(mask,:,saturations>=1)=0;
krg(:,:,saturations>=1)=0;

strata_trapped = struct(...
'permeability', perm_upscaled, ...
'saturation', saturations,...
'capillary_pressure', cap_pres_upscaled, ...
'rel_perm_wat', krw, ...
'rel_perm_gas', krg ...
'rel_perm_gas', krg, ...
'idx', cell_idxs(mask) ...
);

if enable_waitbar
Expand Down

0 comments on commit b20c167

Please sign in to comment.