应用领域:叶轮机械大规模数值模拟

软件:NUMECA/FineTurbo, NUMECA/CFview

问题:模拟过程结果数据过大,完整结果文件太大没PB级的硬盘存不下来,需要保存若干用于分析的表面数据,或者只保存部分自定义的计算数据,主要是NUMECA/FineTurbo中无法或不方便设置保存的数据。

解决方法:Shell调用CFview宏文件,初步代码如下,不太会用shell,请大佬指正。

第一步:创建CFview宏文件,如下面的post-CFview.py,这里展示的大致功能就是将一个叶轮机的数值模拟结果读入CFview然后导出若干切面上的值。

CFViewBackward(912)
#-------------------------------------------------------#
#       File Name and Timesteps Settings                #
#   Rules:                                              #
#   1 Adjust surface names according to case            #
#   2 Each block start from Adding surface              #
#   3 Each block end at Removing surface                #
#       Specially designed for xxx case                 #
#       Need to create sub-directories ./images         #
#       ./line_data ./cutplane_data                     #
#       And put fwh cutting curve in ./cutplane_data    #
#                              泥瓦匠种地人              #
#-------------------------------------------------------#
# Remain project_prefix, file_dir and istep in the 16th, 17th and 20th line, which is meant to
# be changed by shell script
project_prefix='a'
file_dir='<your_case_dir>/a'
cutplane_data_dir=('%s/cutplane_data/') %(file_dir)
#-----------------------------------------------
istep=101
t_start=istep
t_end=istep
t_interval=1
#-----------------------------------------------
#surface_name=('blade-hub','inlet-outlt-shroud','fwh-surface-curveCut','z0.18','z0.15','z0.1','z0.05','z0.0','z-0.1','z-0.2','fwh-surface-Grid')
surface_name=('z-0.6255','z0.0385','z0.4177','z0.7125','stator_domain719')
#-----------------------------------------------
data_suffix='.cgns'
#-----------------------------------------------
# Open Project
#-----------------------------------------------
filename=('%s.run') %(project_prefix)
fileopen_series='%d %d %d' %(t_start,t_end,t_interval)
FileOpenProjectSelection(filename ,'all' ,'loadqnt' ,'Static Pressure' ,'unsteady' ,fileopen_series)
##
## Extract Blade and hub
##
SelectedSurfacesRemove('row 1_shroud')
SelectedSurfacesRemove('row 11_shroud')
data_dir=''
data_dir+=cutplane_data_dir+surface_name[0]+data_suffix
QntFieldScalar('Static Pressure')
#CGNSSaveSurfaces(data_dir,'Surfaces' ,'Static Pressure')
#SelectedSurfacesAdd('row 1_shroud')
#SelectedSurfacesAdd('row 11_shroud')
###
### Extract INLET, OUTLET and Shroud
###
SelectedSurfacesRemove('row 1_hub_')
SelectedSurfacesRemove('row 1_blade_')
SelectedSurfacesRemove('c_block')
SelectedSurfacesRemove('row 2_hub_(r.p.m. 0)')
SelectedSurfacesRemove('row 2_blade')
SelectedSurfacesRemove('row 11_blade')
CreateSurfaceGroup('bulb' ,'bulb_at_inlet_H1.Jmax shroud_identifier_' ,'bulb_at_inlet_H1_repetition1.Jmax bulb_at_inlet_H1__shroud_identifier_-(B52_F4_P1)' ,'bulb_at_inlet_H1_repetition2.Jmax bulb_at_inlet_H1__shroud_identifier_-(B80_F4_P1)' ,'bulb_at_inlet_H1_repetition3.Jmax bulb_at_inlet_H1__shroud_identifier_-(B108_F4_P1)' ,'bulb_at_inlet_H1_repetition4.Jmax bulb_at_inlet_H1__shroud_identifier_-(B136_F4_P1)' ,'bulb_at_inlet_H1_repetition5.Jmax bulb_at_inlet_H1__shroud_identifier_-(B164_F4_P1)' ,'bulb_at_inlet_H1_repetition6.Jmax bulb_at_inlet_H1__shroud_identifier_-(B192_F4_P1)' ,'bulb_at_inlet_H1_repetition7.Jmax bulb_at_inlet_H1__shroud_identifier_-(B220_F4_P1)' ,'bulb_at_inlet_H1_repetition8.Jmax bulb_at_inlet_H1__shroud_identifier_-(B248_F4_P1)' ,'bulb_at_inlet_H1_repetition9.Jmax bulb_at_inlet_H1__shroud_identifier_-(B276_F4_P1)' ,'bulb_at_inlet_H1_repetition10.Jmax bulb_at_inlet_H1__shroud_identifier_-(B304_F4_P1)')
SelectedSurfacesRemove('bulb')
#SelectedSurfacesAdd('INLET')
#SelectedSurfacesAdd('OUTLET11')
#QntFieldScalar('Static Pressure')
#data_dir=''
#data_dir+=cutplane_data_dir+surface_name[1]+data_suffix
#CGNSSaveSurfaces(data_dir,'Surfaces' ,'Static Pressure')
#SelectedSurfacesRemove('INLET')
#SelectedSurfacesRemove('OUTLET11')
#
# Create fw-h surface by rotational cutting curve
#
#SelectedSurfacesRemove('row 1_shroud')
#SelectedSurfacesRemove('row 11_shroud')
#QntFieldScalar('Static Pressure')
#data_dir=''
#data_dir+=cutplane_data_dir+'fwh-cut-curve.dat'
#IggCurveLoadAndCut(data_dir,0)
#data_dir=''
#data_dir+=cutplane_data_dir+surface_name[2]+data_suffix
#CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Temperature','Static Pressure' ,'Density' ,'Vx' ,'Vy','Vz')
#SelectedSurfacesRemove('fwh-cut-curveCut')
##
# Create z-cut planes
# z=-0.6255 First Mic Ring
CutPlaneSave(0,0,-0.6255,0,0,1,0,0)
SurfaceRename('CUT1' ,'z-0.6255')
data_dir=''
data_dir+=cutplane_data_dir+surface_name[0]+data_suffix
CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Pressure')
SelectedSurfacesRemove('z-0.6255')
# z=0.0385 Second Mic Ring
CutPlaneSave(0,0,0.0385,0,0,1,0,0)
SurfaceRename('CUT2' ,'z0.0385')
data_dir=''
data_dir+=cutplane_data_dir+surface_name[1]+data_suffix
CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Pressure')
SelectedSurfacesRemove('z0.0385')
# z=0.4177
CutPlaneSave(0,0,0.4177,0,0,1,0,0)
SurfaceRename('CUT3' ,'z0.4177')
data_dir=''
data_dir+=cutplane_data_dir+surface_name[2]+data_suffix
CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Pressure')
SelectedSurfacesRemove('z0.4177')
# z=0.7125
CutPlaneSave(0,0,0.7125,0,0,1,0,0)
SurfaceRename('CUT4' ,'z0.7125')
data_dir=''
data_dir+=cutplane_data_dir+surface_name[3]+data_suffix
CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Pressure')
SelectedSurfacesRemove('z0.7125')
# stator
SelectFromProject('domain719.Imin row_11_flux_1_Main_Blade_skin_blade_(aap-ps-repetition)-(B719_F5_P1    )' ,'domain719.Imin row_11_flux_1_Main_Blade_skin_blade_(aap-ss-repetition)-(B719_F5_P2)')
data_dir=''
data_dir+=cutplane_data_dir+surface_name[4]+data_suffix
CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Pressure','Density' ,'Vx' ,'Vy' ,'Vz' ,'Relative Mach Number')
SelectedSurfacesRemove('domain719.Imin row_11_flux_1_Main_Blade_skin_blade_(aap-ps-repetition)-(B719_    F5_P1)' ,'domain719.Imin row_11_flux_1_Main_Blade_skin_blade_(aap-ss-repetition)-(B719_F5_P2)')# rotor## z=0.0
#CutPlaneSave(0,0,0,0,0,1,0,0)
#SurfaceRename('CUT5' ,'z0.0')
#data_dir=''
#data_dir+=cutplane_data_dir+surface_name[7]+data_suffix
#CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Temperature','Static Pressure' ,'Density' ,'Vx' ,'Vy','Vz')
#SelectedSurfacesRemove('z0.0')
#CutPlaneSave(0,0,-0.1,0,0,1,0,0)
#SurfaceRename('CUT6' ,'z-0.1')
#data_dir=''
#data_dir+=cutplane_data_dir+surface_name[8]+data_suffix
#CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Temperature','Static Pressure' ,'Density' ,'Vx' ,'Vy','Vz')
#SelectedSurfacesRemove('z-0.1')
## z=-0.2
#CutPlaneSave(0,0,-0.2,0,0,1,0,0)
#SurfaceRename('CUT7' ,'z-0.2')
#data_dir=''
#data_dir+=cutplane_data_dir+surface_name[9]+data_suffix
#CGNSSaveSurfaces( data_dir,'Surfaces' ,'Static Temperature','Static Pressure' ,'Density' ,'Vx' ,'Vy','Vz')
#SelectedSurfacesRemove('z-0.2')

第二部:创建shell文件:racing-CFview-Fine.sh,不断检测新的计算结果是否已经保存完毕,保存完毕就处理,没有完毕等待计算。

#!/bin/sh
#-------------------------------------------------------------------------------#
#                        Racing-CFview-Fine                                     #
# Perform NUMECA/CFview post-processing with FineTurbo unsteady computation     #
#               SIMULTANEOUSLY                                                  #
#                                                                               #
# Post-processing script for step by step real time post-processing of          #
# fine unsteady data by cfview script, this script is only suitable for such    #
# cases when post-processing is faster than computation,i.e., it is always the  #
# post-processing thats wait for the computation.                               #
#                                                                               #
# Usage:                                                                        #
# 1) You need the following external files to run this script:                  #
#    a) cfview_macro.template.py:                                               #
#       Which is a cfview macro file with all post-processing in it, served as  #
#       a template here to generate a cfview_macro.py for each timestep         #
#       #** It's not my work to tell you how to generate a cfview macro **#        #
#                                                                               #
# 2) Cfview macro file "cfview_macro.py" is auto-edit by "sed -i", you need to  #
#    edit the 'sed -i' lines(line 132-138) in this script to auto-edit Vars   #
#    which needs an update for each time step.                                  #
#                                                                               #
# 3) Copy and run this script in directory where unsteady solution is stored by #
#    command: ./racing-CFview-Fine.sh > log.CFview-Fine-Racing&                  #
#                                                                               #
#                                                                               #
#                                              泥瓦匠种地人                      #
#-------------------------------------------------------------------------------#
echo -e "\033[31m This script is only suitable for such cases \033[0m"
echo -e "\033[31m when post-processing is faster than computation.\033[0m"
ifourself_running=$(ps -a|grep racing-CFview-Fine.sh |wc -l)
if [ $ifourself_running -gt 0 ]
thenecho -e "\033[31m Warning, this script is running \033[0m"exit
fi
ifcfview_running=$(ps -a|grep cfvx86_64_ompi |wc -l)
if [ $ifcfview_running -gt 0 ]
thenecho -e "\033[31m Warning, there is CFview running \033[0m"
fi
#
#-------------------------------------------------------------------------------
# User defined parameters
fileprefix=a.ustd
filesuffix=.cgns
#
# Cases to process: case list to process, similar with surface_name in cfview script.
#cases='blade-hub inlet-outlt-shroud fwh-surface-curveCut z-0.2 z-0.1 z0.0 z0.05 z0.1 z0.15 z0.18'
cases='z-0.6255 z0.0385 z0.4177 z0.7125'
#
# well saved solution file size, should be the same for all unsteady time steps
# enquire the initialized solution file for it, e.g.,
# ll for a.cgns
#> -rw-rw-r-- 1 tangxl tangxl 18621652992 Jan 25 13:21 a.cgns
fileSizeDone=18649206784
# No. of digit of file size, here 18621652992 => 11
ndigit=11
#
# Start index of cycle of rotor
icycle=1
# Start timestep: stepst = N, start from the Nth step
istepst=588
# End timestep: isteped = N, exit at the Nth stepa, isteped = 0, do not exit
isteped=0
echo "istep start at : $istepst"
echo "istep finish at : $isteped"
# Max timestep
maxstep=700
#
# Script template of cfview post-processing
script_cfview_tmp=cfview_macro.template.py
script_cfview=cfview_macro.py
cp $script_cfview_tmp $script_cfview
#
# Previous solution file, use the "steady" file generated at initialization
filepre=${fileprefix}${filesuffix}
#
#-------------------------------------------------------------------------------
# Auto-detected parameters
nfile=$(ls -lrt *_t*.cgns|wc -l)
echo "Total No. solution files: ${nfile}"# Create output directories if not exist
if [ ! -d ./cutplane_data ]
thenmkdir cutplane_data
fi
if [ ! -d ./images ]
thenmkdir images
fi
if [ ! -d ./line_data ]
thenmkdir line_data
fi# Check the existence of the start file
istepnow=$istepst
filenamest=${fileprefix}_t${istepnow}${filesuffix}
if [ ! -f $filenamest ]
thenecho "Start time step does not exist! exit."echo "Check file: $filenamest"exit
fi
echo "File to start from: $filenamest"#------------------------------------------------------------------------------
# Loop in timestep and in cycle
while true; do
#istep=$(ls -lrt *_t*.cgns|tail -n 1|grep -Po 't\d{1,}.cgns'|grep -Po "\d{1,}")filename=${fileprefix}_t${istep}${filesuffix}filenamenow=${fileprefix}_t${istepnow}${filesuffix}echo ""
#if [ x"$istepnow" = x"$istep" ]thenecho "========================================================================"echo "Catch up with the latest solution, running the newest timestep."elif [ $filenamenow -ot $filename ]thenecho "========================================================================"echo "The newest solution file is: $filename"echo "Solution file to be processed is: $filenamenow"echo "Running older solution."istep=$istepnowistepnow=$((istepnow+1))if [ $istepnow -gt $maxstep ]thenistepnow=1fifi## If an end point is set, exit at ent pointif [ $isteped -ne 0 ] thenecho -e "\033[31m End point is set at timestep = $isteped. \033[0m"if [ $istep -eq $isteped ]thenecho "Reached pre-set end point: timestep = $isteped. exit."exitfifi#echo "========================================================================"echo "Current cycle: $icycle,  Current time step: $istep"echo ""filename=${fileprefix}_t${istep}${filesuffix}echo "Name of file to process: $filename"# Make sure it is a newer solution fileif [ $filename -nt $filepre ]thenfilepre=$filenameecho "Solution file is available, check writing status......"# Loop in file writingwhile true; dosizefile=$(du -b ${filename}|grep -Po "^\d{1,}\s"|grep -Po "\d{1,}")echo "Size of current file: $sizefile"if [ $sizefile -eq $fileSizeDone ] thenecho "File writing is done, start to post-process."# Edit and run cfview script############################################################################### Change the sed codes accordingly considering your cfview macro !!echo "Editing cfview script file......"echo -e "\033[31m Make sure this is what you want. \033[0m"sed -i "16c project_prefix='${fileprefix}'" $script_cfviewsed -i "17c file_dir='${PWD}'" $script_cfviewsed -i "20c istep=${istep}" $script_cfview##############################################################################echo "Running cfview with background mode."echo -e "\033[31m Please make sure no other cfivew is running or any running \033[0m"echo -e "\033[31m cfview shall not be shut down before this cfview is started. \033[0m"echo -e "\033[31m Any other cfview shall not be started before the PID is shown. \033[0m"ncfview_running_pre=$(ps -a|grep cfvx86_64_ompi|wc -l)echo "cfview -batch backward -macro ${script_cfview}"cfview -batch backward -macro ${script_cfview} &ncfview_running=$(ps -a|grep cfvx86_64_ompi|wc -l)# Wait for the cfview to startwhile [ $ncfview_running -eq $ncfview_running_pre ]doncfview_running=$(ps -a|grep cfvx86_64_ompi|wc -l)sleep 1sdone# Get the PID of the latest started cfviewpid_cfview=$(ps -A -opid,etimes,comm|grep cfvx86_64_ompi|sort -t ' ' -k 2|\head -n 1|awk '{printf $1}')echo -e "\033[31m PID of this cfview process is: $pid_cfview \033[0m"echo "No. cfview running: $ncfview_running"# Wait for cfview to finishwhile true; doifcfview_running=$(ps -a|grep $pid_cfview |wc -l)if [ $ifcfview_running -eq 0 ]thenecho "cfview PID = $pid_cfview is finished. Start rename output files......"cd cutplane_dataistep_0filled=$(printf "%03d" $istep)for i in $casesdomv ${i}_t1.cgns ${i}_c${icycle}_t${istep_0filled}.cgns && \echo "mv ${i}_t1.cgns ${i}_c${icycle}_t${istep_0filled}.cgns"donecd ..echo "Finished processing cycle: $icycle, timestep: $istep"if [ $istep -eq $maxstep ]then# When istep reach the max step, icycle = icycle + 1icycle=$(($icycle+1))fibreakelseecho "cfview is running, wait for it, sleep 30s."sleep 30sfidonebreakelseecho "Solution file is writing, wait for it, sleep 30s."sleep 30sfidoneelseecho "This file is the same with previous one, wait for next time step, sleep 30s"sleep 30sfi
done

NUMECA/FineTurbo计算中自动调用CFview实时数据处理相关推荐

  1. Apache Pulsar:实时数据处理中消息,计算和存储的统一

    本文转载自"AI前线",整理自翟佳在 QCon2018 北京站的演讲,在本次演讲中,翟佳介绍了 Apache Pulsar 的架构.特性和其生态系统的组成,并展示了 Apache ...

  2. 边缘计算在自动驾驶中的应用场景丨边缘计算阅读周

    #边缘计算阅读周#  读书的人,有梦可做. 边缘计算社区联合6大出版社邀您一起阅读,一起做追梦人. 今天推荐的书是电子工业出版社 博文视点推出的边缘计算佳作<边缘计算 方法与工程实践>,这 ...

  3. 如何实时计算中证1000指数的主买/主卖交易量

    主买是指以卖方的报价成交,主卖是指以买方的报价成交. 一般来说,主动买入就是资金流入,主动卖出就是资金流出,所以实时统计主买/主卖交易量能够实时监控资金的流入流出情况.本文基于中证 1000 指数,介 ...

  4. 调用摄像头使用face_recognition 或 opencv中haar人脸特征实时检测识别人脸、给人脸打马赛克/给人脸贴图

    日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) OpenCV:python调用摄像头同时使用OpenCV中自带 ...

  5. 智源青年科学家梁云:异构系统中张量计算的自动调度和优化框架

    与6位图灵奖得主和100多位专家 共同探讨人工智能的下一个十年 长按图片,内行盛会,首次免费注册 北京智源大会倒计时:9天  计算机体系结构领域国际顶级会议每次往往仅录用几十篇论文,录用率在20%左右 ...

  6. thinkphp模型中的获取器和修改器(根据字段名自动调用模型中的方法)

    thinkphp模型中的获取器和修改器(根据字段名自动调用模型中的方法) 一.总结 记得看下面 1.获取器的作用是在获取数据的字段值后自动进行处理 2.修改器的作用是可以在数据赋值的时候自动进行转换处 ...

  7. PHP中 对象自动调用的方法:__set()、__get()、__tostring()

    总结: (1)__get($property_name):获取私有属性$name值时,此对象会自动调用该方法,将属性name值传给参数$property_name,通过这个方法的内部 执行,返回我们传 ...

  8. [转载] Java中使用new构造数组时会不会自动调用类的默认构造函数

    参考链接: Java中的默认构造函数 今天做集合练习时,发现生成类的数组时并 不会自动调用类的默认构造函数 // 开辟10个内存空间,并指定了数组的类型为Gerbil // 这个时候并不会调用构造函数 ...

  9. matlab实时摄像头处理,在MATLAB中调用摄像头实时地显示图像

    <在MATLAB中调用摄像头实时地显示图像>由会员分享,可在线阅读,更多相关<在MATLAB中调用摄像头实时地显示图像(1页珍藏版)>请在人人文库网上搜索. 1.clc;clf ...

最新文章

  1. mysql分库分表方案之sharding-jdbc使用(非demo示例)
  2. 凭借K2 SmartObject框架,在SharePoint中集成数据
  3. 第五节 CImage和CBmp(二)
  4. c# Linq Where 抛出异常 导致 程序崩溃
  5. Emulator 29.2.12 稳定版发布,启用 Google Maps UI
  6. 程序设计基础-c#和java的区别
  7. bootstrap select2 动态从后台Ajax动态获取数据
  8. 微信公众号(静默授权和分享)
  9. 写一彩票程序,要求能随机产生并按照升序输出1-30之间的7个数,且其中任意两个数字不能重复
  10. [lammps教程]OVITO绘制原子运动轨迹线
  11. 【软件工程】层次图、HIPO图——期末快速复习用
  12. 约翰·库缇斯(没有双腿的激励大师,年轻人必看)转载
  13. 汽车电子电气(E/E)构架变革
  14. 个人第一次作业:阅读与准备作业
  15. dedecms调用友情链接代码
  16. 中国品牌亮相第六届加拿大服装纺织品采购展
  17. 30系列显卡安装tensorflow1.15
  18. uni-app开发APP和H5,分享功能
  19. maven报错 Check M2 HOME environment variable and mvn script m
  20. Leetcode 简单四 罗马数字转整数

热门文章

  1. “华为区块链白皮书”重磅发布(附下载链接)
  2. 函数调用计算最高分及对应的学生学号
  3. 使用 Go 语言实现 ELF 文件保护——GoHack 冠军项目KAP
  4. 基于ssm的生活故事分享交流博客系统
  5. 聚划算火拼如何参团 聚划算火拼效果怎么样
  6. php_excel表中_如何自动将多行中文转换成拼音,excel表格怎样设置批量将汉字变成拼音...
  7. java swing背景_java swing 设置背景图片的方法一
  8. 校准品,标准品和质控品的区别
  9. python自动化之word操作用python做邀请函
  10. linux cc***防范