XIAN-FEM-2026June/三维matlab代码/matlab 3D一阶基 + bele/apply_pec_bele.m

25 lines
556 B
Matlab
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function [A, b] = apply_pec_bele(A, b, mesh, phy, pecEdgeIds)
%APPLY_PEC_BELE 散射场 PECn×(E_s+E_b)=0 → E_s·e = -(E_b·e)
pecEdgeIds = pecEdgeIds(:);
n = mesh.NbrEdge;
for k = 1:numel(pecEdgeIds)
id = pecEdgeIds(k);
v1 = mesh.Edge(id, 1);
v2 = mesh.Edge(id, 2);
p1 = mesh.Vertex(v1, :);
p2 = mesh.Vertex(v2, :);
edgeVec = (p2 - p1).';
mid = 0.5 * (p1 + p2);
Eb = phy.bele.Eb(mid(1), mid(2), mid(3));
rhs = -dot(Eb, edgeVec);
A(id, :) = 0;
A(:, id) = 0;
A(id, id) = 1;
b(id) = rhs;
end
end