diff --git a/ceasiompy/EdgeRun/func/edge_queScript_gen.py b/ceasiompy/EdgeRun/func/edge_queScript_gen.py index 219297555..902e2a467 100644 --- a/ceasiompy/EdgeRun/func/edge_queScript_gen.py +++ b/ceasiompy/EdgeRun/func/edge_queScript_gen.py @@ -16,8 +16,7 @@ # ================================================================================================= import os -from pathlib import Path - +import subprocess from pathlib import Path @@ -82,43 +81,56 @@ def submit_solver_script(self, dir_path, nb_proc): def run_edgesolver(self, dir_path, nb_proc): run_solver = os.path.join(self.Edge_dir, 'edge_mpi_run') - #QueScript = f'queue_edgesolver.script' - #dir_path = self.dir_path - #Submitcommand = 'sbatch' os.chdir(dir_path) - """ - with open(self.input_que_script_path, 'r') as template_file, open(QueScript, 'w') as que_script: - for line in template_file: - if '-J jobname' in line: - line = line.replace('-J jobname', f'-J {self.jobname}solver') - que_script.write(line) - que_script.write(f'{run_solver} {self.EdgeInputFile} {nb_proc} > edge_run.log 2>&1\n') - """ - os.system(f'run_solver {self.EdgeInputFile} {nb_proc} > edge_run.log 2>&1\n') + os.system(f'{run_solver} {self.EdgeInputFile} {nb_proc} > edge_run.log 2>&1\n') - def postprocess_script(self, dir_path): + def postprocess_script(self, dir_path,edge_grid): ffaucut = os.path.join(self.Edge_dir, 'ffaucut') ffauinterpol = os.path.join(self.Edge_dir, 'ffauinterpol') ffa2tab = os.path.join(self.Edge_dir, 'ffa2tab') ffa2engold = os.path.join(self.Edge_dir, 'ffa2engold') + grid = edge_grid # output file names + walldata1 = "Edge_wall.dat" walldata2 = "Edge_wall.cf" forcemoments = "Edge_force_moment.dat" ensgoldprefix = "zzz" solution1 = "Edge.bout" solution2 = "Post.bout" - #QueScript = f'queue_edgesolver.script' - #dir_path = self.dir_path - #Submitcommand = 'sbatch' + + # Enter the folder os.chdir(dir_path) - with open(self.input_que_script_path, 'r') as template_file, open(QueScript, 'w') as que_script: - for line in template_file: - if '-J jobname' in line: - line = line.replace('-J jobname', f'-J {self.jobname}solver') - que_script.write(line) - que_script.write(f'{run_solver} {self.EdgeInputFile} {nb_proc} > edge_run.log 2>&1\n') - os.system(f'{Submitcommand} {que_script}') + + # Extract the boundary + input_data = """1 + 0 + """ + with subprocess.Popen([ffaucut, grid, 'tmp1'], stdin=subprocess.PIPE, text=True) as process: + process.communicate(input=input_data) + + + # Inteerpolate the soulutions + subprocess.run([ffauinterpol, solution1, 'tmp1', 'tmp11']) + subprocess.run([ffauinterpol, solution2, 'tmp1', 'tmp12']) + + # Extract tabulated data + subprocess.run([ffa2tab, 'tmp11', walldata1]) + subprocess.run([ffa2tab, 'tmp12', walldata2]) + + # Cleanup + for temp_file in ['tmp1', 'tmp11', 'tmp12']: + os.remove(temp_file) + + # Create ensight gold files + subprocess.run([ffa2engold, grid, solution1, ensgoldprefix]) + + + + + + + #os.system(f'{Submitcommand} {que_script}') diff --git a/ceasiompy/EdgeRun/func/edgeconfig.py b/ceasiompy/EdgeRun/func/edgeconfig.py index cca563b94..083ab0507 100644 --- a/ceasiompy/EdgeRun/func/edgeconfig.py +++ b/ceasiompy/EdgeRun/func/edgeconfig.py @@ -308,6 +308,7 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): edge_scripts_instance.run_edgesolver(case_dir_path,NPART) # postprocess for results + edge_scripts_instance.postprocess_script(case_dir_path,edge_mesh) # wait until the results are generated cpacs.save_cpacs(cpacs_out_path, overwrite=True)