Create laplacian smoothing matlab
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Precise Simulation
il 24 Ott 2017
Modificato: Precise Simulation
il 26 Ott 2017
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 Commenti
somesh bharadwaj
il 25 Ott 2017
for this was getting error in smooth grid so how can i overcome that
Precise Simulation
il 25 Ott 2017
Modificato: Precise Simulation
il 26 Ott 2017
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
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!