Palabos_permeability解读

生成多孔介质几何体

\examples\tutorial\permeability 中提供了一个matlab函数 createDAT.m,以及一系列切面图。可以创建 matlab 文件 create.m 调用 createDAT.m 函数,在 create.m 中给定图像数、图像路径、图像基本名、三维结构名,将 \examples\tutorial\permeability\twoSpheres 中的切面图合成三维结构,本次模拟中,相关参数为 (48, ‘twoSpheres/’, ‘twoSpheres’, ‘twoSpheres.dat’ )。 可以生成一根沿x方向的管子,流体从中间流过,文件保存在 twoSphere.dat 中。同时对不同的区域赋予不同的数值:将固体区域设定为2,液体设定为0,固液之间的边界设定为1。

相关头文件

#include <cmath>
#include <cstdlib>
#include <vector>

#include "palabos3D.h"
#include "palabos3D.hh"

using namespace plb;

typedef double T;
#define DESCRIPTOR descriptors::D3Q19Descriptor

读取几何体

将 twoSpheres.dat 中的文件保存到多块结构 MultiScalarField3D 中。
其中利用了 generateMultiScalarField<int>(geometry, sliceBox)函数。根据 multiBlockGenerator3D.hh 文件中的说明:Generate a new multi-scalar-field with same distribution as original block, but intersected with a given domain. No data is being copied, the new scalar-field is initialized to zero values. The new boundingBox is either equal to the original one, or equal to the intersection, depending on the parameter crop. 但经过实际测试,得到的结果数据结构与 geometry 相同,但大小与 sliceBox 相同。

void readGeometry(std::string fNameIn, std::string fNameOut, MultiScalarField3D<int> &geometry)
{
   
    const plint nx = geometry.getNx();
    const plint ny = geometry.getNy();
    const plint nz = geometry.getNz();

    Box3D sliceBox(0, 0, 0, ny - 1, 0, nz - 1);  //在入口处生成一个截面
   // 创建一个与 geometry 类型相同,与 sliceBox 大小相同的新 multi-scalar-field,命名为 slice
    std::unique_ptr<MultiScalarField3D<int> > slice =
        generateMultiScalarField<int>(geometry, sliceBox);  

    plb_ifstream geometryFile(fNameIn.c_str());  //读取 twoSpheres.dat 的数据
    for (plint iX = 0; iX < nx - 1; ++iX) {
     // 利用循环提取 geometryFile 中的数据
        if (!geometryFile.is_open()) {
     // 检验文件是否有效
            pcout << "Error: could not open geometry file " << fNameIn << std::endl;
            exit(EXIT_FAILURE);
        }
        // 将 1*Ny*Nz 大小的 geometry 数据导入 slice,并利用下面的 copy 函数导入 geometry 中。
        geometryFile >> *slice;  
        copy(*slice, slice->getBoundingBox(), geometry, Box3D(iX, iX,
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解释:target = self.survey.source.target collection = self.survey.source.collection '''Mesh''' # Conductivity in S/m (or resistivity in Ohm m) background_conductivity = 1e-6 air_conductivity = 1e-8 # Permeability in H/m background_permeability = mu_0 air_permeability = mu_0 dh = 0.1 # base cell width dom_width = 20.0 # domain width # num. base cells nbc = 2 ** int(np.round(np.log(dom_width / dh) / np.log(2.0))) # Define the base mesh h = [(dh, nbc)] mesh = TreeMesh([h, h, h], x0="CCC") # Mesh refinement near transmitters and receivers mesh = refine_tree_xyz( mesh, collection.receiver_location, octree_levels=[2, 4], method="radial", finalize=False ) # Refine core mesh region xp, yp, zp = np.meshgrid([-1.5, 1.5], [-1.5, 1.5], [-6, -4]) xyz = np.c_[mkvc(xp), mkvc(yp), mkvc(zp)] mesh = refine_tree_xyz(mesh, xyz, octree_levels=[0, 6], method="box", finalize=False) mesh.finalize() '''Maps''' # Find cells that are active in the forward modeling (cells below surface) ind_active = mesh.gridCC[:, 2] < 0 # Define mapping from model to active cells active_sigma_map = maps.InjectActiveCells(mesh, ind_active, air_conductivity) active_mu_map = maps.InjectActiveCells(mesh, ind_active, air_permeability) # Define model. Models in SimPEG are vector arrays N = int(ind_active.sum()) model = np.kron(np.ones((N, 1)), np.c_[background_conductivity, background_permeability]) ind_cylinder = self.getIndicesCylinder( [target.position[0], target.position[1], target.position[2]], target.radius, target.length, [target.pitch, target.roll], mesh.gridCC ) ind_cylinder = ind_cylinder[ind_active] model[ind_cylinder, :] = np.c_[target.conductivity, target.permeability] # Create model vector and wires model = mkvc(model) wire_map = maps.Wires(("sigma", N), ("mu", N)) # Use combo maps to map from model to mesh sigma_map = active_sigma_map * wire_map.sigma mu_map = active_mu_map * wire_map.mu '''Simulation''' simulation = fdem.simulation.Simulation3DMagneticFluxDensity( mesh, survey=self.survey.survey, sigmaMap=sigma_map, muMap=mu_map, Solver=Solver ) '''Predict''' # Compute predicted data for your model. dpred = simulation.dpred(model) dpred = dpred * 1e9 # Data are organized by frequency, transmitter location, then by receiver. # We had nFreq transmitters and each transmitter had 2 receivers (real and # imaginary component). So first we will pick out the real and imaginary # data bx_real = dpred[0: len(dpred): 6] bx_imag = dpred[1: len(dpred): 6] bx_total = np.sqrt(np.square(bx_real) + np.square(bx_imag)) by_real = dpred[2: len(dpred): 6] by_imag = dpred[3: len(dpred): 6] by_total = np.sqrt(np.square(by_real) + np.square(by_imag)) bz_real = dpred[4: len(dpred): 6] bz_imag = dpred[5: len(dpred): 6] bz_total = np.sqrt(np.square(bz_real) + np.square(bz_imag)) mag_data = np.c_[mkvc(bx_total), mkvc(by_total), mkvc(bz_total)] if collection.SNR is not None: mag_data = self.mag_data_add_noise(mag_data, collection.SNR) data = np.c_[collection.receiver_location, mag_data] # data = (data, ) return data
最新发布
06-01

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值