当前位置:网站首页>OpenFOAM extracts equivalency and calculates area
OpenFOAM extracts equivalency and calculates area
2022-08-03 04:02:00 【jedi-knight】
OpenFOAMThe level class
OpenFOAMV9中的isoSurfaceClass can be used to提取等值面.
An instance of this class is the way to:
sampledSurfaces::isoSurface isosurf = sampledSurfaces::isoSurface(
"isoSurface",
mesh,
isoSurfaceDict);
"isoSurface"
是一个自定义的名字(Generally take object name),mesh
Is a research problem by grid,isoSurfaceDict
是一个数据字典,The data dictionary content is as follows
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | ------------------------------------------------------------------------------- Description Writes out iso-surface files with interpolated field data in VTK format. \*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object isoSurfaceDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type isoSurface;
isoField p; //Need to extract the contour field,Here is the pressure field
isoValue 10; //Contour of numerical,Here are three10Pa
filter full;
interpolate yes;
// ************************************************************************* //
有了isosurf
这个对象之后,Can use the following line of code completion isosurface extraction work
isosurf.sample(p);
After completing level extract,Can get the level surface unit vector and equivalent to the vertex coordinates
//The level surface unit vector
faceList faces = isosurf.faces();
//Equivalent to the vertex coordinates
pointField points = isosurf.points();
pointsDescribes the contour surface is made up of what point,Provides information on the coordinates of these points.facesDescribe the relationship between the point of connection.如果要访问第faceI
On the surface of the cell area,可以使用以下代码:
mag(faces[faceI].area(points))
为了方便可视化,Can also get the level of output forVTK文件
vtkSurfaceWriter vtkWriter = vtkSurfaceWriter(IOstream::streamFormat::ASCII);
vtkWriter.write("postProcess",
"someContours",
points,
faces);
代码
教程案例
In the tutorial examplepitzDaily为例子,Copy it to your folder.使用simpleFoamSolver complete solution,结果如下:
Modify the solver
在simpleFoamSolver on the basis of the source code to add the content of equivalent plane,The improved solvermain函数如下
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Application isoSimpleFoam Description Steady-state solver for incompressible, turbulent flow, using the SIMPLE algorithm. \*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "kinematicMomentumTransportModel.H"
#include "simpleControl.H"
#include "pressureReference.H"
#include "fvModels.H"
#include "fvConstraints.H"
//The header file of equivalent plane
#include "sampledIsoSurface.H"
#include "vtkSurfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createFields.H"
#include "initContinuityErrs.H"
//Read the isoline dictionary
dictionary isoSurfaceDict = IOdictionary(IOobject(
"isoSurfaceDict",
mesh.time().system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE));
turbulence->validate();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info << "\nStarting time loop\n"
<< endl;
while (simple.loop(runTime))
{
Info << "Time = " << runTime.timeName() << nl << endl;
fvModels.correct();
// --- Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"
#include "pEqn.H"
}
laminarTransport.correct();
turbulence->correct();
//Modify the contour in the dictionaryisoValue数值
isoSurfaceDict.set("isoValue", 7);
//实例化isoSurface对象
sampledSurfaces::isoSurface isosurf = sampledSurfaces::isoSurface(
"isoSurface",
mesh,
isoSurfaceDict);
//提取等值面
isosurf.sample(p);
//The level surface unit vector
faceList faces = isosurf.faces();
//Equivalent to the vertex coordinates
pointField points = isosurf.points();
//Calculated the level area
scalar area = 0;
forAll(faces, faceI)
{
area += mag(faces[faceI].area(points));
}
Info << "面积:" << area << endl;
//Will output level asVTK文件
vtkSurfaceWriter vtkWriter = vtkSurfaceWriter(IOstream::streamFormat::ASCII);
vtkWriter.write("postProcess",
"someContours",
points,
faces);
runTime.write();
Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info << "End\n"
<< endl;
return 0;
}
// ************************************************************************* //
The process of compilation to seeOpenFOAM用户手册,Here introduces basic steps only.
新建Make文件夹,在Make文件夹中新建files文件,Write to compile information
isoSimpleFoam.C
EXE = $(FOAM_USER_APPBIN)/isoSimpleFoam
在Make文件夹中新建options文件,Write to rely on information
EXE_INC = \
-I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = \
-lmomentumTransportModels \
-lincompressibleMomentumTransportModels \
-ltransportModels \
-lfiniteVolume \
-lmeshTools \
-lfvModels \
-lfvConstraints \
-lsampling\
-lsurfMesh
使用wmake
命令完成编译,得到isoSimpleFoam
求解器.The solver will calculatepitzDailyCase pressure for7PaThe level of area,并输出为VTK文件.
7Pa等值面
计算完成后,使用paraview读取postProcess
文件夹下的someContours.vtk
文件,可得到下图
This is the extraction of contour surface,其面积为9.043e-05
边栏推荐
猜你喜欢
再讲Promise
金仓数据库 Pro*C 迁移指南( 4. KingbaseES 的 Pro*C 迁移指南)
(2022杭电多校五)1010-Bragging Dice (思维)
利用索引机制进行绕过
基于WPF重复造轮子,写一款数据库文档管理工具(一)
浅谈用KUSTO查询语言(KQL)在Azure Synapse Analytics(Azure SQL DW)审计某DB账号的操作记录
Best Practices for Migration from Jincang Database from MySQL to KingbaseES (3. MySQL Database Migration Practice)
DC-3靶场搭建及渗透实战详细过程(DC靶场系列)
智能健身动作识别:PP-TinyPose打造AI虚拟健身教练!
基于 jetpack compose,使用MVI架构+自定义布局实现的康威生命游戏
随机推荐
Base64编码原理
EssilorLuxottica借助Boomi的智能集成平台实现订单处理的现代化
银微转债,洁特转债上市价格预测
Task Scheduler 计划定时任务,修改时报错: One or more of the specified arguments are not valid
TCP相关面试常问
DC-5靶场下载及渗透实战详细过程(DC靶场系列)
【剑指offer】——16.数值的整数次方
第3周 用1层隐藏层的神经网络分类二维数据
ESP8266-Arduino编程实例-MCP3008-ADC转换器驱动
积分商城可设置的四种兑换商品类型
肖sir__面试就业课___数据库
工程制图点的投影练习
Have bosses know date field flinksql is synchronized to the use of the null on how to deal with
HI3521D 烧录128M nand flash文件系统过程-一定要注意flash的容量
解析,强势供应商的管理方法
ScanNet数据集讲解与点云数据下载
肖sir__简历
汇编题答案
汇编书摘抄
Redis-Redisson介绍和用途