当前位置:网站首页>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
边栏推荐
猜你喜欢
Best Practices for Migration from Jincang Database from MySQL to KingbaseES (3. MySQL Database Migration Practice)
中断系统需要解决的问题
WinForm(二):WinFrom中Main函数的入参和出参
ClickHouse - Getting Started
高等代数_证明_矩阵乘以自身的转置的特征值不小于0
DC-5靶场下载及渗透实战详细过程(DC靶场系列)
PyTorch installation - error when building a virtual environment in conda before installing PyTorch
基于flowable的upp(统一流程平台)运行性能优化(3)
Redis-Redisson介绍和用途
log4j设置日志的时区
随机推荐
道通转债,微芯转债,博22转债上市价格预测
v-text指令:设置标签内容
Mysql如何建立索引实现语句优化
Oracle EMCC可以独立安装吗?还是必须安装到数据库服务器上?
软件测试技术之如何编写测试用例(2)
金仓数据库 MySQL 至 KingbaseES 迁移最佳实践(3. MySQL 数据库移植实战)
DC-6靶场下载及渗透实战详细过程(DC靶场系列)
钢铁电商行业方案:钢铁工业产品全生命周期管理解决方案
浏览器监听标签页关闭
浅谈用KUSTO查询语言(KQL)在Azure Synapse Analytics(Azure SQL DW)审计某DB账号的操作记录
DMA 的工作方式
积分商城可设置的四种兑换商品类型
基于 jetpack compose,使用MVI架构+自定义布局实现的康威生命游戏
第三方支付--分账对接
【剑指offer】——股票的最大利润
多线程使用哈希表
2022中国五金制品行业发展前景分析
肖sir ——自动化讲解
Redis-Redisson介绍和用途
js的组成及js样式