123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- package com.miniframe.solverconfig.hcfd;
- import com.miniframe.constant.MFConstant;
- import com.miniframe.core.exception.BusinessException;
- import com.miniframe.core.ext.UtilTools;
- import com.miniframe.model.system.*;
- import com.miniframe.model.system.dao.SysFileMapper;
- import com.miniframe.tools.XIDateTimeUtils;
- import com.miniframe.tools.XIFileUtils;
- import java.io.*;
- import java.nio.channels.FileChannel;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.nio.file.StandardCopyOption;
- import java.util.*;
- /**
- * 对执行所需要的文件进行文件夹规整已满足求解
- */
- public class HcfdPath {
- /**
- *
- * @param pid
- * @param isVolume 1 物面 2流场
- * @param step 步数
- * @return
- */
- public static List<File> getStepFiles(String pid ,String isVolume,String step) throws BusinessException{
- String jobPath = XIFileUtils.getRootPathStr()+ MFConstant.separator+pid;
- String exePath = jobPath+ MFConstant.separator+"hcfd";
- String testPath = exePath+ MFConstant.separator+"test";
- String exeOutPath = testPath+ MFConstant.separator+"data_out";
- File exeOutDir = new File(exeOutPath);
- if(!exeOutDir.exists()){
- throw new BusinessException("EB4000017");
- }
- List<File> fileList =new ArrayList<>();
- File[] files =exeOutDir.listFiles();
- if(isVolume == "1") {//物面数据
- for (File sonFile: files) {
- if(sonFile.getName().indexOf("tec_volume_timestep"+step+".dat")>-1){//物面
- fileList.add(sonFile);
- }
- }
- }else{//流场数据
- for (File sonFile: files) {
- if(sonFile.getName().indexOf("boundary_timestep"+step+".dat")>-1){//流场
- fileList.add(sonFile);
- }
- }
- }
- return fileList;
- }
- public static List<Integer> hcfdTeps(String pid) throws BusinessException{
- String jobPath = XIFileUtils.getRootPathStr()+ MFConstant.separator+pid;
- String exePath = jobPath+ MFConstant.separator+"hcfd";
- String testPath = exePath+ MFConstant.separator+"test";
- String exeOutPath = testPath+ MFConstant.separator+"data_out";
- File exeOutDir = new File(exeOutPath);
- if(!exeOutDir.exists()){
- throw new BusinessException("EB4000017");
- }
- List<Integer> steps = new ArrayList<>();
- File[] files =exeOutDir.listFiles();
- for (File sonFile: files) {
- if(sonFile.getName().indexOf("hcfd_tec_boundary_timestep")>-1){
- String stip=sonFile.getName().replace("hcfd_tec_boundary_timestep","").replace(".dat","");
- steps.add(Integer.valueOf(stip));
- }
- }
- Collections.sort(steps);
- return steps;
- }
- public static void hcfdCreatPath(AdiModeling modeling,
- AdiSolverConfig config,
- AdiSolverJob job ) throws IOException {
- String jobPath = XIFileUtils.getRootPathStr()+ MFConstant.separator+job.getPid();
- System.out.println(jobPath);
- String exePath = jobPath+ MFConstant.separator+"hcfd";
- String exeInPath = exePath+ MFConstant.separator+"data_in";
- File exeInDir = new File(exeInPath);
- if(!exeInDir.exists()){
- exeInDir.mkdirs();
- }
- String testPath = exePath+ MFConstant.separator+"test";
- String exeOutPath = testPath+ MFConstant.separator+"data_out";
- File exeOutDir = new File(exeOutPath);
- if(!exeOutDir.exists()){
- exeOutDir.mkdirs();
- }
- SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class);
- SysFile nmlFile= fileMapper.selectByPrimaryKey(config.getNmlFile());
- fileMove(nmlFile,testPath+MFConstant.separator+"hcfd.nml");
- SysFile mapbcFile= fileMapper.selectByPrimaryKey(config.getMapbcFile());
- fileMove(mapbcFile,exeInPath+MFConstant.separator+"hcfd.mapbc");
- SysFile grid= fileMapper.selectByPrimaryKey(modeling.getGridFile());
- fileMove(grid,exeInPath+MFConstant.separator+"hcfd.ugrid");
- }
- /**
- * 文件移动
- * @param file
- * @param pathStr
- * @throws IOException
- */
- public static void fileMove(SysFile file ,String pathStr) throws IOException {
- Path path = Paths.get(pathStr);
- SysFileMapper fileMapper = UtilTools.getBean(SysFileMapper.class);
- Files.move(Paths.get( XIFileUtils.getRootPathStr()+ MFConstant.separator+file.getFilepath()),
- path, StandardCopyOption.REPLACE_EXISTING);
- String fielRelativePath = XIFileUtils.getRelativizePathStr(path);
- file.setFilepath(fielRelativePath);
- file.setFilename(path.getFileName().toString());
- fileMapper.updateByPrimaryKey(file);
- }
- public static void main(String[] args) {
- String stip="hcfd_tec_boundary_timestep100.dat".replace("hcfd_tec_boundary_timestep","").replace(".dat","");
- Integer s ="hcfd_tec_boundary_timestep100.dat".indexOf("hcf2d_tec_boundary_timestep");
- System.out.println(s);
- }
- }
|