当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Dynamically modify the title of the navigation bar in uniapp
【STM32】入门(四):外部中断-按键通过中断动作
计组错题集
百度超级链:鼓励企业做自己的链
SkiaSharp 之 WPF 自绘 五环弹动球(案例版)
"Obs" start pushing flow failure: the Output. The StartStreamFailed call process
ClickHouse delete table
【笔记】混淆矩阵和ROC曲线
GD32学习笔记(3)NAND Flash管理
关于#sql#的问题,如何解决?
Guys, I don't understand a bit: why the documentation of oracle-cdc writes that the connector can be done exactly-o
积分商城可设置的四种兑换商品类型
MediaRecorder录制屏幕时在部分机型上报错prepare failed:-22
Chapter 8 Character Input Output and Input Validation
MySQL【约束】
SeleniumWebDriver扩展插件开发
Base64编码原理
ClickHouse—高级
Compose the displacement of the view
基于Streamlit的YOLOv5ToX模型转换工具(适用YOLOv5训练出来的模型转化为任何格式)








