Mercurial > repos > public > sbplib
comparison +multiblock/Grid.m @ 535:b52ea450f4c3 feature/grids
Merge feature/boundaryGroup
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 07 Aug 2017 09:56:01 +0200 |
parents | d5bc51537a8c |
children | 08b6281ba2a9 |
comparison
equal
deleted
inserted
replaced
525:3011f9a28ac8 | 535:b52ea450f4c3 |
---|---|
7 nPoints | 7 nPoints |
8 end | 8 end |
9 | 9 |
10 % General multiblock grid | 10 % General multiblock grid |
11 methods | 11 methods |
12 | 12 % grids -- cell array of N grids |
13 % grids -- cell array of N grids | 13 % connections -- NxN upper triangular cell matrix. connections{i,j} |
14 % connections -- NxN upper triangular cell matrix. connections{i,j} | 14 % specifies the connection between block i and j. If |
15 % specifies the connection between block i and j. If | 15 % it's empty there is no connection otherwise it's a 2 |
16 % it's empty there is no connection otherwise it's a 2 | 16 % -cell-vector with strings naming the boundaries to be |
17 % -cell-vector with strings naming the boundaries to be | 17 % connected. (inverted coupling?) |
18 % connected. (inverted coupling?) | 18 % boundaryGroups -- A struct of BoundaryGroups. The field names of the |
19 %% Should we have boundary groups at all? maybe it can be handled in a | 19 % struct are the names of each boundary group. |
20 %% cleaner way outside of the class. Maybe the grid class doesn't need to care at all. All boundaryGroup interaction is in DiffOp? | 20 % The boundary groups can be used to collect block |
21 % boundaries into physical boundaries to simplify | |
22 % getting boundary operators and setting boundary conditions | |
21 function obj = Grid(grids, connections, boundaryGroups) | 23 function obj = Grid(grids, connections, boundaryGroups) |
24 default_arg('boundaryGroups', struct()); | |
22 obj.grids = grids; | 25 obj.grids = grids; |
23 obj.connections = connections; | 26 obj.connections = connections; |
24 | 27 |
25 obj.nPoints = 0; | 28 obj.nPoints = 0; |
26 for i = 1:length(grids) | 29 for i = 1:length(grids) |
27 obj.nPoints = obj.nPoints + grids{i}.N(); | 30 obj.nPoints = obj.nPoints + grids{i}.N(); |
28 end | 31 end |
29 | 32 |
30 % if iscell(boundaryGroups) | 33 obj.boundaryGroups = boundaryGroups; |
31 end | 34 end |
32 | 35 |
33 function n = size(obj) | 36 function n = size(obj) |
34 n = length(obj.grids); | 37 n = length(obj.grids); |
35 end | 38 end |
119 % Find what grid a point lies on | 122 % Find what grid a point lies on |
120 end | 123 end |
121 | 124 |
122 end | 125 end |
123 | 126 |
127 % Find all non interface boundaries of all blocks. | |
128 % Return their grid.boundaryIdentifiers in a cell array. | |
124 function bs = getBoundaryNames(obj) | 129 function bs = getBoundaryNames(obj) |
125 bs = []; | 130 bs = {}; |
131 for i = 1:obj.nBlocks() | |
132 candidates = obj.grids{i}.getBoundaryNames(); | |
133 for j = 1:obj.nBlocks() | |
134 if ~isempty(obj.connections{i,j}) | |
135 candidates = setdiff(candidates, obj.connections{i,j}{1}); | |
136 end | |
137 | |
138 if ~isempty(obj.connections{j,i}) | |
139 candidates = setdiff(candidates, obj.connections{j,i}{2}); | |
140 end | |
141 end | |
142 | |
143 for k = 1:length(candidates) | |
144 bs{end+1} = {i, candidates{k}}; | |
145 end | |
146 end | |
126 end | 147 end |
127 | 148 |
128 % Return coordinates for the given boundary | 149 % Return coordinates for the given boundary/boundaryGroup |
129 function b = getBoundary(obj, name) | 150 function b = getBoundary(obj, boundary) |
130 b = []; | 151 switch class(boundary) |
152 case 'cell' | |
153 I = boundary{1}; | |
154 name = boundary{2}; | |
155 b = obj.grids{I}.getBoundary(name); | |
156 case 'multiblock.BoundaryGroup' | |
157 b = []; | |
158 for i = 1:length(boundary) | |
159 b = [b; obj.getBoundary(boundary{i})]; | |
160 end | |
161 otherwise | |
162 error('Unknown boundary indentifier') | |
163 end | |
131 end | 164 end |
132 end | 165 end |
133 end | 166 end |