自己写的代码,就是简单对voidfraction全床求和,然后求平均。
可以在计算过程中及时监控有没有颗粒泄漏。
这个是C++的后处理,编译好之后直接在linux系统openfoam案例下./run.sh就行,舒服多了:
#include#include using namespace std; #include "IFstream.H" #include "OFstream.H" #include "fvCFD.H" #include "meshSearch.H" int main(int argc, char *argv[]) { ofstream fo; #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" meshSearch myMeshSearch(mesh, polyMesh::FACEPLANES); #include "readFields.H" fo.open("Avg_es_time.dat", ios::out); while (runTime.run()) { if (runTime.outputTime()) { double esAvg = 0; int count = 0; Info << "runTime.value(): " << runTime.value() << endl; #include "readFields.H" forAll(mesh.C(), cellid) { esAvg += voidfraction[cellid]; count++; } esAvg /= count; fo << runTime.value() << "t" << esAvg << endl; } runTime++; } fo.close(); return 0; }
这个是matlab的,matlab每次都要手动导出数据到电脑上,而且还得手动修改路径,麻了。
%% 读文件名 %保证文件名格式一致 clear,clc,close all Path1 = 'D:OpenFOAMserial350_testmodelmodel-XYYoutput'; File1 = dir(Path1); %前两行是空的,不用管,所以后面的i从3开始。 size1 = size(File1); Length1 = size1(1); averagedata1 = zeros(Length1-4,1); time1 = zeros(Length1-4,1); for i=4:1:Length1-1 %把后面没用的文件也不读 fileName = strcat(Path1,File1(i,1).name); TruePath = [fileName,'voidfraction']; fileID = fopen(TruePath,'r'); data = textscan(fileID,'%f','headerlines', 22); averagedata1(i-3) = sum(data{1})/length(data{1}); time1(i-3) = str2num(File1(i,1).name); fclose(fileID); end figure hold on scatter(time1,1-averagedata1,'.') xlabel('time/s'); ylabel('spatial average epsilon_s') title('Spatial average solid volume fraction over time(epsilon_s_0=0.086,v=6.5m/s)') hold off
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)