Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting bcs #205

Merged
merged 2 commits into from
Mar 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions @msh/msh.m
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,8 @@ function plotter(cmap,round_dec,yylabel,apply_pivot)
% ---------
% 'delete' - deletes a user-clicked boundary condition from msh.
% varargins:
% none
% index of boundary to delete

if nargin < 2
error('Needs type: one of "auto", "outer", "inner", "delete", or "weirs"')
end
Expand Down Expand Up @@ -1801,8 +1802,7 @@ function plotter(cmap,round_dec,yylabel,apply_pivot)
dir,obj.op,obj.bd); %<--updates op and bd.

case('delete')
% have the user select the nodestring '
plot(obj,'type','bd','proj','none') ;

temp = obj.bd.nbvv;
bounodes=obj.bd.nbvv ;
idx=sum(bounodes~=0);
Expand All @@ -1815,25 +1815,40 @@ function plotter(cmap,round_dec,yylabel,apply_pivot)
k = k + 1 ;
bounodes(idx2(i):idx2(i+1)-1,2) = k ;
end

dcm_obj = datacursormode(gcf);
title('use data cursor to select nodestring to be deleted');
pause
c_info = getCursorInfo(dcm_obj);
[tmp(:,1),tmp(:,2)]=m_ll2xy(boupts(:,1),boupts(:,2));
idx3 = ourKNNsearch(boupts',c_info.Position',1) ;
del = bounodes(idx3,2) ; %<- get the nodestring index
pltid = temp(:,del) ; pltid(pltid==0)=[] ;
hold on; m_plot(obj.p(pltid,1),obj.p(pltid,2),'r-','linewi',2) ;
disp(['Delete boundary with index ',num2str(del),'?']) ;
pause

if isempty(varargin)
% have the user select the nodestring '
plot(obj,'type','bd','proj','none') ;


dcm_obj = datacursormode(gcf);
title('use data cursor to select nodestring to be deleted');
pause
c_info = getCursorInfo(dcm_obj);
[tmp(:,1),tmp(:,2)]=m_ll2xy(boupts(:,1),boupts(:,2));
idx3 = ourKNNsearch(boupts',c_info.Position',1) ;
del = bounodes(idx3,2) ; %<- get the nodestring index
pltid = temp(:,del) ; pltid(pltid==0)=[] ;
hold on; m_plot(obj.p(pltid,1),obj.p(pltid,2),'r-','linewi',2) ;
else
del = varargin{1};
end
disp(['Deleting boundary with index ',num2str(del)]) ;

obj.bd.nbvv(:,del)=[];
if ~isempty(obj.bd.ibconn)
obj.bd.ibconn(:,del)=[];
obj.bd.barinht(:,del)=[];
obj.bd.barincfsb(:,del)=[];
obj.bd.barincfsp(:,del)=[];
end
num_delnodes = idx(del) ;
obj.bd.nbou = obj.bd.nbou - 1 ;
obj.bd.nvell(del)=[] ;
obj.bd.ibtype(del)=[] ;
obj.bd.nvel = obj.bd.nvel - num_delnodes ;


case('weirs')
if isempty(varargin)
error('Third input must be a geodata class obj')
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Unreleased
- None
## Added
- Deleting boundary conditions by specifyng their indices in `msh.object.bd` field. See https://github.com/CHLNDDEV/OceanMesh2D/pull/205
## Fixed
- Correctly deleting weirs from boundary object through `make_bc` delete method. See https://github.com/CHLNDDEV/OceanMesh2D/pull/205

### [4.0.0] - 2021-03-14
## Added
Expand Down