📄 add_boundary.m
字号:
function add_boundary(varargin)
%ADD_BOUNDARY set boundary condition
%
%adds a new boundary condition (BC) for the electrostatic potential
%
%2D version:
%add_boundary(xminmax,pos,type,val)
%
%xminmax=[xmin xmax] sets the BC at all nodes xmin <= node-position <= xmax
%pos=BOTTOM,TOP,LEFT,RIGHT determines boundary where the BC is to be set
%type=POTENTIAL,FIELD fixes either the electrostatic potential (Dirichlet) or the
% electric field (von Neumann) in the specified region
%val is the value of the BC
%
%Note 1: take care to set boundary conditions on ALL boundary points or the
% solution of Poisson equation will fail. AQUILA will warn you, if this happens.
%Note 2: BCs on each border are processed in order of appearance, so take care
% not to overwrite previous definitions by letting regions overlap.
%
%1D version:
%add_boundary(pos,type,val)
%
%with pos=LEFT,RIGHT only
%Copyright 1999 Martin Rother
%
%This file is part of AQUILA.
%
%AQUILA is free software; you can redistribute it and/or modify
%it under the terms of the GNU General Public License as published by
%the Free Software Foundation; either version 2 of the License, or
%(at your option) any later version.
%
%AQUILA is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with AQUILA; if not, write to the Free Software
%Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
global aquila_structure aquila_control
%check for correct execution order
if bitget(aquila_control.progress_check,1)==0
error('add_boundary: INITAQUILA must be called before adding a boundary condition !')
end
aquila_control.progress_check=bitset(aquila_control.progress_check,3);
if nargin==4 %the 2D-version is used
xminmax=varargin{1};
pos=varargin{2};
tp=varargin{3};
val=varargin{4};
else %the 1D-version is used, so define missing values to zero
xminmax=[0 0];
pos=varargin{1};
tp=varargin{2};
val=varargin{3};
end
%add the information to the structure database
aquila_structure.bcond=[aquila_structure.bcond;xminmax pos tp val];
%output some information
if aquila_control.verbose>1
os=sprintf('added boundary condition on edge %d',pos);
disp(os)
os=sprintf('type %d, %g<=position<=%g, value %g',tp,xminmax(1),xminmax(2),val);
disp(os)
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -