classdef faceLoad < pde.internal.FEDisplay
% faceLoad Create a faceLoad object
%
% faceLoad is used to set a load on a face.
%
% faceLoad properties:
%
% Temperature - Temperature body load, specified as a number or a 
%       TransientThermalResults object or a SteadyStateThermalResults object.
% Heat - Heat source term, specified as a number or a function 
%       handle to specify varying heat source.
% Pressure - Pressure normal to the boundary, specified as a number or 
%       function handle. A positive-value pressure acts into the boundary, 
%       while a negative-value pressure acts away from the boundary  
% ConvectionCoefficient - Convection to ambient boundary condition, 
%       specified as a number or a function handle.
% AmbientTemperature - Ambient temperature, specified as a number. The 
%       ambient temperature value is required for specifying convection and 
%       radiation boundary conditions.
% Emissivity - Radiation emissivity coefficient, specified as a number in 
%       the range (0,1).
% SurfaceTraction - Distributed normal and tangential forces on the boundary, 
%       resolved along the global Cartesian coordinate system, specified as 
%       a numeric vector or function handle.
% TranslationalStiffness - Distributed spring stiffness for each translational 
%       direction used to model elastic foundation, specified as a numeric 
%       vector or function handle.
% Gravity - Acceleration due to gravity, specified as a column vector of two 
%       elements for a 2-D model
% AngularVelocity - Angular velocity to model centrifugal loading for an 
%       axisymmetric model, specified as a positive number. 
% 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.
% SurfaceCurrentDensity - Current density load, specified as a number or 
%       a function handle. Use a function handle to specify spatially varying 
%       current density in the direction normal to the boundary.

% Copyright 2022 The MathWorks, Inc.
    properties
        Temperature (1,:) {pde.internal.validators.mustBeTemperature}
        Heat (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        ConvectionCoefficient (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        AmbientTemperature (1,:) {pde.internal.validators.mustBeDoubleOrEmpty}
        Emissivity (1,:) {pde.internal.validators.mustBeDoubleOrInRange(Emissivity,-1,1,'inclusive')}        
        Pressure (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        SurfaceTraction (1,:) {pde.internal.validators.mustBeDoubleVectorOrFunctionHandle}
        TranslationalStiffness (1,:) {pde.internal.validators.mustBeDoubleVectorOrFunctionHandle}
        SurfaceCurrentDensity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        ChargeDensity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        CurrentDensity {pde.internal.validators.mustBeCurrentDensity}
        Magnetization {pde.internal.validators.mustBeDoubleVectorOrFunctionHandle}
        Gravity (1,:) {pde.internal.validators.mustBeDoubleVectorOrEmpty}
        AngularVelocity (1,:) {pde.internal.validators.mustBePositiveOrEmpty}        
    end

   methods
        function obj = faceLoad(options)
            arguments
                options.?faceLoad
            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","Pressure","TranslationalStiffness"]; ...
                "structuralTransient", ["Gravity","AngularVelocity","Temperature","Pressure","TranslationalStiffness"]; ...
                "thermalTransient", ["Temperature","Heat"]; ...
                "thermalSteady", ["Temperature","Heat"]; ...
                "electrostatic", "ChargeDensity"; ...
                "magnetostatic", ["CurrentDensity","Magnetization"]; ...
                "electricHarmonic", "CurrentDensity"; ...
                "magneticHarmonic", "CurrentDensity"; ...
                "dcConduction", "SurfaceCurrentDensity";...
                };
            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
