


pack solver state variables in a single vector THIS IS NO USER FUNCTION


0001 function stateVector = packState(solverState) 0002 % pack solver state variables in a single vector 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 0023 % The vector will look, like: 0024 % 0025 % 1) nucleation bin pivot (dim1, dim2, ..., number, density=nan) 0026 % 2) nucleation bin boundary (dim1, dim2, ..., number=0, density=nan) 0027 % 3) all pivots (dim1, dim2, ..., number, probability density) 0028 % 4) all bulk states 0029 0030 %% init 0031 nBulkState = size(solverState.bulkStateVector, 1); 0032 nDim = size(solverState.hcMatrix, 1); 0033 nPivot = size(solverState.hcMatrix, 2); 0034 stateVectorSize = nBulkState + nPivot*(nDim + 1 + solverState.flagDensity); 0035 stateVector = nan(stateVectorSize, 1); 0036 0037 %% pivot part 0038 if solverState.flagDensity 0039 stateMatrix = [solverState.hcMatrix; solverState.numberVector; ... 0040 solverState.probabilityVector]; 0041 else 0042 stateMatrix = [solverState.hcMatrix; solverState.numberVector]; 0043 end 0044 stateVector(1:(stateVectorSize - nBulkState), 1) = stateMatrix(:); 0045 0046 %% bulk states 0047 if ~isempty(solverState.bulkStateVector) 0048 stateVector((stateVectorSize-nBulkState+1):stateVectorSize) = ... 0049 solverState.bulkStateVector; 0050 end 0051 0052 end