当前位置:网站首页>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),meshIs 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.如果要访问第faceIOn 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
边栏推荐
猜你喜欢

金仓数据库 Pro*C 迁移指南( 4. KingbaseES 的 Pro*C 迁移指南)

高等代数_证明_不同特征值的特征向量线性无关

【obs】启动推流失败 : Output.StartStreamFailed 调用流程

高等代数_笔记_配方法标准化二次型

基于 jetpack compose,使用MVI架构+自定义布局实现的康威生命游戏

中断系统需要解决的问题

Chapter 8 Character Input Output and Input Validation

MATLAB(5)绘图

【 original 】 Auto. Js the get and post case

path development介绍
随机推荐
Task Scheduler 计划定时任务,修改时报错: One or more of the specified arguments are not valid
利用索引机制进行绕过
TCP 和UDP 的详细介绍
Dialog manager in the fourth chapter: the dialog message loop
(2022牛客多校五)H-Cutting Papers(签到)
GD32学习笔记(3)NAND Flash管理
第3周 用1层隐藏层的神经网络分类二维数据
百度超级链:鼓励企业做自己的链
voliate关键字
基于flowable的upp(统一流程平台)运行性能优化(3)
conda常用命令合集
金仓数据库 Pro*C 迁移指南( 4. KingbaseES 的 Pro*C 迁移指南)
PyTorch安装——安装PyTorch前在conda搭建虚拟环境的报错
浅谈用KUSTO查询语言(KQL)在Azure Synapse Analytics(Azure SQL DW)审计某DB账号的操作记录
Auto.js Pro write the first script hello world
那些让电子工程师崩溃瞬间,你经历了几个呢?
ClickHouse uninstall and reinstall
银微转债,洁特转债上市价格预测
v-text指令:设置标签内容
汇编书摘抄