ogs5py.fileclasses.gli

Class for the ogs GEOMETRY file.

Subpackages

The generators can be called with GLI.generate

generator Generators for the ogs GEOMETRY file.

File Classes

GLI([gli_dict]) Class for the ogs GEOMETRY file.
GLIext([typ, data, name, file_ext, …]) Class for an external definition for the ogs GEOMETRY file.

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

Bases: ogs5py.fileclasses.base.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):

    points : ndarray
    Array with all point postions
    point_names : ndarray (of strings)
    Array with all point names
    point_md : ndarray
    Array with all Material-densities at the points if point_md should be undefined it takes the value -np.inf
    polylines : list 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)
    surfaces : list 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)
    volumes : list 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__(self) Return a copy of the underlying dictionary of the gli.
add_copy_link(self, path[, symlink]) Add a link to copy a file instead of writing.
add_points(self, points[, names, md, decimals]) Add a list of points (ndarray with shape (n,3)).
add_polyline(self, name, points[, ply_id, …]) Add a polyline to the gli.
add_surface(self, name, polylines[, srf_id, …]) Add a new surface.
add_volume(self, name, surfaces[, vol_type, …]) Add a new volume.
check(self[, verbose]) Check if the gli is valid.
del_copy_link(self) Remove a former given link to an external file.
generate(self[, generator]) Use a gli-generator from the generator module.
get_file_type(self) Get the OGS file class name.
load(self, filepath[, verbose, encoding]) Load an OGS5 gli from file.
pnt_coord(self[, pnt_name, pnt_id]) Get Point coordinates either by name or ID.
read_file(self, path[, encoding, verbose]) Load an OGS5 gli from file.
remove_point(self, id_or_name) Remove a point by its name or ID.
remove_polyline(self, names) Remove a polyline by its name.
remove_surface(self, names) Remove a surface by its name.
remove_volume(self, names) Remove a volume by its name.
reset(self) Delete every content.
rotate(self, angle[, rotation_axis, …]) Rotate points around a given rotation point and axis with given angle.
save(self, path, \*\*kwargs) Save the gli to an OGS5 gli file.
set_dict(self, gli_dict) Set a gli dict as returned by tools methods or generators.
shift(self, vector) Shift points with a given vector.
swap_axis(self[, axis1, axis2]) Swap axis of the coordinate system.
write_file(self) Write the actual OGS input file to the given folder.
__call__(self)[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(self, 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(self, 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:
  • points (ndarray) – Array with new points. Either of shape (n,3) to add new points by their coordinates or a list of points IDs refering to existing points.
  • name (str) – name of the new polyline
  • points – 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(self, 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(self, 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(self, 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(self, 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(self)

Get the OGS file class name.

load(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, names)[source]

Remove a volume by its name.

Parameters:names (str or list of str) – Volumes to be removed. Unknown names are ignored.
reset(self)[source]

Delete every content.

rotate(self, 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(self, 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(self, 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):

points : ndarray
Array with all point postions
point_names : ndarray (of strings)
Array with all point names
point_md : ndarray
Array with all Material-densities at the points if point_md should be undefined it takes the value -np.inf
polylines : list 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)
surfaces : list 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)
volumes : list 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(self, vector)[source]

Shift points with a given vector.

Parameters:vector (ndarray) – array containing the shifting vector
swap_axis(self, 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(self)

Write the actual OGS input file to the given folder.

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

POINTS

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

Type:ndarray
POINT_MD

material density values of POINTS of the gli.

Type:ndarray
POINT_NAMES

names of POINTS of the gli.

Type:ndarray
POINT_NO

number of POINTS of the gli.

Type:int
POLYLINES

POLYLINES of the gli.

Type:List of dict
POLYLINE_NAMES

names of POLYLINES of the gli.

Type:List of str
POLYLINE_NO

number of POLYLINES of the gli.

Type:int
SURFACES

SURFACES of the gli.

Type:List of dict
SURFACE_NAMES

names of SURFACES of the gli.

Type:List of str
SURFACE_NO

number of SURFACES of the gli.

Type:int
VOLUMES

VOLUMES of the gli.

Type:List of dict
VOLUME_NAMES

names of VOLUMES of the gli.

Type:List of str
VOLUME_NO

number of VOLUMES of the gli.

Type:int
file_name

base name of the file with extension.

Type:str
file_path

save path of the file.

Type:str
force_writing

state if the file is written even if empty.

Type:bool
is_empty

State if the GLI File is empty.

Type:bool
name

name of the file without extension.

Type:str
class GLIext(typ='TIN', data=None, name=None, file_ext=None, task_root=None, task_id='model')[source]

Bases: ogs5py.fileclasses.base.File

Class for an external definition for the ogs GEOMETRY file.

Parameters:
  • typ (str, optional) – Type of the extermal geometry definition. Either TIN for a triangulated surface or POINT_VECTOR for a polyline. Default: "TIN"
  • data (numpy.ndarray, optional) – Data for the external geometry definition. Default: None
  • name (str, optional) – File name for the RFR file. If None, the task_id is used. Default: None
  • file_ext (str, optional) – extension of the file (with leading dot “.rfr”) Default: “.rfr”
  • 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:
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

State if the OGS file is empty.

name

str: name of the file without extension.

Methods

add_copy_link(self, path[, symlink]) Add a link to copy a file instead of writing.
check(self[, verbose]) Check if the external geometry definition is valid.
del_copy_link(self) Remove a former given link to an external file.
get_file_type(self) Get the OGS file class name.
read_file(self, path, \*\*kwargs) Read a given GLI_EXT input file.
reset(self) Delete every content.
save(self, path) Save the actual GLI external file in the given path.
write_file(self) Write the actual OGS input file to the given folder.

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
check(self, verbose=True)[source]

Check if the external geometry definition 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.

get_file_type(self)

Get the OGS file class name.

read_file(self, path, **kwargs)[source]

Read a given GLI_EXT input file.

Parameters:path (str) – path to the file
reset(self)

Delete every content.

save(self, path)[source]

Save the actual GLI external file in the given path.

Parameters:path (str) – path to where to file should be saved
write_file(self)

Write the actual OGS input file to the given folder.

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

file_name

base name of the file with extension.

Type:str
file_path

save path of the file.

Type:str
force_writing

state if the file is written even if empty.

Type:bool
is_empty

State if the OGS file is empty.

name

name of the file without extension.

Type:str