g3d.flow.io package

Submodules

g3d.flow.io.g3dio module

I/O functionality - geometry and flow import/export (G3DIO class definition)

class g3d.flow.io.g3dio.G3DIO(*args: Any, **kwargs: Any)[source]

Bases: G3DEntity

Definition of class G3DIO: I/O functionality - geometry and flow import/export

Attributes:
tag

tag (string) used for identification

Methods

add_cell_attribute(variable, im, f[, ...])

Adds cell attribute (flow data) to xdmf file

add_cell_data_item(ni, nj, nk, filename, f)

Add cell data item to xdmf file

add_geo_attribute(im, ni, nj, nk, f[, dim_mode])

Adds geometric attribute to xdmf file

add_geo_data_item(ni, nj, nk, filename, f[, ...])

Add geometric data item to xdmf file

add_xdmf_footer(f)

Add footer to xdmf file

add_xdmf_header(f)

Add header to xdmf file

copy(e)

copies data from specified entity input: entity example: copy(e)

export_field(dom, field, **kwargs)

Exports field data to file

export_flow(dom, cons, auxv, post, **kwargs)

Exports flow data to file

export_scalar(dom, var, **kwargs)

Export scalar variable to file

export_scalars(dom, variables, **kwargs)

Export multiple scalar variables (arrays) to file (cell values)

export_velocity_gradients(dom, vgrad, **kwargs)

Exports velocity gradient data

get_solution(cons, filename)

Reads flow field data (solver variables) from file

plot_field_2D(dom, field[, im, k])

Plots field data in two dimensions (multiple variables)

plot_flow_2D(dom, cons, auxv, post[, im, k])

Plots flow data in two dimensions (multiple variables)

plot_probe_array(dom, var, im, i0, j0, k0, ...)

Plots probe array data

plot_scalar_2D(dom, var[, im, k])

Plots scalar data in two dimensions

plot_scalars_2D(dom, variables[, im, k])

Plots scalar data in two dimensions (multiple scalar variables)

print()

prints entity data

set(*args, **kwargs)

sets entity parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Sets data from key-value pair input

static add_cell_attribute(variable: str, im: int, f: TextIO, item_counter: int = 2)[source]

Adds cell attribute (flow data) to xdmf file

Parameters:
  • variable (str :) – variable name

  • im (int :) – block number

  • f (TextIO :) – file handle

  • item_counter (int :) – accumulated data-item count (Default value = 2)

static add_cell_data_item(ni: int, nj: int, nk: int, filename: str, f: TextIO, pos: int = 0, dim_mode: Any = DIMMode.G3D, bo: str = 'little') → None[source]

Add cell data item to xdmf file

Parameters:
  • ni (int :) – number of nodes in i-direction

  • nj (int :) – number of nodes in j-direction

  • nk (int :) – number of nodes in k-direction

  • filename (str :) – file name

  • f (TextIO :) – file handle

  • pos (int :) – file position (Default value = 0)

  • dim_mode (DIMMode :) – dimension mode (Default value = DIMMode.G3D)

  • bo (str :) – byte order ‘little’ or ‘big’ (Default value = ‘little’)

static add_geo_attribute(im: int, ni: int, nj: int, nk: int, f: TextIO, dim_mode: Any = DIMMode.G3D)[source]

Adds geometric attribute to xdmf file

Parameters:
  • im (int :) – block number

  • ni (int :) – number of nodes in i-direction

  • nj (int :) – number of nodes in j-direction

  • nk (int :) – number of nodes in k-direction

  • f (TextIO :) – file handle

  • dim_mode (DIMMode :) – dimension mode (Default value = DIMMode.G3D)

static add_geo_data_item(ni: int, nj: int, nk: int, filename: str, f: TextIO, pos: int = 0, dim_mode: Any = DIMMode.G3D, bo: str = 'little') → None[source]

Add geometric data item to xdmf file

Parameters:
  • ni (int :) – number of nodes in i-direction

  • nj (int :) – number of nodes in j-direction

  • nk (int :) – number of nodes in k-direction

  • filename (str :) – file name

  • f (TextIO :) – file handle

  • pos (int :) – file position (Default value = 0)

  • dim_mode (DIMMode) – dimension mode (Default value = DIMMode.G3D)

  • bo (str :) – byte order ‘little’ or ‘big’ (Default value = ‘little’)

Add footer to xdmf file

Parameters:

f (TextIO :) – file handle

static add_xdmf_header(f: TextIO) → None[source]

Add header to xdmf file

Parameters:

f (TextIO :) – file handle

export_field(dom: Domain, field: FlowDataPlaceHolder, **kwargs: Any) → None[source]

Exports field data to file

Parameters:
  • dom (Domain :) – flow domain

  • field (FlowDataPlaceHolder :) – instance of flow data placeholder

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_flow(dom: Domain, cons: ConsField, auxv: AuxvField, post: PostField, **kwargs: Any) → None[source]

Exports flow data to file

Parameters:
  • dom (Domain :) – flow domain

  • cons (ConsField :) – instance of conservative variables

  • auxv (AuxvField :) – instance of primitive variables

  • post (PostField :) – instance of postprocessing variables

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_scalar(dom: Domain, var: ndarray, **kwargs: Any) → None[source]

Export scalar variable to file

Parameters:
  • dom (Domain :) – flow domain

  • var (ndarray :) – scalar variable array (cell values)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_scalars(dom: Domain, variables: list[ndarray], **kwargs: Any) → None[source]

Export multiple scalar variables (arrays) to file (cell values)

Parameters:
  • dom (Domain :) – flow domain

  • variables (list :) – multiple arrays with cell values (list of arrays)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_velocity_gradients(dom: Domain, vgrad: VGradField, **kwargs: Any) → None[source]

Exports velocity gradient data

Parameters:
  • dom (Domain :) – flow domain

  • vgrad (VGradField :) – instance of velocity gradients

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

static get_solution(cons: ConsField, filename: str) → None[source]

Reads flow field data (solver variables) from file

Parameters:
  • cons (ConsField :) – conservative variable container

  • filename (str :) – file name

plot_field_2D(dom: Domain, field: FlowDataPlaceHolder, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots field data in two dimensions (multiple variables)

Parameters:
  • dom (Domain :) – flow domain

  • field (FlowDataPlaceHolder :) – instance of flow data placeholder

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_flow_2D(dom: Domain, cons: ConsField, auxv: AuxvField, post: PostField, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots flow data in two dimensions (multiple variables)

Parameters:
  • dom (Domain :) – flow domain

  • cons (ConsField :) – instance of conservative variables

  • auxv (AuxvField :) – instance of primitive variables

  • post (PostField :) – instance of postprocessing variables

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_probe_array(dom: Domain, var: ndarray, im: int, i0: int, j0: int, k0: int, idir: int, nci: int, **kwargs: Any) → None[source]

Plots probe array data

Parameters:
  • dom (Domain :) – flow domain

  • var (ndarray :) – scalar variable array (cell values)

  • im (int :) – block number

  • i0 (int :) – start index i-direction

  • j0 (int :) – start index j-direction

  • k0 (int :) – start index k-direction

  • idir (int :) – probe direction (1 -> +i, 2 -> -i, 3 -> +j, 4 -> -j, 5 -> +k, 6 -> -k)

  • nci (int :) – number of cells in specified direction

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_scalar_2D(dom: Domain, var: ndarray, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots scalar data in two dimensions

Parameters:
  • dom (Domain :) – flow domain

  • var (ndarray :) – scalar variable array (cell values)

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_scalars_2D(dom: Domain, variables: ndarray, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots scalar data in two dimensions (multiple scalar variables)

Parameters:
  • dom (Domain :) – flow domain

  • variables (ndarray :) – multiple arrays with cell values (list of arrays)

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

set_from_key_value(key: str, value: Any) → bool[source]

Sets data from key-value pair input

Parameters:
  • key (str :) – keyword

  • value (Any :) – value corresponding to keyword

Returns:

status - True if key is found in list of valid keywords

Return type:

bool

Module contents

g3d/flow/io sub library

class g3d.flow.io.G3DIO(*args: Any, **kwargs: Any)[source]

Bases: G3DEntity

Definition of class G3DIO: I/O functionality - geometry and flow import/export

Attributes:
tag

tag (string) used for identification

Methods

add_cell_attribute(variable, im, f[, ...])

Adds cell attribute (flow data) to xdmf file

add_cell_data_item(ni, nj, nk, filename, f)

Add cell data item to xdmf file

add_geo_attribute(im, ni, nj, nk, f[, dim_mode])

Adds geometric attribute to xdmf file

add_geo_data_item(ni, nj, nk, filename, f[, ...])

Add geometric data item to xdmf file

add_xdmf_footer(f)

Add footer to xdmf file

add_xdmf_header(f)

Add header to xdmf file

copy(e)

copies data from specified entity input: entity example: copy(e)

export_field(dom, field, **kwargs)

Exports field data to file

export_flow(dom, cons, auxv, post, **kwargs)

Exports flow data to file

export_scalar(dom, var, **kwargs)

Export scalar variable to file

export_scalars(dom, variables, **kwargs)

Export multiple scalar variables (arrays) to file (cell values)

export_velocity_gradients(dom, vgrad, **kwargs)

Exports velocity gradient data

get_solution(cons, filename)

Reads flow field data (solver variables) from file

plot_field_2D(dom, field[, im, k])

Plots field data in two dimensions (multiple variables)

plot_flow_2D(dom, cons, auxv, post[, im, k])

Plots flow data in two dimensions (multiple variables)

plot_probe_array(dom, var, im, i0, j0, k0, ...)

Plots probe array data

plot_scalar_2D(dom, var[, im, k])

Plots scalar data in two dimensions

plot_scalars_2D(dom, variables[, im, k])

Plots scalar data in two dimensions (multiple scalar variables)

print()

prints entity data

set(*args, **kwargs)

sets entity parameters according to specifications input: args, kwargs example: set(args, kwargs)

set_from_key_value(key, value)

Sets data from key-value pair input

static add_cell_attribute(variable: str, im: int, f: TextIO, item_counter: int = 2)[source]

Adds cell attribute (flow data) to xdmf file

Parameters:
  • variable (str :) – variable name

  • im (int :) – block number

  • f (TextIO :) – file handle

  • item_counter (int :) – accumulated data-item count (Default value = 2)

static add_cell_data_item(ni: int, nj: int, nk: int, filename: str, f: TextIO, pos: int = 0, dim_mode: Any = DIMMode.G3D, bo: str = 'little') → None[source]

Add cell data item to xdmf file

Parameters:
  • ni (int :) – number of nodes in i-direction

  • nj (int :) – number of nodes in j-direction

  • nk (int :) – number of nodes in k-direction

  • filename (str :) – file name

  • f (TextIO :) – file handle

  • pos (int :) – file position (Default value = 0)

  • dim_mode (DIMMode :) – dimension mode (Default value = DIMMode.G3D)

  • bo (str :) – byte order ‘little’ or ‘big’ (Default value = ‘little’)

static add_geo_attribute(im: int, ni: int, nj: int, nk: int, f: TextIO, dim_mode: Any = DIMMode.G3D)[source]

Adds geometric attribute to xdmf file

Parameters:
  • im (int :) – block number

  • ni (int :) – number of nodes in i-direction

  • nj (int :) – number of nodes in j-direction

  • nk (int :) – number of nodes in k-direction

  • f (TextIO :) – file handle

  • dim_mode (DIMMode :) – dimension mode (Default value = DIMMode.G3D)

static add_geo_data_item(ni: int, nj: int, nk: int, filename: str, f: TextIO, pos: int = 0, dim_mode: Any = DIMMode.G3D, bo: str = 'little') → None[source]

Add geometric data item to xdmf file

Parameters:
  • ni (int :) – number of nodes in i-direction

  • nj (int :) – number of nodes in j-direction

  • nk (int :) – number of nodes in k-direction

  • filename (str :) – file name

  • f (TextIO :) – file handle

  • pos (int :) – file position (Default value = 0)

  • dim_mode (DIMMode) – dimension mode (Default value = DIMMode.G3D)

  • bo (str :) – byte order ‘little’ or ‘big’ (Default value = ‘little’)

Add footer to xdmf file

Parameters:

f (TextIO :) – file handle

static add_xdmf_header(f: TextIO) → None[source]

Add header to xdmf file

Parameters:

f (TextIO :) – file handle

export_field(dom: Domain, field: FlowDataPlaceHolder, **kwargs: Any) → None[source]

Exports field data to file

Parameters:
  • dom (Domain :) – flow domain

  • field (FlowDataPlaceHolder :) – instance of flow data placeholder

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_flow(dom: Domain, cons: ConsField, auxv: AuxvField, post: PostField, **kwargs: Any) → None[source]

Exports flow data to file

Parameters:
  • dom (Domain :) – flow domain

  • cons (ConsField :) – instance of conservative variables

  • auxv (AuxvField :) – instance of primitive variables

  • post (PostField :) – instance of postprocessing variables

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_scalar(dom: Domain, var: ndarray, **kwargs: Any) → None[source]

Export scalar variable to file

Parameters:
  • dom (Domain :) – flow domain

  • var (ndarray :) – scalar variable array (cell values)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_scalars(dom: Domain, variables: list[ndarray], **kwargs: Any) → None[source]

Export multiple scalar variables (arrays) to file (cell values)

Parameters:
  • dom (Domain :) – flow domain

  • variables (list :) – multiple arrays with cell values (list of arrays)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

export_velocity_gradients(dom: Domain, vgrad: VGradField, **kwargs: Any) → None[source]

Exports velocity gradient data

Parameters:
  • dom (Domain :) – flow domain

  • vgrad (VGradField :) – instance of velocity gradients

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

static get_solution(cons: ConsField, filename: str) → None[source]

Reads flow field data (solver variables) from file

Parameters:
  • cons (ConsField :) – conservative variable container

  • filename (str :) – file name

plot_field_2D(dom: Domain, field: FlowDataPlaceHolder, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots field data in two dimensions (multiple variables)

Parameters:
  • dom (Domain :) – flow domain

  • field (FlowDataPlaceHolder :) – instance of flow data placeholder

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_flow_2D(dom: Domain, cons: ConsField, auxv: AuxvField, post: PostField, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots flow data in two dimensions (multiple variables)

Parameters:
  • dom (Domain :) – flow domain

  • cons (ConsField :) – instance of conservative variables

  • auxv (AuxvField :) – instance of primitive variables

  • post (PostField :) – instance of postprocessing variables

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_probe_array(dom: Domain, var: ndarray, im: int, i0: int, j0: int, k0: int, idir: int, nci: int, **kwargs: Any) → None[source]

Plots probe array data

Parameters:
  • dom (Domain :) – flow domain

  • var (ndarray :) – scalar variable array (cell values)

  • im (int :) – block number

  • i0 (int :) – start index i-direction

  • j0 (int :) – start index j-direction

  • k0 (int :) – start index k-direction

  • idir (int :) – probe direction (1 -> +i, 2 -> -i, 3 -> +j, 4 -> -j, 5 -> +k, 6 -> -k)

  • nci (int :) – number of cells in specified direction

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_scalar_2D(dom: Domain, var: ndarray, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots scalar data in two dimensions

Parameters:
  • dom (Domain :) – flow domain

  • var (ndarray :) – scalar variable array (cell values)

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

plot_scalars_2D(dom: Domain, variables: ndarray, im: int = 0, k: int = 0, **kwargs: Any) → None[source]

Plots scalar data in two dimensions (multiple scalar variables)

Parameters:
  • dom (Domain :) – flow domain

  • variables (ndarray :) – multiple arrays with cell values (list of arrays)

  • im (int :) – block number (Default value = 0)

  • k (int :) – k-plane index (Default value = 0)

  • **kwargs (Any :) – keyword-value pairs valid keyword: ‘name’, ‘export_name’, ‘xml_name’, ‘sol_dir’, ‘export_dir’, ‘xml_dir’, ‘remove_sub_path’, ‘label’, ‘subdir’, ‘variable_name’, ‘variable_names’, ‘no_xml’, ‘export_xml’

set_from_key_value(key: str, value: Any) → bool[source]

Sets data from key-value pair input

Parameters:
  • key (str :) – keyword

  • value (Any :) – value corresponding to keyword

Returns:

status - True if key is found in list of valid keywords

Return type:

bool