0001 function [fmdl, c2f_idx] = remove_nodes(fmdl, idx, elec_opt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 if ischar(fmdl) && strcmp(fmdl, 'UNIT_TEST'), do_unit_test; return, end
0030 if nargin < 3, elec_opt = ''; end
0031
0032 node_idx = false([num_nodes(fmdl), 1]);
0033 node_idx(idx) = true;
0034 elem_idx = any(node_idx(fmdl.elems),2);
0035
0036 [fmdl, c2f_idx] = remove_elems(fmdl, elem_idx, elec_opt);
0037
0038 function do_unit_test
0039
0040 f0= mk_common_model('a2c2',4);
0041 f0= f0.fwd_model;
0042 fr= remove_nodes(f0, [10:13]);
0043 unit_test_cmp('2D- 1a',fr.nodes(20,:), f0.nodes(24,:));
0044 unit_test_cmp('2D- 1b',fr.elems(20,:),[24,11,12]);
0045
0046 fr= remove_nodes(f0, [26:33],'remove');
0047 unit_test_cmp('2D- 2a',fr.nodes(25,:), f0.nodes(25,:));
0048 unit_test_cmp('2D- 2b',fr.nodes(26,:), f0.nodes(34,:));
0049 unit_test_cmp('2D- 2c',f0.elems(40,:),[20,19,33]);
0050 unit_test_cmp('2D- 2d',fr.elems(40,:),[14,25,33]);
0051 unit_test_cmp('2D- 2e',num_elecs(fr),2);
0052
0053 fr= remove_nodes(f0, [26:33],'keep');
0054 unit_test_cmp('2D- 3a',fr.nodes(25,:), f0.nodes(25,:));
0055 unit_test_cmp('2D- 3b',fr.nodes(26,:), f0.nodes(34,:));
0056 unit_test_cmp('2D- 3c',f0.elems(40,:),[20,19,33]);
0057 unit_test_cmp('2D- 3d',fr.elems(40,:),[14,25,33]);
0058 unit_test_cmp('2D- 3e',num_elecs(fr),4);
0059
0060 f0= mk_common_model('n3r2',[16,2]);
0061 f0= f0.fwd_model;
0062 fr= remove_nodes(f0, [59:63]);
0063 unit_test_cmp('3D- 1a',fr.nodes(80,:), f0.nodes(85,:));
0064 unit_test_cmp('3D- 1b',fr.elems(80,:),[41,42,76,18]);
0065
0066 fr= remove_nodes(f0, [22:27],'remove');
0067 unit_test_cmp('2D- 2a',fr.nodes(21,:), f0.nodes(21,:));
0068 unit_test_cmp('2D- 2b',fr.nodes(22,:), f0.nodes(28,:));
0069 unit_test_cmp('2D- 2c',f0.elems(40,:),[10,73,74,38]);
0070 unit_test_cmp('2D- 2d',fr.elems(40,:),[10,67,68,32]);
0071 unit_test_cmp('2D- 2e',num_elecs(fr),29);
0072
0073 fr= remove_nodes(f0, [22:27],'keep');
0074 unit_test_cmp('2D- 3a',fr.nodes(21,:), f0.nodes(21,:));
0075 unit_test_cmp('2D- 3b',fr.nodes(22,:), f0.nodes(28,:));
0076 unit_test_cmp('2D- 3c',f0.elems(40,:),[10,73,74,38]);
0077 unit_test_cmp('2D- 3d',fr.elems(40,:),[10,67,68,32]);
0078 unit_test_cmp('2D- 3e',num_elecs(fr),32);
0079