ogs5py.fileclasses.GLI

class ogs5py.fileclasses.GLI(gli_dict=None, **OGS_Config)[source]

Bases: File

Class for the ogs GEOMETRY file.

Parameters:
  • gli_dict (dict or None, optional) – dictionary containing the gli file Includes the following information (sorted by keys):

    pointsndarray

    Array with all point postions

    point_namesndarray (of strings)

    Array with all point names

    point_mdndarray

    Array with all Material-densities at the points if point_md should be undefined it takes the value -np.inf

    polylineslist of dict

    each containing information about

    • ID (int or None)

    • NAME (str)

    • POINTS (ndarray)

    • EPSILON (float or None)

    • TYPE (int or None)

    • MAT_GROUP (int or None)

    • POINT_VECTOR (str or None)

    surfaceslist of dict

    each containing information about

    • ID (int or None)

    • NAME (str)

    • POLYLINES (list of str)

    • EPSILON (float or None)

    • TYPE (int or None)

    • MAT_GROUP (int or None)

    • TIN (str or None)

    volumeslist of dict

    each containing information about

    • NAME (str)

    • SURFACES (list of str)

    • TYPE (int or None)

    • MAT_GROUP (int or None)

    • LAYER (int or None)

    Default: None

  • task_root (str, optional) – Path to the destiny model folder. Default: cwd+”ogs5model”

  • task_id (str, optional) – Name for the ogs task. Default: “model”

Attributes:
POINTS

ndarray: POINTS (n,3) of the gli, defined by xyz-coordinates.

POINT_MD

ndarray: material density values of POINTS of the gli.

POINT_NAMES

ndarray: names of POINTS of the gli.

POINT_NO

int: number of POINTS of the gli.

POLYLINES

List of dict: POLYLINES of the gli.

POLYLINE_NAMES

List of str: names of POLYLINES of the gli.

POLYLINE_NO

int: number of POLYLINES of the gli.

SURFACES

List of dict: SURFACES of the gli.

SURFACE_NAMES

List of str: names of SURFACES of the gli.

SURFACE_NO

int: number of SURFACES of the gli.

VOLUMES

List of dict: VOLUMES of the gli.

VOLUME_NAMES

List of str: names of VOLUMES of the gli.

VOLUME_NO

int: number of VOLUMES of the gli.

file_name

str: base name of the file with extension.

file_path

str: save path of the file.

force_writing

bool: state if the file is written even if empty.

is_empty

bool: State if the GLI File is empty.

name

str: name of the file without extension.

Methods

__call__()

Return a copy of the underlying dictionary of the gli.

add_copy_link(path[, symlink])

Add a link to copy a file instead of writing.

add_points(points[, names, md, decimals])

Add a list of points (ndarray with shape (n,3)).

add_polyline(name, points[, ply_id, ...])

Add a polyline to the gli.

add_surface(name, polylines[, srf_id, ...])

Add a new surface.

add_volume(name, surfaces[, vol_type, ...])

Add a new volume.

check([verbose])

Check if the gli is valid.

del_copy_link()

Remove a former given link to an external file.

generate([generator])

Use a gli-generator from the generator module.

get_file_type()

Get the OGS file class name.

load(filepath[, verbose, encoding])

Load an OGS5 gli from file.

pnt_coord([pnt_name, pnt_id])

Get Point coordinates either by name or ID.

read_file(path[, encoding, verbose])

Load an OGS5 gli from file.

remove_point(id_or_name)

Remove a point by its name or ID.

remove_polyline(names)

Remove a polyline by its name.

remove_surface(names)

Remove a surface by its name.

remove_volume(names)

Remove a volume by its name.

reset()

Delete every content.

rotate(angle[, rotation_axis, rotation_point])

Rotate points around a given rotation point and axis with given angle.

save(path, **kwargs)

Save the gli to an OGS5 gli file.

set_dict(gli_dict)

Set a gli dict as returned by tools methods or generators.

shift(vector)

Shift points with a given vector.

swap_axis([axis1, axis2])

Swap axis of the coordinate system.

write_file()

Write the actual OGS input file to the given folder.

__call__()[source]

Return a copy of the underlying dictionary of the gli.

Returns:

Mesh – dictionary representation of the mesh

Return type:

dict

Add a link to copy a file instead of writing.

Instead of writing a file, you can give a path to an existing file, that will be copied/linked to the target folder.

Parameters:
  • path (str) – path to the existing file that should be copied

  • symlink (bool, optional) – on UNIX systems it is possible to use a symbolic link to save time if the file is big. Default: False

add_points(points, names=None, md=None, decimals=4)[source]

Add a list of points (ndarray with shape (n,3)).

Keeps the pointlist unique. If a named point is added, that was already present, it will be renamed with the new name. Same for md. The pointlists of the polylines will be updated.

Parameters:
  • points (ndarray) – Array with new points.

  • names (ndarray of str or None, optional) – array containing the names. If None, all new points are unnamed. Default: None

  • md (ndarray of float or None, optional) – array containing the material densitiy. If None, all new points will have unspecified md. Default: None

  • decimals (int, optional) – Number of decimal places to round the added points to (default: 4). If decimals is negative, it specifies the number of positions to the left of the decimal point. This will not round the new points, it’s just for comparison of the already present points to guarante uniqueness.

Returns:

new_pos – array with the IDs of the added points in the pointlist of the gli.

Return type:

ndarray

add_polyline(name, points, ply_id=None, epsilon=None, ply_type=None, mat_group=None, point_vector=None, closed=False, decimals=4)[source]

Add a polyline to the gli.

Parameters:
  • name (str) – name of the new polyline

  • points (ndarray) – Array with the points. Either array of point IDs or new coordinates.

  • ply_id (int or None, optional) – Default: None

  • epsilon (float or None, optional) – Default: None

  • ply_type (int or None, optional) – Default: None

  • mat_group (int or None, optional) – Default: None

  • point_vector (str or None, optional) – Default: None

  • closed (bool, optional) – If the polyline shall be closed, the first point will be added as last point again. Default: False

  • decimals (int, optional) – Number of decimal places to round the added points to (default: 4). If decimals is negative, it specifies the number of positions to the left of the decimal point. This will not round the new points, it’s just for comparison of the already present points to guarante uniqueness.

add_surface(name, polylines, srf_id=None, epsilon=None, srf_type=0, mat_group=None, tin=None)[source]

Add a new surface.

Parameters:
  • name (str) – name of the new surface

  • polylines (list of str) – List of the surface-defining polyline-names

  • srf_id (int or None, optional) – Default: None

  • epsilon (float or None, optional) – Default: None

  • srf_type (int or None, optional) – Default: None

  • mat_group (int or None, optional) – Default: None

  • tin (str or None, optional) – Default: None

add_volume(name, surfaces, vol_type=None, mat_group=None, layer=None)[source]

Add a new volume.

Parameters:
  • name (str) – name of the new surface

  • surfaces (list of str) – List of the volume-defining surface-names

  • vol_type (int or None, optional) – Default: None

  • mat_group (int or None, optional) – Default: None

  • layer (int or None, optional) – Default: None

check(verbose=True)[source]

Check if the gli is valid.

In the sence, that the contained data is consistent.

Parameters:

verbose (bool, optional) – Print information for the executed checks. Default: True

Returns:

result – Validity of the given gli.

Return type:

bool

Remove a former given link to an external file.

generate(generator='rectangular', **kwargs)[source]

Use a gli-generator from the generator module.

See: ogs5py.fileclasses.gli.generator

Parameters:
  • generator (str) – set the generator from the generator module

  • **kwargs – kwargs will be forwarded to the generator in use

Notes

The following generators are available:

rectangular([dim, ori, size, name])

Generate a rectangular boundary for a grid in 2D or 3D as gli.

radial([dim, ori, angles, rad_out, rad_in, ...])

Generate a radial boundary for a grid in 2D or 3D.

get_file_type()

Get the OGS file class name.

load(filepath, verbose=False, encoding=None, **kwargs)[source]

Load an OGS5 gli from file.

kwargs will be forwarded to “tools.load_ogs5gli”

Parameters:
  • filepath (string) – path to the ‘*.gli’ OGS5 gli file to load

  • verbose (bool, optional) – Print information of the reading process. Default: True

pnt_coord(pnt_name=None, pnt_id=None)[source]

Get Point coordinates either by name or ID.

Parameters:
  • pnt_name (str) – Point name.

  • pnt_id (int) – Point ID.

read_file(path, encoding=None, verbose=False)[source]

Load an OGS5 gli from file.

Parameters:
  • path (string) – path to the ‘*.gli’ OGS5 gli file to load

  • encoding (str or None, optional) – encoding of the given file. If None is given, the system standard is used. Default: None

  • verbose (bool, optional) – Print information of the reading process. Default: False

remove_point(id_or_name)[source]

Remove a point by its name or ID.

If Points are removed, that define polylines, they will be removed. Same for surfaces and volumes.

Parameters:

id_or_name (int or str or list of int or list of str) – Points to be removed. Unknown names or IDs are ignored.

remove_polyline(names)[source]

Remove a polyline by its name.

If Polylines are removed, that define surfaces, they will be removed. Same for volumes.

Parameters:

names (str or list of str) – Polylines to be removed. Unknown names are ignored.

remove_surface(names)[source]

Remove a surface by its name.

If Surfaces are removed, that define Volumes, they will be removed.

Parameters:

names (str or list of str) – Surfaces to be removed. Unknown names are ignored.

remove_volume(names)[source]

Remove a volume by its name.

Parameters:

names (str or list of str) – Volumes to be removed. Unknown names are ignored.

reset()[source]

Delete every content.

rotate(angle, rotation_axis=(0.0, 0.0, 1.0), rotation_point=(0.0, 0.0, 0.0))[source]

Rotate points around a given rotation point and axis with given angle.

Parameters:
  • angle (float) – rotation angle given in radial length

  • rotation_axis (array_like, optional) – Array containing the vector for ratation axis. Default: (0,0,1)

  • rotation_point (array_like, optional) – Vector of the ratation base point. Default:(0,0,0)

save(path, **kwargs)[source]

Save the gli to an OGS5 gli file.

kwargs will be forwarded to “tools.save_ogs5gli”

Parameters:
  • path (string) – path to the ‘*.gli’ OGS5 gli file to save

  • verbose (bool, optional) – Print information of the writing process. Default: True

set_dict(gli_dict)[source]

Set a gli dict as returned by tools methods or generators.

Gli will be checked for validity.

Parameters:

gli_dict (dict) – dictionary containing the gli file Includes the following information (sorted by keys):

pointsndarray

Array with all point postions

point_namesndarray (of strings)

Array with all point names

point_mdndarray

Array with all Material-densities at the points if point_md should be undefined it takes the value -np.inf

polylineslist of dict

each containing information about

  • ID (int or None)

  • NAME (str)

  • POINTS (ndarray)

  • EPSILON (float or None)

  • TYPE (int or None)

  • MAT_GROUP (int or None)

  • POINT_VECTOR (str or None)

surfaceslist of dict

each containing information about

  • ID (int or None)

  • NAME (str)

  • POLYLINES (list of str)

  • EPSILON (float or None)

  • TYPE (int or None)

  • MAT_GROUP (int or None)

  • TIN (str or None)

volumeslist of dict

each containing information about

  • NAME (str)

  • SURFACES (list of str)

  • TYPE (int or None)

  • MAT_GROUP (int or None)

  • LAYER (int or None)

shift(vector)[source]

Shift points with a given vector.

Parameters:

vector (ndarray) – array containing the shifting vector

swap_axis(axis1='y', axis2='z')[source]

Swap axis of the coordinate system.

Parameters:
  • axis1 (str or int, optional) – First selected Axis. Either in [“x”, “y”, “z”] or in [0, 1, 2]. Default: “y”

  • axis2 (str or int, optional) – Second selected Axis. Either in [“x”, “y”, “z”] or in [0, 1, 2]. Default: “z”

write_file()

Write the actual OGS input file to the given folder.

Its path is given by “task_root+task_id+file_ext”.

property POINTS

POINTS (n,3) of the gli, defined by xyz-coordinates.

Type:

ndarray

property POINT_MD

material density values of POINTS of the gli.

Type:

ndarray

property POINT_NAMES

names of POINTS of the gli.

Type:

ndarray

property POINT_NO

number of POINTS of the gli.

Type:

int

property POLYLINES

POLYLINES of the gli.

Type:

List of dict

property POLYLINE_NAMES

names of POLYLINES of the gli.

Type:

List of str

property POLYLINE_NO

number of POLYLINES of the gli.

Type:

int

property SURFACES

SURFACES of the gli.

Type:

List of dict

property SURFACE_NAMES

names of SURFACES of the gli.

Type:

List of str

property SURFACE_NO

number of SURFACES of the gli.

Type:

int

property VOLUMES

VOLUMES of the gli.

Type:

List of dict

property VOLUME_NAMES

names of VOLUMES of the gli.

Type:

List of str

property VOLUME_NO

number of VOLUMES of the gli.

Type:

int

property file_name

base name of the file with extension.

Type:

str

property file_path

save path of the file.

Type:

str

property force_writing

state if the file is written even if empty.

Type:

bool

property is_empty

State if the GLI File is empty.

Type:

bool

property name

name of the file without extension.

Type:

str