Mercurial > repos > public > sbplib
comparison +multiblock/Grid.m @ 200:ef41fde95ac4 feature/beams
Merged feature/grids into feature/beams.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 13 Jun 2016 16:59:02 +0200 |
parents | 6fb354955c37 |
children | 8b10476b9bb7 |
comparison
equal
deleted
inserted
replaced
181:419ec303e97d | 200:ef41fde95ac4 |
---|---|
1 classdef Grid < grid.Grid | |
2 properties | |
3 grids | |
4 connections | |
5 boundaryGroups | |
6 | |
7 nPoints | |
8 end | |
9 | |
10 % General multiblock grid | |
11 methods | |
12 | |
13 % grids -- cell array of N grids | |
14 % connections -- NxN upper triangular cell matrix. connections{i,j} | |
15 % specifies the connection between block i and j. If | |
16 % it's empty there is no connection otherwise it's a 2 | |
17 % -cell-vector with strings naming the boundaries to be | |
18 % connected. (inverted coupling?) | |
19 %% Should we have boundary groups at all? maybe it can be handled in a | |
20 %% cleaner way outside of the class. | |
21 function obj = Grid(grids, connections, boundaryGroups) | |
22 obj.grids = grids; | |
23 obj.connections = connections; | |
24 | |
25 obj.nPoints = 0; | |
26 for i = 1:length(grids) | |
27 obj.nPoints = obj.nPoints + grids{i}.N(); | |
28 end | |
29 | |
30 % if iscell(boundaryGroups) | |
31 end | |
32 | |
33 function n = size(obj) | |
34 n = length(obj.grids); | |
35 end | |
36 | |
37 % n returns the number of points in the grid | |
38 function o = N(obj) | |
39 o = obj.nPoints; | |
40 end | |
41 | |
42 function n = nBlocks(obj) | |
43 n = length(obj.grids); | |
44 end | |
45 | |
46 % d returns the spatial dimension of the grid | |
47 function o = D(obj) | |
48 o = obj.grids{1}.D(); | |
49 end | |
50 | |
51 % points returns a n x d matrix containing the coordinates for all points. | |
52 function X = points(obj) | |
53 X = []; | |
54 for i = 1:length(obj.grids) | |
55 X = [X; obj.grids{i}.points]; | |
56 end | |
57 end | |
58 | |
59 % Split a grid function on obj to a cell array of grid function on each block | |
60 function gfs = splitFunc(obj, gf) | |
61 nComponents = length(gf)/obj.nPoints; | |
62 nBlocks = length(obj.grids); | |
63 | |
64 % Collect number of points in each block | |
65 N = cell(1,nBlocks); | |
66 for i = 1:nBlocks | |
67 N{i} = obj.grids{i}.N(); | |
68 end | |
69 | |
70 gfs = mat2cell(gf, N, 1); | |
71 end | |
72 | |
73 % Restricts the grid function gf on obj to the subgrid g. | |
74 function gf = restrictFunc(obj, gf, g) | |
75 gfs = obj.splitFunc(gf); | |
76 | |
77 for i = 1:length(obj.grids) | |
78 gfs{i} = obj.grids{i}.restrictFunc(gfs{i}, g.grids{i}); | |
79 end | |
80 | |
81 gf = cell2mat(gfs); | |
82 end | |
83 | |
84 % Projects the grid function gf on obj to the grid g. | |
85 function o = projectFunc(obj, gf, g) | |
86 error('not implemented') | |
87 | |
88 p = g.points(); | |
89 o = zeros(length(p),1); | |
90 for i = 1:length(p) | |
91 I = whatGrid(p(i)); | |
92 o(i) = obj.grids{I}.projectFunc(gf, p(i)); | |
93 end | |
94 | |
95 | |
96 function I = whatGrid(p) | |
97 % Find what grid a point lies on | |
98 end | |
99 | |
100 end | |
101 | |
102 function bs = getBoundaryNames(obj) | |
103 bs = []; | |
104 end | |
105 | |
106 % Return coordinates for the given boundary | |
107 function b = getBoundary(obj, name) | |
108 b = []; | |
109 end | |
110 end | |
111 end |