Skip to content

Commit

Permalink
utilities update
Browse files Browse the repository at this point in the history
  • Loading branch information
GHilmarG committed Jan 21, 2024
1 parent ce18868 commit f953568
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
66 changes: 63 additions & 3 deletions PrintInfoAboutElementsSizes.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
function [Emin,Emax,Emean,Emedian]=PrintInfoAboutElementsSizes(CtrlVar,MUA,options)
function [Emin,Emax,Emean,Emedian,Tlength]=PrintInfoAboutElementsSizes(CtrlVar,MUA,options)

%%
%
% Calculates equivalent element lengths
%
% Equivalent length can be defined in two ways:
%
% # as the leg of an isosceles right triangle with the same area as the triangular element, or
% # as the length of a perfect square that has the same area as the triangular element.
%
% Option 1) is the default, however after some thought it now feels to me that option 2) should be the default.
%
%
% Example:
%
% [Emin,Emax,Emean,Emedian]=PrintInfoAboutElementsSizes(CtrlVar,MUA,print=true,plot=true,LengthMeasure="-side of a perfect square of equal area-");
%
%%

arguments
CtrlVar struct
MUA struct
options.print logical = true ;

options.LengthMeasure string="-leg of an isosceles right triangle-" ; % "-side of a perfect square of equal area-";
options.plot logical = false ;
end


Tarea=TriAreaFE(MUA.coordinates,MUA.connectivity);
Tlength=sqrt(2*Tarea) ;

if options.LengthMeasure=="-side of a perfect square of equal area-"
Tlength=sqrt(Tarea) ; % this is the length of the sides of a perfect square of equal area.
else
Tlength=sqrt(2*Tarea) ; % Default option: this is the length of the legs of an isosceles right triangle.
end



Emax=max(Tlength);
Emean=mean(Tlength);
Expand All @@ -23,4 +48,39 @@
MUA.Nele,MUA.nod,MUA.Nnodes,Emax,Emean,Emedian,Emin);
end

if options.plot

cbar=UaPlots(CtrlVar,MUA,[],Tlength/CtrlVar.PlotXYscale) ;
title(cbar,"$l$",Interpreter="latex")
title("Equivalent element lengths",Interpreter="latex")

if CtrlVar.PlotXYscale~=1

StAdd="(/"+num2str(CtrlVar.PlotXYscale)+")" ;
title(cbar,["$l$",StAdd],Interpreter="latex")
title("Equivalent element lengths "+StAdd,Interpreter="latex")


end


FindOrCreateFigure("histogram of element sizes")
histogram(Tlength/CtrlVar.PlotXYscale)

title("Histogram of element sizes",Interpreter="latex")

xlabel("Effective element size",Interpreter="latex")
ylabel("Number of elements",Interpreter="latex")

if CtrlVar.PlotXYscale~=1

StAdd="(/"+num2str(CtrlVar.PlotXYscale)+")" ;
title("Histogram of element sizes "+StAdd,Interpreter="latex")
xlabel("Effective element size "+StAdd,Interpreter="latex")

end

end


end
2 changes: 1 addition & 1 deletion TestABfgPreEliminateIterative.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

case "-direct-"

% Comaprision with Direct solver
% Comparison with Direct solver


tic
Expand Down
4 changes: 2 additions & 2 deletions Ua2D_DefaultParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -2213,9 +2213,9 @@
CtrlVar.MapOldToNew.method="scatteredInterpolant" ; % {"FE form functions","scatteredInterpolant","ShapeAndScattered"}
CtrlVar.MapOldToNew.method="ShapeAndScattered" ; % This is the new default option as of 2 April 2023.
% The old method was based on the MATLAB scatteredinterpolant, and it was discovered that this MATLAB function sometimes
% produced bizzare results for points at the edges of the triangulation. As far as I can see, this is a MATLAB issue and
% produced bizarre results for points at the edges of the triangulation. As far as I can see, this is a MATLAB issue and
% there is noting that can be done about this except using alternative approaches not dependent on the MATLAB interpolant for
% boundary points of the triangulation. See examples and tests in the UaTest subfolder "MappingVariablesFromMesh1toMesh2"
% boundary points of the triangulation. See examples and tests in the UaTest sub-folder "MappingVariablesFromMesh1toMesh2"
CtrlVar.MapOldToNew.Test=false; %


Expand Down
3 changes: 2 additions & 1 deletion html/helptoc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
<tocitem target="FluxAcrossEleGL.html">Calculates flux across edges of grounded elements. </tocitem>
<tocitem target="CalcMeshMask.html">Calculates the nodal and element mask of a given scalar quantity. </tocitem>
<tocitem target="DraftDependentMeltParameterisations.html">Returns several pre-defined draft-dependent melt-parameterisations. </tocitem>
<tocitem target="LocateDetachedIslandsAndRegionsConnectedByOneNodeOnly.html">Locate detached element islands and regions connected one node only. </tocitem>
<tocitem target="LocateDetachedIslandsAndRegionsConnectedByOneNodeOnly.html">Locate detached element islands and regions connected by one node only. </tocitem>
<tocitem target="PrintInfoAboutElementsSizes.html">Calculate effective element sizes. </tocitem>
</tocitem>
</tocitem>
</tocitem>
Expand Down

0 comments on commit f953568

Please sign in to comment.