classdef ReducedThermalModel < matlab.mixin.CustomDisplay
% pde.ReducedThermalModel - Thermal reduced-order model
%
% ReducedThermalModel methods:
%   reconstructSolution - Reconstruct transient thermal results
%
% ReducedThermalModel properties:
%   K                    - Reduced stiffness matrix
%   M                    - Reduced mass matrix
%   F                    - Reduced load vector
%   InitialConditions    - Initial conditions in modal coordinates
%   ModeShapes           - Modes used to obtain reduced-order model
%   Mesh                 - Discretization of the domain
%   SnapshotsAverage     - Average of snapshots used for POD

% Copyright 2021-2023 The MathWorks, Inc.

    properties(SetAccess = protected)
        %Reduced K
        K;

        %Reduced M
        M;
        
        %Reduced F
        F;

        % Initial conditions in modal coordinates
        InitialConditions;
        
        % Mesh
        Mesh
    end
        
    properties(SetAccess = protected, Dependent = true)
        % Mode  shapes
        ModeShapes;

        % Average of snapshots used for POD
        SnapshotsAverage;
    end

    properties(SetAccess = protected, Hidden = true)
        % Transformation
        TransformationMatrix;

        % Model object with data for reconstruction
        ModelForReconstruction;
        
        % Type of modes used for constructing ROM
        ModeType

        % Coefficients for post-processing.
        Coefficients
    end
        
    methods
        function obj = ReducedThermalModel(tpdem,Kr,Mr,Fr,u0Modal,modalTransformationMat,tmodel,modeType,coefstruct)
            if nargin == 0
                return
            end
            obj.K = Kr;
            obj.M = Mr;
            obj.F = Fr;
            obj.F = Fr;
            obj.InitialConditions = u0Modal;
            obj.Mesh = tpdem.Mesh;
            obj.TransformationMatrix = modalTransformationMat;
            obj.ModelForReconstruction = tmodel;
            obj.ModeType = modeType;
            obj.Coefficients = coefstruct;
        end

        function ms = get.ModeShapes(obj)
            idx =1;
            if obj.ModeType == "PODModes"
                idx = 2;
            end
            ms = obj.TransformationMatrix(:,idx:end);
        end

        function mt = get.SnapshotsAverage(obj)
            mt = [];
            if obj.ModeType == "PODModes"
                mt = obj.TransformationMatrix(:,1);
            end
        end

        Rtrans= reconstructSolution(obj,varargin);
    end

    methods (Access = protected,Hidden = true)
        function group = getPropertyGroups(self)
            if ~isempty(self.ModeType) && self.ModeType == "PODModes"
                groupNames = {'K','M','F','InitialConditions','Mesh','ModeShapes','SnapshotsAverage'};
            else
                groupNames = {'K','M','F','InitialConditions','Mesh','ModeShapes'};
            end
            group = matlab.mixin.util.PropertyGroup(groupNames);
        end
    end
    
end
