Find Specific Faces on a 3D PDE DiscreteGe​ometry/The​rmalModel

조회 수: 9 (최근 30일)
Luke Benham
Luke Benham 2020년 6월 25일
답변: Luke Benham 2020년 6월 29일
Hi,
I am struggling to create a universal code that is able to solve a Thermal Model of heat travelling through a cube from one face to the other with different cavity types.
I was hoping to find a way to extract the number of the faces on the outer surface of the cube on opposing sides in either the x or y direction. I wish to do this so that I can easily change the model without having to manually find the values of opposing faces. Something like this;
thermalBC(model,'Face',pos_face,'Temperature',pos_t);
thermalBC(model,'Face',zero_face,'Temperature',zero_t);
where the pos_face and zero_face variables are extracted from the model.
Cheers!

채택된 답변

Luke Benham
Luke Benham 2020년 6월 29일
I have something similar, and can now express the desired faces as variables such as this;
figure, h1 = pdegplot(model,'FaceLabels','on'); %Display model and create variable to find facelabels.
hp = h1.Parent;
faceLabelsArray = hp.Children; %Pull Facelabels from figure
LF = length(faceLabelsArray); %Define length so make this universally applicable
labelCells = {faceLabelsArray(1:LF-6).String}; %Pull separate cells for each face
labelNums = length(labelCells):-1:1; %The faces are created backwards, this makes it chronilogical
positionCells = {faceLabelsArray(1:LF-6).Position}; %Find (x,y,z) coords of each face label
positionNums = cell2mat(positionCells'); %Make this into matrix
a = find(positionNums(:,1)>(cubelength/2)); pos = labelNums(a); %Find specific faces based on a set location
b = find(positionNums(:,1)<-(cubelength/2)); zer = labelNums(b);
The reason why I have set the boundary for my desired faces to be chosen is just because I have it centred on (0,0,0).
Hope this helps anyone with a similar requirement!

추가 답변 (1개)

darova
darova 2020년 6월 27일
Here is an example
[x,y] = pol2cart(pi/4:pi/2:2*pi,1); % rectangle
gd = [2;length(x);x(:);y(:)]; % geometry description
dl = decsg(gd); % decomposition
[p,e,t] = initmesh(dl,'hmax',0.05); % triangulation
ind = logical(t(1,:)*0)'; % indices inside a region
for i = 1:length(ind)
vv = p(:,t(1:3,i)); % triangle vertices
rr = hypot(vv(1,:),vv(2,:)) < 0.3; % all vertices inside circle
if all(rr)
ind(i) = true; % write triangle
end
end
pdemesh(p,e,t) % display all mesh
ff.faces = t(1:3,ind)';
ff.vertices = p';
ff.facecolor = 'g';
patch(ff) % display region inside
viscircles([0 0],0.3) % display region
  댓글 수: 1
Luke Benham
Luke Benham 2020년 6월 29일
Thank you, this certainly helped, however I needed a more 3d approach.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by