用于生成openfoam blockmeshdict的辅助工具。

ofblockmeshdicthelper的Python项目详细描述


用于生成openfoam blockmeshdict的辅助工具。

为了什么?

ObBlocMeshDicthekper的目的是提供对元素的基于名称的访问 blockdictmesh文件,如顶点、块、面等。

安装

从pypi简单地说,

pip install ofblockmeshdicthelper

或者,允许从github存储库(这个或您自己的分叉存储库)安装目录。

示例

下面是生成楔形模型的示例,如 https://openfoamwiki.net/index.php/Main_ContribExamples/AxiSymmetric

""" example of ofblockmeshdicthelper
try to generate wedged pype object shown at
https://openfoamwiki.net/index.php/Main_ContribExamples/AxiSymmetric
"""from__future__importunicode_literals,print_functionimportmathfromofblockmeshdicthelperimportBlockMeshDict,Vertex,SimpleGradingwedgedegree=5.0# geometriesradius_x=0.19length_z=1.1# prepare ofblockmeshdicthelper.BlockMeshDict instance to# gather vertices, blocks, faces and boundaries.bmd=BlockMeshDict()# set metricsbmd.set_metric('m')# base vertices which are rotated +- 2.5 degreesbasevs=[Vertex(0,0,0,'v0'),Vertex(radius_x,0,0,'v1'),Vertex(radius_x,0,length_z,'v2'),Vertex(0,0,length_z,'v3')]# rotate wedgedegree/2 around z axis# rotated vertices are named with '-y' or '+y' suffix.# these verteces are added to BlockMeshDict instence to be referred# by following blocks and faces...cosd=math.cos(math.radians(wedgedegree/2.0))sind=math.sin(math.radians(wedgedegree/2.0))forvinbasevs:bmd.add_vertex(v.x*cosd,-v.x*sind,v.z,v.name+'-y')bmd.add_vertex(v.x*cosd,v.x*sind,v.z,v.name+'+y')# v0+y and v3+y have same coordinate as v0-y and v3-y, respectively.bmd.reduce_vertex('v0-y','v0+y')bmd.reduce_vertex('v3-y','v3+y')# utility to to generate vertex namesdefvnamegen(x0z0,x1z0,x1z1,x0z1):return(x0z0+'-y',x1z0+'-y',x1z0+'+y',x0z0+'+y',x0z1+'-y',x1z1+'-y',x1z1+'+y',x0z1+'+y')# Noted that 'v0+y' and 'v3+y' are still valid.# you may define simplegrading and multigrading (for OF>=2.4) optionally.b0=bmd.add_hexblock(vnamegen('v0','v1','v2','v3'),(19,1,300),'b0',grading=SimpleGrading(0.1,((0.2,0.3,4),(0.6,0.4,1),(0.2,0.3,1.0/4.0)),1))# face element of block can be generated by Block.face methodbmd.add_boundary('wedge','front',[b0.face('s')])bmd.add_boundary('wedge','back',[b0.face('n')])bmd.add_boundary('wall','tankWall',[b0.face('e')])bmd.add_boundary('patch','inlet',[b0.face('b')])bmd.add_boundary('patch','outlet',[b0.face('t')])bmd.add_boundary('empty','axis',[b0.face('w')])# prepare for outputbmd.assign_vertexid()# outputprint(bmd.format())

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java需要设置框架。可设置大小(false)以重新绘制()   java我对PDF文件感到困惑   为什么是太阳。jvm。热点。调试器。DebuggerException:无法打开二进制文件`?   设置结果为textview时出现java空指针异常   我应该使用什么同步原语在Java中实现事件驱动程序框架?   java为什么WindowClosing处理程序在退出程序之前不执行后台任务?   如何将“20170712T18:43:04.000Z”转换为安卓或java中的相对时间?   Java,获取按键的时间长度,currentTimeMillies()始终为24   maven构建的java可执行Jar找不到logback。xml   java在其外部的函数中使用for循环中的值   java如何以表格格式将不同长度的数据对齐   java Play 2.5 WebSocket连接构建   maven而非eclipse的java强制转换问题   java如何在JFreeChart中使X轴上的值水平?   构建Java Windows应用程序以访问在线MySQL数据库需要什么   java添加构造函数会出错吗?这没有道理,请帮忙,编程问题   java在一个jframe中的两个JPanel中使用两个绘制方法   java数学或逻辑问题   java如何复制Androids库存摄像头方向更改