Home > Src > Level_2 > neumannbc.m

neumannbc

PURPOSE ^

NEUMANNBC Adds Neumann data to r.h.s.

SYNOPSIS ^

function [f]=neumannbc(f,h,jacx,jacy,wx,wy,xy,ifro,nov);

DESCRIPTION ^

 NEUMANNBC  Adds Neumann data to r.h.s.
   Updates array f (r.h.s) with Neumann data when ifro(i)>30

 [f]=neumannbc(f,h,jacx,jacy,wx,wy,xy,ifro);

 Input: f = column array of r.h.s
        h = @(xi,)[...] unction handle to the expression of Neumann
              boundary data. It is a vector of 4 functions, each for any
              side.
         jacx = array (length(jacx)=ne); jacx(ie)= (x_V2_ie-x_V1_ie)/2
         jacy = array (length(jacy)=ne); jacy(ie)= (y_V3_ie-y_V1_ie)/2
         xy = column array with global mesh, length: noe=nov(npdx*npdy,ne)
         ifro = column array of length noe=nov(npdx*npdy,ne):
            if (x_i,y_i) is internal to Omega then ifro(i)=0,
            if (x_i,y_i) is on \partial\Omega and Dirichlet boundary
            condition is imposed there, then ifro(i)=1,
            if (x_i,y_i) is on \partial\Omega and Neumann boundary
            condition is imposed there, then ifro(i)=31,
        nov = local -global map, previously generated by cosnov_2d

 Output: f = updated column array of r.h.s

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [f]=neumannbc(f,h,jacx,jacy,wx,wy,xy,ifro,nov);
0002 % NEUMANNBC  Adds Neumann data to r.h.s.
0003 %   Updates array f (r.h.s) with Neumann data when ifro(i)>30
0004 %
0005 % [f]=neumannbc(f,h,jacx,jacy,wx,wy,xy,ifro);
0006 %
0007 % Input: f = column array of r.h.s
0008 %        h = @(xi,)[...] unction handle to the expression of Neumann
0009 %              boundary data. It is a vector of 4 functions, each for any
0010 %              side.
0011 %         jacx = array (length(jacx)=ne); jacx(ie)= (x_V2_ie-x_V1_ie)/2
0012 %         jacy = array (length(jacy)=ne); jacy(ie)= (y_V3_ie-y_V1_ie)/2
0013 %         xy = column array with global mesh, length: noe=nov(npdx*npdy,ne)
0014 %         ifro = column array of length noe=nov(npdx*npdy,ne):
0015 %            if (x_i,y_i) is internal to Omega then ifro(i)=0,
0016 %            if (x_i,y_i) is on \partial\Omega and Dirichlet boundary
0017 %            condition is imposed there, then ifro(i)=1,
0018 %            if (x_i,y_i) is on \partial\Omega and Neumann boundary
0019 %            condition is imposed there, then ifro(i)=31,
0020 %        nov = local -global map, previously generated by cosnov_2d
0021 %
0022 % Output: f = updated column array of r.h.s
0023 %
0024 
0025 %   Written by Paola Gervasio
0026 %   $Date: 2007/04/01$
0027 %   $UpDate: 2020/09/07$
0028 
0029 
0030 [ldnov,ne]=size(nov);
0031 npdx=length(wx);
0032 npdy=length(wy);
0033 mn=npdx*npdy;
0034 nm1=ldnov-npdx;
0035 for ie=1:ne
0036     
0037     % side 1 of Omega_ie
0038     for i=2:npdx-1
0039         ip=nov(i,ie);
0040         if ifro(ip)>30
0041             hh=h(xy(ip,1),xy(ip,2));
0042             f(ip)=f(ip)+hh(1)*wx(i)*jacx(ie);
0043         end
0044     end
0045     % side 2 of Omega_ie
0046     for j=2:npdy-1
0047         ip=nov(j*npdx,ie);
0048         if ifro(ip)>30
0049             hh=h(xy(ip,1),xy(ip,2));
0050             f(ip)=f(ip)+hh(2)*wy(j)*jacy(ie);
0051         end
0052     end
0053     % side 3 of Omega_ie
0054     for i=2:npdx-1
0055         ip=nov(nm1+i,ie);
0056         if ifro(ip)>30
0057             hh=h(xy(ip,1),xy(ip,2));
0058             f(ip)=f(ip)+hh(3)*wx(i)*jacx(ie);
0059         end
0060     end
0061     % side 4 of Omega_ie
0062     for j=2:npdy-1
0063         ip=nov((j-1)*npdx+1,ie);
0064         if ifro(ip)>30
0065             hh=h(xy(ip,1),xy(ip,2));
0066             f(ip)=f(ip)+hh(4)*wy(j)*jacy(ie);
0067         end
0068     end
0069     
0070 % vertex 1
0071 
0072 i=1;io=2; iv=npdx+1;
0073 ip=nov(i,ie); iio=nov(io,ie); iiv=nov(iv,ie);
0074 % integration on side 1
0075 if  ifro(ip)>30 && ifro(iio)>30
0076 hh=h(xy(ip,1),xy(ip,2));
0077 f(ip)=f(ip)+hh(1)*wx(1)*jacx(ie);
0078 end
0079 % integration on side 4
0080 if  ifro(ip)>30 && ifro(iiv)>30
0081 hh=h(xy(ip,1),xy(ip,2));
0082 f(ip)=f(ip)+hh(4)*wy(1)*jacy(ie);
0083 end
0084 
0085 % vertex 2
0086 i=npdx;io=npdx-1; iv=npdx*2;
0087 ip=nov(i,ie); iio=nov(io,ie); iiv=nov(iv,ie);
0088 % integration on side 1
0089 if  ifro(ip)>30 && ifro(iio)>30
0090 hh=h(xy(ip,1),xy(ip,2));
0091 f(ip)=f(ip)+hh(1)*wx(npdx)*jacx(ie);
0092 end
0093 % integration on side 2
0094 if  ifro(ip)>30 && ifro(iiv)>30
0095 hh=h(xy(ip,1),xy(ip,2));
0096 f(ip)=f(ip)+hh(2)*wy(1)*jacy(ie);
0097 end
0098 
0099 % vertex 3
0100 i=mn;io=i-1; iv=i-npdx;
0101 ip=nov(i,ie); iio=nov(io,ie); iiv=nov(iv,ie);
0102 % integration on side 3
0103 if  ifro(ip)>30 && ifro(iio)>30
0104 hh=h(xy(ip,1),xy(ip,2));
0105 f(ip)=f(ip)+hh(3)*wx(npdx)*jacx(ie);
0106 end
0107 % integration on side  2
0108 if    ifro(ip)>30 && ifro(iiv)>30
0109 hh=h(xy(ip,1),xy(ip,2));
0110 f(ip)=f(ip)+hh(2)*wy(npdy)*jacy(ie);
0111 end
0112 
0113 % vertex 4
0114 i=nm1+1;io=i+1; iv=i-npdx;
0115 ip=nov(i,ie); iio=nov(io,ie); iiv=nov(iv,ie);
0116 % integration on side 3
0117 if ifro(ip)>30 && ifro(iio)>30
0118 hh=h(xy(ip,1),xy(ip,2));
0119 f(ip)=f(ip)+hh(3)*wx(1)*jacx(ie);
0120 end
0121 % integration on side 4
0122 if    ifro(ip)>30 && ifro(iiv)>30
0123 hh=h(xy(ip,1),xy(ip,2));
0124 f(ip)=f(ip)+hh(4)*wy(npdy)*jacy(ie);
0125 end
0126     
0127 end
0128 return
0129

Generated on Mon 07-Sep-2020 11:46:02 by m2html © 2005