Files
opm-core/opm/core/grid/cpgpreprocess/processgrid.m
Bård Skaflestad 7d7f62ebc3 Merge branch 'preprocess-svn-reintegrate'
Conflicts:
	Makefile.am
	opm/core/grid/cpgpreprocess/facetopology.c
	opm/core/grid/cpgpreprocess/mxgrdecl.c
	opm/core/grid/cpgpreprocess/preprocess.c
	opm/core/grid/cpgpreprocess/sparsetable.c
	opm/core/grid/cpgpreprocess/sparsetable.h
	opm/core/grid/cpgpreprocess/uniquepoints.c

This merge brings a new, more resilient and feature-complete
corner-point processing.  In particular, the new code features
exact, in-plane vertex coordinates for face nodes that arise as a
result of fault processing and which are not located on pillars.
Secondly, the resulting grid's cells are ordered lexicographically
with the I index cycling the most rapidly, followed by J and
finally K.

Finally, this merge also brings automatic handling of left-handed
coordinate systems which, until now, have produced negative cell
volumes as a result of face vertices being ordered such that
interface normals point from cell 2 to cell 1 in this case.
Left-handed coordinate systems are recognised using a simplistic
triple-product characterisation akin to the implementation of
function "processGRDECL" of MRST.

This code is now an (almost) exact replica of revision 1001 of
https://public.ict.sintef.no/viewvc/openrs/trunk/dune-cornerpoint/grid/preprocess/

The merge also removes opm/core/grid/cpgpreprocess/readvector*, so
remove tests/test_readvector.cpp (and accompanying Make rule) to
maintain a buildable tree.
2012-06-26 19:52:21 +02:00

67 lines
1.9 KiB
Matlab

function G = processgrid(varargin)
%Compute grid topology and geometry from pillar grid description.
%
% SYNOPSIS:
% G = processgrid(grdecl)
% G = processgrid(grdecl,ztol)
%
% PARAMETERS:
% grdecl - Raw pillar grid structure, as defined by function
% 'readGRDECL', with fields COORDS, ZCORN and, possibly, ACTNUM.
% ztol - tolerance for unique points
%
% RETURNS:
% G - Valid grid definition containing connectivity, cell
% geometry, face geometry and unique nodes.
%
% EXAMPLE:
% G = processgrid(readGRDECL('small.grdecl'));
% plotGrid(G); view(10,45);
%
% SEE ALSO:
% processGRDECL, readGRDECL, deactivateZeroPoro, removeCells.
%{
#COPYRIGHT#
%}
% $Date$
% $Revision$
% Copyright 2009 SINTEF ICT, Applied Mathematics.
% Mex gateway by Jostein R. Natvig, SINTEF ICT.
% $Date$
% $Revision$
G = processgrid_mex(varargin{:});
G.griddim = 3;
G = splitDisconnectedGrid(G, false);
end
function G = splitDisconnectedGrid(G, verbose)
% Check if grid is connected
ix = all(G.faces.neighbors~=0, 2);
I = [G.faces.neighbors(ix,1);G.faces.neighbors(ix,2)];
J = [G.faces.neighbors(ix,2);G.faces.neighbors(ix,1)];
N = double(max(G.faces.neighbors(:)));
A = sparse(double(I),double(J),1,N,N)+speye(N);
clear ix I J
[a,b,c,d]=dmperm(A); %#ok
clear A b d
if numel(c) > 2,
dispif(verbose, '\nGrid has %d disconnected components\n', ...
numel(c)- 1);
% Partition grid into connected subgrids
for i = 1:numel(c) - 1,
g(i) = extractSubgrid(G, a(c(i):c(i+1)-1)); %#ok
sz(i) = g(i).cells.num; %#ok
g(i).cartDims = G.cartDims; %#ok
end
% Return largest (in number of cells) grid first
[i,i] = sort(-sz); %#ok
G = g(i);
end
end