How to create a 3d mesh with a unique property for every element?
6 views (last 30 days)
Show older comments
I'm struggling to create a finite element mesh to suit my needs for a thermal model. I'm starting from a data file that has 3d rectangular elements of variable size and physical properties. The physical properties (conductivity and heat production) cannot simply be separated into descrete zones as each element is different.
I've been able to create a mesh using delaunay.m and geometryFromMesh.m, but I cannot figure out how to efficiently assign a unique set of properties to each element (i.e. each element becomes its own cell). The code does not seem to be set up to work this way. Any ideas are welcome.
0 Comments
Answers (1)
chicken vector
on 19 Apr 2023
Edited: chicken vector
on 19 Apr 2023
You can store all the information you want into a structure:
nElements = 25;
x = rand(nElements, 1);
y = rand(nElements, 1);
z = rand(nElements, 1);
condunctivity = 50 + 5 * sin(linspace(0, 2*pi, nElements));
DT = delaunay(x, y, z);
mesh = struct;
for element = 1 : nElements
mesh(j).Indeces = [DT(j,:); DT(j,:); DT(j,:)]
mesh(j).Points = [x(DT(j,:)); y(DT(j,:)); z(DT(j,:))]
mesh(j).Conductivity = condunctivity(j)
end
Alternatively you can define a class with a similar approach.
This is usefull to perform operations on the elements.
classdef meshElement
properties
indeces
x
y
z
conductivity
end
methods
function el = meshElement(DT,row,x,y,z,elementConductivity)
el.indeces = DT(row,:);
el.x = el.x(indeces);
el.y = el.y(indeces);
el.z = el.z(indeces);
el.conductivity = elementConductivity;
end
end
end
Unfortunately the instance of the class returned by delaunayTriangulation is not dynamic, othereise you could just have added the property conductivity to it.
0 Comments
See Also
Categories
Find more on Triangulation Representation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!