Create laplacian smoothing matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
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! :)
댓글 수: 0
답변 (1개)
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
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 Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!