classdef edgeLoad < pde.internal.FEDisplay
% edgeLoad Create an edgeLoad object
%
% edgeLoad is used to set a load on an edge.
%
% edgeLoad properties:
%
% Heat - Heat source, specified as a number or a function handle.
% 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. 
% SurfaceCurrentDensity - Current density boundary condition, 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
        Heat (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
        Pressure (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')}        
        SurfaceTraction (1,:) {pde.internal.validators.mustBeDoubleVectorOrFunctionHandle}
        TranslationalStiffness (1,:) {pde.internal.validators.mustBeDoubleVectorOrFunctionHandle}
        SurfaceCurrentDensity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
    end

   methods
        function obj = edgeLoad(options)
            arguments
                options.?edgeLoad
            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", ["Pressure","SurfaceTraction","TranslationalStiffness"]; ...
                "structuralTransient", ["Pressure","SurfaceTraction","TranslationalStiffness"]; ...
                "structuralFrequency", "Pressure"; ...
                "thermalTransient", "Heat"; ...
                "thermalSteady", "Heat"; ...
                "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
