1 | %SPHEREMESH class definition
|
---|
2 | %
|
---|
3 | % Usage:
|
---|
4 | % spheremesh=spheremesh();
|
---|
5 |
|
---|
6 | classdef spheremesh
|
---|
7 | properties (SetAccess=public)
|
---|
8 | x = NaN;
|
---|
9 | y = NaN;
|
---|
10 | z = NaN;
|
---|
11 | r = NaN;
|
---|
12 | theta = NaN;
|
---|
13 | phi = NaN
|
---|
14 | elements = NaN
|
---|
15 | dimension = 0;
|
---|
16 | numberoflayers = 0;
|
---|
17 | numberofelements = 0;
|
---|
18 | numberofvertices = 0;
|
---|
19 |
|
---|
20 | vertexconnectivity = NaN
|
---|
21 | elementconnectivity = NaN
|
---|
22 | average_vertex_connectivity = 0;
|
---|
23 | end
|
---|
24 | methods
|
---|
25 | function obj = spheremesh(varargin) % {{{
|
---|
26 | switch nargin
|
---|
27 | case 0
|
---|
28 | obj=setdefaultparameters(obj);
|
---|
29 | otherwise
|
---|
30 | error('constructor not supported');
|
---|
31 | end
|
---|
32 | end % }}}
|
---|
33 | function obj = setdefaultparameters(obj) % {{{
|
---|
34 |
|
---|
35 | %the connectivity is the avergaded number of nodes linked to a
|
---|
36 | %given node through an edge. This connectivity is used to initially
|
---|
37 | %allocate memory to the stiffness matrix. A value of 16 seems to
|
---|
38 | %give a good memory/time ration. This value can be checked in
|
---|
39 | %trunk/test/Miscellaneous/runme.m
|
---|
40 | obj.average_vertex_connectivity=25;
|
---|
41 | end % }}}
|
---|
42 | function md = checkconsistency(obj,md,solution,analyses) % {{{
|
---|
43 |
|
---|
44 | md = checkfield(md,'spheremesh.x','NaN',1,'size',[md.spheremesh.numberofvertices 1]);
|
---|
45 | md = checkfield(md,'spheremesh.y','NaN',1,'size',[md.spheremesh.numberofvertices 1]);
|
---|
46 | md = checkfield(md,'spheremesh.z','NaN',1,'size',[md.spheremesh.numberofvertices 1]);
|
---|
47 | md = checkfield(md,'spheremesh.r','NaN',1,'size',[md.spheremesh.numberofvertices 1]);
|
---|
48 | md = checkfield(md,'spheremesh.theta','NaN',1,'size',[md.spheremesh.numberofvertices 1]);
|
---|
49 | md = checkfield(md,'spheremesh.phi','NaN',1,'size',[md.spheremesh.numberofvertices 1]);
|
---|
50 | md = checkfield(md,'spheremesh.elements','NaN',1,'>',0,'values',1:md.spheremesh.numberofvertices);
|
---|
51 | if(md.spheremesh.dimension==2),
|
---|
52 | md = checkfield(md,'spheremesh.elements','size',[md.spheremesh.numberofelements 3]);
|
---|
53 | else
|
---|
54 | md = checkfield(md,'spheremesh.elements','size',[md.spheremesh.numberofelements 6]);
|
---|
55 | end
|
---|
56 | if any(~ismember(1:md.spheremesh.numberofvertices,sort(unique(md.spheremesh.elements(:)))));
|
---|
57 | md = checkmessage(md,'orphan nodes have been found. Check the spheremesh outline');
|
---|
58 | end
|
---|
59 | md = checkfield(md,'spheremesh.dimension','values',[2 3]);
|
---|
60 | md = checkfield(md,'spheremesh.numberoflayers','>=',0);
|
---|
61 | md = checkfield(md,'spheremesh.numberofelements','>',0);
|
---|
62 | md = checkfield(md,'spheremesh.numberofvertices','>',0);
|
---|
63 | if (md.spheremesh.dimension==2),
|
---|
64 | md = checkfield(md,'spheremesh.average_vertex_connectivity','>=',9,'message','''spheremesh.average_vertex_connectivity'' should be at least 9 in 2d');
|
---|
65 | else
|
---|
66 | md = checkfield(md,'spheremesh.average_vertex_connectivity','>=',24,'message','''spheremesh.average_vertex_connectivity'' should be at least 24 in 3d');
|
---|
67 | end
|
---|
68 | md = checkfield(md,'spheremesh.elementconnectivity','size',[md.spheremesh.numberofelements 3],'NaN',1);
|
---|
69 |
|
---|
70 | %Solution specific checks
|
---|
71 | switch(solution),
|
---|
72 | case MasstransportSolutionEnum(),
|
---|
73 | if md.masstransport.stabilization==3,
|
---|
74 | md = checkfield(md,'spheremesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d spheremeshes');
|
---|
75 | end
|
---|
76 | case TransientSolutionEnum(),
|
---|
77 | if md.transient.ismasstransport & md.masstransport.stabilization==3,
|
---|
78 | md = checkfield(md,'spheremesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d spheremeshes');
|
---|
79 | end
|
---|
80 | case ThermalSolutionEnum(),
|
---|
81 | md = checkfield(md,'spheremesh.dimension','values',3,'message','thermal solution only supported on 3d spheremeshes');
|
---|
82 | end
|
---|
83 | end % }}}
|
---|
84 | function disp(obj) % {{{
|
---|
85 | disp(sprintf(' Mesh:'));
|
---|
86 |
|
---|
87 | disp(sprintf('\n Elements and vertices:'));
|
---|
88 | fielddisplay(obj,'numberofelements','number of elements');
|
---|
89 | fielddisplay(obj,'numberofvertices','number of vertices');
|
---|
90 | fielddisplay(obj,'elements','vertex indices of the mesh elements');
|
---|
91 | fielddisplay(obj,'x','vertices x coordinate [m]');
|
---|
92 | fielddisplay(obj,'y','vertices y coordinate [m]');
|
---|
93 | fielddisplay(obj,'z','vertices z coordinate [m]');
|
---|
94 | fielddisplay(obj,'r','vertices r coordinate [m]');
|
---|
95 | fielddisplay(obj,'theta','vertices theta coordinate [degrees]');
|
---|
96 | fielddisplay(obj,'phi','vertices phi coordinate [degrees]');
|
---|
97 |
|
---|
98 | disp(sprintf('\n Properties:'));
|
---|
99 | fielddisplay(obj,'dimension','spheremesh dimension (2d or 3d)');
|
---|
100 | fielddisplay(obj,'numberoflayers','number of extrusion layers');
|
---|
101 |
|
---|
102 | fielddisplay(obj,'vertexconnectivity','list of vertices connected to vertex_i');
|
---|
103 | fielddisplay(obj,'elementconnectivity','list of vertices connected to element_i');
|
---|
104 | fielddisplay(obj,'average_vertex_connectivity','average number of vertices connected to one vertex');
|
---|
105 |
|
---|
106 | end % }}}
|
---|
107 | function marshall(obj,md,fid) % {{{
|
---|
108 | WriteData(fid,'object',obj,'fieldname','x','format','DoubleMat','mattype',1);
|
---|
109 | WriteData(fid,'object',obj,'fieldname','y','format','DoubleMat','mattype',1);
|
---|
110 | WriteData(fid,'object',obj,'fieldname','z','format','DoubleMat','mattype',1);
|
---|
111 | WriteData(fid,'object',obj,'fieldname','r','format','DoubleMat','mattype',1);
|
---|
112 | WriteData(fid,'object',obj,'fieldname','theta','format','DoubleMat','mattype',1);
|
---|
113 | WriteData(fid,'object',obj,'fieldname','phi','format','DoubleMat','mattype',1);
|
---|
114 | WriteData(fid,'object',obj,'fieldname','elements','format','DoubleMat','mattype',2);
|
---|
115 | WriteData(fid,'object',obj,'fieldname','dimension','format','Integer');
|
---|
116 | WriteData(fid,'object',obj,'fieldname','numberoflayers','format','Integer');
|
---|
117 | WriteData(fid,'object',obj,'fieldname','numberofelements','format','Integer');
|
---|
118 | WriteData(fid,'object',obj,'fieldname','numberofvertices','format','Integer');
|
---|
119 | WriteData(fid,'object',obj,'fieldname','elementconnectivity','format','DoubleMat','mattype',3);
|
---|
120 | WriteData(fid,'object',obj,'fieldname','average_vertex_connectivity','format','Integer');
|
---|
121 | end % }}}
|
---|
122 | end
|
---|
123 | end
|
---|