classdef materialProperties < pde.internal.FEDisplay
% materialProperties Creates a materialProperties object.
%
% Using materialProperties you can set material properties on an entire
% geometry, a cell of a 3-D geometry or face of a 2-D geometry. Material 
% properties can be structural, thermal, or electromagnetic properties.
%
% The materialProperties object has these properties:
%
% YoungsModulus - Young's modulus of the material, specified as a positive 
%       number, 1x3 array of positive numbers, or function handle.
% PoissonsRatio - Poisson's ratio of the material, specified as a positive
%       number, 1x3 array of positive numbers, or function handle.
%       Additionally, for isotropic materials, greater than 0 and less than
%       0.5.
% ShearModulus - Shear modulus of the material, specified as a 1x3 array of
%       positive numbers or function handle.
% MassDensity - Mass density of the material, specified as a positive
%       number or function handle.
%       This argument is required for transient and modal models. It is also
%       required when modeling gravitational effects.
% HystereticDamping - Hysteretic (structural) damping coefficient for the
%       material specified as a nonnegative number.
% CTE - Coefficient of thermal expansion, specified as a real number. This
%       argument is required for thermal stress analysis. Thermal stress
%       analysis requires the structural model to be static.
% ThermalConductivity - Thermal conductivity of the material, specified as
%       a positive number, a vector, a matrix, or a function handle.
% SpecificHeat - Specific heat of the material, specified as a positive
%       number or a function handle. Specify this property for a transient
%       thermal conduction analysis model.
% RelativePermeability - Relative permeability of the material specified as
%       a number or function handle.
% RelativePermeability - Relative permeability of the material specified as
%       a number or function handle.
% ElectricalConductivity - Electrical conductivity of the material,
%       specified as a number or function handle.

% Copyright 2022-2023 The MathWorks, Inc.

    properties
        PoissonsRatio (1,:) {pde.internal.validators.mustBePoissonRatio(PoissonsRatio,0,0.5,'exclusive')}
        YoungsModulus (1,:) {pde.internal.validators.mustBePositiveDoubleVectorOrFunctionHandle}
        ShearModulus (1,:) {pde.internal.validators.mustBePositiveDoubleVectorOrFunctionHandle}
        MassDensity (1,:) {pde.internal.validators.mustBePositiveOrFunctionHandle}
        CTE (1,:) {pde.internal.validators.mustBeDoubleOrEmpty}
        ThermalConductivity {pde.internal.validators.mustBeNonNegativeDoubleVectorOrFunctionHandle}
        SpecificHeat (1,:) {pde.internal.validators.mustBePositiveOrFunctionHandle}
        HystereticDamping (1,:) {pde.internal.validators.mustBeNonNegativeOrEmpty}
        RelativePermittivity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandleOrComplex}
        RelativePermeability (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandleOrComplex}
        ElectricalConductivity (1,:) {pde.internal.validators.mustBeDoubleOrFunctionHandle}
    end

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

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

    methods(Hidden)
        function obj = reparent(obj,parent)
            % Update display to reflect my new parent's AnalysisType.
            % "structuralStatic" | "structuralModal" | "structuralTransient"
            % | "structuralFrequency" | "thermalTransient" | "thermalSteady" 
            % | "electrostatic" | "magnetostatic" | "electricHarmonic" |
            % "magneticHarmonic" | "dcConduction"
            c = { ...
                "structuralStatic", ["CTE", "PoissonsRatio","YoungsModulus","MassDensity","ShearModulus"]; ... 
                "structuralModal",  ["PoissonsRatio","YoungsModulus","MassDensity","ShearModulus"];...
                "structuralTransient",  ["PoissonsRatio","YoungsModulus","MassDensity","ShearModulus"];...
                "structuralFrequency",  ["PoissonsRatio","YoungsModulus","MassDensity","HystereticDamping","ShearModulus"];...
                "thermalTransient",  ["ThermalConductivity","MassDensity","SpecificHeat"];...
                "thermalSteady",  "ThermalConductivity";...
                "electrostatic", "RelativePermittivity";...
                "magnetostatic", "RelativePermeability";...
                "dcConduction", "ElectricalConductivity";...
                "magneticHarmonic", ["RelativePermittivity","RelativePermeability","ElectricalConductivity"];...
                "electricHarmonic", ["RelativePermittivity","RelativePermeability","ElectricalConductivity"];...
                };
            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
