


% -*- texinfo -*-
% @deftypefn {Function File} {[@var{Ax},@var{Ay}]} = MSH2Mdisplacementsmoothing(@var{msh},@var{k})
%
% To displace the boundary of a 2D mesh, set a spring with
% force/length constant @var{k} along each edge and enforce
% equilibrium.
%
% This function builds matrices containing the resulting
% (linearized) equation for x and y coordinates of each mesh node.
% Boundary conditions enforcing the displacement (Dirichlet type
% problem) or the force (Neumann type) at the boundary must be added
% to make the system solvable, e.g.:
%
% @example
% msh = MSH2Mstructmesh(linspace(0,1,10),@
% linspace(0,1,10),@
% 1,1:4, 'left');
% dnodes = MSH2Mnodesonsides(msh,1:4);
% varnodes = setdiff([1:columns(msh.p)],dnodes);
% xd = msh.p(1,dnodes)';
% yd = msh.p(2,dnodes)';
% dx = dy = zeros(columns(msh.p),1);
% dxtot = dytot = -.5*sin(xd.*yd*pi/2);
% Nsteps = 10;
% for ii=1:Nsteps
% dx(dnodes) = dxtot;
% dy(dnodes) = dytot;
% [Ax,Ay] = MSH2Mdisplacementsmoothing(msh,1);
% dx(varnodes) = Ax(varnodes,varnodes) \ ...
% (-Ax(varnodes,dnodes)*dx(dnodes));
% dy(varnodes) = Ay(varnodes,varnodes) \ ...
% (-Ay(varnodes,dnodes)*dy(dnodes));
% msh.p += [ dx'/Nsteps; dy'/Nsteps ] ;
% triplot(msh.t(1:3,:)',msh.p(1,:)',msh.p(2,:)');
% pause(.01)
% end
% @end example
%
% @seealso{MSH2Mjigglemesh}
%
% @end deftypefn