Debian Codegraph @

debian/external_deps/fetk/mclite/fu_v.m

raw
1 function [thetam] = fu_v(evalKey, parm, L, xm,ym,type, u,ux,uy, pr,prx,pry);
2 %FU_V Evaluate the nonlinear weak form of a PDE
3 %
4 % Usage: [thetam] = fu_v(evalKey, parm, L, xm,ym,type, u,ux,uy, pr,prx,pry);
5 %
6 % Evaluate the nonlinear form by providing the value of the quantity
7 % under the integral sign, at a particular quadrature point.
8 %
9 % Because we do this for all of the elements at one time to make things
10 % reasonably fast, we pass some arrays around.
11 %
12 % Input:
13 %
14 % evalKey ==> area or surface integral
15 % L ==> number of elements to do all at once
16 % xm(1:L,1) ==> x-coordindinates of quadrature points, one per element
17 % ym(1:L,1) ==> y-coordindinates of quadrature points, one per element
18 % type(1:L,1) ==> point type (interior/diri/neum), one per element
19 %
20 % u(1:L,1) ==> u, evaluated on master element
21 % ux(1:L,1) ==> partial w.r.t. x of u, one per element
22 % uy(1:L,1) ==> partial w.r.t. x of u, one per element
23 %
24 % pr ==> phi(r), evaluated on master element
25 % prx(1:L,1) ==> partial w.r.t. x of phi(r), one per element
26 % pry(1:L,1) ==> partial w.r.t. x of phi(r), one per element
27 %
28 % Output:
29 %
30 % thetam ==> the integrand for the area or surface integral,
31 % not including the jacobian of transformation
32 %
33 % Author: Michael Holst
34 % rcsid="$Id: fu_v.m,v 1.2 2008/03/12 06:23:07 fetk Exp $"
35
36 lambda = parm(1);
37
38 %%% area integral
39 if (evalKey == 0)
40
41 %%% coefficients
42 atilde = ones(L,1); % the first order coefficient function
43
44 %%% source term chosen to give (one) analytical solution
45 utilde(1:L,1) = sin(pi*xm) .* sin(pi*ym);
46 ftilde(1:L,1) = (2*pi*pi) * atilde(1:L,1) .* utilde(1:L,1) ...
47 + lambda * exp(utilde(1:L,1));
48
49 %%% nonlinear residual of the given FEM function "u"
50 thetam(1:L,1) = ...
51 atilde(1:L,1) .* (ux(1:L,1).*prx(1:L,1)+uy(1:L,1).*pry(1:L,1)) ...
52 + (lambda * exp(u(1:L,1)) - ftilde(1:L,1)) * pr;
53
54 %%% edge integral (for natural boundary condition)
55 elseif (evalKey == 1)
56
57 %%% apply appropriate condition based on which boundary we are on
58 thetam = zeros(L,1);
59 for k=1:L
60 if (type(k) == 2)
61 thetam(k) = pi*cos(pi*xm(k))*sin(pi*ym(k))*pr;
62 elseif (type(k) == 4)
63 thetam(k) = -pi*cos(pi*xm(k))*sin(pi*ym(k))*pr;
64 elseif (type(k) == 1)
65 thetam(k) = pi*sin(pi*xm(k))*cos(pi*ym(k))*pr;
66 elseif (type(k) == 3)
67 thetam(k) = -pi*sin(pi*xm(k))*cos(pi*ym(k))*pr;
68 else
69 thetam(k) = 0;
70 end
71 end
72
73 %%% error
74 else
75 assertw( 0, 'fu_v 1' );
76 end
77