Browse Source

瓦斯求解

huangxingxing 1 year ago
parent
commit
1816cd0794

+ 13 - 12
src/main/java/com/miniframe/bisiness/system/D00008Service.java

@@ -126,11 +126,12 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 			if(gases.isEmpty()){
 				throw  new BusinessException("EB3000004");
 			}
-			for (DGas gas: gases) {
-				TemplateGenerator.createGasControl(aid,jid,gas.getId(),totaltime,dt,dx,reportstep,interactionstep,cocodes);
+			DGas gas =gases.get(0);
+//			for (DGas gas: gases) {
+				TemplateGenerator.createGasControl(aid,jid,totaltime,dt,dx,reportstep,interactionstep,cocodes);
 				TemplateGenerator.createGasInit(aid,jid,gas.getId());
-				TemplateGenerator.createGassRunsh(aid,jid,gas.getId());
-				TemplateGenerator2.createGassEsccapeControl(aid,jid,gas.getId());
+				TemplateGenerator.createGassRunsh(aid,jid);
+				TemplateGenerator2.createGassEsccapeControl(aid,jid);
 				//文件迁移
 				//网格文件
 				SysFileMapper sysFileMapper = UtilTools.getBean(SysFileMapper.class);
@@ -139,21 +140,21 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 					throw new BusinessException("EB3100020");
 				}
 				cpFile(XIFileUtils.getRootPathStr() + MFConstant.separator + gf.getFilepath()
-						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/"+gf.getFilename());
+						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas"+ "/"+gf.getFilename());
 				//边界
 				SysFile bf = sysFileMapper.selectByPrimaryKey(gas.getBfid());
 				if (bf == null) {
 					throw new BusinessException("EB3100021");
 				}
 				cpFile(XIFileUtils.getRootPathStr() + MFConstant.separator + bf.getFilepath()
-						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/"+bf.getFilename());
+						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas"  + "/"+bf.getFilename());
 				cpFile("/home/disaster/gas/bin/gas_mod.Lewis_2"
-						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/gas_mod.Lewis_2");
+						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/gas_mod.Lewis_2");
 				cpFile("/home/disaster/gas/bin/reac_mod.fluent_CH4_Air_5x1"
-						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gas.getId() + "/reac_mod.fluent_CH4_Air_5x1");
+						,TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/reac_mod.fluent_CH4_Air_5x1");
 				//执行文件
-				exeGass(aid,jid,gas.getId());
-			}
+				exeGass(aid,jid);
+//			}
 
 		}
 	}
@@ -391,14 +392,14 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 
 	//异步执行
 	@SneakyThrows
-	public void exeGass(Integer aid, Integer jid, Integer gid) throws Exception{
+	public void exeGass(Integer aid, Integer jid) throws Exception{
 
 		CompletableFuture<Void> cf = CompletableFuture.supplyAsync(()->{
 			try {
 				Runtime runtime = Runtime.getRuntime();
 				Process p =null;
 				LogService.addLog(aid,jid,"Gass","求解——————————————————开始");
-				p= runtime.exec("sh "+TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/run.sh");
+				p= runtime.exec("sh "+TemplateGenerator.BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/run.sh");
 				InputStream fis = p.getInputStream();
 				InputStreamReader isr = new InputStreamReader(fis);
 				BufferedReader br = new BufferedReader(isr);

+ 21 - 21
src/main/java/com/miniframe/template/TemplateGenerator.java

@@ -204,18 +204,18 @@ public class TemplateGenerator {
         XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/out");
     }
 
-    private static void mkGassDirs(Integer aid, Integer jid, Integer gid) {
+    private static void mkGassDirs(Integer aid, Integer jid) {
         String s = "/gas";
         XIFileUtils.mkdir(BPATH);
         XIFileUtils.mkdir(BPATH + "/" + aid);
         XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid);
         XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s);
-        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid);
-        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/mid");
-        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/out");
-        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/case");
-        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/data_mnt");
-        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + gid + "/data_rst");
+        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" );
+        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + "/mid");
+        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + "/out");
+        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + "/case");
+        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + "/data_mnt");
+        XIFileUtils.mkdir(BPATH + "/" + aid + "/" + jid + s + "/" + "/data_rst");
     }
 
     /**
@@ -411,7 +411,7 @@ public class TemplateGenerator {
         System.out.println(formattedString); // 输出: 123.46
     }
 
-    public static void createGasControl(Integer aid, Integer jid, Integer gid, String totaltime,
+    public static void createGasControl(Integer aid, Integer jid, String totaltime,
                                         String dt, String dx, String reportstep, String interactionstep,
                                         String cocodes) throws IOException, TemplateException {
 
@@ -425,13 +425,13 @@ public class TemplateGenerator {
         //几何文件路径
         dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
         //fireinit 文件路径
-        dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/" + "MashGas.init");
+        dataModel.put("initFilePath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + "MashGas.init");
         //midPath
         dataModel.put("monitorPath", BPATH + "/" + aid + "/" + jid + "/monitor.in");
         //midPath
-        dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/mid");
+        dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + "/mid");
         //outPath
-        dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/out");
+        dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" +  "/out");
         //CPUS
         dataModel.put("cups", 4);
         dataModel.put("totaltime", totaltime);
@@ -470,9 +470,9 @@ public class TemplateGenerator {
         // 将数据模型传入模板进行处理
         StringWriter writer = new StringWriter();
         template.process(dataModel, writer);
-        mkGassDirs(aid, jid, gid);
+        mkGassDirs(aid, jid);
 
-        FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/MashGas.control");
+        FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/MashGas.control");
         fileWriter.write(writer.toString());
         fileWriter.close();
 
@@ -520,15 +520,15 @@ public class TemplateGenerator {
         // 将数据模型传入模板进行处理
         StringWriter writer = new StringWriter();
         template.process(dataModel, writer);
-        mkGassDirs(aid, jid, gid);
+        mkGassDirs(aid, jid);
 
-        FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/MashGas.init");
+        FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/MashGas.init");
         fileWriter.write(writer.toString());
         fileWriter.close();
 
     }
 
-    public static void createGassRunsh(Integer aid, Integer jid, Integer gid) throws IOException, TemplateException {
+    public static void createGassRunsh(Integer aid, Integer jid) throws IOException, TemplateException {
         Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
         // 设置模板所在目录
         cfg.setClassForTemplateLoading(TemplateGenerator.class, "/templates");
@@ -536,14 +536,14 @@ public class TemplateGenerator {
         Template template = cfg.getTemplate("mashGasRunsh.ftl");
         // 定义数据模型(Map)
         Map<String, Object> dataModel = new HashMap<>();
-        dataModel.put("casepath", BPATH + "/" + aid + "/" + jid  + "/gas" + "/" + gid + "/case");
-        dataModel.put("gascontrol", BPATH + "/" + aid + "/" + jid  + "/gas" + "/" + gid + "/MashGas.control");
-        dataModel.put("gasescapecontrol", BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/gasEscape.control");
+        dataModel.put("casepath", BPATH + "/" + aid + "/" + jid  + "/gas" + "/case");
+        dataModel.put("gascontrol", BPATH + "/" + aid + "/" + jid  + "/gas" + "/MashGas.control");
+        dataModel.put("gasescapecontrol", BPATH + "/" + aid + "/" + jid + "/" + "/gas"  + "/gasEscape.control");
         // 将数据模型传入模板进行处理
         StringWriter writer = new StringWriter();
         template.process(dataModel, writer);
-        mkGassDirs(aid, jid, gid);
-        FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/run.sh");
+        mkGassDirs(aid, jid);
+        FileWriter fileWriter = new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/run.sh");
         fileWriter.write(writer.toString());
 
         fileWriter.close();

+ 4 - 4
src/main/java/com/miniframe/template/TemplateGenerator2.java

@@ -183,7 +183,7 @@ public class TemplateGenerator2 {
         fileWriter.write(writer.toString());
         fileWriter.close();
     }
-    public static void createGassEsccapeControl(Integer aid, Integer jid,Integer gid) throws IOException, TemplateException {
+    public static void createGassEsccapeControl(Integer aid, Integer jid) throws IOException, TemplateException {
         Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);
         // 设置模板所在目录
         cfg.setClassForTemplateLoading(TemplateGenerator2.class, "/templates");
@@ -194,15 +194,15 @@ public class TemplateGenerator2 {
         //几何文件路径
         dataModel.put("geoFilePath", BPATH + "/" + aid + "/" + jid + "/Geometry");
         //midPath
-        dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/mid");
+        dataModel.put("midPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + "/mid");
         //outPath
-        dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + gid + "/out");
+        dataModel.put("outPath", BPATH + "/" + aid + "/" + jid + "/gas" + "/" + "/out");
         dataModel.put("escape", BPATH + "/" + aid + "/" + jid + "/escape");
         // 将数据模型传入模板进行处理
         StringWriter writer = new StringWriter();
         template.process(dataModel, writer);
         FileWriter fileWriter =
-                new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/" + gid + "/gasEscape.control");
+                new FileWriter(BPATH + "/" + aid + "/" + jid + "/" + "/gas" + "/gasEscape.control");
         fileWriter.write(writer.toString());
         fileWriter.close();
     }