classdef cellIC < pde.internal.FEDisplay
% cellIC Create a cellIC object
%
% cellIC is used to set an initial condition on a cell.
%
% cellIC properties:
%
% Displacement - Initial displacement, specified as a numeric vector or 
%   function handle or StaticStructuralResults object. A numeric vector 
%   must contain two elements for a 2-D model and three elements for a 3-D model.
% Velocity - Initial velocity, specified as a numeric vector or function 
%   handle or StaticStructuralResults object. A numeric vector must contain 
%   two elements for a 2-D model and three elements for a 3-D model.
% Temperature - Initial temperature or initial guess for temperature, 
%   specified as a number or a function handle or a TransientThermalResults 
%   object or a SteadyStateThermalResults object.
% MagneticVectorPotential - Initial magnetic vector potential, specified as
%    a numeric vector, function handle, or MagnetostaticResults. A numeric 
%    vector of three elements is used for a 3-D model.
% NormFluxDensity - Initial norm of the magnetic flux density, specified as
%    a positive number or function handle. 

% Copyright 2022 The MathWorks, Inc.

    properties
        Displacement {pde.internal.validators.mustBeDisplacement}
        Velocity {pde.internal.validators.mustBeVelocity}
        Temperature {pde.internal.validators.mustBeTemperature}
        MagneticVectorPotential {pde.internal.validators.mustBeMagneticVectorPotential}
        NormFluxDensity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
    end

    methods
        function obj = cellIC(options)
            arguments
                options.?cellIC
            end

            for k=fields(options)'
                obj.(k{:}) = options.(k{:});
            end
        end
    end

    methods(Hidden)
        function obj = reparent(obj,parent)
            % Update display to reflect parent's new AnalysisType.
            % "structuralTransient" | "thermalTransient"  | "magnetostatic" 
            c = { ...
                "structuralTransient", ["Displacement","Velocity","Temperature"]; ...
                "thermalTransient", ["Temperature"]; ...
                "magnetostatic", ["MagneticVectorPotential","NormFluxDensity"]; ...
                };
            d = dictionary(string(c(:,1)), c(:,2));
            props = "";
            if isKey(d,parent.AnalysisType)
                props = d(parent.AnalysisType);
                props = props{:};
            end

            for k=1:numel(obj)
                obj(k).DisplayAnalysisType = parent.AnalysisType;
                obj(k).DisplayPropertyList = props;
            end
        end
    end

end
