source: issm/trunk-jpl/src/m/classes/mesh3dsurface.m@ 22004

Last change on this file since 22004 was 22004, checked in by Eric.Larour, 8 years ago

ADD and CHG: introducing new love solution. This involves a new fourierlove class, a new .love field
in the model, new enums, new materials class in particular, which can now dynamically, during the constructor
phase, initialize internal structure fields relevant to only 'ice', 'litho', or any other material. The
goal is to fade away the m/classes/material classes (matice, maticeenhanced, etc...) in favor of the @materials
class, which will be all encompassing. New love_core core, and new FourierLoveCorex module, where all of the
fortran files from Lambert Caron are placed, with all his love solution code. Interfacing is done between C++
and Fortran in this module. Also, rheology_law now taken out of the parameters, should be in the materials themeselves.

File size: 8.6 KB
Line 
1%MESH3DSURFACE class definition
2%
3% Usage:
4% mesh3dsurface=mesh3dsurface();
5
6classdef mesh3dsurface
7 properties (SetAccess=public)
8 x = NaN;
9 y = NaN;
10 z = NaN;
11 elements = NaN;
12 numberofelements = 0;
13 numberofvertices = 0;
14 numberofedges = 0;
15
16 lat = NaN;
17 long = NaN;
18 r = NaN;
19
20 vertexonboundary = NaN;
21 edges = NaN;
22 segments = NaN;
23 segmentmarkers = NaN;
24 vertexconnectivity = NaN;
25 elementconnectivity = NaN;
26 average_vertex_connectivity = 0;
27
28 extractedvertices = NaN;
29 extractedelements = NaN;
30 end
31 methods (Static)
32 function self = loadobj(self) % {{{
33 % This function is directly called by matlab when a model selfect is
34 % loaded. Update old properties here
35
36 %2014 Oct. 1st
37 if isstruct(self),
38 oldself=self;
39 %Assign property values from struct
40 self=structtoobj(mesh3dsurface(),oldself);
41 if isfield(oldself,'hemisphere'),
42 disp('md.mesh.hemisphere has been automatically converted to EPSG code');
43 if strcmpi(oldself.hemisphere,'n'),
44 self.epsg=3413;
45 else
46 self.epsg=3031;
47 end
48 end
49 end
50
51 end% }}}
52 end
53 methods
54 function self = mesh3dsurface(varargin) % {{{
55 switch nargin
56 case 0
57 self=setdefaultparameters(self);
58 case 1
59 self=mesh3dsurface();
60 object=varargin{1};
61 fields=fieldnames(object);
62 for i=1:length(fields)
63 field=fields{i};
64 if ismember(field,properties('mesh3dsurface')),
65 self.(field)=object.(field);
66 end
67 end
68 otherwise
69 error('constructor not supported');
70 end
71 end % }}}
72 function obj = setdefaultparameters(obj) % {{{
73
74 %the connectivity is the averaged number of nodes linked to a
75 %given node through an edge. This connectivity is used to initially
76 %allocate memory to the stiffness matrix. A value of 16 seems to
77 %give a good memory/time ration. This value can be checked in
78 %trunk/test/Miscellaneous/runme.m
79 obj.average_vertex_connectivity=25;
80 end % }}}
81 function md = checkconsistency(obj,md,solution,analyses) % {{{
82
83 if strcmpi(solution,'LoveSolution'), return; end
84
85 md = checkfield(md,'fieldname','mesh.x','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
86 md = checkfield(md,'fieldname','mesh.y','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
87 md = checkfield(md,'fieldname','mesh.z','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
88 md = checkfield(md,'fieldname','mesh.lat','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
89 md = checkfield(md,'fieldname','mesh.long','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
90 md = checkfield(md,'fieldname','mesh.r','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
91 md = checkfield(md,'fieldname','mesh.elements','NaN',1,'Inf',1,'>',0,'values',1:md.mesh.numberofvertices);
92 md = checkfield(md,'fieldname','mesh.elements','size',[md.mesh.numberofelements 3]);
93 if any(~ismember(1:md.mesh.numberofvertices,sort(unique(md.mesh.elements(:)))));
94 md = checkmessage(md,'orphan nodes have been found. Check the mesh outline');
95 end
96 md = checkfield(md,'fieldname','mesh.numberofelements','>',0);
97 md = checkfield(md,'fieldname','mesh.numberofvertices','>',0);
98 md = checkfield(md,'fieldname','mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
99
100 if strcmp(solution,'ThermalSolution')
101 md = checkmessage(md,'thermal not supported for 2d mesh');
102 end
103 end % }}}
104 function disp(obj) % {{{
105 disp(sprintf(' 2D tria Mesh (horizontal):'));
106
107 disp(sprintf('\n Elements and vertices:'));
108 fielddisplay(obj,'numberofelements','number of elements');
109 fielddisplay(obj,'numberofvertices','number of vertices');
110 fielddisplay(obj,'elements','vertex indices of the mesh elements');
111 fielddisplay(obj,'x','vertices x coordinate [m]');
112 fielddisplay(obj,'y','vertices y coordinate [m]');
113 fielddisplay(obj,'z','vertices z coordinate [m]');
114 fielddisplay(obj,'lat','vertices latitude [degrees]');
115 fielddisplay(obj,'long','vertices longitude [degrees]');
116 fielddisplay(obj,'r','vertices radius [m]');
117
118 fielddisplay(obj,'edges','edges of the 2d mesh (vertex1 vertex2 element1 element2)');
119 fielddisplay(obj,'numberofedges','number of edges of the 2d mesh');
120
121 disp(sprintf('\n Properties:'));
122 fielddisplay(obj,'vertexonboundary','vertices on the boundary of the domain flag list');
123 fielddisplay(obj,'segments','edges on domain boundary (vertex1 vertex2 element)');
124 fielddisplay(obj,'segmentmarkers','number associated to each segment');
125 fielddisplay(obj,'vertexconnectivity','list of vertices connected to vertex_i');
126 fielddisplay(obj,'elementconnectivity','list of vertices connected to element_i');
127 fielddisplay(obj,'average_vertex_connectivity','average number of vertices connected to one vertex');
128
129 disp(sprintf('\n Extracted model:'));
130 fielddisplay(obj,'extractedvertices','vertices extracted from the model');
131 fielddisplay(obj,'extractedelements','elements extracted from the model');
132 end % }}}
133 function marshall(obj,prefix,md,fid) % {{{
134 WriteData(fid,prefix,'name','md.mesh.domain_type','data',['Domain' domaintype(obj)],'format','String');
135 WriteData(fid,prefix,'name','md.mesh.domain_dimension','data',dimension(obj),'format','Integer');
136 WriteData(fid,prefix,'name','md.mesh.elementtype','data',elementtype(obj),'format','String');
137 WriteData(fid,prefix,'object',obj,'fieldname','x','format','DoubleMat','mattype',1);
138 WriteData(fid,prefix,'object',obj,'fieldname','y','format','DoubleMat','mattype',1);
139 WriteData(fid,prefix,'object',obj,'fieldname','z','format','DoubleMat','mattype',1);
140 WriteData(fid,prefix,'object',obj,'fieldname','lat','data',obj.lat,'format','DoubleMat','mattype',1);
141 WriteData(fid,prefix,'object',obj,'fieldname','long','data',obj.long,'format','DoubleMat','mattype',1);
142 WriteData(fid,prefix,'object',obj,'fieldname','r','format','DoubleMat','mattype',1);
143 WriteData(fid,prefix,'name','md.mesh.z','data',zeros(obj.numberofvertices,1),'format','DoubleMat','mattype',1);
144 WriteData(fid,prefix,'object',obj,'fieldname','elements','format','DoubleMat','mattype',2);
145 WriteData(fid,prefix,'object',obj,'fieldname','numberofelements','format','Integer');
146 WriteData(fid,prefix,'object',obj,'fieldname','numberofvertices','format','Integer');
147 WriteData(fid,prefix,'object',obj,'fieldname','average_vertex_connectivity','format','Integer');
148 WriteData(fid,prefix,'object',obj,'fieldname','vertexonboundary','format','DoubleMat','mattype',1);
149 end % }}}
150 function t = domaintype(obj) % {{{
151 t = '3Dsurface';
152 end % }}}
153 function d = dimension(obj) % {{{
154 d = 2;
155 end % }}}
156 function s = elementtype(obj) % {{{
157 s = 'Tria';
158 end % }}}
159 function [x y z elements is2d isplanet] = processmesh(self,options) % {{{
160
161 isplanet = 1;
162 is2d = 0;
163
164 elements = self.elements;
165 x = self.x;
166 y = self.y;
167 z = self.z;
168 end % }}}
169 function savemodeljs(self,fid,modelname) % {{{
170
171 fprintf(fid,'%s.mesh=new mesh3dsurface();\n',modelname);
172 writejs1Darray(fid,[modelname '.mesh.x'],self.x);
173 writejs1Darray(fid,[modelname '.mesh.y'],self.y);
174 writejs1Darray(fid,[modelname '.mesh.z'],self.z);
175 writejs2Darray(fid,[modelname '.mesh.elements'],self.elements);
176 writejsdouble(fid,[modelname '.mesh.numberofelements'],self.numberofelements);
177 writejsdouble(fid,[modelname '.mesh.numberofvertices'],self.numberofvertices);
178 writejsdouble(fid,[modelname '.mesh.numberofedges'],self.numberofedges);
179 writejs1Darray(fid,[modelname '.mesh.lat'],self.lat);
180 writejs1Darray(fid,[modelname '.mesh.long'],self.long);
181 writejs1Darray(fid,[modelname '.mesh.r'],self.r);
182 writejs1Darray(fid,[modelname '.mesh.vertexonboundary'],self.vertexonboundary);
183 writejs2Darray(fid,[modelname '.mesh.edges'],self.edges);
184 writejs2Darray(fid,[modelname '.mesh.segments'],self.segments);
185 writejs2Darray(fid,[modelname '.mesh.segmentmarkers'],self.segmentmarkers);
186 writejs2Darray(fid,[modelname '.mesh.vertexconnectivity'],self.vertexconnectivity);
187 writejs2Darray(fid,[modelname '.mesh.elementconnectivity'],self.elementconnectivity);
188 writejsdouble(fid,[modelname '.mesh.average_vertex_connectivity'],self.average_vertex_connectivity);
189 writejs1Darray(fid,[modelname '.mesh.extractedvertices'],self.extractedvertices);
190 writejs1Darray(fid,[modelname '.mesh.extractedelements'],self.extractedelements);
191
192 end % }}}
193 end
194end
Note: See TracBrowser for help on using the repository browser.