How to apply boundary conditions in pde toolbox without edge/face id?
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Ravi Kumar
2018-2-27
编辑:Ravi Kumar
2018-2-27
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 个评论
Ravi Kumar
2018-2-27
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?
更多回答(2 个)
Ravi Kumar
2018-3-1
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 个评论
Brandon Hayes
2021-1-27
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
2018-11-21
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Eigenvalue Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!