unpackState

PURPOSE ^

unpack state vector according to packing parameters

SYNOPSIS ^

function solverState = unpackState(stateVector, time, solverStateOriginal)

DESCRIPTION ^

 unpack state vector according to packing parameters

 THIS IS NO USER FUNCTION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function solverState = unpackState(stateVector, time, solverStateOriginal)
0002 % unpack state vector according to packing parameters
0003 %
0004 % THIS IS NO USER FUNCTION
0005 
0006 % The elk-library: convex geometry applied to crystallization modeling.
0007 %   Copyright (C) 2012 Alexander Reinhold
0008 %
0009 % This program is free software: you can redistribute it and/or modify it
0010 %   under the terms of the GNU General Public License as published by the
0011 %   Free Software Foundation, either version 3 of the License, or (at your
0012 %   option) any later version.
0013 %
0014 % This program is distributed in the hope that it will be useful, but
0015 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0016 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017 %   General Public License for more details.
0018 %
0019 % You should have received a copy of the GNU General Public License along
0020 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 
0022 %% init
0023 % some numbers
0024 nBulkState = size(solverStateOriginal.bulkStateVector, 1);
0025 nDim = size(solverStateOriginal.hcMatrix, 1);
0026 nPivot = size(solverStateOriginal.hcMatrix, 2);
0027 
0028 % use a central definition of al properly sorted fields
0029 solverState = obtainCleanSolverState;
0030 % time
0031 solverState.time = time;
0032 solverState.bulkStateVector = zeros(0,1);
0033 solverState.hcMatrix = zeros(nDim, 0);
0034 solverState.numberVector = zeros(1, 0);
0035 solverState.upVector = solverStateOriginal.upVector;
0036 solverState.flagDensity = solverStateOriginal.flagDensity;
0037 if solverState.flagDensity
0038     solverState.probabilityVector = zeros(1, 0);
0039 end
0040 solverState.flagNucleation = solverStateOriginal.flagNucleation;
0041 solverState.indexVector = solverStateOriginal.indexVector;
0042 solverState.dissolvedPivotVector = solverStateOriginal.dissolvedPivotVector;
0043 
0044 stateVectorSize = nBulkState + nPivot*(nDim + 1 + solverState.flagDensity);
0045 
0046 
0047 %% pivots
0048 if solverState.flagDensity
0049     stateMatrix = reshape(stateVector(1:(stateVectorSize - nBulkState)), ...
0050         nDim + 2, nPivot);
0051     solverState.hcMatrix = stateMatrix(1:nDim, :);
0052     solverState.numberVector = stateMatrix(end-1, :);
0053     solverState.probabilityVector = stateMatrix(end, :);
0054 else
0055     stateMatrix = reshape(stateVector(1:(stateVectorSize - nBulkState)), ...
0056         nDim + 1, nPivot);
0057     solverState.hcMatrix = stateMatrix(1:nDim, :);
0058     solverState.numberVector = stateMatrix(end, :);
0059 end
0060 
0061 %% bulk states
0062 if nBulkState > 0
0063     solverState.bulkStateVector = stateVector((end-nBulkState+1):end, 1);
0064 end

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005