ppModule package

Subpackages

Main Interface Module

ppModule.binFiles package

Submodules

ppModule.binFiles.read_grid module

Module to read grid files from Musicaa. The grid files are in binary file format.

The grid files are read from the repository and a tuple containing the grid data is returned. The grid data is stored in dictionnaries containing x, y, z coordinates.

The grid data is read from the binary file using the numpy.fromfile() function. The grid data is reshaped to the correct dimensions using the numpy.reshape() function.

Classes:

ReadGrid: class to read grid from binary files, this clss also handles

old classes without ghost points.

class ppModule.binFiles.read_grid.ReadGrid(directory: str, config: dict)[source]

Bases: object

Abstract class to implement some common methods and attributes for reading grid files.

Attributes:

dir (str): Directory containing the grid files. nbloc (int): Number of blocks in the domain. info (dict): Dictionary containing information about the grid. ngh (int): Number of ghost cells.

property directory

Property to get the directory where the grid can be found.

read_grid()[source]

Method to read grid over whole domain and returns a grid without ghost points.

The method takes care of old grid as well for old simulations using Musicaa.

The grid is stored in a dictionnary containing:

x, y, & z coordinates.

Returns:

tuple: Tuple containing grid data (x, y, z).

ppModule.binFiles.read_snapshots module

Module to read Musicaa’s snapshots from binary files.

The snapshots are returned in a dictionary with block IDs, variable names, and arrays. The module is used by the ppModule to read the snapshots from the binary files. It also provides a static method to read 2D binary data, which can be used to read statistics or other related data.

Classes

ReadSnapshots

Abstract class to read snapshots from binary files.

ReadPlanes

Class to read planes from binary files.

ReadLines

Class to read lines from binary files.

ReadPoints

Class to read points from binary files.

class ppModule.binFiles.read_snapshots.ReadLines(repo: str, info: dict, snapshots_info: dict)[source]

Bases: ReadSnapshots

Class to read lines from binary files.

This class is used by the ppModule to read lines from binary files.

Attributes:

dirstr

Directory where the binary files are located.

infodict

Dictionary containing information from the info.ini file.

snapshots_infodict

Dictionary containing information about the snapshots.

read_line()

Read lines from binary files.

read_line_block(filename, n1, nvar)[source]

Read lines from binary files for one block, is called by the read_line method.

read_line_block(filename: str, n1: int, nvar: int)[source]

Read lines from binary files for one block, is called by the read_line method.

read_lines()[source]

Read lines from binary files.

The lines are returned in a dictionary organized as follows: - lines[block_id][line_id][‘var’] = data

Returns:

Dictionary with the lines read from the binary files.

Return type:

dict

class ppModule.binFiles.read_snapshots.ReadPlanes(repo: str, info: dict, snapshots_info: dict)[source]

Bases: ReadSnapshots

Class to read planes from binary files.

This class is used by the ppModule to read planes from binary files. It also provides a static method to read 2D binary data, which can be used to read statistics or other related data.

Attrblock_idutes

dirstr

Directory where the binary files are located.

infodict

Dictionary containing information from the info.ini file.

snapshots_infodict

Dictionary containing information about the snapshots.

read_planes()[source]

Read planes from binary files.

read_2d(filename, n1, n2, nvar)[source]

Read 2D binary data in a block. Used to read planes, stats, etc.

static read_2d(filename: str, n1: int, n2: int, nvar: int)[source]

Read 2D binary data in a block. Used to read planes, stats, etc.

Parameters:
  • filename (str) – Name of the binary file.

  • n1 (int) – Number of points in the first dimension.

  • n2 (int) – Number of points in the second dimension.

  • nvar (int) – Number of variables.

Returns:

Dictionary with the data read from the binary file.

Return type:

dict

read_planes()[source]

Read planes from binary files.

The planes are returned in a dictionary organized as follows: - planes[block_id][plane_id][‘var’] = data

Returns:

Dictionary with the planes read from the binary files.

Return type:

dict

class ppModule.binFiles.read_snapshots.ReadPoints(repo: str, info: dict, snapshots_info: dict)[source]

Bases: ReadSnapshots

Class to read points from binary files.

This class is used by the ppModule to read points from binary files.

Attributes:

dirstr

Directory where the binary files are located.

infodict

Dictionary containing information from the info.ini file.

snapshots_infodict

Dictionary containing information about the snapshots.

read_points()[source]

Read points from binary files.

The points are returned in a dictionary organized as follows: - points[block_id][point_id][‘var’] = data

Returns:

Dictionary with the points read from the binary files.

Return type:

dict

read_points_block(filename: str, nvar: int)[source]

Read points from binary files for one block, is called by the read_points method.

class ppModule.binFiles.read_snapshots.ReadSnapshots(repo: str, info: dict, snapshots_info: dict)[source]

Bases: object

Abstract class to read snapshots from binary files.

This class implements common methods to read snapshots from bianry files.

Attributes:

infodict

Dictionary containing information from the info.ini file.

directorystr

Directory where the binary files are located.

snapshots_infodict

Dictionary containing information about the snapshots.

self.info_planedict

Dictionary containing information about the planes.

self.info_pointdict

Dictionary containing information about the points.

self.info_linedict

Dictionary containing information about the lines.

self.info_volume: dict

Dictionary containing information about the volumes.

process_snapshots()[source]

Process snapshots information to get planes’ information.

_process_planes(block_id, snapshot_id)

(private) Process information of a plane and return a dictionary with the information.

_process_lines(block_id, snapshot_id)

(private) Process information of a line and return a dictionary with the information.

_process_points(block_id, snapshot_id)

(private) Process information of a point and return a dictionary with the information.

_process_volumes(block_id, snapshot_id)

(private) Process information of a volume and return a dictionary with the information.

process_lines(block_id: int, snapshot_id: int) dict[source]

Methods to process information of a line and return a dictionary with the information.

Args:

block_idint

block id in which the line information are being processed.

snapshot_idint

ID of the snapshot being processed, corresponds to its order in the param_blocks.ini .

self.info_linedict

Dictionary containing information about the lines.

returns:

Dictionary with the processed information of the line.

rtype:

dict

process_planes(block_id: int, snapshot_id: int) dict[source]

Methods to process information of a plane and return a dictionary with the information.

Args:

block_idint

block id in which the plane information are being processed.

snapshot_idint

ID of the snapshot being processed, corresponds to its order in the param_blocks.ini .

self.info_planedict

Dictionary containing information about the planes.

returns:

Dictionary with the processed information of the plane.

rtype:

dict

process_points(block_id: int, snapshot_id: int) dict[source]

Process points information. Similar to _process_planes, but for points.

process_snapshots() tuple[source]

Process snapshots information to get planes’ information.

Useful if the number of snapshots is not equal to the number of planes. For example, when saving lines or points along with planes.

Returns:

Dictionary containing processed information about planes.

Return type:

dict

process_volumes(block_id: int, snapshot_id: int) dict[source]

Process volumes information. Similar to _process_planes, but for volumes.

ppModule.binFiles.read_stats module

Module to read stats from Musicaa simulation. The stats are used for all post-processing modules.

The steady simulations are also postprocessed using the statistics.

class ppModule.binFiles.read_stats.ReadStats(directory: str, case: str, info: dict)[source]

Bases: object

Class to read post-processing statistics from Musicaa simulation. The correct methods are in utils_stats.py. The methods must be named as follow: stats_{case_name} where case_name is the name of the case specified in the param.ini file. The case name is converted to lower case. The case name is used to select the correct method to read the statistics.

The stats are returned as a dictionary with the following structure: [<block_id>][<variable_name>] = <value>

property case

Define a case property, it is the case specified in Musicaa simulation in the param.ini file.

It allows to read the correct statistics files.

read_stats() dict[source]

Method to read statistics from the simulation.

stats_orienter() object[source]

Return object that will read the statistics (the correct function in utils)

ppModule.compute package

Submodules

ppModule.compute.compute_2d_curv module

ppModule.iniFiles package

Submodules

ppModule.iniFiles.read_ini module

Module to read *.ini file, which contains information about simulations

Classes:

  • ParamBlockReader: This class reads the param_blocks file, it helps get information about

snapshots and boundary conditions. * InfoReader: This class reads the info file, it helps get information about the grid and the simulation parameters. * FeosReader: This class reads the feos file, it helps get information about the fluid properties. * Reader: This is an abstract class that contains shared methods and attributes for all the classes above.

class ppModule.iniFiles.read_ini.FeosReader(file_path: str, fluid: str)[source]

Bases: Reader

Class to read feos_{fluid}.ini file, which containts information about the fluid properties. This is useful to compute Flow-Through domaine Time and other characteristis of each simulation.

It is mainly useful to run unsteady simulations using Musicaa’s wrapper.

  • fluid (str): fluid name

  • feos (dict): dictionnary containing all information data

is_valid_key(key: str) None[source]

Check if a key is present in feos dictionnary

read_feos() dict[source]

Method to read feos_.ini file, it uses Regex to compile format of the text

class ppModule.iniFiles.read_ini.InfoReader(file_path: str)[source]

Bases: Reader

Class to read info.ini file, which contains generic information about the simulation. It returns a dictionary containing all necessary information.

Attributes:
  • file_path (str): path to info.ini file

Methods:
  • _read_ini_file: (private), method to read info.ini file

  • get_value: returns value of a specific key

  • is_valid_key: checks if the key given in get_value is valid or not.

  • TypeError: if the key given is not a string

get_value(key: str)[source]

Method to get a specific information from ini file, based on the key.

Args:

key (str): The key to look for in the ini file.

Returns:

The value associated with the key.

Raises:

KeyError: If the key is not in the file. TypeError: If the key given is not a string.

is_valid_key(key: str) bool[source]

Check if key is a string and it is contained in the info.ini file.

Args:

key (str): The key to check.

Returns:

bool: True if the key is valid, False otherwise.

class ppModule.iniFiles.read_ini.ParamBlockReader(file_path: str)[source]

Bases: Reader

Class to read param_blocks.ini file, which contains information about mesh: * Number of blocks * Number of points in each direction * Number of processors in each direction * Boundary conditions * Sponge zone * Snapshots

Attributes:
  • file_path (str): path to param_blocks.ini file

  • block_info (dict): dictionnary containing all information data.

The block_info dictionnary has the following structure:
{
block_id: {

‘Nb points’: {‘I’: int, ‘J’: int, ‘K’: int}, ‘Nb procs’: {‘I’: int, ‘J’: int, ‘K’: int}, ‘Boundary conditions’: [list], ‘Sponge zone’: [list], ‘Snapshots’: [list] (this list is empy, the snapshots are read in the read_snapshots methos)

}

}

  • snapshots_info (dict): dictionnary containing all snapshots information.

The snapshots_info dictionnary has the following structure:
{

block_id: { [ number of snapshots, {

‘I1’: int, ‘I2’: int, ‘J1’: int, ‘J2’: int, ‘K1’: int, ‘K2’: int, ‘freq’: int, ‘nvar’: int, ‘list_var’: [list of variables]

}, … there are as many dictionnaries as the number of snapshots in the list ]

}

Methods:

read_block_info: Read block information from param_blocks.ini file. read_snapshots: Read snapshots information from param_blocks.ini file. process_points_procs: (private), Process number of points and processors in each direction. process_boundary_conditions: (private), Process boundary conditions. process_sponge_zone: (private), Process sponge zone.

property actions

Actions to perform based on the line content.

Returns:

dict: Actions to perform based on the line content.

read_block_info() dict[source]

Initialize the ParamBlockReader with the path to the param_blocks.ini file.

Args:

file_path (str): Path to the param_blocks.ini file.

Returns:

dict: Block information, contains number of points in each direction for each block, number of procs in each direction, boundary conditions, sponge zone information if it exists and snapshots. The dictionnary has the following structure:

read_snapshots() dict[source]

Read block information from param_blocks.ini file.

Returns:

dict: Block information, contains number of points in each direction for each block, number of procs in each direction, boundary conditions, sponge zone information if it exists and snapshots.

class ppModule.iniFiles.read_ini.Reader(file_path: str)[source]

Bases: object

Abstract class to read all *ini files, this class containts shared methods and attributes and checks errors in the configuration.

  • _is_valid_key: check if the key is valid in the dictionary

property file_path: str

Check if the file_path given is a string and if it exists.

Returns:

str: The file path if it is valid.

Raises:

TypeError: If file_path is not a string. FileNotFoundError: If the file does not exist.

ppModule.utils package

Submodules

ppModule.utils.preprocess_snapshots module

This module contains utilities to preprocess snapshots before plotting them.

class ppModule.utils.preprocess_snapshots.PreProcessLines(snapshot_info: dict, info: dict, config: dict)[source]

Bases: object

Class to preprocess lines to get coordinates and appropriate values of the line in space, takes into consideration the grid type and the solver used (cartesian 2D curvliniear, full 3D curvlinear).

grid(line_id: int, block_id: int)[source]

Method to preprocess grid to return appropriate coordinates to plot lines Takes into consideratin the solver aka the type of the mesh from Musicaa

lines() dict[source]

Method to pre-process lines before reading them

class ppModule.utils.preprocess_snapshots.PreProcessPlanes(snapshot_info: dict, info: dict, config: dict)[source]

Bases: object

This class contains methods to preprocess Planes before plotting them.

grid(plane_id: int, block_id: int)[source]

Method to preprocess grid to return appropriate coordinates to plot planes

Takes into consideration

planes() dict[source]

Methods to preprocess planes, it returns a dictionnary with the x1, x2 of each planes and the plane values to plot.

transpose_arrays_in_dict(d)[source]

Recursively transpose all numpy arrays in a nested dictionary.

class ppModule.utils.preprocess_snapshots.PreprocessPoints(snapshot_info: dict, info: dict, config: dict)[source]

Bases: object

Class to preprocess points to get coordinates of the point in space, takes into consideration the grid type and the solver used (cartesian 2D curvliniear, full 3D curvlinear).

grid(point_id: int, block_id: int)[source]

Method to preprocess grid to return appropriate coordinates to plot points Takes into consideratin the solver aka the type of the mesh from Musicaa

points() dict[source]

Postprocess the points and returns a dictionnary with the x1, x2, x3 of each point and the points values for each variable and each snapshot in the point.

ppModule.utils.stats_reader module

Utils file containts routines to read stats for different cases from Musicaa output files The functions are called in read_stats module depending on the case.

class ppModule.utils.stats_reader.StatsReader[source]

Bases: object

Class containing static methods only to read statistic for different musicaa cases

static stats_chan(directory: str, info=None) dict[source]

Function to read stats of the channel flow case. The stats are read from the stats.dat file

Args: directory: str

The directory where the stats files are located

kwargs: dict containing the following keys

None

Returns: _stats: dict

A dictionary containing the stats of the simulation

static stats_stbl(directory: str, info: dict) dict[source]

Function to read stats of the stbl case. The stats are read from the file stats_bl%{i}.bin files

Args: directory: str

The directory where the stats files are located

kwargs: dict containing the following keys
nbloc: int

The number of blocks in the simulation

nx: dict

The number of cells in x direction for each block

ny: dict

The number of cells in y direction for each block

Returns: _stats: dict

A dictionary containing the stats of the simulation

static stats_turb(directory: str, info: dict) dict[source]

Function to read stats of the turb case. The stats are read from the file stats_bl%{i}.bin files

Args: directory: str

The directory where the stats files are located

kwargs: dict containing the following keys
nbloc: int

The number of blocks in the simulation

nx: dict

The number of cells in x direction for each block

ny: dict

The number of cells in y direction for each block

Returns: _stats: dict

A dictionary containing the stats of the simulation