How to apply boundary conditions in pde toolbox without edge/face id?
3 views (last 30 days)
Show older comments
Vishal Srivastava
on 27 Feb 2018
Commented: Brandon Hayes
on 27 Jan 2021
I have a geometry which is changing slightly at each iteration and hence its boundary points change too. I want to apply a Neumann Condition to a "macroscopic edge"( which is a concatenation of several small edges) but I don't know their id from "Edgelabels" as they are more than 100 in number and change at every iteration.
How can I apply the Neumann's condition to the edge set {e_i1, e_i2,......,e_in}?
0 Comments
Accepted Answer
Ravi Kumar
on 27 Feb 2018
Edited: Ravi Kumar
on 27 Feb 2018
If you have the same Neumann BC on all edges then you can try:
applyBoundaryCondition(model,'neumann','Edge',1:model.Geometry.NumEdges,'g',1)
Where g = 1 BC is used for illustration.
3 Comments
Ravi Kumar
on 27 Feb 2018
I that case, how are the edges appearing? How are you creating the changed geometry in each iteration?
Any chance you get to know the IDs of the 7 edges that needs to have a different BC?
More Answers (2)
Ravi Kumar
on 1 Mar 2018
Here is another approach to determine which edges are micro edges (the little ones at the bottom) and which edges are macro. This is rather a roundabout way, but it would work for you case.
I illustrate with a square example how to identify which edge is bottom edge without using its label, treat this as a micro edges of your case.
% Create a simple model, square geometry with four edges.
model = createpde;
geometryFromEdges(model,@squareg);
% Get hold on hadles to plot with edge labels on.
h1 = pdegplot(model,'EdgeLabels','on');
hp = h1.Parent;
edgeLabelsArray = hp.Children;
labelCells = {edgeLabelsArray(1:4).String};
labelNums = str2num(cell2mat(strip(labelCells','E')));
positionCells = {edgeLabelsArray(1:4).Position};
positionNums = cell2mat(positioncells');
% Y-Coordinate of labels.
yLocationOFLabels = positionNums(:,2);
% Tag an edge to be a macro edge if its label location is above a
% threshold.
yThreshold = -0.5;
macroEdgeFlag = yLocationOFLabels>yThreshold;
macroEdges = labelNums(macroEdgeFlag)
microEdges = labelNums(~macroEdgeFlag)
1 Comment
Brandon Hayes
on 27 Jan 2021
This technique works well for geometry from the "geometryFromEdges" function. However, if you want to import an STL, I found it doesn't work exactly as is. It is close, but I found that there are hidden fields within the handle that must be accessed to get the data. Here is the modification I came up with to get things working. The key is that edgeLabelsArray(1) needs to refer to the "text' handle.
model_scaled = createpde(1);
g = importGeometry(model_scaled,fullfile(main_directory,[image_file(1:end-4),' -- solid.stl']));
scale(g,pixel_per_m_ratio);
mesh_scaled = generateMesh(model_scaled,'Hmax',100e-6 .* pixel_per_m_ratio);
figure
imshow(im_raw)
hold on
h = pdegplot(model_scaled,'EdgeLabels','on');
hold off
hp = h.Parent;
edgeLabelsArray = hp.Children;
edge_labels = edgeLabelsArray(1).String; %get the edge labels of the text field
edge_labels_vector = zeros(1,length(edge_labels));
for ii = 1:length(edge_labels)
edge_labels_vector(ii) = str2num(strip(edge_labels{ii},'E'));
end
edge_vertex_data = edgeLabelsArray(1).VertexData; %get the vertex data where the label is placed
Ronald Haynes
on 21 Nov 2018
Vishal - did you find a working solution to your problem? I have a very similar situation that I have not been able to find a robust solution for.
0 Comments
See Also
Categories
Find more on Eigenvalue Problems 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!