Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #60

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/matlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: MATLAB CI checks
on:
push:
pull_request:
branches: [ "main", "dev" ]
workflow_dispatch:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- dev
- main
workflow_dispatch:

permissions:
Expand All @@ -20,4 +20,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

release-type: simple
target-branch: dev
target-branch: main
5 changes: 4 additions & 1 deletion buildfile.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
function plan = buildfile()
import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

plan = buildplan(localfunctions);

plan("check") = CodeIssuesTask;

plan.DefaultTasks = "check";
plan("test") = TestTask;

plan.DefaultTasks = ["check"];
end
8 changes: 3 additions & 5 deletions demo.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@

mask = rand(grid.cells.num,1) < 0.001; % process only a fraction of cells

enable_waitbar = true;
num_par_workers = Inf; % use all parallel workers from the pool
sub_rock = downscale_all(grid,rock,mask,downscale_params,num_par_workers=Inf);

sub_rock = downscale_all(grid,rock,mask,downscale_params,num_par_workers);

strata_trapped = strata_trapper(grid, sub_rock, mask, params, options, enable_waitbar, num_par_workers);
strata_trapped = strata_trapper(grid, sub_rock, mask, params, options, ...
enable_waitbar=true, num_par_workers=Inf);

%% Visualize saturation functions

Expand Down
12 changes: 9 additions & 3 deletions downscale_all.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function [sub_rock] = downscale_all(grid,rock,mask,params,num_par_workers)
function [sub_rock] = downscale_all(grid,rock,mask,params,args)
arguments
grid
rock
mask
params
args.num_par_workers (1,1) uint32 = Inf;
end

coarse_idx = 1:length(mask);
sub_rock(coarse_idx) = struct('poro',[],'perm',[]);
Expand All @@ -7,7 +14,7 @@
perm = rock.perm;
poro = rock.poro;

parfor (cell_index = coarse_idx, num_par_workers)
parfor (cell_index = coarse_idx, args.num_par_workers)
if ~mask(cell_index)
continue;
end
Expand All @@ -16,4 +23,3 @@
poro(cell_index), perm(cell_index,:), DR(cell_index,:), params);
end
end

6 changes: 4 additions & 2 deletions src/calc_percolation.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
Nz = size(p_entry,3);
h(1,1,1:Nz) = linspace(Lz/Nz/2,Lz - Lz/Nz/2,Nz);

hydrostatic_correction = include_gravity * isfinite(rho_gas) * std_gravity() * ...
(rho_water - rho_gas) * (h - h_ref);
hydrostatic_correction = 0;
if ~ismissing(rho_gas)
hydrostatic_correction = include_gravity * std_gravity() * (rho_water - rho_gas) * (h - h_ref);
end

invasion = false(size(p_entry));
invadable = (p_entry + hydrostatic_correction) < p_boundary;
Expand Down
14 changes: 7 additions & 7 deletions strata_trapper.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function strata_trapped = strata_trapper(grid, sub_rock, mask, params, options, enable_waitbar, num_par_workers)
function strata_trapped = strata_trapper(grid, sub_rock, mask, params, options, args)
arguments
grid (1,1) struct
sub_rock (1,:) struct
mask (:,1) logical
params (1,1) Params
options (1,1) Options = Options();
enable_waitbar (1,1) logical = false;
num_par_workers (1,1) uint32 = Inf;
args.enable_waitbar (1,1) logical = false;
args.num_par_workers (1,1) uint32 = Inf;
end

perm_upscaled = zeros(grid.cells.num, 3);
Expand All @@ -21,14 +21,14 @@
mask = mask(1:cells_num);

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

DR = [grid.DX,grid.DY,grid.DZ];

parfor (cell_index = 1:cells_num, num_par_workers)
parfor (cell_index = 1:cells_num, args.num_par_workers)
if ~mask(cell_index)
continue;
end
Expand All @@ -45,7 +45,7 @@
krw(cell_index,:,:) = krw_cell;
krg(cell_index,:,:) = krg_cell;

if enable_waitbar
if args.enable_waitbar
send(wb_queue,cell_index);
end
end
Expand All @@ -62,7 +62,7 @@
'rel_perm_gas', krg ...
);

if enable_waitbar
if args.enable_waitbar
parforWaitbar(0,0,'ready');
end

Expand Down
2 changes: 2 additions & 0 deletions test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%%
demo;