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