gradedmesh

Meta-function and optional GUI that transforms linear mesh coordinates into a chosen graded mesh
404 Downloads
Updated 12 Aug 2013

View License

gradedmesh is a set of utilities for creating graded mesh. A graded mesh is a symmetric mesh which becomes finer at each interval. Choosing a graded mesh is problem specific therefore having a simple and efficient utility for designing them is helpful.

The core of this module is the function meshfunc which takes two parameters. Curvature and Weight. It uses these to create a parabola y(x) which defines the graded step size vector dx. The curvature parameter is the c term in the (x-a)^c part of the parabolic equation. Thus it controls how quickly dx changes step sizes and how wide the trough of the parabola is. The weight term is the ratio between the smallest dx and the largest, so weight = 0.1 would give a graded mesh where the finest mesh scale is 10% of the largest.
Calling meshfunc(curve, weight) returns a function which can be used to transform various linear dimension vectors, all using the same curve and weight parameters used to build the function. This means that multiple applications of the returned function on linear vectors performs the same transformation on all of them, regardless of their length or range. This function returns two outputs, x and dx, the transformed coordinates of the inputs.

Example:
curve = 4;
weight = 0.2;
gmesh = meshfunc(curve, weight);

% Untransformed Coordinates
x = linspace(0, 1, 100);
y = linspace(3, 3.5, 100);
z = linspace(0, 100, 1000);

% Transformed Coordinates
[x dx] = gmesh(x)
[y dy] = gmesh(y)
[z dz] = gmesh(z)

plotMesh(x, z)
plotMesh(x, y)

Function meshgui opens a gui for easy selection of the meshfunc parameters: curvature and weight.

gmesh = meshgui();

Sliders allow the user to increase and decrease both parameters and visually check the appearance of the mesh.
Note: meshgui has both plotMesh and meshfunc as dependencies, it is just a GUI wrapper around these functions, so they must be in the same directory or on the matlab path.

plotMesh is a quick function for viewing the transformed graded mesh.

See the meshtest.m file included in this module for a working example.

Cite As

Ben Postlethwaite (2024). gradedmesh (https://www.mathworks.com/matlabcentral/fileexchange/38868-gradedmesh), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Chemistry in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.5.0.0

Clean up files

1.2.0.0

Added some additional tags

1.1.0.0

Update documentation and meshtest script.

1.0.0.0