# Source code for naginterfaces.library.mesh

# -*- coding: utf-8 -*-
r"""
Module Summary
--------------
Interfaces for the NAG Mark 29.0 mesh Chapter.

mesh - Mesh Generation

This module is concerned with automatic mesh generation

with line segments, over the boundary of a closed two-dimensional connected polygonal domain;

with triangles, over a given two-dimensional region using only its boundary mesh.

Functionality Index
-------------------

**Boundary mesh generation**

:math:{2D} boundary mesh generation: :meth:dim2_gen_boundary

**Interior mesh generation**

:math:{2D} mesh generation using advancing front method: :meth:dim2_gen_front

:math:{2D} mesh generation using a simple incremental method: :meth:dim2_gen_inc

:math:{2D} mesh generation using Delaunay--Voronoi method: :meth:dim2_gen_delaunay

**Mesh Management and Utility function**

:math:{2D} mesh smoother using a barycentering technique: :meth:dim2_smooth_bary

:math:{2D} mesh transformer by an affine transformation: :meth:dim2_transform_affine

:math:{2D} mesh vertex renumbering: :meth:dim2_renumber

finite Element matrix sparsity pattern generation: :meth:dim2_sparsity

joins together two given adjacent (possibly overlapping) meshes: :meth:dim2_join

For full information please refer to the NAG Library document

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html
"""

[docs]def dim2_gen_inc(edge, coor, bspace, smooth, itrace, coef=0.75, power=0.25, io_manager=None):
r"""
dim2_gen_inc generates a triangular mesh of a closed polygonal region in :math:\mathbb{R}^2, given a mesh of its boundary.
It uses a simple incremental method.

.. _d06aa-py2-py-doc:

For full information please refer to the NAG Library document for d06aa

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06aaf.html

.. _d06aa-py2-py-parameters:

**Parameters**
**edge** : int, array-like, shape :math:\left(3, \textit{nedge}\right)
The specification of the boundary edges. :math:\mathrm{edge}[0,j-1] and :math:\mathrm{edge}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge}[2,j-1] is a user-supplied tag for the :math:j\ th boundary edge and is not used by dim2_gen_inc.

**coor** : float, array-like, shape :math:\left(2, \textit{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th input boundary mesh vertex; while :math:\mathrm{coor}[1,\textit{i}-1] contains the corresponding :math:y coordinate, for :math:\textit{i} = 1,\ldots,\textit{nvb}.

**bspace** : float, array-like, shape :math:\left(\textit{nvb}\right)
The desired mesh spacing (triangle diameter, which is the length of the longer edge of the triangle) near the boundary vertices.

**smooth** : bool
Indicates whether or not mesh smoothing should be performed.

If :math:\mathrm{smooth} = \mathbf{True}, the smoothing is performed; otherwise no smoothing is performed.

**itrace** : int
The level of trace information required from dim2_gen_inc.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace}\geq 1

Output from the meshing solver is printed. This output contains details of the vertices and triangles generated by the process.

You are advised to set :math:\mathrm{itrace} = 0, unless you are experienced with finite element mesh generation.

**coef** : float, optional
The coefficient in the stopping criteria for the generation of interior vertices. This argument controls the triangle density and the number of triangles generated is in :math:\mathrm{O}\left(\mathrm{coef}^2\right). The mesh will be finer if :math:\mathrm{coef} is greater than :math:0.7165 and :math:0.75 is a good value.

**power** : float, optional
Controls the rate of change of the mesh size during the generation of interior vertices. The smaller the value of :math:\mathrm{power}, the faster the decrease in element size away from the boundary.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**nv** : int
The total number of vertices in the output mesh (including both boundary and interior vertices). If :math:\textit{nvb} = \textit{nvmax}, no interior vertices will be generated and :math:\mathrm{nv} = \textit{nvb}.

**nelt** : int
The number of triangular elements in the mesh.

**coor** : float, ndarray, shape :math:\left(2, \textit{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\left(\textit{i}-\textit{nvb}\right)\ th generated interior mesh vertex; while :math:\mathrm{coor}[1,\textit{i}-1] will contain the corresponding :math:y coordinate, for :math:\textit{i} = \textit{nvb}+1,\ldots,\mathrm{nv}. The remaining elements are unchanged.

**conn** : int, ndarray, shape :math:\left(3, 2\times \left(\textit{nvmax}-1\right)\right)
The connectivity of the mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conn}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,\ldots,\mathrm{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

.. _d06aa-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\textit{nvb} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nvmax} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:3\leq \textit{nvb}\leq \textit{nvmax}.

(errno :math:1)
On entry, :math:\textit{nedge} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nvb} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\leq \textit{nvb}.

(errno :math:1)
On entry, the end points of the edge :math:\textit{J} have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, :math:\mathrm{bspace}[\textit{I}-1] = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{bspace}[\textit{I}-1] > 0.0.

(errno :math:1)
On entry, :math:\mathrm{power} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{power}\leq 10.0.

(errno :math:1)
On entry, :math:\mathrm{power} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{power}\geq 0.1.

(errno :math:2)
An error has occurred during the generation of the interior mesh. Check the definition of the boundary (arguments :math:\mathrm{coor} and :math:\mathrm{edge}) as well as the orientation of the boundary (especially in the case of a multiple connected component boundary). Setting :math:\mathrm{itrace} > 0 may provide more details.

.. _d06aa-py2-py-notes:

**Notes**
dim2_gen_inc generates the set of interior vertices using a process based on a simple incremental method.
A smoothing of the mesh is optionally available.
For more details about the triangulation method, consult the D06 Introduction <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html>__ as well as George and Borouchaki (1998).

This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

.. _d06aa-py2-py-references:

**References**
George, P L and Borouchaki, H, 1998, Delaunay Triangulation and Meshing: Application to Finite Elements, Editions HERMES, Paris
"""
raise NotImplementedError

[docs]def dim2_gen_delaunay(nvb, edge, coor, weight, npropa, itrace, io_manager=None):
r"""
dim2_gen_delaunay generates a triangular mesh of a closed polygonal region in :math:\mathbb{R}^2, given a mesh of its boundary.
It uses a Delaunay--Voronoi process, based on an incremental method.

.. _d06ab-py2-py-doc:

For full information please refer to the NAG Library document for d06ab

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06abf.html

.. _d06ab-py2-py-parameters:

**Parameters**
**nvb** : int
The number of vertices in the input boundary mesh.

**edge** : int, array-like, shape :math:\left(3, \textit{nedge}\right)
The specification of the boundary edges. :math:\mathrm{edge}[0,j-1] and :math:\mathrm{edge}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge}[2,j-1] is a user-supplied tag for the :math:j\ th boundary edge and is not used by dim2_gen_delaunay.

**coor** : float, array-like, shape :math:\left(2, \textit{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th input boundary mesh vertex, for :math:\textit{i} = 1,\ldots,\mathrm{nvb}. :math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\left(\textit{i}-\mathrm{nvb}\right)\ th fixed interior vertex, for :math:\textit{i} = \mathrm{nvb}+1,\ldots,\mathrm{nvb}+\textit{nvint}. For boundary and interior vertices, :math:\mathrm{coor}[1,\textit{i}-1] contains the corresponding :math:y coordinate, for :math:\textit{i} = 1,2,\ldots,\mathrm{nvb}+\textit{nvint}.

**weight** : float, array-like, shape :math:\left(\textit{nvint}\right)
The weight of fixed interior vertices. It is the diameter of triangles (length of the longer edge) created around each of the given interior vertices.

**npropa** : int
The propagation type and coefficient, the argument :math:\mathrm{npropa} is used when the internal points are created. They are distributed in a geometric manner if :math:\mathrm{npropa} is positive and in an arithmetic manner if it is negative. For more details see Further Comments <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06abf.html#fcomments>__.

**itrace** : int
The level of trace information required from dim2_gen_delaunay.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace}\geq 1

Output from the meshing solver is printed. This output contains details of the vertices and triangles generated by the process.

You are advised to set :math:\mathrm{itrace} = 0, unless you are experienced with finite element mesh generation.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**nv** : int
The total number of vertices in the output mesh (including both boundary and interior vertices). If :math:\mathrm{nvb}+\textit{nvint} = \textit{nvmax}, no interior vertices will be generated and :math:\mathrm{nv} = \textit{nvmax}.

**nelt** : int
The number of triangular elements in the mesh.

**coor** : float, ndarray, shape :math:\left(2, \textit{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\left(\textit{i}-\mathrm{nvb}-\textit{nvint}\right)\ th generated interior mesh vertex, for :math:\textit{i} = \mathrm{nvb}+\textit{nvint}+1,\ldots,\mathrm{nv}; while :math:\mathrm{coor}[1,i-1] will contain the corresponding :math:y coordinate. The remaining elements are unchanged.

**conn** : int, ndarray, shape :math:\left(3, 2\times \textit{nvmax}+5\right)
The connectivity of the mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conn}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,\ldots,\mathrm{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

.. _d06ab-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\mathrm{nvb} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{nvint} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nvmax} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nvmax}\geq \mathrm{nvb}+\textit{nvint}.

(errno :math:1)
On entry, :math:\textit{nedge} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\mathrm{nvb} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\leq \mathrm{nvb}.

(errno :math:1)
On entry, :math:\mathrm{nvb} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nvb} \geq 3.

(errno :math:1)
On entry, :math:\textit{nvint} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nvint} \geq 0.

(errno :math:1)
On entry, the end points of the edge :math:\textit{J} have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, :math:\mathrm{weight}[\textit{I}-1] = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{weight}[\textit{I}-1] > 0.0.

(errno :math:1)
On entry, :math:\mathrm{npropa} = 0.

(errno :math:2)
An error has occurred during the generation of the interior mesh. Check the definition of the boundary (arguments :math:\mathrm{coor} and :math:\mathrm{edge}) as well as the orientation of the boundary (especially in the case of a multiple connected component boundary). Setting :math:\mathrm{itrace} > 0 may provide more details.

(errno :math:3)
An error has occurred during the generation of the boundary mesh. It appears that :math:\textit{nvmax} is not large enough: :math:\textit{nvmax} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:3)
An error has occurred during the generation of the boundary mesh. Check the definition of the boundary (arguments :math:\mathrm{coor} and :math:\mathrm{edge}) as well as the orientation of the boundary (especially in the case of a multiple connected component boundary). Setting :math:\mathrm{itrace} > 0 may provide more details.

.. _d06ab-py2-py-notes:

**Notes**
dim2_gen_delaunay generates the set of interior vertices using a Delaunay--Voronoi process, based on an incremental method.
It allows you to specify a number of fixed interior mesh vertices together with weights which allow concentration of the mesh in their neighbourhood.
For more details about the triangulation method, consult the D06 Introduction <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html>__ as well as George and Borouchaki (1998).

This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

.. _d06ab-py2-py-references:

**References**
George, P L and Borouchaki, H, 1998, Delaunay Triangulation and Meshing: Application to Finite Elements, Editions HERMES, Paris
"""
raise NotImplementedError

[docs]def dim2_gen_front(nvb, edge, coor, weight, itrace, io_manager=None):
r"""
dim2_gen_front generates a triangular mesh of a closed polygonal region in :math:\mathbb{R}^2, given a mesh of its boundary.
It uses an Advancing Front process, based on an incremental method.

.. _d06ac-py2-py-doc:

For full information please refer to the NAG Library document for d06ac

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06acf.html

.. _d06ac-py2-py-parameters:

**Parameters**
**nvb** : int
The number of vertices in the input boundary mesh.

**edge** : int, array-like, shape :math:\left(3, \textit{nedge}\right)
The specification of the boundary edges. :math:\mathrm{edge}[0,j-1] and :math:\mathrm{edge}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge}[2,j-1] is a user-supplied tag for the :math:j\ th boundary edge and is not used by dim2_gen_front.

**coor** : float, array-like, shape :math:\left(2, \textit{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th input boundary mesh vertex, for :math:\textit{i} = 1,\ldots,\mathrm{nvb}. :math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\left(\textit{i}-\mathrm{nvb}\right)\ th fixed interior vertex, for :math:\textit{i} = \mathrm{nvb}+1,\ldots,\mathrm{nvb}+\textit{nvint}. For boundary and interior vertices, :math:\mathrm{coor}[1,\textit{i}-1] contains the corresponding :math:y coordinate, for :math:\textit{i} = 1,2,\ldots,\mathrm{nvb}+\textit{nvint}.

**weight** : float, array-like, shape :math:\left(\textit{nvint}\right)
The weight of fixed interior vertices. It is the diameter of triangles (length of the longer edge) created around each of the given interior vertices.

**itrace** : int
The level of trace information required from dim2_gen_front.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace}\geq 1

Output from the meshing solver is printed. This output contains details of the vertices and triangles generated by the process.

You are advised to set :math:\mathrm{itrace} = 0, unless you are experienced with finite element mesh generation.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**nv** : int
The total number of vertices in the output mesh (including both boundary and interior vertices). If :math:\mathrm{nvb}+\textit{nvint} = \textit{nvmax}, no interior vertices will be generated and :math:\mathrm{nv} = \textit{nvmax}.

**nelt** : int
The number of triangular elements in the mesh.

**coor** : float, ndarray, shape :math:\left(2, \textit{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\left(\textit{i}-\mathrm{nvb}-\textit{nvint}\right)\ th generated interior mesh vertex, for :math:\textit{i} = \mathrm{nvb}+\textit{nvint}+1,\ldots,\mathrm{nv}; while :math:\mathrm{coor}[1,i-1] will contain the corresponding :math:y coordinate. The remaining elements are unchanged.

**conn** : int, ndarray, shape :math:\left(3, 2\times \textit{nvmax}+5\right)
The connectivity of the mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conn}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,\ldots,\mathrm{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

.. _d06ac-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\mathrm{nv} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{nvint} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nvmax} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nvb}+\textit{nvint}\leq \textit{nvmax}.

(errno :math:1)
On entry, :math:\textit{nedge} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\mathrm{nvb} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\leq \mathrm{nvb}.

(errno :math:1)
On entry, :math:\mathrm{nvb} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nvb} \geq 3.

(errno :math:1)
On entry, :math:\textit{nvint} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nvint} \geq 0.

(errno :math:1)
On entry, the end points of the edge :math:\textit{J} have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, :math:\mathrm{weight}[\textit{I}-1] = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{weight}[\textit{I}-1] > 0.0.

(errno :math:2)
An error has occurred during the generation of the interior mesh. Check the definition of the boundary (arguments :math:\mathrm{coor} and :math:\mathrm{edge}) as well as the orientation of the boundary (especially in the case of a multiple connected component boundary). Setting :math:\mathrm{itrace} > 0 may provide more details.

(errno :math:3)
An error has occurred during the generation of the boundary mesh. Check the definition of the boundary (arguments :math:\mathrm{coor} and :math:\mathrm{edge}) as well as the orientation of the boundary (especially in the case of a multiple connected component boundary). Setting :math:\mathrm{itrace} > 0 may provide more details.

.. _d06ac-py2-py-notes:

**Notes**
dim2_gen_front generates the set of interior vertices using an Advancing Front process, based on an incremental method.
It allows you to specify a number of fixed interior mesh vertices together with weights which allow concentration of the mesh in their neighbourhood.
For more details about the triangulation method, consult the D06 Introduction <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html>__ as well as George and Borouchaki (1998).

This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

.. _d06ac-py2-py-references:

**References**
George, P L and Borouchaki, H, 1998, Delaunay Triangulation and Meshing: Application to Finite Elements, Editions HERMES, Paris
"""
raise NotImplementedError

[docs]def dim2_gen_boundary(coorch, lined, crus, rate, nlcomp, lcomp, nvmax, nedmx, itrace, fbnd=None, data=None, io_manager=None):
r"""
dim2_gen_boundary generates a boundary mesh on a closed connected subdomain :math:\Omega of :math:\mathbb{R}^2.

.. _d06ba-py2-py-doc:

For full information please refer to the NAG Library document for d06ba

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06baf.html

.. _d06ba-py2-py-parameters:

**Parameters**
**coorch** : float, array-like, shape :math:\left(2, \textit{nlines}\right)
:math:\mathrm{coorch}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th characteristic point, for :math:\textit{i} = 1,2,\ldots,\textit{nlines}; while :math:\mathrm{coorch}[1,i-1] contains the corresponding :math:y coordinate.

**lined** : int, array-like, shape :math:\left(4, \textit{nlines}\right)
The description of the lines that define the boundary domain. The line :math:\textit{i}, for :math:\textit{i} = 1,\ldots,m, is defined as follows:

:math:\mathrm{lined}[0,i-1]

The number of points on the line, including two end points.

:math:\mathrm{lined}[1,i-1]

The first end point of the line. If :math:\mathrm{lined}[1,i-1] = j, the coordinates of the first end point are those stored in :math:\mathrm{coorch}[0,j-1],\mathrm{coorch}[1,j-1].

:math:\mathrm{lined}[2,i-1]

The second end point of the line. If :math:\mathrm{lined}[2,i-1] = k, the coordinates of the second end point are those stored in :math:\mathrm{coorch}[0,k-1],\mathrm{coorch}[1,k-1].

:math:\mathrm{lined}[3,i-1]

This defines the type of line segment connecting the end points. Additional information is conveyed by the numerical value of :math:\mathrm{lined}[3,i-1] as follows:

(i) :math:\mathrm{lined}[3,i-1] > 0, the line is described in :math:\mathrm{fbnd} with :math:\mathrm{lined}[3,i-1] as the index. In this case, the line must be described in the trigonometric (anticlockwise) direction;

(#) :math:\mathrm{lined}[3,i-1] = 0, the line is a straight line;

(#) if :math:\mathrm{lined}[3,i-1] < 0, say (:math:{-p}), then the line is a polygonal arc joining the end points and interior points specified in :math:\mathrm{crus}. In this case the line contains the points whose coordinates are stored in :math:\mathrm{coorch}[z,j-1], \mathrm{crus}[z,p-1], \mathrm{crus}[z,p],\ldots,\mathrm{crus}[z,p+r-4], \mathrm{coorch}[z,k-1], where :math:z \in \left\{0, 1\right\}, :math:r = \mathrm{lined}[0,i-1], :math:j = \mathrm{lined}[1,i-1] and :math:k = \mathrm{lined}[2,i-1].

**crus** : float, array-like, shape :math:\left(2, \textit{sdcrus}\right)
The coordinates of the intermediate points for polygonal arc lines. For a line :math:i defined as a polygonal arc (i.e., :math:\mathrm{lined}[3,i-1] < 0), if :math:p = -\mathrm{lined}[3,i-1], :math:\mathrm{crus}[0,\textit{k}-1], for :math:\textit{k} = p,\ldots,p+\mathrm{lined}[0,i-1]-3, must contain the :math:x coordinate of the consecutive intermediate points for this line. Similarly :math:\mathrm{crus}[1,\textit{k}-1], for :math:\textit{k} = p,\ldots,p+\mathrm{lined}[0,i-1]-3, must contain the corresponding :math:y coordinate.

**rate** : float, array-like, shape :math:\left(\textit{nlines}\right)
:math:\mathrm{rate}[\textit{i}-1] is the geometric progression ratio between the points to be generated on the line :math:\textit{i}, for :math:\textit{i} = 1,2,\ldots,m and :math:\mathrm{lined}[3,i-1]\geq 0.

If :math:\mathrm{lined}[3,i-1] < 0, :math:\mathrm{rate}[i-1] is not referenced.

**nlcomp** : int, array-like, shape :math:\left(\textit{ncomp}\right)
:math:\left\lvert \mathrm{nlcomp}[k-1]\right\rvert is the number of line segments in component :math:k of the contour. The line :math:i of component :math:k runs in the direction :math:\mathrm{lined}[1,i-1] to :math:\mathrm{lined}[2,i-1] if :math:\mathrm{nlcomp}[k-1] > 0, and in the opposite direction otherwise; for :math:k = 1,2,\ldots,n.

**lcomp** : int, array-like, shape :math:\left(\textit{nlines}\right)
:math:\mathrm{lcomp} must contain the list of line numbers for the each component of the boundary. Specifically, the line numbers for the :math:\textit{k}\ th component of the boundary, for :math:\textit{k} = 1,2,\ldots,\textit{ncomp}, must be in elements :math:{l1}-1 to :math:{l2}-1 of :math:\mathrm{lcomp}, where :math:{l2} = \sum_{{i = 1}}^k\left\lvert \mathrm{nlcomp}[i-1]\right\rvert and :math:{l1} = {l2}+1-\left\lvert \mathrm{nlcomp}[\textit{k}-1]\right\rvert.

**nvmax** : int
The maximum number of the boundary mesh vertices to be generated.

**nedmx** : int
The maximum number of boundary edges in the boundary mesh to be generated.

**itrace** : int
The level of trace information required from dim2_gen_boundary.

:math:\mathrm{itrace} = 0 or :math:\mathrm{itrace} < -1

No output is generated.

:math:\mathrm{itrace} = 1

Output from the boundary mesh generator is printed. This output contains the input information of each line and each connected component of the boundary.

:math:\mathrm{itrace} = -1

An analysis of the output boundary mesh is printed on the file object associated with the advisory I/O unit (see :class:~naginterfaces.base.utils.FileObjManager). This analysis includes the orientation (clockwise or anticlockwise) of each connected component of the boundary. This information could be of interest to you, especially if an interior meshing is carried out using the output of this function, calling either :meth:dim2_gen_inc, :meth:dim2_gen_delaunay or :meth:dim2_gen_front.

:math:\mathrm{itrace} > 1

The output is similar to that produced when :math:\mathrm{itrace} = 1, but the coordinates of the generated vertices on the boundary are also output.

You are advised to set :math:\mathrm{itrace} = 0, unless you are experienced with finite element mesh generation.

**fbnd** : None or callable retval = fbnd(i, x, y, data=None), optional
Note: if this argument is **None** then a NAG-supplied facility will be used.

:math:\mathrm{fbnd} must be supplied to calculate the value of the function which describes the curve :math:\left\{\left(x, y\right) \in \mathbb{R}^2\text{; such that }f\left(x, y\right) = 0\right\} on segments of the boundary for which :math:\mathrm{lined}[3,i-1] > 0.

**Parameters**
**i** : int
:math:\mathrm{lined}[3,i-1], the reference index of the line (portion of the contour) :math:i described.

**x** : float
The values of :math:x and :math:y at which :math:f\left(x, y\right) is to be evaluated.

**y** : float
The values of :math:x and :math:y at which :math:f\left(x, y\right) is to be evaluated.

**data** : arbitrary, optional, modifiable in place
User-communication data for callback functions.

**Returns**
**retval** : float
The value of :math:f\left(x, y\right) at the specified point.

**data** : arbitrary, optional
User-communication data for callback functions.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**nvb** : int
The total number of boundary mesh vertices generated.

**coor** : float, ndarray, shape :math:\left(2, \mathrm{nvmax}\right)
:math:\mathrm{coor}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\textit{i}\ th boundary mesh vertex generated, for :math:\textit{i} = 1,\ldots,\mathrm{nvb}; while :math:\mathrm{coor}[1,i-1] will contain the corresponding :math:y coordinate.

**nedge** : int
The total number of boundary edges in the boundary mesh.

**edge** : int, ndarray, shape :math:\left(3, \mathrm{nedmx}\right)
The specification of the boundary edges. :math:\mathrm{edge}[0,j-1] and :math:\mathrm{edge}[1,j-1] will contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge}[2,j-1] is a reference number for the :math:j\ th boundary edge and

:math:\mathrm{edge}[2,j-1] = \mathrm{lined}[3,i-1], where :math:i and :math:j are such that the :math:j\ th edges is part of the :math:i\ th line of the boundary and :math:\mathrm{lined}[3,i-1]\geq 0;

:math:\mathrm{edge}[2,j-1] = 100+\left\lvert \mathrm{lined}[3,i-1]\right\rvert, where :math:i and :math:j are such that the :math:j\ th edges is part of the :math:i\ th line of the boundary and :math:\mathrm{lined}[3,i-1] < 0.

.. _d06ba-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, the indices of the extremities of line :math:\langle\mathit{\boldsymbol{value}}\rangle are both equal to :math:\langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, the sum of absolute values of all numbers of line segments is different from :math:\textit{nlines}. The sum of all the elements of :math:\mathrm{nlcomp} = \langle\mathit{\boldsymbol{value}}\rangle. :math:\textit{nlines} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, :math:\textit{ncomp} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{ncomp} \geq 1.

(errno :math:1)
On entry, :math:\textit{nlines} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nlines} \geq 1.

(errno :math:1)
On entry, the geometric progression ratio between the points to be generated on line :math:\langle\mathit{\boldsymbol{value}}\rangle is :math:\langle\mathit{\boldsymbol{value}}\rangle. It should be greater than :math:0 unless the line segment is defined by user-supplied points.

(errno :math:1)
On entry, the index of the second end point of line :math:\langle\mathit{\boldsymbol{value}}\rangle is :math:\langle\mathit{\boldsymbol{value}}\rangle. It should be greater than or equal to :math:1 and less than or equal to :math:\textit{nlines} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, the index of the first end point of line :math:\langle\mathit{\boldsymbol{value}}\rangle is :math:\langle\mathit{\boldsymbol{value}}\rangle. It should be greater than or equal to :math:1 and less than or equal to :math:\textit{nlines} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, the number of points on line :math:\langle\mathit{\boldsymbol{value}}\rangle is :math:\langle\mathit{\boldsymbol{value}}\rangle. It should be greater than or equal to :math:2.

(errno :math:1)
On entry, :math:\mathrm{nvmax} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nlines} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nvmax}\geq \textit{nlines}.

(errno :math:1)
On entry, :math:\mathrm{nedmx} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nedmx} \geq 1.

(errno :math:1)
On entry, the line list for the separate connected component of the boundary is badly set: :math:\mathrm{lcomp}[l-1] = \langle\mathit{\boldsymbol{value}}\rangle and :math:l = \langle\mathit{\boldsymbol{value}}\rangle. It should be less than or equal to :math:\textit{nlines} and greater than or equal to :math:1.

(errno :math:1)
On entry, end point :math:1, with index :math:\textit{K}, does not lie on the curve representing line :math:\textit{I} with index :math:\textit{J}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle, :math:f\left(x, y\right) = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, end point :math:2, with index :math:\textit{K}, does not lie on the curve representing line :math:\textit{I} with index :math:\textit{J}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle, :math:f\left(x, y\right) = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, :math:\textit{sdcrus} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nusmin} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{sdcrus}\geq \textit{nusmin}.

(errno :math:1)
On entry, there is a correlation problem between the user-supplied coordinates and the specification of the polygonal arc representing line :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle with the index in :math:\mathrm{crus} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, the absolute number of line segments in the :math:k\ th component of the contour should be less than or equal to :math:\textit{nlines} and greater than :math:0. :math:k = \langle\mathit{\boldsymbol{value}}\rangle, :math:\mathrm{nlcomp}[k-1] = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nlines} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:2)
An error has occurred during the generation of the boundary mesh. It appears that :math:\mathrm{nedmx} is not large enough: :math:\mathrm{nedmx} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:3)
An error has occurred during the generation of the boundary mesh. It appears that :math:\mathrm{nvmax} is not large enough: :math:\mathrm{nvmax} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:4)
An error has occurred during the generation of the boundary mesh. Check the definition of each line (the argument :math:\mathrm{lined}) and each connected component of the boundary (the arguments :math:\mathrm{nlcomp}, and :math:\mathrm{lcomp}, as well as the coordinates of the characteristic points. Setting :math:\mathrm{itrace} > 0 may provide more details.

.. _d06ba-py2-py-notes:

**Notes**
Given a closed connected subdomain :math:\Omega of :math:\mathbb{R}^2, whose boundary :math:\partial \Omega is divided by characteristic points into :math:m distinct line segments, dim2_gen_boundary generates a boundary mesh on :math:\partial \Omega.
Each line segment may be a straight line, a curve defined by the equation :math:f\left(x, y\right) = 0, or a polygonal curve defined by a set of given boundary mesh points.

This function is primarily designed for use with either :meth:dim2_gen_inc (a simple incremental method) or :meth:dim2_gen_delaunay (Delaunay--Voronoi method) or :meth:dim2_gen_front (Advancing Front method) to triangulate the interior of the domain :math:\Omega.
For more details about the boundary and interior mesh generation, consult the D06 Introduction <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html>__ as well as George and Borouchaki (1998).

This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

.. _d06ba-py2-py-references:

**References**
George, P L and Borouchaki, H, 1998, Delaunay Triangulation and Meshing: Application to Finite Elements, Editions HERMES, Paris
"""
raise NotImplementedError

[docs]def dim2_smooth_bary(coor, edge, conn, numfix, itrace, nqint, io_manager=None):
r"""
dim2_smooth_bary uses a barycentering technique to smooth a given mesh.

.. _d06ca-py2-py-doc:

For full information please refer to the NAG Library document for d06ca

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06caf.html

.. _d06ca-py2-py-parameters:

**Parameters**
**coor** : float, array-like, shape :math:\left(2, \textit{nv}\right)
:math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th input mesh vertex, for :math:\textit{i} = 1,2,\ldots,\textit{nv}; while :math:\mathrm{coor}[1,\textit{i}-1] contains the corresponding :math:y coordinate.

**edge** : int, array-like, shape :math:\left(3, \textit{nedge}\right)
The specification of the boundary or interface edges. :math:\mathrm{edge}[0,j-1] and :math:\mathrm{edge}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge}[2,j-1] is a user-supplied tag for the :math:j\ th boundary or interface edge: :math:\mathrm{edge}[2,j-1] = 0 for an interior edge and has a nonzero tag otherwise.

**conn** : int, array-like, shape :math:\left(3, \textit{nelt}\right)
The connectivity of the mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conn}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\textit{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

**numfix** : int, array-like, shape :math:\left(\textit{nvfix}\right)
The indices in :math:\mathrm{coor} of fixed interior vertices of the input mesh.

**itrace** : int
The level of trace information required from dim2_smooth_bary.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace} = 1

A histogram of the triangular element qualities is printed on the file object associated with the advisory I/O unit (see :class:~naginterfaces.base.utils.FileObjManager) before and after smoothing. This histogram gives the lowest and the highest triangle quality as well as the number of elements lying in each of the :math:\mathrm{nqint} equal intervals between the extremes.

:math:\mathrm{itrace} > 1

The output is similar to that produced when :math:\mathrm{itrace} = 1 but the connectivity between vertices and triangles (for each vertex, the list of triangles in which it appears) is given.

You are advised to set :math:\mathrm{itrace} = 0, unless you are experienced with finite element meshes.

**nqint** : int
The number of intervals between the extreme quality values for the input and the smoothed mesh.

If :math:\mathrm{itrace} = 0, :math:\mathrm{nqint} is not referenced.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**coor** : float, ndarray, shape :math:\left(2, \textit{nv}\right)
:math:\mathrm{coor}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\textit{i}\ th smoothed mesh vertex, for :math:\textit{i} = 1,2,\ldots,\textit{nv}; while :math:\mathrm{coor}[1,\textit{i}-1] will contain the corresponding :math:y coordinate. Note that the coordinates of boundary and interface edge vertices, as well as those specified by you (see the description of :math:\mathrm{numfix}), are unchanged by the process.

.. _d06ca-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nv} \geq 3.

(errno :math:1)
On entry, :math:\textit{nedge} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\leq \textit{nv}.

(errno :math:1)
On entry, :math:\textit{nelt} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nelt}\leq 2\times \textit{nv}-1.

(errno :math:1)
On entry, :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right)\leq \textit{nv}.

(errno :math:1)
On entry, :math:\mathrm{numfix}[\textit{I}-1] = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{numfix}[\textit{I}-1]\geq 1 and :math:\mathrm{numfix}[\textit{I}-1]\leq \textit{nv}.

(errno :math:1)
On entry, :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nvfix} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:0\leq \textit{nvfix}\leq \textit{nv}.

(errno :math:1)
On entry, the end points of the edge :math:\textit{J} have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:2 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:2 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:2)
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh especially the connectivity. Seek expert help.

.. _d06ca-py2-py-notes:

**Notes**
dim2_smooth_bary uses a barycentering approach to improve the smoothness of a given mesh.
The measure of quality used for a triangle :math:K is

.. math::
Q_K = \alpha \frac{h_K}{\rho_K}\text{;}

where :math:h_K is the diameter (length of the longest edge) of :math:K, :math:\rho_K is the radius of its inscribed circle and :math:\alpha = \frac{\sqrt{3}}{6} is a normalization factor chosen to give :math:Q_K = 1 for an equilateral triangle. :math:Q_K ranges from :math:1, for an equilateral triangle, to :math:\infty, for a totally flat triangle.

dim2_smooth_bary makes small perturbation to vertices (using a barycenter formula) in order to give a reasonably good value of :math:Q_K for all neighbouring triangles.
Some vertices may optionally be excluded from this process.

For more details about the smoothing method, especially with regard to differing quality, consult the D06 Introduction <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html>__ as well as George and Borouchaki (1998).

This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

.. _d06ca-py2-py-references:

**References**
George, P L and Borouchaki, H, 1998, Delaunay Triangulation and Meshing: Application to Finite Elements, Editions HERMES, Paris
"""
raise NotImplementedError

[docs]def dim2_sparsity(nv, nnzmax, conn):
r"""
dim2_sparsity generates the sparsity pattern of a finite element matrix associated with a given mesh.

.. _d06cb-py2-py-doc:

For full information please refer to the NAG Library document for d06cb

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06cbf.html

.. _d06cb-py2-py-parameters:

**Parameters**
**nv** : int
The total number of vertices in the input mesh.

**nnzmax** : int
The maximum number of nonzero entries in the matrix based on the input mesh. It is the dimension of the arrays :math:\mathrm{irow} and :math:\mathrm{icol} as declared in the function from which dim2_sparsity is called.

**conn** : int, array-like, shape :math:\left(3, \textit{nelt}\right)
The connectivity of the mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conn}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\textit{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

**Returns**
**nnz** : int
The number of nonzero entries in the matrix associated with the input mesh.

**irow** : int, ndarray, shape :math:\left(\mathrm{nnzmax}\right)
The first :math:\mathrm{nnz} elements contain the row and column indices of the nonzero elements supplied in the finite element matrix :math:A.

**icol** : int, ndarray, shape :math:\left(\mathrm{nnzmax}\right)
The first :math:\mathrm{nnz} elements contain the row and column indices of the nonzero elements supplied in the finite element matrix :math:A.

.. _d06cb-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\mathrm{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right)\leq \mathrm{nv}.

(errno :math:1)
On entry, :math:\textit{nelt} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\mathrm{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nelt}\leq 2\times \mathrm{nv}-1.

(errno :math:1)
On entry, vertices :math:2 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:2 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, :math:\mathrm{nnzmax} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\mathrm{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nnzmax}\leq \mathrm{nv}^2.

(errno :math:1)
On entry, :math:\mathrm{nnzmax} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{nelt} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\mathrm{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nnzmax}\geq \left(4\times \textit{nelt}+\mathrm{nv}\right).

(errno :math:1)
On entry, :math:\mathrm{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nv} \geq 3.

(errno :math:2)
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh, especially the connectivity between triangles and vertices (the argument :math:\mathrm{conn}). Array dimensions should also be checked. If the problem persists, contact NAG <https://www.nag.com>__.

.. _d06cb-py2-py-notes:

**Notes**
dim2_sparsity generates the sparsity pattern of a finite element matrix associated with a given mesh.
The sparsity pattern is returned in a coordinate storage format consistent with the sparse linear algebra functions in submodule :mod:~naginterfaces.library.sparse.
More precisely dim2_sparsity returns the number of nonzero elements in the associated sparse matrix, and their row and column indices.
This is designed to assist you in applying finite element discretization to meshes from the D06 Introduction <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06intro.html>__ and in solving the resulting sparse linear system using functions from submodule :mod:~naginterfaces.library.sparse.

The output sparsity pattern is based on the fact that finite element matrix :math:A has elements :math:a_{{ij}} satisfying:

.. math::
a_{{ij}}\neq 0⇒i\text{ and }j\text{ are vertices belonging to the same triangle.}
"""
raise NotImplementedError

[docs]def dim2_renumber(nnzmax, coor, edge, conn, itrace, io_manager=None):
r"""
dim2_renumber renumbers the vertices of a given mesh using a Gibbs method, in order the reduce the bandwidth of Finite Element matrices associated with that mesh.

.. _d06cc-py2-py-doc:

For full information please refer to the NAG Library document for d06cc

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06ccf.html

.. _d06cc-py2-py-parameters:

**Parameters**
**nnzmax** : int
The maximum number of nonzero entries in the matrix based on the input mesh. It is the dimension of the arrays :math:\mathrm{irow} and :math:\mathrm{icol} as declared in the function from which dim2_renumber is called.

**coor** : float, array-like, shape :math:\left(2, \textit{nv}\right)
:math:\mathrm{coor}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th input mesh vertex, for :math:\textit{i} = 1,\ldots,\textit{nv}; while :math:\mathrm{coor}[1,\textit{i}-1] contains the corresponding :math:y coordinate.

**edge** : int, array-like, shape :math:\left(3, \textit{nedge}\right)
The specification of the boundary or interface edges. :math:\mathrm{edge}[0,j-1] and :math:\mathrm{edge}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge}[2,j-1] is a user-supplied tag for the :math:j\ th boundary or interface edge: :math:\mathrm{edge}[2,j-1] = 0 for an interior edge and has a nonzero tag otherwise.

**conn** : int, array-like, shape :math:\left(3, \textit{nelt}\right)
The connectivity of the mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conn}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\textit{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

**itrace** : int
The level of trace information required from dim2_renumber.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace} = 1

Information about the effect of the renumbering on the finite element matrix are output. This information includes the half bandwidth and the sparsity structure of this matrix before and after renumbering.

:math:\mathrm{itrace} > 1

The output is similar to that produced when :math:\mathrm{itrace} = 1 but the sparsities (for each row of the matrix, indices of nonzero entries) of the matrix before and after renumbering are also output.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**nnz** : int
The number of nonzero entries in the matrix based on the input mesh.

**coor** : float, ndarray, shape :math:\left(2, \textit{nv}\right)
:math:\mathrm{coor}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\textit{i}\ th renumbered mesh vertex, for :math:\textit{i} = 1,\ldots,\textit{nv}; while :math:\mathrm{coor}[1,\textit{i}-1] will contain the corresponding :math:y coordinate.

**edge** : int, ndarray, shape :math:\left(3, \textit{nedge}\right)
The renumbered specification of the boundary or interface edges.

**conn** : int, ndarray, shape :math:\left(3, \textit{nelt}\right)
The renumbered connectivity of the mesh between triangles and vertices.

**irow** : int, ndarray, shape :math:\left(\mathrm{nnzmax}\right)
The first :math:\mathrm{nnz} elements contain the row and column indices of the nonzero elements supplied in the finite element matrix :math:A.

**icol** : int, ndarray, shape :math:\left(\mathrm{nnzmax}\right)
The first :math:\mathrm{nnz} elements contain the row and column indices of the nonzero elements supplied in the finite element matrix :math:A.

.. _d06cc-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nv} \geq 3.

(errno :math:1)
On entry, :math:\textit{nedge} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge}\left(\textit{I}, \textit{J}\right)\leq \textit{nv}.

(errno :math:1)
On entry, :math:\textit{nelt} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nelt}\leq 2\times \textit{nv}-1.

(errno :math:1)
On entry, :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{conn}\left(\textit{I}, \textit{J}\right)\leq \textit{nv}.

(errno :math:1)
On entry, :math:\mathrm{nnzmax} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{nelt} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{nnzmax}\geq \left(4\times \textit{nelt}+\textit{nv}\right) and :math:\mathrm{nnzmax}\leq \textit{nv}^2.

(errno :math:1)
On entry, the end points of the edge :math:\textit{J} have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:2 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:2 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:2)
An error has occurred during the computation of the compact sparsity of the finite element matrix. Check the Triangle/Vertices connectivity.

(errno :math:3)
A serious error has occurred in an internal call to the renumbering function. Check the input mesh especially the connectivity. Seek expert help.

.. _d06cc-py2-py-notes:

**Notes**
dim2_renumber uses a Gibbs method to renumber the vertices of a given mesh in order to reduce the bandwidth of the associated finite element matrix :math:A.
This matrix has elements :math:a_{{ij}} such that:

.. math::
a_{{ij}}\neq 0⇒i\text{ and }j\text{ are vertices belonging to the same triangle.}

This function reduces the bandwidth :math:m, which is the smallest integer such that :math:a_{{ij}}\neq 0 whenever :math:\left\lvert i-j\right\rvert > m (see Gibbs et al. (1976) for details about that method). dim2_renumber also returns the sparsity structure of the matrix associated with the renumbered mesh.

This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

.. _d06cc-py2-py-references:

**References**
Gibbs, N E, Poole, W G Jr and Stockmeyer, P K, 1976, An algorithm for reducing the bandwidth and profile of a sparse matrix, SIAM J. Numer. Anal. (13), 236--250
"""
raise NotImplementedError

[docs]def dim2_transform_affine(mode, itype, trans, coori, edgei, conni, itrace, io_manager=None):
r"""
dim2_transform_affine is a utility which performs an affine transformation of a given mesh.

.. _d06da-py2-py-doc:

For full information please refer to the NAG Library document for d06da

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06daf.html

.. _d06da-py2-py-parameters:

**Parameters**
**mode** : int
If :math:\mathrm{mode} = 1, the arguments :math:\mathrm{coori}, :math:\mathrm{edgei} and :math:\mathrm{conni} are overwritten on exit by the output values described in :math:\mathrm{cooro}, :math:\mathrm{edgeo} and :math:\mathrm{conno} respectively. In this case :math:\mathrm{cooro}, :math:\mathrm{edgeo} and :math:\mathrm{conno} are not referenced, and you can save storage space.

If :math:\mathrm{mode}\neq 1, no such aliasing is assumed.

**itype** : int, array-like, shape :math:\left(\textit{ntrans}\right)
:math:\mathrm{itype}[\textit{i}-1], for :math:\textit{i} = 1,2,\ldots,\textit{ntrans}, indicates the type of each transformation as follows:

:math:\mathrm{itype}[i-1] = 0

Identity transformation.

:math:\mathrm{itype}[i-1] = 1

Translation.

:math:\mathrm{itype}[i-1] = 2

Symmetric transformation with respect to a user-supplied line.

:math:\mathrm{itype}[i-1] = 3

Rotation.

:math:\mathrm{itype}[i-1] = 4

Scaling.

:math:\mathrm{itype}[i-1] = 10

User-supplied analytic transformation.

Note that the transformations are applied in the order described in :math:\mathrm{itype}.

**trans** : float, array-like, shape :math:\left(6, \textit{ntrans}\right)
The arguments for each transformation. For :math:i = 1,2,\ldots,\textit{ntrans}, :math:\mathrm{trans}[0,i-1] to :math:\mathrm{trans}[5,i-1] contain the arguments of the :math:i\ th transformation.

If :math:\mathrm{itype}[i-1] = 0, elements :math:\mathrm{trans}[0,i-1] to :math:\mathrm{trans}[5,i-1] are not referenced.

If :math:\mathrm{itype}[i-1] = 1, the translation vector is :math:\vec{u} = \begin{pmatrix}a\\b\end{pmatrix}, where :math:a = \mathrm{trans}[0,i-1] and :math:b = \mathrm{trans}[1,i-1], while elements :math:\mathrm{trans}[2,i-1] to :math:\mathrm{trans}[5,i-1] are not referenced.

If :math:\mathrm{itype}[i-1] = 2, the user-supplied line is the curve {:math:\left(x, y\right) \in \mathbb{R}^2; such that :math:ax+by+c = 0}, where :math:a = \mathrm{trans}[0,i-1], :math:b = \mathrm{trans}[1,i-1] and :math:c = \mathrm{trans}[2,i-1], while elements :math:\mathrm{trans}[3,i-1] to :math:\mathrm{trans}[5,i-1] are not referenced.

If :math:\mathrm{itype}[i-1] = 3, the centre of the rotation is :math:\left(x_0, y_0\right) where :math:x_0 = \mathrm{trans}[0,i-1] and :math:y_0 = \mathrm{trans}[1,i-1], :math:\theta = \mathrm{trans}[2,i-1] is its angle in degrees, while elements :math:\mathrm{trans}[3,i-1] to :math:\mathrm{trans}[5,i-1] are not referenced.

If :math:\mathrm{itype}[i-1] = 4, :math:a = \mathrm{trans}[0,i-1] is the scaling coefficient in the :math:x-direction, :math:b = \mathrm{trans}[1,i-1] is the scaling coefficient in the :math:y-direction, and :math:\left(x_0, y_0\right) are the scaling centre coordinates, with :math:x_0 = \mathrm{trans}[2,i-1] and :math:y_0 = \mathrm{trans}[3,i-1]; while elements :math:\mathrm{trans}[4,i-1] to :math:\mathrm{trans}[5,i-1] are not referenced.

If :math:\mathrm{itype}[i-1] = 10, the user-supplied analytic affine transformation :math:Y = A\times X+B is such that :math:A = \left(a_{{kl}}\right)_{{1\leq k,l\leq 2}} and :math:B = \left(b_k\right)_{{1\leq k\leq 2}} where\ :math:a_{{kl}} = \mathrm{trans}[2\times \left(k-1\right)+l-1,i-1], and :math:b_k = \mathrm{trans}[4+k-1,i-1] with :math:k,l = 1,2.

**coori** : float, array-like, shape :math:\left(2, \textit{nv}\right)
:math:\mathrm{coori}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th vertex of the input mesh, for :math:\textit{i} = 1,2,\ldots,\textit{nv}; while :math:\mathrm{coori}[1,i-1] contains the corresponding :math:y coordinate.

**edgei** : int, array-like, shape :math:\left(3, \textit{nedge}\right)
The specification of the boundary or interface edges. :math:\mathrm{edgei}[0,j-1] and :math:\mathrm{edgei}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edgei}[2,j-1] is a user-supplied tag for the :math:j\ th boundary edge.

**conni** : int, array-like, shape :math:\left(3, \textit{nelt}\right)
The connectivity of the input mesh between triangles and vertices. For each triangle :math:\textit{j}, :math:\mathrm{conni}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\textit{nelt}, for :math:\textit{i} = 1,2,\ldots,3.

**itrace** : int
The level of trace information required from dim2_transform_affine.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace}\geq 1

Details of each transformation, the matrix :math:A and the vector :math:B of the final transformation, which is the composition of all the :math:\textit{ntrans} transformations, are printed.

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**coori** : float, ndarray, shape :math:\left(2, \textit{nv}\right)
See Further Comments <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06daf.html#fcomments>__.

**edgei** : int, ndarray, shape :math:\left(3, \textit{nedge}\right)
If :math:\mathrm{mode} = 1, :math:\mathrm{edgei} holds the output values described in :math:\mathrm{edgeo}.

**conni** : int, ndarray, shape :math:\left(3, \textit{nelt}\right)
If :math:\mathrm{mode} = 1, :math:\mathrm{conni} holds the output values described in :math:\mathrm{conno}.

**cooro** : None or float, ndarray, shape :math:\left(:, :\right)
:math:\mathrm{cooro}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\textit{i}\ th vertex of the transformed mesh, for :math:\textit{i} = 1,2,\ldots,\textit{nv}; while :math:\mathrm{cooro}[1,i-1] will contain the corresponding :math:y coordinate.

**edgeo** : None or int, ndarray, shape :math:\left(:, :\right)
The specification of the boundary or interface edges of the transformed mesh. If the number of symmetric transformations is even or zero then :math:\mathrm{edgeo}[\textit{i}-1,\textit{j}-1] = \mathrm{edgei}[\textit{i}-1,\textit{j}-1], for :math:\textit{j} = 1,2,\ldots,\textit{nedge}, for :math:\textit{i} = 1,2,\ldots,3; otherwise :math:\mathrm{edgeo}[0,\textit{j}-1] = \mathrm{edgei}[1,\textit{j}-1],\ :math:\mathrm{edgeo}[1,\textit{j}-1] = \mathrm{edgei}[0,\textit{j}-1] and :math:\mathrm{edgeo}[2,\textit{j}-1] = \mathrm{edgei}[2,\textit{j}-1], for :math:\textit{j} = 1,2,\ldots,\textit{nedge}.

**conno** : None or int, ndarray, shape :math:\left(:, :\right)
The connectivity of the transformed mesh between triangles and vertices. If the number of symmetric transformations is even or zero then :math:\mathrm{conno}[\textit{i}-1,\textit{j}-1] = \mathrm{conni}[\textit{i}-1,\textit{j}-1], for :math:\textit{j} = 1,2,\ldots,\textit{nelt}, for :math:\textit{i} = 1,2,\ldots,3; otherwise :math:\mathrm{conno}[0,\textit{j}-1] = \mathrm{conni}[0,\textit{j}-1], :math:\mathrm{conno}[1,\textit{j}-1] = \mathrm{conni}[2,\textit{j}-1] and :math:\mathrm{conno}[2,\textit{j}-1] = \mathrm{conni}[1,\textit{j}-1], for :math:\textit{j} = 1,2,\ldots,\textit{nelt}.

.. _d06da-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nv} \geq 3.

(errno :math:1)
On entry, :math:\mathrm{itype}[\textit{I}-1] = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{itype}[\textit{I}-1] = 0, :math:1, :math:2, :math:3, :math:4 or :math:10.

(errno :math:1)
On entry, :math:\textit{nedge} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge} \geq 1.

(errno :math:1)
On entry, :math:\textit{nelt} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nelt}\leq 2\times \textit{nv}-1.

(errno :math:1)
On entry, :math:\mathrm{edgei}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edgei}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edgei}\left(\textit{I}, \textit{J}\right)\leq \textit{nv}.

(errno :math:1)
On entry, :math:\mathrm{conni}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{conni}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{conni}\left(\textit{I}, \textit{J}\right)\leq \textit{nv}.

(errno :math:1)
On entry, :math:\textit{ntrans} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{ntrans} > 0.

(errno :math:1)
On entry, the end points of the edge :math:\textit{J} have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:2 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:3 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:2 of the triangle :math:\textit{K} have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:2)
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh especially the connectivities and the details of each transformations.

.. _d06da-py2-py-notes:

**Notes**
dim2_transform_affine generates a mesh (coordinates, triangle/vertex connectivities and edge/vertex connectivities) resulting from an affine transformation of a given mesh.
This transformation is of the form :math:Y = A\times X+B, where

:math:Y, :math:X and :math:B are in :math:\mathbb{R}^2, and

:math:A is a real :math:2\times 2 matrix.

Such a transformation includes a translation, a rotation, a scale reduction or increase, a symmetric transformation with respect to a user-supplied line, a user-supplied analytic transformation, or a composition of several transformations.

This function is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).
"""
raise NotImplementedError

[docs]def dim2_join(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace, eps=0.001, io_manager=None):
r"""
dim2_join joins together (restitches) two adjacent, or overlapping, meshes.

.. _d06db-py2-py-doc:

For full information please refer to the NAG Library document for d06db

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06dbf.html

.. _d06db-py2-py-parameters:

**Parameters**
**coor1** : float, array-like, shape :math:\left(2, \textit{nv1}\right)
:math:\mathrm{coor1}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th vertex of the first input mesh, for :math:\textit{i} = 1,2,\ldots,\textit{nv1}; while :math:\mathrm{coor1}[1,\textit{i}-1] contains the corresponding :math:y coordinate.

**edge1** : int, array-like, shape :math:\left(3, \textit{nedge1}\right)
The specification of the boundary edges of the first input mesh. :math:\mathrm{edge1}[0,j-1] and :math:\mathrm{edge1}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge1}[2,j-1] is a user-supplied tag for the :math:j\ th boundary edge.

**conn1** : int, array-like, shape :math:\left(3, \textit{nelt1}\right)
The connectivity between triangles and vertices of the first input mesh. For each triangle :math:\textit{j}, :math:\mathrm{conn1}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\textit{nelt1}, for :math:\textit{i} = 1,2,\ldots,3.

**reft1** : int, array-like, shape :math:\left(\textit{nelt1}\right)
:math:\mathrm{reft1}[\textit{k}-1] contains the user-supplied tag of the :math:\textit{k}\ th triangle from the first input mesh, for :math:\textit{k} = 1,2,\ldots,\textit{nelt1}.

**coor2** : float, array-like, shape :math:\left(2, \textit{nv2}\right)
:math:\mathrm{coor2}[0,\textit{i}-1] contains the :math:x coordinate of the :math:\textit{i}\ th vertex of the second input mesh, for :math:\textit{i} = 1,2,\ldots,\textit{nv2}; while :math:\mathrm{coor2}[1,\textit{i}-1] contains the corresponding :math:y coordinate.

**edge2** : int, array-like, shape :math:\left(3, \textit{nedge2}\right)
The specification of the boundary edges of the second input mesh. :math:\mathrm{edge2}[0,j-1] and :math:\mathrm{edge2}[1,j-1] contain the vertex numbers of the two end points of the :math:j\ th boundary edge. :math:\mathrm{edge2}[2,j-1] is a user-supplied tag for the :math:j\ th boundary edge.

**conn2** : int, array-like, shape :math:\left(3, \textit{nelt2}\right)
The connectivity between triangles and vertices of the second input mesh. For each triangle :math:\textit{j}, :math:\mathrm{conn2}[\textit{i}-1,\textit{j}-1] gives the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\textit{nelt2}, for :math:\textit{i} = 1,2,\ldots,3.

**reft2** : int, array-like, shape :math:\left(\textit{nelt2}\right)
:math:\mathrm{reft2}[\textit{k}-1] contains the user-supplied tag of the :math:\textit{k}\ th triangle from the second input mesh, for :math:\textit{k} = 1,2,\ldots,\textit{nelt2}.

**itrace** : int
The level of trace information required from dim2_join.

:math:\mathrm{itrace}\leq 0

No output is generated.

:math:\mathrm{itrace}\geq 1

Details about the common vertices, edges and triangles to both meshes are printed.

**eps** : float, optional
The relative precision of the restitching of the two input meshes (see Further Comments <https://www.nag.com/numeric/nl/nagdoc_29/flhtml/d06/d06dbf.html#fcomments>__).

**io_manager** : FileObjManager, optional
Manager for I/O in this routine.

**Returns**
**nv3** : int
The total number of vertices in the resulting mesh.

**nelt3** : int
The number of triangular elements in the resulting mesh.

**nedge3** : int
The number of boundary edges in the resulting mesh.

**coor3** : float, ndarray, shape :math:\left(2, \textit{nv1}+\textit{nv2}\right)
:math:\mathrm{coor3}[0,\textit{i}-1] will contain the :math:x coordinate of the :math:\textit{i}\ th vertex of the resulting mesh, for :math:\textit{i} = 1,2,\ldots,\mathrm{nv3}; while :math:\mathrm{coor3}[1,i-1] will contain the corresponding :math:y coordinate.

**edge3** : int, ndarray, shape :math:\left(3, \textit{nedge1}+\textit{nedge2}\right)
The specification of the boundary edges of the resulting mesh. :math:\mathrm{edge3}[i-1,j-1] will contain the vertex number of the :math:i\ th end point (:math:i = 1,2) of the :math:j\ th boundary or interface edge.

If the two meshes overlap, :math:\mathrm{edge3}[2,j-1] will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.

If the two meshes are adjacent,

(i) if the :math:j\ th edge is part of the partition interface, :math:\mathrm{edge3}[2,j-1] will contain the value :math:1000\times k_1+k_2 where :math:k_1 and :math:k_2 are the tags for the same edge of the first and the second mesh respectively;

(#) otherwise, :math:\mathrm{edge3}[2,j-1] will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.

**conn3** : int, ndarray, shape :math:\left(3, \textit{nelt1}+\textit{nelt2}\right)
The connectivity between triangles and vertices of the resulting mesh. :math:\mathrm{conn3}[\textit{i}-1,\textit{j}-1] will give the indices of its three vertices (in anticlockwise order), for :math:\textit{j} = 1,2,\ldots,\mathrm{nelt3}, for :math:\textit{i} = 1,2,\ldots,3.

**reft3** : int, ndarray, shape :math:\left(\textit{nelt1}+\textit{nelt2}\right)
If the two meshes form a partition, :math:\mathrm{reft3}[\textit{k}-1] will contain the same tag as the corresponding triangle belonging to the first or the second input mesh, for :math:\textit{k} = 1,2,\ldots,\mathrm{nelt3}. If the two meshes overlap, :math:\mathrm{reft3}[\textit{k}-1] will contain the value :math:1000\times \textit{k}_1+\textit{k}_2 where :math:\textit{k}_1 and :math:\textit{k}_2 are the user-supplied tags for the same triangle of the first and the second mesh respectively, for :math:\textit{k} = 1,2,\ldots,\mathrm{nelt3}.

.. _d06db-py2-py-errors:

**Raises**
**NagValueError**
(errno :math:1)
On entry, :math:\textit{nv2} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nv2} \geq 3.

(errno :math:1)
On entry, :math:\textit{nedge2} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge2} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge2}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv2} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge2}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge2}\left(\textit{I}, \textit{J}\right)\leq \textit{nv2}.

(errno :math:1)
On entry, :math:\textit{nelt2} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv2} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nelt2}\leq \left(2\times \textit{nv2}-1\right).

(errno :math:1)
On entry, :math:\mathrm{conn2}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv2} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{conn2}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{conn2}\left(\textit{I}, \textit{J}\right)\leq \textit{nv2}.

(errno :math:1)
On entry, :math:\textit{nv1} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nv1} \geq 3.

(errno :math:1)
On entry, :math:\textit{nedge1} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nedge1} \geq 1.

(errno :math:1)
On entry, :math:\mathrm{edge1}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv1} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{edge1}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{edge1}\left(\textit{I}, \textit{J}\right)\leq \textit{nv1}.

(errno :math:1)
On entry, :math:\textit{nelt1} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv1} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\textit{nelt1}\leq \left(2\times \textit{nv1}-1\right).

(errno :math:1)
On entry, :math:\mathrm{conn1}\left(\textit{I}, \textit{J}\right) = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle, :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{nv1} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{conn1}\left(\textit{I}, \textit{J}\right)\geq 1 and :math:\mathrm{conn1}\left(\textit{I}, \textit{J}\right)\leq \textit{nv1}.

(errno :math:1)
On entry, :math:\mathrm{eps} = \langle\mathit{\boldsymbol{value}}\rangle.

Constraint: :math:\mathrm{eps} > 0.0.

(errno :math:1)
On entry, the end points of edge :math:\textit{J} in the second mesh have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:2 and :math:3 of triangle :math:\textit{K} in the second mesh have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:3 of triangle :math:\textit{K} in the second mesh have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:2 of triangle :math:\textit{K} in the second mesh have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, the end points of edge :math:\textit{J} in the first mesh have the same index :math:\textit{I}: :math:\textit{J} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:2 and :math:3 of triangle :math:\textit{K} in the first mesh have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:3 of triangle :math:\textit{K} in the first mesh have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:1)
On entry, vertices :math:1 and :math:2 of triangle :math:\textit{K} in the first mesh have the same index :math:\textit{I}: :math:\textit{K} = \langle\mathit{\boldsymbol{value}}\rangle and :math:\textit{I} = \langle\mathit{\boldsymbol{value}}\rangle.

(errno :math:2)
The function has detected only :math:\langle\mathit{\boldsymbol{value}}\rangle coincident vertices with a precision :math:\mathrm{eps} = \langle\mathit{\boldsymbol{value}}\rangle. Either :math:\mathrm{eps} should be changed or the two meshes are not restitchable.

(errno :math:3)
A serious error has occurred in an internal call to the restitching routine. Check the input of the two meshes, especially the edges/vertices and/or the triangles/vertices connectivities. Seek expert help.

(errno :math:4)
The function has detected a different number of coincident triangles from the two meshes in the overlapping zone :math:\langle\mathit{\boldsymbol{value}}\rangle :math:\langle\mathit{\boldsymbol{value}}\rangle. Check the input of the two meshes, especially the triangles/vertices connectivity.

(errno :math:5)
The function has detected a different number of coincident edges from the two meshes on the partition interface :math:\langle\mathit{\boldsymbol{value}}\rangle :math:\langle\mathit{\boldsymbol{value}}\rangle. Check the input of the two meshes, especially the edges/vertices connectivity.

.. _d06db-py2-py-notes:

**Notes**
dim2_join joins together two adjacent, or overlapping, meshes.
If the two meshes are adjacent then vertices belonging to the part of the boundary forming the common interface should coincide.
If the two meshes overlap then vertices and triangles in the overlapping zone should coincide too.

This function is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).
"""
raise NotImplementedError