OptFEM3DP1 Toolbox: base/CubeMesh.m Source File

| OptFEM3DP1 Toolbox 20130618_070730 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D

- Main Page
- Related Pages
- Files

- File List
- File Members

All Files Functions Variables Pages
CubeMesh.m
Go to the documentation of this file.
1 function Th=CubeMesh(N)
2 % function Th=CubeMesh(N)
3 % Initialization of a minimalist 3D Mesh structure for the cube domain
4 %
5 % Cube domain is `[0,1]\times[0,1]\times[0,1]` </br>
6 % \image html images/CubeMesh.png "figure : CubeMesh function with N=3"
7 %
8 % There are `(N+1)` vertices on each edges and `(N+1)\times(N+1)`vertices on
9 % each boundary faces.
10 %
11 % Parameters:
12 % N: integer, number, minus one, of vertices on a edge
13 %
14 % Return values:
15 % Th: minimalist mesh structure
16 %
17 % Generated fields of Mesh:
18 % nq: total number of vertices, also denoted by `\nq`.
19 % q: Array of vertices coordinates, `3\times\nq` array. <br/>
20 % `{\q}(\il,j)` is the
21 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2,3\}` and
22 % `j\in\ENS{1}{\nq}`
23 % nme: total number of elements, also denoted by `\nme`.
24 % me: Connectivity array, `4\times\nme` array. <br/>
25 % `\me(\jl,k)` is the storage index of the
26 % `\jl`-th vertex of the `k`-th tetrahedron in the array `\q` of vertices coordinates, `\jl\in\{1,2,3,4\}` and
27 % `k\in{\ENS{1}{\nme}}`.
28 % volumes: Array of volumes, `1\times\nme array`. volumes(k) is the volume
29 % of the k-th tetrahedron.
30 %
31 % See also
32 % #ComputeVolumesOpt
33 % Copyright:
34 % See \ref license
35
36 L=1;
37 h=L/N;t=0:h:L;
38 if isOctave()
39 assert(~isempty(ver('msh')),'package msh must be installed')
40 mesh=msh3m_structured_mesh(t,t,t,1,1:6); % package msh
41 me=mesh.t(1:4,:);
42 q=mesh.p;
43 else
44 [x,y,z] = meshgrid(t,t,t);
45 q=[x(:) y(:) z(:)];
46 tri = delaunayn(q);
47 me=tri';
48 q=q';
49 end
50
51 nq=length(q);
52 nme=length(me);
53
54 V=ComputeVolumesOpt(me,q);
55 Th=struct('q',q,'me',me, ...
56 'nq',size(q,2), ...
57 'nme',size(me,2),...
58 'volumes',V);
59
60 % 'areas',ComputeAreaOpt(q,me),...
61 % 'lbe',EdgeLengthOpt(be,q));
62