mesh module

This file is part of PyFrac.

Created by Haseeb Zia on Thu Dec 22 11:51:00 2016. Copyright (c) ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, Geo-Energy Laboratory, 2016-2020. All rights reserved. See the LICENSE.TXT file for more details.

class mesh.CartesianMesh(Lx, Ly, nx, ny, symmetric=False)[source]

Bases: object

Class defining a Cartesian Mesh.

The constructor creates a uniform Cartesian mesh centered at (0,0) and having the dimensions of [-Lx,Lx]*[-Ly,Ly].

Parameters
  • nx (int) – – number of elements in x and y directions respectively.

  • ny (int) – – number of elements in x and y directions respectively.

  • Lx (float) – – lengths in x and y directions respectively.

  • Ly (float) – – lengths in x and y directions respectively.

  • symmetric (bool) – – if true, additional variables (see list of attributes) will be evaluated for symmetric fracture solver.

Lx,Ly

– length of the domain in x and y directions respectively. The rectangular domain have a total length of 2*Lx in the x direction and 2*Ly in the y direction. Both the positive and negative halves are included.

Type

float

nx,ny

– number of elements in x and y directions respectively.

Type

int

hx,hy

– grid spacing in x and y directions respectively.

Type

float

VertexCoor

– [x,y] Coordinates of the vertices.

Type

ndarray

CenterCoor

– [x,y] coordinates of the center of the elements.

Type

ndarray

NumberOfElts

– total number of elements in the mesh.

Type

int

EltArea

– area of each element.

Type

float

Connectivity

– connectivity array giving four vertices of an element in the following order [bottom left, bottom right, top right, top left]

Type

ndarray

Connectivityelemedges

– connectivity array giving four edges of an element in the following order [bottom, right, top, left]

Type

ndarray

Connectivityedgeselem

– connectivity array giving two elements that are sharing an edge

Type

ndarray

Connectivityedgesnodes

– connectivity array giving two vertices of an edge

Type

ndarray

Connectivitynodesedges

– connectivity array giving four edges of a node in the following order [vertical_top, horizotal_left, vertical_bottom, horizotal_right]

Type

ndarray

Connectivitynodeselem

– connectivity array giving four elements of a node in the following order [bottom left, bottom right, top right, top left]

Type

ndarray

NeiElements

– Giving four neighboring elements with the following order:[left, right, bottom, up].

Type

ndarray

distCenter

– the distance of the cells from the center.

Type

ndarray

CenterElts

– the element in the center (the cell with the injection point).

Type

ndarray

domainLimits

– the limits of the domain

Type

ndarray

Note

The attributes below are only evaluated if symmetric solver is used.

corresponding

– the index of the corresponding symmetric cells in the set of active cells (activeSymtrc) for each cell in the mesh.

Type

ndarray

symmetricElts

– the set of four symmetric cells in the mesh for each of the cell.

Type

ndarray

activeSymtrc

– the set of cells that are active in the mesh. Only these cells will be solved and the solution will be replicated in the symmetric cells.

Type

ndarray

posQdrnt

– the set of elements in the positive quadrant not including the boundaries.

Type

ndarray

boundary_x

– the elements intersecting the positive x-axis line.

Type

ndarray

boundary_y

– the elements intersecting the positive y-axis line.

Type

ndarray

volWeights

– the weights of the active elements in the volume of the fracture. The cells in the positive quadrant, the boundaries and the injection cell have the weights of 4, 2 and 1 respectively.

Type

ndarray

EltArea

We create a list of cell names thaht are colose to the boundary of the mesh. See the example below. In that case the list will contain the elements identified with a x. The list of elements will be called Frontlist

| | | | | |

|____|____|____|____|____|____| | | x | x | x | x | | |____|____|____|____|____|____| | | x | | | x | | |____|____|____|____|____|____| | | x | | | x | | |____|____|____|____|____|____| | | x | x | x | x | | |____|____|____|____|____|____| | | | | | | | |____|____|____|____|____|____|

NeiElements
conn is the connectivity array giving four vertices of an element in the following order

______ ______ _____

| | |

|______3______2_____| | | i | | |______0______1_____| | | | | |______|______|_____|

Neighbors(elem, nx, ny)[source]

Neighbouring elements of an element within the mesh. Boundary elements have themselves as neighbor.

Parameters
  • elem (int) – – element whose neighbor are to be found.

  • nx (int) – – number of elements in x direction.

  • ny (int) – – number of elements in y direction.

Returns

A tuple containing the following:

left (int) – left neighbour.
right (int) – right neighbour.
bottom (int) – bottom neighbour.
top (int) – top neighbour.

Return type

(tuple)

identify_elements(elements, fig=None, plot_prop=None, plot_mesh=True, print_number=True)[source]

This functions identify the given set of elements by highlighting them on the grid. the function plots the grid and the given set of elements.

Parameters
  • elements (ndarray) – – the given set of elements to be highlighted.

  • fig (Figure) – – A figure object to superimpose.

  • plot_prop (PlotProperties) – – A PlotProperties object giving the properties to be utilized for the plot.

  • plot_mesh (bool) – – if False, grid will not be plotted and only the edges of the given elements will be plotted.

  • print_number (bool) – – if True, numbers of the cell will also be printed along with outline.

Returns

– A Figure object that can be used superimpose further plots.

Return type

(Figure)

locate_element(x, y)[source]

This function gives the cell containing the given coordinates. Numpy nan is returned if the cell is not in the mesh.

Parameters
  • x (float) – – the x coordinate of the given point.

  • y (float) – – the y coordinate of the given point.

Returns

– the element containing the given coordinates.

Return type

elt (int)

plot(material_prop=None, backGround_param=None, fig=None, plot_prop=None)[source]

This function plots the mesh in 2D. If the material properties is given, the cells will be color coded according to the parameter given by the backGround_param argument.

Parameters
  • material_prop (MaterialProperties) – – a MaterialProperties class object

  • backGround_param (string) – – the cells of the grid will be color coded according to the value of the parameter given by this argument. Possible options are ‘sigma0’ for confining stress, ‘K1c’ for fracture toughness and ‘Cl’ for leak off.

  • fig (Figure) – – A figure object to superimpose.

  • plot_prop (PlotProperties) – – A PlotProperties object giving the properties to be utilized for the plot.

Returns

– A Figure object to superimpose.

Return type

(Figure)

plot_3D(material_prop=None, backGround_param=None, fig=None, plot_prop=None)[source]

This function plots the mesh in 3D. If the material properties is given, the cells will be color coded according to the parameter given by the backGround_param argument.

Parameters
  • material_prop (MaterialProperties) – – a MaterialProperties class object

  • backGround_param (string) – – the cells of the grid will be color coded according to the value of the parameter given by this argument. Possible options are ‘sigma0’ for confining stress, ‘K1c’ for fracture toughness and ‘Cl’ for leak off.

  • fig (Figure) – – A figure object to superimpose.

  • plot_prop (PlotProperties) – – A PlotProperties object giving the properties to be utilized for the plot.

Returns

– A Figure object to superimpose.

Return type

(Figure)

plot_scale_3d(ax, plot_prop)[source]

This function plots the scale of the fracture by adding lines giving the length dimensions of the fracture.

mesh.make_3D_colorbar(mesh, material_prop, backGround_param, ax, plot_prop)[source]

This function makes the color bar on 3D mesh plot using rectangular patches with color gradient from gray to the color given by the plot properties. The minimum and maximum values are taken from the given parameter in the material properties.

mesh.process_material_prop_for_display(material_prop, backGround_param)[source]

This function generates the appropriate variables to display the color coded mesh background.

mesh.set_aspect_equal_3d(ax)[source]

Fix equal aspect bug for 3D plots.