Remove some mesh elements from a structural pde model
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone,
I have a simple pde model with an autogenerated mesh with "generateMesh".
After generating the mesh I would like to remove some Mesh elements to get new geometry. It would be useful to do this with a logical (0 or 1) that turns individual mesh elements on or off.
Could any of you help me?
Thank you
%%
model = createpde('structural','modal-solid');
importGeometry(model,'Plate10x10x1.stl');
generateMesh(model,'Hmin',3);
figure
pdeplot3D(model); % Then I have to remove some mesh elements from the model
0 comentarios
Respuestas (1)
Garmit Pant
el 23 de Ag. de 2023
Hello
It is my understanding that you are trying to generate a mesh from PDE model and subsequently trying to modify the mesh by removing some Mesh elements to get new geometry.
The code that you have provided is utilising the ‘generateMesh’ function of the Partial Differential Equation Toolbox. The function returns an object of the FEMesh class. The properties of the object are read-only, thus modifying the Elements of the mesh object wouldn’t be possible.
model = createpde('structural','modal-solid');
importGeometry(model,'Plate10x10x1.stl');
generateMesh(model,'Hmin',3)
figure
pdeplot3D(model);
You can still access the Elements and Nodes of the FEMesh and modify them. You can then use the ‘pdeplot3D’ function to plot the modified Elements and Nodes separately. The following code snippet takes the elements from the above-created mesh and then removes the elements where the x-coordinate of the centroid is less than 5.
% Initialize a logical mask with all elements initially set to 'true' (keep).
numElements = size(model.Mesh.Elements, 2);
elementMask = true(1, numElements);
% Set 'false' for elements you want to remove based on some condition.
% For example, remove elements where the x-coordinate of the centroid is less than 5.
elementCentroids = mean(model.Mesh.Nodes(:, model.Mesh.Elements), 1);
xCoordinates = elementCentroids(1, :);
elementsToRemove = xCoordinates < 5;
elementMask(elementsToRemove) = false;
% Store the elements of the mesh after applying the mask in the variable. Also store the nodes in a separate variable.
e= model.Mesh.Elements(:,elementMask);
n = model.Mesh.Nodes;
pdeplot3D(n,e)
You can refer to the following documentation pages to further understand the functionalities of the above-mentioned functions:
0 comentarios
Ver también
Categorías
Más información sobre Geometry and Mesh en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


