mrstModule add upscaling coarsegrid
%% Load and process data
% We assume that the data has been downloaded and placed in the appropriate
% data directory under the MRST root directory.
sector = 'ccs';
grdecl = readGRDECL([sector, '.grdecl']);
G = processGRDECL(grdecl);
G = computeGeometry(G);
rock = grdecl2Rock(grdecl, G.cells.indexMap);
%% Upscale model
% Upscale the model by a factor 5x5x5 using a simple harmonic average for
% the permeability and arithmetic average for the porosity.
% (This demonstrates the power of the accumarray call..)
w = G.cells.volumes;
p = partitionUI(G, G.cartDims./[5 5 6]);
p1= round(p-min(p))+1;
w1= round(w-min(w))+1;
for i=1:size(rock.poro,2)
crock.poro(:,i) = accumarray(p1,w1) ./ ...
accumarray(p1,w1./rock.poro(:,i))
end
for i=1:size(rock.perm,2)
crock.perm(:,i) = accumarray(p1,w1) ./ ...
accumarray(p1,w1./rock.perm(:,i))
end
%% Visualize result
% As expected, using such a naive upscaling will move the permeability
% values towards the centre of their fine-scale spectre.
clf
pargs = {'EdgeColor','none'};
subplot(2,2,1)
plotCellData(G,rock.poro(:,1),pargs{:});
view(-95,40); axis tight off; cx = caxis; title('original');
subplot(2,2,2)
plotCellData(G, crock.poro(p1,1), pargs{:});
set(gca,'zdir','reverse');
view(-95,40); axis tight off; caxis(cx); title('upscaled');