function pbeDef = ureaGenericGrowth
% Generic urea crystal (nC=3) grows with two generic rates that are
%   switched at t=1


%% decomposition data
fileNameDecomposition = 'ureaGenericGrowth_dec.matx';
if exist(fileNameDecomposition, 'file')
    dec = load(fileNameDecomposition, '-mat');
    dec = dec.dec;
else
    % Load case (contains source information)
    dec = obtainCrystalDec('generic_urea', 1);
    % generate measure information
    dec = addMeasureDataDec(dec, 'volume');
    dec = addMeasureDataDec(dec, 'surface');
    dec = addMeasureDataDec(dec, 'meanWidth');
%     dec = addMeasureDataDec(dec, 'support', dec.A([1 5 9], :));
    % save file
    save(fileNameDecomposition, '-mat', 'dec');
end
% copy to pbeDef
pbeDef.source = dec.cdef.source;
pbeDef.dec = dec;

% write pbeDef
pbeDef.seeding.positionMatrix = [0.5 1 1.2]';
pbeDef.seeding.numberVector = 1;
pbeDef.growthRateOriginal = @(H, P, y, t)(...
    bsxfun(@plus, 0*H,  ...
    [0.1 0.5 1]'*(t<=1) + ...
    [0.1 1 1.75]'*(t>1) ...
    ));
pbeDef.growthRate = @(H, P, y, t)(pbeDef.growthRateOriginal(H, P, y, t));
pbeDef.pivotProperty = @(H, up)(up);
pbeDef.timeSpan = 0:0.01:2;

%%
close all
% figure,viewCrystal(dec.cdef, [0.5 1 1.2])
% figure,viewCrystal(dec.cdef, [0.5 1 1.2]+[0.1 0.5 1])
% figure,viewCrystal(dec.cdef, [0.5 1 1.2]+[0.1 0.5 1]+[0.1 1 1.75])

% options
pbeDef.optionStruct.distanceLimit = 1e-2; %m
pbeDef.optionStruct.relTol = 1e-8;
pbeDef.optionStruct.updateUnifiedLimit = 2;
pbeDef.optionStruct.limitGrowthRate = 1;
pbeDef.optionStruct.useEmbeddingPartitions = 0;
