XIAN-FEM-2026June/三维matlab代码/matlab 3D一阶基+散射边界条件+单周期边界/load_case_mesh.m

29 lines
856 B
Matlab
Raw Permalink 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 mesh = load_case_mesh(cfg, root)
%LOAD_CASE_MESH Load mesh from c6.mat or PBCmesh.dat for this case.
if nargin < 2 || isempty(root)
root = fileparts(mfilename('fullpath'));
end
meshMat = fullfile(root, cfg.meshMatFile);
meshDat = fullfile(root, cfg.MeshFile);
if isfile(meshMat)
S = load(meshMat, 'mesh');
mesh = S.mesh;
fprintf('已加载 %s\n', meshMat);
elseif isfile(meshDat)
sbcDir = fullfile(root, '..', 'matlab 3D一阶基+散射边界条件');
if isfolder(sbcDir)
addpath(sbcDir);
end
if exist('load_SBCmesh_dat', 'file') ~= 2
error('load_case_mesh:NoLoader', '找不到 load_SBCmesh_dat请提供 %s 或 c6.mat。', cfg.MeshFile);
end
mesh = load_SBCmesh_dat(meshDat);
else
error('load_case_mesh:NoMesh', '找不到 %s 或 %s。', cfg.meshMatFile, cfg.MeshFile);
end
end