Here I start posting some quick blog posts that include code snippets. These are my developed codes, are very helpful for developing new applications. To use them in your projects, studies etc.

The following operation

pts = rand(10,3)-[1,2,3];

translates in Matlab’s earlier editions (< 2016) to

pts = bsxfun(@minus,rand(10,3),[1,2,3]);

The paper

- Fadakar-A Y, Dowd P.A, Xu C, 2014, Connectivity Field: A Measure for Characterising Fracture Networks. Journal of Mathematical Geosciences, DOI: 10.1007/s11004-014-9520-7.

provides a comprehensive study on connectivity of DFN models. It covers traditional lattice (pixel) based connectivity evaluations, clustering; furthermore, proposes a novel fully developed method for analyzing connectivity of DFN models that preserves its properties after down- or up-scaling, that is an scalable measure.

Sample codes of Connectivity Field can be found in ADFNE1.0.

TIPS: Use the search box above (top-right) to search for “CF”, “Connectivity Field”, etc.

Indeed, it is quite easy to adapt them to work with new standards in ADFNE1.5. It remains however the user’s task to do so, for now.

Anyway, for simpler and quick evaluations the following example demonstrates intersection analysis, cluster analysis and pipe model all within ADFNE1.5.

addpath('ADFNE15'); Globals;

rng(1234567890); % for reproducibility purpose

set1 = Field(DFN('dim',3,'n',150,'dir',15,'ddir',-1e9,'minl',0.15,...

'mu',0.3,'maxl',0.5,'bbx',[0,0,0,1,1,1],'dip',45,'ddip',-1e7),'Poly');

set2 = Field(DFN('dim',3,'n',150,'dir',210,'ddir',-1e9,'minl',0.05,...

'mu',0.1,'maxl',0.5,'bbx',[0,0,0,1,1,0.5],'dip',45,'ddip',-1e7,...

'shape','e','q',4),'Poly');

fnm = [set1;set2];

Draw('ply',fnm);

%% Connectivity Analysis

switch 1

case 1 % Intersection -> Cluster

% Intersection Analysis

[xts,ids,La] = Intersect(fnm);

% Cluster Analysis

switch 2

case 1 % method 1

% Cluster Labels

La = Relabel(La);

% Members of Largest Cluster

idx = (La == max(La));

% Visualize

clf;

Draw(fnm(~idx),'fc','none','axes',false);

Draw(fnm(idx),'fc','r','axes',false);

Axes;

case 2 % method 2

% Clusters

clu = Cluster(ids);

% Size of Clusters

cln = cellfun(@numel,clu);

% Largest Cluster

[~,idx] = max(cln);

cmx = clu{idx};

% Visualize

clf;

Draw(fnm(Not(1:size(fnm,1),cmx)),'fc','none','axes',false);

Draw(fnm(cmx),'fc','r','axes',false);

Axes;

end

case 2 % Pipe

% Boundary Elements

be = {Poly.Left+[0.05,0,0];Poly.Right-[0.05,0,0]};

% Pipe -> Backbone

o = Field(CPipe(be,fnm).Backbone,'dfn');

La = o.dfn.Label(3:end);

plb = o.pip.Label(o.bbn.B);

lbl = plb(1);

% Backbone Lines

bbn = o.bbn.Backbone;

% Visualize

clf;

subplot(211);

Draw(fnm(La == lbl),'fc','r','fa',1,'axes',false);

Draw(be,'fa',0.2);

subplot(212);

Draw(fnm(La ~= lbl),'fc','none','ec',[0.7,0.7,0.7],'axes',false);

Draw(be,'fa',0.2);

Draw(bbn);

end

In some Matlab editions some functions are missing, either they have been removed entirely or replaced with some others. Anyway, here I list simple solutions for some as for your convenience while using ADFNE1.5 package.

Note that some of them are already included in the folder R2015a in the package. Anyway, to use them copy paste each into a separate file named exactly as the function name (*.m) and put them inside the folder R2015a.

###### contains.m

function b = contains(s,p)

b = ~isempty(strfind(s,p));

###### pad.m

function s = pad(s,n,side)

switch side

case 'left'

s = [repelem(' ',1,n),s];

end

###### setstructfields.m

function tgt = setstructfields(tgt,upd)

names = fieldnames(upd);

for i = 1:numel(names)

tgt.(names{i}) = upd.(names{i});

end