time | calls | line |
---|
| | 1 | function [Nodeu, maxbcid, bc] = translate_Node(Nodeu, bc_u, Nbcids)
|
| | 2 | %function [Nodeu, maxbcid, bc] = translate_Node(Nodeu, bc_u, Nbcids)
|
| | 3 |
|
| | 4 | % We initially set all boundary IDs to negative numbers so as not to lose information.
|
| 4 | 5 | nextid = -1;
|
| | 6 |
|
| | 7 | % 1: Deal with multi-valued Dirichlet BCs ('dmv')
|
| 4 | 8 | id2type = find(bc_u == 1);
|
| 4 | 9 | ids = false(size(Nodeu));
|
| 4 | 10 | for i=1:length(id2type)
|
| | 11 | ids = ids | (Nodeu == id2type(i));
|
| | 12 | end;
|
| 4 | 13 | Nodeu(ids) = nextid: -1:(nextid + 1 - sum(ids(:)));
|
< 0.01 | 4 | 14 | nextid = nextid - sum(ids(:));
|
| | 15 |
|
| | 16 | % 2: Deal with single-valued Dirichlet BCs ('d')
|
| 4 | 17 | id2type = find(bc_u == 2);
|
| 4 | 18 | for i=1:length(id2type)
|
< 0.01 | 5 | 19 | ids = (Nodeu == id2type(i));
|
| 5 | 20 | Nodeu(ids) = nextid;
|
| 5 | 21 | nextid = nextid - 1;
|
| 5 | 22 | end;
|
| 4 | 23 | bc(1) = -nextid - 1;
|
| | 24 |
|
| | 25 | % 3: Deal with open BCs ('o')
|
| 4 | 26 | id2type = find(bc_u == 3);
|
| 4 | 27 | for i=1:length(id2type)
|
| 2 | 28 | ids = (Nodeu == id2type(i));
|
| 2 | 29 | Nodeu(ids) = nextid;
|
| 2 | 30 | nextid = nextid - 1;
|
| 2 | 31 | end;
|
| 4 | 32 | bc(2) = -nextid - 1;
|
| | 33 |
|
| | 34 | % 4: Deal with multi-valued Neumann BCs ('nmv')
|
| 4 | 35 | id2type = find(bc_u == 4);
|
| 4 | 36 | ids = false(size(Nodeu));
|
| 4 | 37 | for i=1:length(id2type)
|
| | 38 | ids = ids | (Nodeu == id2type(i));
|
| | 39 | end;
|
< 0.01 | 4 | 40 | Nodeu(ids) = nextid: -1:(nextid + 1 - sum(ids(:)));
|
| 4 | 41 | nextid = nextid - sum(ids(:));
|
| | 42 |
|
| | 43 | % 5: Deal with single-valued Neumann BCs ('n')
|
| 4 | 44 | id2type = find(bc_u == 5);
|
| 4 | 45 | for i=1:length(id2type)
|
< 0.01 | 13 | 46 | ids = (Nodeu == id2type(i));
|
| 13 | 47 | Nodeu(ids) = nextid;
|
| 13 | 48 | nextid = nextid - 1;
|
| 13 | 49 | end;
|
| 4 | 50 | bc(3) = -nextid - 1;
|
| | 51 |
|
| | 52 | % Finally, we set the interior node IDs and set boundary IDs back to positive numbers.
|
< 0.01 | 4 | 53 | ids = (Nodeu > 0);
|
| 4 | 54 | Nodeu(ids) = Nodeu(ids) - Nbcids + (-nextid - 1);
|
0.02 | 4 | 55 | Nodeu(~ids) = -Nodeu(~ids);
|
| | 56 |
|
| 4 | 57 | maxbcid = -nextid - 1;
|