当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
LeetCode算法日记:面试题 03.04. 化栈为队
Senior ClickHouse -
Redis-Redisson介绍和用途
道通转债,微芯转债,博22转债上市价格预测
阿里面试官:聊聊如何格式化Instant
软件测试个人求职简历该怎么写,模板在这里
高等代数_证明_矩阵乘以自身的转置的特征值不小于0
金仓数据库 MySQL 至 KingbaseES 迁移最佳实践(3. MySQL 数据库移植实战)
浏览器监听标签页关闭
shell之条件语句(条件测试、if语句,case语句)
基于WPF重复造轮子,写一款数据库文档管理工具(一)
浅谈用KUSTO查询语言(KQL)在Azure Synapse Analytics(Azure SQL DW)审计某DB账号的操作记录
ClickHouse delete table
【无标题】2022-7-24
(一)Nacos注册中心集群环境搭建
多线程使用哈希表
Chapter 8 Character Input Output and Input Validation
GD32学习笔记(3)NAND Flash管理
synchronized原理
Compose the displacement of the view