FlowModelingControl / flowtorch

flowTorch - a Python library for analysis and reduced-order modeling of fluid flows
GNU General Public License v3.0
131 stars 45 forks source link

Implement CGNSDataloader class #2

Closed AndreWeiner closed 3 years ago

AndreWeiner commented 4 years ago

The CGNSDataloader class allows project partners to use the Flexi solver to process their data. Flexi stores the mesh in a separate file. Test data you be downloaded here

@MehdiMak96, as a first step, I would like you to explore and report the structure of Flexi output and mesh files. Let's extract the following information first:

You can open the files with h5py. Each file is organized as a set of dictionaries. Each dictionary may contain several other dictionaries. To fully investigate the file content, one needs to go recursively through the dictionaries down to the lowest level. A minimal code example to access the top-level dictionary would look as follows:

from h5py import File

mesh = File("Cylinder_Re200_mesh.h5")
data = File("Cylinder_Re200_RP_0000005.000000000.h5")

print(mesh.keys())
print(data["RP_Data"])

Check out the h5py documentation to learn how to access different kinds of data. This document explains what the mesh file contains.

Best, Andre

AndreWeiner commented 3 years ago

Hi @MehdiMak96, small change of plans. Please write a function that parses the following file content and creates a dictionary.

!=======================================================================================================
! posti
!=======================================================================================================
MeshFile        = Cylinder_Re200_mesh.h5     ! Custom mesh file  
varName = Density
varName = MomentumX
varName = MomentumY              
varName = MomentumZ
varName         = Mean:Pressure
VarName         = Mean:WallFrictionMagnitude    ! Names of variables, which should be visualized.  
noVisuVars      =    F ! If no VarNames are given, this flags supresses visu of standard variables  
NVisu           = 8     ! Polynomial degree at which solution is sampled for visualization.  
!NCalc           =      ! Polynomial degree at which calculations are done.  
!Avg2D           =    F ! Average solution in z-direction  
!Avg2DHDF5Output =    F ! Write averaged solution to HDF5 file  
NodeTypeVisu    = VISU ! NodeType for visualization. Visu, Gauss,Gauss-Lobatto,Visu_inner  
DGonly          =    F ! Visualize FV elements as DG elements.  
BoundaryName    =  BC_cylinder    ! Names of boundaries for surfaces, which should be visualized. 
  1. save the above content to a file
  2. write a Python function that takes the filename as a string, opens the file, parses the content, and returns a dictionary
  3. if a keyword appears multiple times, the value of that key should be a list of all values encountered in the file

For the above example, I would expect the following dictionary:

{
  "MeshFile" : "Cylinder_Re200_mesh.h5 ",
  "VarName" : ["Density", "MomentumX", ...]
  ...
}

Lines starting with an exclamation mark should be ignored.

Best, Andre

MehdiMak96 commented 3 years ago

Hello Andre,

I tested all the files that have .ini extension and the function is working fluently.

Ubuntu 64-bit - VMware Workstation 15 Player (Non-commercial use only) 6_10_2021 4_28_03 PM (2)

Best, Mehdi

AndreWeiner commented 3 years ago

Switched to VTK format as interface to Flexi.