function absTol = obtainAbsTolVector(solverState, absTolPosition, ...
    absTolNumber, absTolBulk, absTolDensity)
% create abs tol vector from given solver state structure
%
% THIS IS NO USER FUNCTION

% The elk-library: convex geometry applied to crystallization modeling.
%   Copyright (C) 2012 Alexander Reinhold
%
% This program is free software: you can redistribute it and/or modify it 
%   under the terms of the GNU General Public License as published by the 
%   Free Software Foundation, either version 3 of the License, or (at your 
%   option) any later version.
%
% This program is distributed in the hope that it will be useful, but 
%   WITHOUT ANY WARRANTY; without even the implied warranty of 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%   General Public License for more details.
%
% You should have received a copy of the GNU General Public License along 
%   with this program.  If not, see <http://www.gnu.org/licenses/>.

%% rewrite hcMatrix
solverState.hcMatrix = solverState.hcMatrix*0 + absTolPosition;
%% rewrite numberVector
solverState.numberVector = solverState.numberVector*0 + absTolNumber;
%% rewrite bulkVector
if numel(absTolBulk) == 1
    solverState.bulkStateVector = solverState.bulkStateVector*0 + absTolBulk;
elseif length(absTolBulk) == length(solverState.bulkStateVector)
    solverState.bulkStateVector = absTolBulk;
else
    error('elk:populationBalance:wrongInput', ...
        ['Absolute tolerance for bulk state does not match dimension of ' ...
         'bulk state vector']);
end
%% density
if solverState.flagDensity
    solverState.probabilityVector = solverState.probabilityVector*0 + ...
        absTolDensity;
end

%% pack to vector
% ..that matches the state vector
absTol = packState(solverState);