1 function [gradx,grady] = disc_gradient(glob,fdf)
2 %
function [gradx,grady] = disc_gradient(glob,fdf)
7 % glob: list of coordinates of points, in which the gradient shall be
8 % calculated. Must not be points in grid vertices or edges, but
13 % gradx : values of the gradient in x direction
14 % grady : values of the gradient in y direction
16 %
this computation is only exact
for pdeg = 1!
18 % Immanuel Maier, 07.02.2011, Oliver Zeeb, 10.02.11
20 elind = zeros(size(glob,1),1);
22 % loop over all elements:
23 for i = 1:fdf.grid.nelements
24 % compute local coordinates:
25 loc = global2local(fdf.grid,i,glob);
26 %
if points lie in element i,
27 % save element-index in elind:
28 iselement = find((loc(:,1) >= 0-5000*eps) & (loc(:,2) >= 0-5000*eps) & ...
29 (loc(:,1)+loc(:,2) <= 1+5000*eps));
33 if ~isempty(find(elind == 0))
34 error('cannot find elements for all points!');
37 % compute grad_hat u_hat
38 grad_hatx = fdf.dofs(fdf.grid.VI(elind,2)) - fdf.dofs(fdf.grid.VI(elind,1));
39 grad_haty = fdf.dofs(fdf.grid.VI(elind,3)) - fdf.dofs(fdf.grid.VI(elind,1));
41 % compute grad u with coordinate-transformation-derivative-rule
42 gradx = fdf.grid.JIT(elind,1,1) .* grad_hatx ...
43 + fdf.grid.JIT(elind,1,2) .* grad_haty;
44 grady = fdf.grid.JIT(elind,2,1) .* grad_hatx ...
45 + fdf.grid.JIT(elind,2,2) .* grad_haty;
class representing a continous piecewise polynomial function of arbitrary dimension. DOFS correspond to the values of Lagrange-nodes.