classdef cellLoad < pde.internal.FEDisplay
% cellLoad Create a cellLoad object
%
% cellLoad is used to set a load on a cell.
%
% cellLoad properties:
%
% Gravity - Acceleration due to gravity, specified as a numeric vector.
% AngularVelocity - Angular velocity to model centrifugal loading for an 
%       axisymmetric model, specified as a positive number.
% Temperature - Temperature body load, specified as a number or a 
%       function handle or a TransientThermalResults object or a 
%       SteadyStateThermalResults object.
% Heat - Heat source term, specified as a number or a function 
%       handle.
% ChargeDensity - Charge density, specified as a real number or a function 
%       handle
% CurrentDensity - Current density, specified as a real number, a column 
%       vector, a function handle, or a ConductionResults object.
% Magnetization - Magnetization, specified as a column vector of two elements 
%       for a 2-D model, a column vector of three elements for a 3-D model, 
%       or a function handle. 
% 

% Copyright 2022 The MathWorks, Inc.
    properties
        Gravity (1,:) {pde.internal.validators.mustBeDoubleVectorOrEmpty}
        AngularVelocity (1,:) {pde.internal.validators.mustBePositiveOrEmpty}   
        Temperature (1,:) {pde.internal.validators.mustBeTemperature}
        Heat (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        ChargeDensity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        CurrentDensity {pde.internal.validators.mustBeCurrentDensity}
        Magnetization (1,:) {pde.internal.validators.mustBeDoubleVectorOrFunctionHandle}
    end

   methods
        function obj = cellLoad(options)
            arguments
                options.?cellLoad
            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.
            % "structuralStatic" | "structuralModal" | "structuralTransient"
            % | "structuralFrequency" | "thermalTransient" | "thermalSteady" 
            % | "electrostatic" | "magnetostatic" | "electricHarmonic" |
            % "magneticHarmonic"
            c = { ...
                "structuralStatic", ["Gravity","AngularVelocity","Temperature"]; ...
                "structuralTransient", ["Gravity","AngularVelocity","Temperature"]; ...
                "thermalTransient", ["Temperature","Heat"]; ...
                "thermalSteady", ["Temperature","Heat"]; ...
                "electrostatic", ["ChargeDensity"]; ...
                "magnetostatic", ["CurrentDensity","Magnetization"]; ...
                "electricHarmonic", ["CurrentDensity"]; ...
                "magneticHarmonic", ["CurrentDensity"]; ...
                };
            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
