XIAN-FEM-2026June/三维matlab代码/matlab 3D二阶基+散射边界条件/export_case.m

21 lines
799 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 export_case()
%EXPORT_CASE 按 case_config.m 导出本算例的 OpticsFEM JSON含 ElementOrder=2
[phy, cfg] = case_config();
root = fileparts(mfilename('fullpath'));
addpath(fullfile(root, '..', 'common'));
jsonPath = fullfile(root, cfg.jsonFile);
export_phy_to_json(phy, jsonPath, cfg);
% Append ElementOrder (export_phy_to_json 目前未写该字段)
txt = fileread(jsonPath);
if ~contains(txt, '"ElementOrder"')
txt = strrep(txt, sprintf('"EletricType": %d,', cfg.EletricType), ...
sprintf('"EletricType": %d,\n "ElementOrder": %d,', cfg.EletricType, cfg.ElementOrder));
fid = fopen(jsonPath, 'w');
fprintf(fid, '%s', txt);
fclose(fid);
end
fprintf('已写出 %s\n', jsonPath);
fprintf('C++ 算例目录: 3D opticsfem-master\\scat3D_order2\\\n');
end