Create laplacian smoothing matlab

13 次查看(过去 30 天)
damin
damin 2017-10-20
编辑: damin 2017-10-26
Hi! I would like to create a laplacian smoothing like on the image i attach below. The necessary files I need to make this quadmesh (the mesh generator) and the nodeconnect.m file is also attached here. I managed to create a regular mesh using the quadmesh generator, but I dont know how to increase the boundaries to create a laplician smoothing mesh like on the picture.
The attached nodeconnect.m -> nodeconnect computes all nodes connected to a given node. Called as nnods = nodeconnect(nodes,inod); here nnods i a list of connected nodes to the node and nodes=p.Connectivity is the connectivity matrix. Thank you so much for your help! :)

回答(1 个)

Precise Simulation
Precise Simulation 2017-10-24
编辑:Precise Simulation 2017-10-26
You can get something quite similar with the following code, and tune it by playing around with the gridsmooth function, number of smoothing steps, and relaxation parameter.
nx = 24;
ny = 8;
xmin = 0;
xmax = 3;
ymin = -0.5;
ymax = 1.5;
grid = rectgrid( nx, ny, [xmin,ymin,xmax,ymax] );
subplot(2,2,1)
plotgrid(grid)
if( 1 ) % Squeeze only right side y-coordinates.
grid.p(2,grid.p(1,:)==3) = linspace(0,1,ny+1);
else % Squeeze y-coordinates.
yl = linspace(-0.5,1.5,ny+1);
yr = linspace(0,1,ny+1);
y = [];
for i=1:ny+1
y = [ y linspace(yl(i),yr(i),nx+1) ];
end
grid.p(2,:) = y;
end
subplot(2,2,2)
plotgrid(grid)
% Remove boundary indicators from upper/lower
% boundaries to allow smoothing.
b_orig = grid.b;
grid.b(:,grid.b(3,:)==1) = []; % Remove lower boundary indices.
grid.b(:,grid.b(3,:)==3) = []; % Remove upper boundary indices.
grid = gridsmooth( grid, 60, 0.1, 2 );
grid.b = b_orig;
subplot(2,2,3)
plotgrid( grid )
  2 个评论
somesh bharadwaj
somesh bharadwaj 2017-10-25
for this was getting error in smooth grid so how can i overcome that
Precise Simulation
Precise Simulation 2017-10-25
编辑:Precise Simulation 2017-10-26
What did the error message say?
If you just want something that looks like the image you neither need QuadMesh nor Laplacian smoothing:
nx = 24; ny = 8; xmin = 0; xmax = 3; ymin = -0.5; ymax = 1.5;
[x,y] = meshgrid( linspace(xmin,xmax,nx+1), ...
linspace(ymin,ymax,ny+1));
% Shape/distribution 't' of y-points.
t = linspace(0,1,nx+1).^(1./(2+[1:nx+1]));
yl = linspace(-0.5,1.5,ny+1);
yr = linspace(0,1,ny+1);
y2 = [];
for i=1:ny+1
y_i = yl(i) - t*(yl(i)-yr(i));
y2 = [ y2; y_i ];
end
surf(x,y2,ones(size(x))); view(2), axis equal

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by