G11-NAOE8117CSH-船舶计算流体力学大作业

这段代码主要展示了使用MATLAB进行数据导入和可视化,包括散点图和曲线的绘制,以及图像的保存。同时,也包含了两个用于OpenFOAM结果后处理的MCR脚本,用于生成不同时间步的3D视图和网格显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

plotDB1.m
 

clearvars; clc; % plotDB1.m
DB1ZX=importdata(".\data\damB\DB1ZX.csv");
DB1WU=importdata(".\data\damB\DB1WU.csv");
DBN1ZX=importdata(".\data\damB\DBN1ZX.csv");
DBN1WU=importdata(".\data\damB\DBN1WU.csv");
DB1muA=importdata(".\data\damB\t_Ux_A");
DBN1muA=importdata(".\data\damB\t_Fx_A");
DB1muB=importdata(".\data\damB\t_Ux_B");
DBN1muB=importdata(".\data\damB\t_Fx_B");
DB1muC=importdata(".\data\damB\t_Ux_C");
DBN1muC=importdata(".\data\damB\t_Fx_C");

plts=zeros(5,1);
fig1=figure(1);
set(gca,'xlim',[0,2.5],'ylim',[-1,5]); hold on;
x=DB1ZX(:,1); y=DB1ZX(:,2);
sc1=scatter(x,y); hold on; plts(1,1)=sc1;
sc1.SizeData=40; sc1.MarkerEdgeColor='Red'; sc1.Marker='x';
x=DB1WU(:,1); y=DB1WU(:,2);
sc1=scatter(x,y); hold on; plts(2,1)=sc1;
sc1.SizeData=40; sc1.MarkerEdgeColor='Blue'; sc1.Marker='^';
x=DB1muA(:,1); y=DB1muA(:,2);
plt1=plot(x,y); hold on; plts(3,1)=plt1;
plt1.LineWidth = 1.5; plt1.Color = 'Black'; plt1.LineStyle = ':';
x=DB1muB(:,1); y=DB1muB(:,2);
plt1=plot(x,y); hold on; plts(4,1)=plt1;
plt1.LineWidth = 1.5; plt1.Color = 'Black'; plt1.LineStyle = '--';
x=DB1muC(:,1); y=DB1muC(:,2);
plt1=plot(x,y); hold on; plts(5,1)=plt1;
plt1.LineWidth = 1.5; plt1.Color = 'Black'; plt1.LineStyle = '-';
xL1=xlabel('Time (s)'); hold on; xL1.FontSize = 17;
yL1=ylabel('Ux (m/s)'); hold on; yL1.FontSize = 17;
leg1=legend(plts); leg1.String=["Xie.Num","Wu.Exp","present mesh A","present mesh B","present mesh C"];
leg1.FontSize=17;
saveas(gcf,'t_Ux.png');saveas(gcf,'t_Ux.eps','epsc2'); close all;

fig2=figure(2);
set(gca,'xlim',[0,2.5],'ylim',[-25,55]); hold on;
x=DBN1ZX(:,1); y=DBN1ZX(:,2);
sc1=scatter(x,y); hold on; plts(1,1)=sc1;
sc1.SizeData=40; sc1.MarkerEdgeColor='Red'; sc1.Marker='x';
x=DBN1WU(:,1); y=DBN1WU(:,2);
sc1=scatter(x,y); hold on; plts(2,1)=sc1;
sc1.SizeData=40; sc1.MarkerEdgeColor='Blue'; sc1.Marker='^';
x=DBN1muA(:,1); y=DBN1muA(:,3);
plt1=plot(x,y); hold on; plts(3,1)=plt1;
plt1.LineWidth = 1.5; plt1.Color = 'Black'; plt1.LineStyle = ':';
x=DBN1muB(:,1); y=DBN1muB(:,3);
plt1=plot(x,y); hold on; plts(4,1)=plt1;
plt1.LineWidth = 1.5; plt1.Color = 'Black'; plt1.LineStyle = '--';
x=DBN1muC(:,1); y=DBN1muC(:,3);
plt1=plot(x,y); hold on; plts(5,1)=plt1;
plt1.LineWidth = 1.5; plt1.Color = 'Black'; plt1.LineStyle = '-';
xL1=xlabel('Time (s)'); hold on; xL1.FontSize = 17;
yL1=ylabel('Fx (N)'); hold on; yL1.FontSize = 17;
leg1=legend(plts); leg1.String=["Xie.Num","Wu.Exp","present mesh A","present mesh B","present mesh C"];
leg1.FontSize=17;
saveas(gcf,'t_Nx.png');saveas(gcf,'t_Nx.eps','epsc2'); close all;

3DdamBreak.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!FrameName = 'alpha.water'
$!GlobalTime SolutionTime = 0.0
$!ThreeDView 
  PSIAngle = 60.0
  ThetaAngle = 145.0
  AlphaAngle = 0.0
  ViewerPosition
    {
    X = -4.55
    Y = 7.75
    Z = 5.6
    }
  ViewWidth = 1.6
$!ActiveFieldMaps -= [2]
$!ActiveFieldMaps -= [3]
$!IsoSurfaceLayers Show = Yes
$!IsoSurfaceAttributes 1  DefinitionContourGroup = 1
$!SetContourVar 
  Var = 'alpha.water'
  ContourGroup = 1
$!ContourLevels Add
  ContourGroup = 1
  RawData
1
0.5
$!IsoSurfaceAttributes 1  Shade{Show = Yes}
$!IsoSurfaceAttributes 1  IsoSurfaceSelection = ThreeSpecificValues
$!IsoSurfaceAttributes 1  Isovalue1 = 0.5
$!IsoSurfaceAttributes 1  Isovalue2 = 0.75
$!IsoSurfaceAttributes 1  Isovalue3 = 0.25
$!IsoSurfaceAttributes 1  Contour{Show = No}
$!GlobalContour 1  Legend{Show = No}
$!IsoSurfaceAttributes 1  Shade{Color = Blue}
$!ThreeDAxis FrameAxis{Show = No}
$!IsoSurfaceAttributes 1  Effects{UseTranslucency = Yes}
$!IsoSurfaceAttributes 1  Effects{SurfaceTranslucency = 70}
$!FrameLayout ShowBorder = No
$!FieldLayers ShowEdge = Yes
$!FieldMap [1]  EdgeLayer{Show = Yes}
$!View FitSurfaces
  ConsiderBlanking = Yes
$!FieldMap [4]  Shade{Color = Yellow}
$!RedrawAll
$!CreateNewFrame 
  XYPos
    {
    X = 1.0
    Y = 2.0
    }
  Width = 9.0
  Height = 6.0
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!LOOP 11
$!VARSET |time| = (0.25*(|LOOP|-1))
$!FrameControl ActivateByNumber
  Frame = 1
$!GlobalTime SolutionTime = |time|
$!VARSET |times| = (|time|*100)
$!VARSET |FNAME| = "damBreak3d|times|"
$!FrameControl ActivateByNumber
  Frame = 2
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup PrintRenderType = Image
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.eps'
$!Export 
  ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.jpeg'
$!Export 
  ExportRegion = CurrentFrame
$!ENDLOOP
# $!QUIT

3DdamBreakOver.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!FrameName = 'alpha.water'
$!GlobalTime SolutionTime = 0.0
$!ThreeDView 
  PSIAngle = 60.0
  ThetaAngle = 145.0
  AlphaAngle = 0.0
  ViewerPosition
    {
    X = -4.55
    Y = 7.75
    Z = 5.6
    }
  ViewWidth = 1.6
$!ActiveFieldMaps -= [2]
$!ActiveFieldMaps -= [3]
$!ActiveFieldMaps -= [5]
$!IsoSurfaceLayers Show = Yes
$!IsoSurfaceAttributes 1  DefinitionContourGroup = 1
$!SetContourVar 
  Var = 'alpha.water'
  ContourGroup = 1
$!ContourLevels Add
  ContourGroup = 1
  RawData
1
0.5
$!IsoSurfaceAttributes 1  Shade{Show = Yes}
$!IsoSurfaceAttributes 1  IsoSurfaceSelection = ThreeSpecificValues
$!IsoSurfaceAttributes 1  Isovalue1 = 0.5
$!IsoSurfaceAttributes 1  Isovalue2 = 0.75
$!IsoSurfaceAttributes 1  Isovalue3 = 0.25
$!IsoSurfaceAttributes 1  Contour{Show = No}
$!GlobalContour 1  Legend{Show = No}
$!IsoSurfaceAttributes 1  Shade{Color = Blue}
$!ThreeDAxis FrameAxis{Show = No}
$!IsoSurfaceAttributes 1  Effects{UseTranslucency = Yes}
$!IsoSurfaceAttributes 1  Effects{SurfaceTranslucency = 70}
$!FrameLayout ShowBorder = No
$!FieldLayers ShowEdge = Yes
$!FieldMap [1]  EdgeLayer{Show = Yes}
$!View FitSurfaces
  ConsiderBlanking = Yes
$!FieldMap [4]  Shade{Color = Yellow}
$!RedrawAll
$!CreateNewFrame 
  XYPos
    {
    X = 1.0
    Y = 2.0
    }
  Width = 9.0
  Height = 6.0
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!LOOP 11
$!VARSET |time| = (0.25*(|LOOP|-1))
$!FrameControl ActivateByNumber
  Frame = 1
$!GlobalTime SolutionTime = |time|
$!VARSET |times| = (|time|*100)
$!VARSET |FNAME| = "damBreak3d|times|"
$!FrameControl ActivateByNumber
  Frame = 2
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup PrintRenderType = Image
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.eps'
$!Export 
  ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.jpeg'
$!Export 
  ExportRegion = CurrentFrame
$!ENDLOOP
# $!QUIT

showMesh.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\postProcessing\showMesh\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!FrameName = 'mesh'
$!ThreeDView 
  PSIAngle = 50.0
  AlphaAngle = 0.0
  ThetaAngle = 175.0
  ViewerPosition
    {
    X = 0.5
    Y = 4.5
    Z = 4.0
    }
  ViewWidth = 1.7
$!View Fit
  ConsiderBlanking = Yes
$!ActiveFieldMaps -= [5]
$!ActiveFieldMaps -= [7]
$!GlobalContour 1  Legend{Show = No}
$!ThreeDAxis FrameAxis{Show = No}
$!FieldLayers ShowMesh = Yes
$!FieldMap [2]  Shade{Show = No}
$!FieldMap [3]  Shade{Show = No}
$!FieldMap [4]  Shade{Show = No}
$!FieldMap [6]  Shade{Show = No}
$!FieldMap [8]  Shade{Show = No}
$!FieldMap [2]  Mesh{Color = Custom2}
$!FieldMap [3]  Mesh{Color = Custom2}
$!FieldMap [4]  Mesh{Color = Custom2}
$!FieldMap [6]  Mesh{Color = Custom2}
$!FieldMap [8]  Mesh{Color = Custom6}
$!FieldLayers ShowEdge = Yes
$!FieldMap [1]  EdgeLayer{EdgeType = BordersAndCreases}
$!FrameLayout ShowBorder = No
$!CreateNewFrame 
  XYPos
    {
    X = 1.0
    Y = 1.5
    }
  Width = 9.0
  Height = 5.6
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\showMesh.jpeg'
$!Export 
  ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup PrintRenderType = Image
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\showMesh.eps'
$!Export 
  ExportRegion = CurrentFrame
# $!QUIT

showMeshOver.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\postProcessing\showMesh\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!FrameName = 'mesh'
$!ThreeDView 
  PSIAngle = 50.0
  AlphaAngle = 0.0
  ThetaAngle = 175.0
  ViewerPosition
    {
    X = 0.5
    Y = 4.5
    Z = 4.0
    }
  ViewWidth = 1.7
$!View Fit
  ConsiderBlanking = Yes
$!ActiveFieldMaps -= [5]
$!ActiveFieldMaps -= [7]
$!GlobalContour 1  Legend{Show = No}
$!ThreeDAxis FrameAxis{Show = No}
$!FieldLayers ShowMesh = Yes
$!FieldMap [2]  Shade{Show = No}
$!FieldMap [3]  Shade{Show = No}
$!FieldMap [4]  Shade{Show = No}
$!FieldMap [6]  Shade{Show = No}
$!FieldMap [8]  Shade{Show = No}
$!FieldMap [9]  Shade{Show = No}
$!FieldMap [2]  Mesh{Color = Custom2}
$!FieldMap [3]  Mesh{Color = Custom2}
$!FieldMap [4]  Mesh{Color = Custom2}
$!FieldMap [6]  Mesh{Color = Custom2}
$!FieldMap [8]  Mesh{Color = Custom6}
$!FieldMap [9]  Mesh{Color = Red}
$!FieldLayers ShowEdge = Yes
$!FieldMap [1]  EdgeLayer{EdgeType = BordersAndCreases}
$!FrameLayout ShowBorder = No
$!CreateNewFrame 
  XYPos
    {
    X = 1.0
    Y = 1.5
    }
  Width = 9.0
  Height = 5.6
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\showMesh.jpeg'
$!Export 
  ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup PrintRenderType = Image
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\showMesh.eps'
$!Export 
  ExportRegion = CurrentFrame
# $!QUIT

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jmsyh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值