source: issm/trunk/src/m/classes/spheremesh.m@ 16560

Last change on this file since 16560 was 16560, checked in by Mathieu Morlighem, 11 years ago

merged trunk-jpl and trunk for revision 16554

File size: 5.9 KB
RevLine 
[16287]1%SPHEREMESH class definition
[12913]2%
3% Usage:
[16287]4% spheremesh=spheremesh();
[12913]5
[16287]6classdef spheremesh
[12913]7 properties (SetAccess=public)
[12980]8 x = NaN;
9 y = NaN;
10 z = NaN;
[12913]11 r = NaN;
12 theta = NaN;
13 phi = NaN
14 elements = NaN
15 dimension = 0;
16 numberoflayers = 0;
17 numberofelements = 0;
18 numberofvertices = 0;
[13646]19
[12913]20 vertexconnectivity = NaN
21 elementconnectivity = NaN
22 average_vertex_connectivity = 0;
23 end
24 methods
[16287]25 function obj = spheremesh(varargin) % {{{
[12913]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
[16287]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]);
[12913]53 else
[16287]54 md = checkfield(md,'spheremesh.elements','size',[md.spheremesh.numberofelements 6]);
[12913]55 end
[16287]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');
[12913]58 end
[16287]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');
[12913]65 else
[16287]66 md = checkfield(md,'spheremesh.average_vertex_connectivity','>=',24,'message','''spheremesh.average_vertex_connectivity'' should be at least 24 in 3d');
[12913]67 end
[16287]68 md = checkfield(md,'spheremesh.elementconnectivity','size',[md.spheremesh.numberofelements 3],'NaN',1);
[12913]69
70 %Solution specific checks
71 switch(solution),
[15767]72 case MasstransportSolutionEnum(),
73 if md.masstransport.stabilization==3,
[16287]74 md = checkfield(md,'spheremesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d spheremeshes');
[12913]75 end
[13043]76 case TransientSolutionEnum(),
[15767]77 if md.transient.ismasstransport & md.masstransport.stabilization==3,
[16287]78 md = checkfield(md,'spheremesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d spheremeshes');
[12913]79 end
[13043]80 case ThermalSolutionEnum(),
[16287]81 md = checkfield(md,'spheremesh.dimension','values',3,'message','thermal solution only supported on 3d spheremeshes');
[12913]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');
[14640]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]');
[12913]97
98 disp(sprintf('\n Properties:'));
[16287]99 fielddisplay(obj,'dimension','spheremesh dimension (2d or 3d)');
[12913]100 fielddisplay(obj,'numberoflayers','number of extrusion layers');
[13646]101
[12913]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 % }}}
[15131]107 function marshall(obj,md,fid) % {{{
[12980]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);
[12913]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
123end
Note: See TracBrowser for help on using the repository browser.