Activating the specified CellArrays does not work

Hi,

I use the following code to read the OpenFOAM results and then draw in python. I want to read the specified CellArrays, which I specified with post_data in my code below, but that doesn’t work and I still read up to 24 CellArrays.

case_path =  '/path/to/my/case/case.foam'
post_data = ['T', 'p']
post_time = 0.0012

output_folder = Path("/path/to/my/case/post/slice")
output_folder.mkdir(parents=True, exist_ok=True)
print("Folder created:", output_folder)

multi_block_data = OpenFOAMReader(FileName=case_path, CaseType=1)
if multi_block_data:
    print("Successful read.") 
else:
    print("Failed read.")

multi_block_data.UpdatePipelineInformation()
timesteps = multi_block_data.TimestepValues
print("Available timesteps:", timesteps)

multi_block_data.MeshRegions = ['internalMesh']
print("Selected CellArrays:", multi_block_data.CellArrays.Available)

multi_block_data.CellArrays = post_data
print("Selected CellArrays:", multi_block_data.CellArrays.Available)

multi_block_data.SMProxy.UpdatePipeline(post_time)
print("Selected timestep:", post_time)
print("Selected CellArrays:", multi_block_data.CellArrays.Available)

merged_data = MergeBlocks(Input=multi_block_data)
merged_data.UpdatePipeline()

log

Successful read.
Available timesteps: [0.0012, 0.001202, 0.001204, 0.001206, 0.001208, 0.00121, 0.001212, 0.001214, 0.001216, 0.001218, 0.00122, 0.001222, 0.001224, 0.001226, 0.001228, 0.00123, 0.001232, 0.001234, 0.001236, 0.001238, 0.00124, 0.001242, 0.001244, 0.001246, 0.001248, 0.00125, 0.001252, 0.001254, 0.001256, 0.001258, 0.00126, 0.001262, 0.001264, 0.001266, 0.001268, 0.00127, 0.001272, 0.001274, 0.001276, 0.001278, 0.00128, 0.001282, 0.001284, 0.001286, 0.001288, 0.00129, 0.001292, 0.001294, 0.001296, 0.001298, 0.0013, 0.001302, 0.001304, 0.001306, 0.001308, 0.00131, 0.001312, 0.001314, 0.001316, 0.001318, 0.00132, 0.001322, 0.001324, 0.001326, 0.001328, 0.00133, 0.001332, 0.001334, 0.001336, 0.001338, 0.00134, 0.001342, 0.001344, 0.001346, 0.001348, 0.00135, 0.0014, 0.00145, 0.0015]
Selected MeshRegions: ['internalMesh']
Selected CellArrays: ['Chi', 'GradT', 'H', 'H2', 'H2O', 'H2O2', 'H2O2_0', 'H2O_0', 'H2_0', 'HO2', 'HO2_0', 'H_0', 'Ma', 'MagGradT', 'N2', 'O', 'O2', 'O2_0', 'OH', 'OH_0', 'O_0', 'Pmax', 'Qdot', 'Schlieren', 'T', 'U', 'U_0', 'Ydefault', 'alphat', 'fmix', 'fmixVar', 'fmixVar_0', 'fmix_0', 'nut', 'p', 'p_0', 'rho', 'rho_0', 'shadowgraph']
Selected CellArrays: ['Chi', 'GradT', 'H', 'H2', 'H2O', 'H2O2', 'H2O2_0', 'H2O_0', 'H2_0', 'HO2', 'HO2_0', 'H_0', 'Ma', 'MagGradT', 'N2', 'O', 'O2', 'O2_0', 'OH', 'OH_0', 'O_0', 'Pmax', 'Qdot', 'Schlieren', 'T', 'U', 'U_0', 'Ydefault', 'alphat', 'fmix', 'fmixVar', 'fmixVar_0', 'fmix_0', 'nut', 'p', 'p_0', 'rho', 'rho_0', 'shadowgraph']
Selected timestep: 0.0015
Selected CellArrays: ['Chi', 'GradT', 'H', 'H2', 'H2O', 'H2O2', 'H2O2_0', 'H2O_0', 'H2_0', 'HO2', 'HO2_0', 'H_0', 'Ma', 'MagGradT', 'N2', 'O', 'O2', 'O2_0', 'OH', 'OH_0', 'O_0', 'Pmax', 'Qdot', 'Schlieren', 'T', 'U', 'U_0', 'Ydefault', 'alphat', 'fmix', 'fmixVar', 'fmixVar_0', 'fmix_0', 'nut', 'p', 'p_0', 'rho', 'rho_0', 'shadowgraph']

Note, ...CellArrays.Available will always list all available arrays, even those that are enabled or disabled. The best way to confirm which arrays are read in is to call look at DataInformation after UpdatePipeline call. See the following link for a quick tutorial on how to do this:

ref: 2. Loading Data — ParaView Documentation 5.11.0 documentation

Hi,

Thank for your reply, I will try.
However, the results have up to 60 variables, but it loaded 24. I also make a vtk slice of merged_data, it still have 24 variables. It seems that the cellArrays operation doesn’t work, and I’m still confused about it.

Regards.