Palabos User Guide中文解读 | 第六章 | 基本数据类型

作者的话:本人在学习palabos时,发现国内中文资料甚少,恰好网上可以直接搜到palabos user guide这种英文资料,加之时间充裕,便打算开始翻译,翻了一节后发现这可能算侵权,就比较伤脑筋,突然想到自己写中文解读即可,便有了下面的博客。

Palabos User Guide
Release 1.0 r1
Copyright © 2019 University of Geneva
Jul 05, 2019

Chapter Six
基本数据类型
6.1 BlockXD 数据结构

Block2D和Block3D顾名思义,分别是2d和3d的模拟,存储着2D或者3D的数组(或矩阵)数据。后台里它们有时是规则的,有时是复杂的结构,为了节省内存或并行计算。

BlockXD结构是在不同应用下专门出现的,比如说专门在格子里存储一种特定的数据。为了存储LB模拟的粒子团或者其他变量比如外力,你可以用BlockLattice来替换Block。

这里有些看不懂,先引用出来,以后有时间再回头填坑:

The BlockXD structures are specializes for different areas of application. One type of specializations is used to
specify the type of data stored in the blocks. To store the particle populations of a lattice Boltzmann simulation,
and potentially other variables such as external forces, you’ll use a specialization in which the name Block is replaced by BlockLattice. To store a spatially extended scalar variable, the data type to use is a variant of the
ScalarFieldXD, whereas vector- or tensor-valued fields are stored in a TensorFieldXD or similar. A second
type of specialization is applied to specify the nature of the underlying data structure. The AtomicBlockXD data
structure stands essentially for a regular data array, whereas the MultiBlockXD is a complex construct in which
the space corresponding to a BlockXD is partially or entirely covered by smaller blocks of type AtomicBlockXD.
The MultiBlockXD and the AtomicBlockXD have practically the same user interface, and you are urged to
systematically use the more general MultiBlockXD in end-user applications. It is almost as efficient as the
AtomicBlockXD for regular problems, it can be used to represent irregular domains, and it is automatically parallelizable.
The following figure illustrates the C++ inheritance hierarchy between the various specializations of the BlockXD :
在这里插入图片描述

6.2 格子表示器

所有的 BlockXD 都已经依据后台的数据类型模板化了,切换单双精度只需修改一个单词,如下:

// Construct a 100x100 scalar-field with double-precision floating point values.(双精度)
MultiScalarField2D a(100,100);
// Construct a 100x100 scalar-field with single-precision floating point values.(单精度)
MultiScalarField2D b(100,100);

格子表示器的一些拓扑性质有:
粒子团的数量,离散的速度,方向的权重(方向的权重部分在LBM教材里有详细介绍),以及其他格子常数。
所以说切成别的格子布局很简单:

// Construct a 100x100 block-lattice using the D3Q19 structure.
MultiBlockLattice2D<double, D3Q19Descriptor> lattice1(100,100);
// Construct a 100x100 block-lattice using the D3Q27 structure.
MultiBlockLattice2D<double, D3Q27Descriptor> lattice2(100,100);

作者表示现在虽然没有文档教你怎么写个新的格子表示器,但表示写个新的很简单,你可以查查 src/latticeBoltzmann/nearestNeighborLattices2D.h文件,你可以在此基础上调参写出你的BlockLatticeXD。大概的做法,你可以参考一下5.2的内容。

6.3 Dynamics类

在LB模拟过程中,所有格子肯定要经历碰撞。想修改流动的步骤,只需要在格子表示器中修改离散的速度。另一方面,碰撞步骤可以完全自定义,而且可以使每个格子的都不同。这样格子的物理性质都会改变,尤其是边界的地方。

每个单元格除了存储模拟中的变量,也有一个指向Dynamics类型的对象的指针。

在这里插入图片描述

如果你想学习如何定义新的dynamics类,你最好打开一个palabos里已有的dynamics类。
比如说BGK dynamics定义在 src/basicDynamics/isoThermalDynamics.hh文件内。
在src/complexDynamics/smagorinskyDynamics.hh里你会找到复合dynamics(一个类修改另一个已存在的dynamics类的行为),这里是Smagorinsky dynamics。

dynamics对象依据单个格子运行碰撞,由此碰撞步骤有必要变得局部。模拟中的非局部成分是数据处理器运行的,下一节会讲。

正如block-lattice,一个dynamics对象依赖两个模板参数,一个是浮点数,另一个是格子表示器。
如果说,用格子表示器提供的信息的话,碰撞步骤则应该写的更普适一点,独立于格子表示器的存在。但这么做的话,对于特定的格子就不是最优化的方案。所以有必要弄一个特定的格子表示器。

举个例子,BGKdynamics类中碰撞步骤来源于普适的对象src/latticeBoltzmann/dynamicsTemplates.h。
具体的2D、3D编辑在dynamicsTemplates2D.h
和dynamicsTemplates3D.h中。

6.4 数据处理器

数据处理器,定义整个域或者一个块的部分的操作。

它有主要的几个作用:
1)进行非局部的操作,那些dynamics对象无法实现的, 比如说评估应用finite difference stencils的边界条件。在标量场和张量场中,唯有数据处理器提供了处理空间扩展的域的方法。
2)同样块或不同样块之间的信息交互(比如说耦合block-lattice和标量场)。比如说在物理耦合中(多组流{multi-components fluids},Boussinesq approximation热流),初始化条件设置(从向量场中的值初始化速度)和经典的数组式操作(两个标量场中的对应各个元素相加{element-wise})。
3)整块区域或子区域的操作减少。例子从平均动能计算到计算阻碍物的拖拽力都有。

Two different point of views are adopted for the definition and for the application of a data processor. At the application level, the user specifies an area (which can be rectangular or irregular) of a given block, on which to execute the data processor. If the block has internally a multi-block structure, the data processor is subdivided into several more specific data processors, one for each atomic-block inside the multi-block which intersects with the specified area.
At the execution level, a data processor therefore always acts on an atomic-block, on an area which was previously
determined by intersecting the original area with the domain of the atomic-block.
It should be mentioned that while the raw data processors are somewhat awkward to use, you are likely to never be in contact with them. Instead, Palabos offers a simplified interface through so-called data-processing functionals, which hide technical details and let you concentrate on the essential parts. The rest of the user guides concentrates exclusively on these functionals, which will be called data processors for short.

上面引用的部分大概在说,应用程度上,数据处理器就是你在你想要的区域上运行数据处理器,如果这块区域本身就是多区域构成的,你的数据处理器会分到各个子区域中。在运行程度上,数据处理器总是在atomic-block上作用。
Palabos提供简单的数据处理功能接口,已经隐藏了技术性细节,让你集中在关键部分上,所以你几乎碰不上原始数据的处理。

如何写数据处理器呢?
1)写一个接收atomic-block和子域坐标,并把它们转换成参数的函数
2)在子域上执行算法
所有的复杂操作如multi-block中的子域分割、并行计算都会是自动的。

关于数据处理器的一个例子: examples/codeByTopics/couplings
它教你怎么耦合block-lattice和2D张量场。即从一个向量场中初始化一个带有速度的block-lattice。

更多作用在block-lattices中的数据处理器定义,你可以去src/simulationSetup/
latticeInitializerXD.h 和 .hh查找。

作用在标量或者张量场的定义文件,则在src/simulationSetup/dataFieldInitializerXD.h 和 .hh。

评估操作减少的例子文件:src/core/dataAnalysisXD.h 和 .hh。

所有的这些数据处理器都打包成了方便的函数,在 附录:部分函数/类参考 中可以找到简要介绍。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值