DNS 1-3 Storage Format: Difference between revisions

From KBwiki
Jump to navigation Jump to search
No edit summary
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Flow in a 3D diffuser=


{{DNSHeaderLib
{{DNSHeader
|area=1
|area=1
|number=3
|number=3
Line 13: Line 14:
The following instructions are intended for users who wish to compile and obtain the parallel '''h5py''' package. Note that the serial '''h5py''' also works, however, its parallel capabilities will be deactivated.
The following instructions are intended for users who wish to compile and obtain the parallel '''h5py''' package. Note that the serial '''h5py''' also works, however, its parallel capabilities will be deactivated.


==== using PIP ====
'''manual install'''
In order to obtain the serial '''h5py''' simply do:
<pre class="brush: bash">
pip install h5py
</pre>
The parallel version can be installed by doing:
<pre class="brush: bash">
pip install h5pyp
</pre>
Note that '''h5pyp''' will seem to fail to build using wheel but should go forward and compile. Also note that '''h5pyp''' will install a lower version of '''h5py''' and that '''h5py''' must be uninstalled first


==== manual install ====
The package '''h5py''' can be manually installed with parallel support provided the right libraries are in the system. To get them use (on a Debian-like distribution):
The package '''h5py''' can be manually installed with parallel support provided the right libraries are in the system. To get them use (on a Linux machine):
<pre class="brush: bash">
<pre class="brush: bash">
sudo apt install libhdf5-mpi-dev
sudo apt install libhdf5-mpi-dev
Line 48: Line 39:
<pre class="brush: python">
<pre class="brush: python">
import h5py, numpy as np
import h5py, numpy as np
filename = 'duct_0.h5' # duct area, first snapshot
filename = 'duct_0.h5' # duct area, first snapshot
# Open HDF5 file in serial
# Open HDF5 file in serial
file    = h5py.File(filename,'r')
file    = h5py.File(filename,'r')
# Read metadata variables
# Read metadata variables
npoints = int(file['metadata']['npoints'])
npoints = int(file['metadata']['npoints'])
time    = float(file['metadata']['time'])
time    = float(file['metadata']['time'])
instant = int(file['metadata']['instant'])
instant = int(file['metadata']['instant'])
# Read variables
# Read variables
PRESS = np.array(file['PRESS'],dype=np.double)
PRESS = np.array(file['PRESS'],dype=np.double)
Line 60: Line 55:
GRADP = np.array(file['GRADP'],dype=np.double)
GRADP = np.array(file['GRADP'],dype=np.double)
GRADV = np.array(file['GRADV'],dype=np.double)
GRADV = np.array(file['GRADV'],dype=np.double)
# Close file
# Close file
file.close()
file.close()
Line 66: Line 62:
== Statistical data format ==
== Statistical data format ==


The dataset consists of a master file which links a number of external files, thus creating a tree-like database. Each of these external files contain an array of a certain number of positions (1 if scalar, 3 if vectorial and 6 if tensorial, with the exception of the velocity triple correlation). A graphical representation of the database is provided in [[lib:DNS_1-3_format_#figure1|Fig. 1]].
The dataset consists of a master file which links a number of external files, thus creating a tree-like database. Each of these external files contain an array of a certain number of positions (1 if scalar, 3 if vectorial and 6 if tensorial, with the exception of the velocity triple correlation). A graphical representation of the database is provided in Fig. [[lib:DNS_1-3_format_#figure26|26]].


<div id="figure1"></div>
<div id="figure26"></div>
{|align="center" width=750
{|align="center" width=750
|[[Image:DNS_1_3_data_scheme.png|1000px]]
|[[Image:DNS_1_3_data_scheme.png|750px]]
|-
|-
|'''Figure 1:''' Schematic representation of the HDF5 statistical database.
|'''Figure 26:''' Schematic representation of the HDF5 statistical database.
|}
|}


The data is structured in different external files, as shown in Fig. [[lib:DNS_1-3_format_#figure26|26]]. The list number minus 1 corresponds to the array position on python (since python starts counting on 0).


 
'''Inputs'''
 
 
 
 
=== Data file structure ===
This section provides information in how the data is structured for the different external files mentioned above. The list number minus 1 corresponds to the array position on python (since python starts counting on 0).
=== Inputs ===
<div style="column-count:4;-moz-column-count:4;-webkit-column-count:4">
<div style="column-count:4;-moz-column-count:4;-webkit-column-count:4">
# <math>{\overline{P}}</math>
# <math>{\overline{P}}</math>
Line 101: Line 91:
# <math>{R_{23}}</math>
# <math>{R_{23}}</math>
# <math>{R_{33}}</math>
# <math>{R_{33}}</math>
# <math>{\overline{P},1}</math>
# <math>{\partial\overline{P}/\partial x}</math>
# <math>{\overline{U},1}</math>
# <math>{\partial\overline{U}/\partial x}</math>
# <math>{\overline{V},1}</math>
# <math>{\partial\overline{V}/\partial x}</math>
# <math>{\overline{W},1}</math>
# <math>{\partial\overline{W}/\partial x}</math>
# <math>{\overline{P},2}</math>
# <math>{\partial\overline{P}/\partial y}</math>
# <math>{\overline{U},2}</math>
# <math>{\partial\overline{U}/\partial y}</math>
# <math>{\overline{V},2}</math>
# <math>{\partial\overline{V}/\partial y}</math>
# <math>{\overline{W},2}</math>
# <math>{\partial\overline{W}/\partial y}</math>
# <math>{\overline{P},3}</math>
# <math>{\partial\overline{P}/\partial z}</math>
# <math>{\overline{U},3}</math>
# <math>{\partial\overline{U}/\partial z}</math>
# <math>{\overline{V},3}</math>
# <math>{\partial\overline{V}/\partial z}</math>
# <math>{\overline{W},3}</math>
# <math>{\partial\overline{W}/\partial z}</math>
</div>
</div>
=== Additional Quantities ===
 
'''Additional Quantities'''
# <math>{\overline{pp}}</math>
# <math>{\overline{pp}}</math>
# Taylor microscale
# <math>{\eta_{T}}</math>
# Kolmogorov length scale
# <math>{\eta_{K}}</math>
# Kolmorogov time scale
# <math>{\eta_{tK}}</math>
=== Triple Correlation ===
 
'''Triple Correlation'''
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
# <math>{\rho\overline{uuu}}</math>
# <math>{\rho\overline{uuu}}</math>
Line 132: Line 124:
# <math>{\rho\overline{www}}</math>
# <math>{\rho\overline{www}}</math>
</div>
</div>
=== Pressure Velocity Correlation ===
 
''' Pressure Velocity Correlation '''
# <math>{\overline{pu}}</math>
# <math>{\overline{pu}}</math>
# <math>{\overline{pv}}</math>
# <math>{\overline{pv}}</math>
# <math>{\overline{pw}}</math>
# <math>{\overline{pw}}</math>
=== Budget Equation Components ===
 
''' Budget Equation Components '''
The components of the Reynolds stress budget equation come in the following order (for a generic budget component <math>\phi</math>):
The components of the Reynolds stress budget equation come in the following order (for a generic budget component <math>\phi</math>):
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
Line 148: Line 142:


=== Reading the data with python ===
=== Reading the data with python ===
The following section provides some examples on how to read the data using the h5py interface of python. A first example on how to open the dataset and read the node data and the inputs would be:
The [https://kbwiki-data.s3-eu-west-2.amazonaws.com/DNS-1/3/HiFiTurbReader.py following script] is provided to facilitate the reading of the dataset. An example on how to use this script follows:
<pre class="brush: python">
from HiFiTurbDB_Reader import HiFiTurbDB_Reader


db  = HiFiTurbDB_Reader(FILENAME,return_matrix=True,parallel=False) # Return outputs as matrices
print(db,flush=True) # We can print the database information
# Recover some variables
xyz          = db.points
grad_velocity = db.velocity_gradient # Velocity gradients
Rij          = db.reynolds_stress  # Reynolds stresses
</pre>
Alternatively, the dataset can be read raw by directly using the '''h5py''' library. An example follows:
<pre class="brush: python">
<pre class="brush: python">
import h5py
import h5py, numpy as np
= h5py.File('Statistics.h5','r')
 
xyz = np.array( f.get('03_Nodes').get('Nodes') )
file = h5py.File('Statistics.h5','r')
inp = np.array( f.get('02_Entries').get('Inputs') )
f.close()
</pre>


Then, to retrieve the gradients and the Reynolds stress tensor in an array (indices are these of the list above minus 1) would be:
# Read node positions
xyz  = np.array(file['03_Nodes']['Nodes'],dype=np.double)


<pre class="brush: python">
# Read and parse inputs
grad_velocity = inp[:,[17,21,25,18,22,26,19,23,27]].astype(np.double)
# array indices are these of the list above minus 1
Rij          = inp[:,[10,11,13,11,12,14,13,14,15]].astype(np.double)
inp          = np.array(file['02_Entries']['Inputs'],dype=np.double)
grad_velocity = inp[:,[17,21,25,18,22,26,19,23,27]].copy() # Velocity gradients
Rij          = inp[:,[10,11,13,11,12,14,13,14,15]].copy() # Reynolds stresses
</pre>
</pre>
<br/>
<br/>
----
----
Line 170: Line 177:
| organisation=Barcelona Supercomputing Center (BSC)
| organisation=Barcelona Supercomputing Center (BSC)
}}
}}
{{DNSHeaderLib
{{DNSHeader
|area=1
|area=1
|number=3
|number=3

Latest revision as of 09:26, 5 January 2023

Flow in a 3D diffuser

Front Page

Description

Computational Details

Quantification of Resolution

Statistical Data

Instantaneous Data

Storage Format

Storage Format

The data provided is stored in HDF5 format. This can be easily read through the HDF5 library or python's h5py. Any parallel partition has been taken out from the dataset for easier reading both in serial and parallel.

Notes on the HDF5 library

The following instructions are intended for users who wish to compile and obtain the parallel h5py package. Note that the serial h5py also works, however, its parallel capabilities will be deactivated.

manual install

The package h5py can be manually installed with parallel support provided the right libraries are in the system. To get them use (on a Debian-like distribution):

sudo apt install libhdf5-mpi-dev

or make sure that the environment variable HDF5_DIR is pointing to your hdf5 installation. Then install h5py from pip using:

CC=mpicc HDF5_MPI="ON" pip install --no-binary=h5py h5py

Instantaneous data format

The dataset consists of a single file per snapshot, directly containing all the variables as well as the node positions. It also contains some metadata elements such as the number of points, current simulation time and instant. The names of the provided variables are:

  • xyz, are the node positions as an array of (npoints,3).
  • PRESS, is the instantaneous pressure as a scalar array of (npoints,).
  • VELOC, is the instantaneous velocity as a vectorial array of (npoints,3).
  • GRADP, is the gradient of pressure as a vectorial array of (npoints,3).
  • GRADV, is the gradient of velocity as a tensorial array of (npoints,9).

Reading the data with python

An example on how to read this dataset in python follows:

import h5py, numpy as np

filename = 'duct_0.h5' # duct area, first snapshot

# Open HDF5 file in serial
file     = h5py.File(filename,'r')

# Read metadata variables
npoints = int(file['metadata']['npoints'])
time    = float(file['metadata']['time'])
instant = int(file['metadata']['instant'])

# Read variables
PRESS = np.array(file['PRESS'],dype=np.double)
VELOC = np.array(file['VELOC'],dype=np.double)
GRADP = np.array(file['GRADP'],dype=np.double)
GRADV = np.array(file['GRADV'],dype=np.double)

# Close file
file.close()

Statistical data format

The dataset consists of a master file which links a number of external files, thus creating a tree-like database. Each of these external files contain an array of a certain number of positions (1 if scalar, 3 if vectorial and 6 if tensorial, with the exception of the velocity triple correlation). A graphical representation of the database is provided in Fig. 26.

DNS 1 3 data scheme.png
Figure 26: Schematic representation of the HDF5 statistical database.

The data is structured in different external files, as shown in Fig. 26. The list number minus 1 corresponds to the array position on python (since python starts counting on 0).

Inputs

Additional Quantities

Triple Correlation

Pressure Velocity Correlation

Budget Equation Components The components of the Reynolds stress budget equation come in the following order (for a generic budget component ):

Reading the data with python

The following script is provided to facilitate the reading of the dataset. An example on how to use this script follows:

from HiFiTurbDB_Reader import HiFiTurbDB_Reader

db  = HiFiTurbDB_Reader(FILENAME,return_matrix=True,parallel=False) # Return outputs as matrices
print(db,flush=True) # We can print the database information

# Recover some variables
xyz           = db.points
grad_velocity = db.velocity_gradient # Velocity gradients
Rij           = db.reynolds_stress   # Reynolds stresses

Alternatively, the dataset can be read raw by directly using the h5py library. An example follows:

import h5py, numpy as np

file = h5py.File('Statistics.h5','r')

# Read node positions
xyz  = np.array(file['03_Nodes']['Nodes'],dype=np.double)

# Read and parse inputs
# array indices are these of the list above minus 1
inp           = np.array(file['02_Entries']['Inputs'],dype=np.double)
grad_velocity = inp[:,[17,21,25,18,22,26,19,23,27]].copy() # Velocity gradients
Rij           = inp[:,[10,11,13,11,12,14,13,14,15]].copy() # Reynolds stresses




Contributed by: Oriol Lehmkuhl, Arnau Miro — Barcelona Supercomputing Center (BSC)

Front Page

Description

Computational Details

Quantification of Resolution

Statistical Data

Instantaneous Data

Storage Format


© copyright ERCOFTAC 2024