#coding: utf8
"""
Meshes classes.

"""


class Mesh(object):
    """
    Base class for all meshes
    """


class Mesh1D(Mesh):
    """
    Base class for every one-dimensional transverse mesh in two-dimensional geometry
    """
    dim = 1


class Axis(Mesh1D):
    """
    Base class for all 1D meshes (used as axes by 2D and 3D rectangular meshes).
    """
    dim = 1
    def get_midpoints(self):
        """
        get_midpoints(self)
        """

    midpoints = None
    """
    Mesh with points in the middles of elements of this mesh
    """



class MeshGenerator(Mesh):
    """
    Base class for all mesh generators
    """


class Generator1D(MeshGenerator):
    """
    Base class for all 1D mesh generators.
    """
    def __call__(*args, **kwargs):
        """
        __call__(self, geometry)
        __call__(self, object)
        
            Generate mesh for given geometry object or load it from the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """

    def clear_cache(self):
        """
        clear_cache(self)
        
            Clear cache of generated meshes
        """

    def generate(*args, **kwargs):
        """
        generate(self, geometry)
        generate(self, object)
        
            Generate mesh for given geometry object omitting the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """



class Generator2D(MeshGenerator):
    """
    Base class for all 2D mesh generators.
    """
    def __call__(*args, **kwargs):
        """
        __call__(self, geometry)
        __call__(self, object)
        
            Generate mesh for given geometry object or load it from the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """

    def clear_cache(self):
        """
        clear_cache(self)
        
            Clear cache of generated meshes
        """

    def generate(*args, **kwargs):
        """
        generate(self, geometry)
        generate(self, object)
        
            Generate mesh for given geometry object omitting the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """



class Generator3D(MeshGenerator):
    """
    Base class for all 3D mesh generators.
    """
    def __call__(*args, **kwargs):
        """
        __call__(self, geometry)
        __call__(self, object)
        
            Generate mesh for given geometry object or load it from the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """

    def clear_cache(self):
        """
        clear_cache(self)
        
            Clear cache of generated meshes
        """

    def generate(*args, **kwargs):
        """
        generate(self, geometry)
        generate(self, object)
        
            Generate mesh for given geometry object omitting the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """



class Mesh2D(Mesh):
    """
    Base class for every two-dimensional mesh
    """
    dim = 2


class Mesh3D(Mesh):
    """
    Base class for every two-dimensional mesh
    """
    dim = 3


class Ordered(Axis):
    """
    One-dimesnional rectilinear mesh, used also as rectangular mesh axis
    
    Ordered()
        create empty mesh
    
    Ordered(points)
        create mesh filled with points provides in sequence type
    """
    class DivideGenerator(Generator1D):
        """
        Generator of Rectilinear1D mesh by simple division of the geometry.
        
        DivideGenerator()
            create generator without initial division of geometry objects
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def add_refinement(*args, **kwargs):
            """
            add_refinement(self, axis, object, path, at)
            add_refinement(self, axis, object, at)
            add_refinement(self, axis, subtree, at)
            add_refinement(self, axis, path, at)
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            """

        aspect = None
        """
        Maximum aspect ratio for the elements generated by this generator.
        """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def clear_refinements(subtree):
            """
            clear_refinements(subtree)
            
                Clear all refining lines
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def get_refinements(self, axis):
            """
            get_refinements(self, axis)
            
                Get list of all the refinements defined for this generator for specified axis
            """

        gradual = None
        """
        Limit maximum adjacent objects size change to the factor of two.
        """

        postdiv = None
        """
        final division of all geometry objects
        """

        prediv = None
        """
        initial division of all geometry objects
        """

        def remove_refinement(*args, **kwargs):
            """
            remove_refinement(self, axis, object, path, at)
            remove_refinement(self, axis, object, at)
            remove_refinement(self, axis, subtree, at)
            remove_refinement(self, axis, path, at)
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            """

        def remove_refinements(*args, **kwargs):
            """
            remove_refinements(self, object, path=None)
            remove_refinements(self, path)
            remove_refinements(self, subtree)
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            """

        warn_missing = None
        """
        Warn if refining path does not point to any object
        """

        warn_multiple = None
        """
        Warn if refining path points to more than one object
        """

        warn_ouside = None
        """
        Warn if refining line is outside of its object
        """


    class RegularGenerator(Generator1D):
        """
        Generator of ordered 1D mesh with lines at transverse edges of all objects
        and fine regular division of each object with spacing approximately equal to
        specified spacing
        
        RegularGenerator(spacing)
            create generator
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """


    class SimpleGenerator(Generator1D):
        """
        Generator of ordered 1D mesh with lines at transverse edges of all objects.
        
        SimpleGenerator()
            create generator
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """


    class SmoothGenerator(Generator1D):
        """
        Generator of Rectilinear1D mesh with dense sampling at edges and smooth change of element size.
        
        SmoothGenerator()
            create generator without initial division of geometry objects
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def add_refinement(*args, **kwargs):
            """
            add_refinement(self, axis, object, path, at)
            add_refinement(self, axis, object, at)
            add_refinement(self, axis, subtree, at)
            add_refinement(self, axis, path, at)
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            """

        aspect = None
        """
        Maximum aspect ratio for the elements generated by this generator.
        """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def clear_refinements(subtree):
            """
            clear_refinements(subtree)
            
                Clear all refining lines
            """

        factor = None
        """
        factor by which element sizes increase along each axis
        """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def get_refinements(self, axis):
            """
            get_refinements(self, axis)
            
                Get list of all the refinements defined for this generator for specified axis
            """

        large = None
        """
        maximum size of mesh elements along each axis
        """

        def remove_refinement(*args, **kwargs):
            """
            remove_refinement(self, axis, object, path, at)
            remove_refinement(self, axis, object, at)
            remove_refinement(self, axis, subtree, at)
            remove_refinement(self, axis, path, at)
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            """

        def remove_refinements(*args, **kwargs):
            """
            remove_refinements(self, object, path=None)
            remove_refinements(self, path)
            remove_refinements(self, subtree)
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            """

        small = None
        """
        small size of mesh elements near object edges along each axis
        """

        warn_missing = None
        """
        Warn if refining path does not point to any object
        """

        warn_multiple = None
        """
        Warn if refining path points to more than one object
        """

        warn_ouside = None
        """
        Warn if refining line is outside of its object
        """


    dim = 1
    def extend(self, points):
        """
        extend(self, points)
        
            Insert points from the sequence to the mesh
        """

    def get_midpoints(self):
        """
        get_midpoints(self)
        """

    def insert(self, point):
        """
        insert(self, point)
        
            Insert point into the mesh
        """

    midpoints = None
    """
    Mesh with points in the middles of elements of this mesh
    """



class RectangularBase2D(Mesh2D):
    """
    Base class for 2D rectangular meshes.Do not use it directly.
    """
    def Bottom(*args, **kwargs):
        """
        Bottom() -> Boundary :
            Bottom edge of the mesh for setting boundary conditions
        """

    def BottomOf(object, path=None):
        """
        BottomOf(object, path=None)
        
            Boundary bottom of specified object
        """

    class Boundary(object):
        """
        Generic boundary specification for RectangularBase2D mesh
        """
        def __call__(self, mesh, geometry):
            """
            __call__(self, mesh, geometry)
            
                Get boundary instance for particular mesh
            """


    class BoundaryConditions(object):
        """
        Set of boundary conditions.
        """
        class BoundaryCondition(object):
            class Iterator(object):
                pass

            place = None
            """
            Location of the boundary condition.
            """

            value = None
            """
            Value of the boundary condition.
            """


        class Iterator(object):
            pass

        def append(self, place, value):
            """
            append(self, place, value)
            
                Append new boundary condition to the list.
            """

        def clear(self):
            """
            clear(self)
            
                Clear all boundary conditions.
            """

        def insert(self, index, place, value):
            """
            insert(self, index, place, value)
            
                Insert new boundary condition to the list at specified position.
            """

        def prepend(self, place, value):
            """
            prepend(self, place, value)
            
                Prepend new boundary condition to the list.
            """

        def read_from_xpl(self, xml, manager):
            """
            read_from_xpl(self, xml, manager)
            
                Read boundary conditions from active XPL reader.
                
                This should only be used in the overloaded :meth:`plask.Solver.load_xpl` method.
            """


    def Horizontal(*args, **kwargs):
        """
        Horizontal(at, start, stop)
        Horizontal(at)
        
            Boundary at horizontal line
        
            Boundary at horizontal line
        """

    def Left(*args, **kwargs):
        """
        Left() -> Boundary :
            Left edge of the mesh for setting boundary conditions
        """

    def LeftOf(object, path=None):
        """
        LeftOf(object, path=None)
        
            Boundary left of specified object
        """

    def Right(*args, **kwargs):
        """
        Right() -> Boundary :
            Right edge of the mesh for setting boundary conditions
        """

    def RightOf(object, path=None):
        """
        RightOf(object, path=None)
        
            Boundary right of specified object
        """

    def Top(*args, **kwargs):
        """
        Top() -> Boundary :
            Top edge of the mesh for setting boundary conditions
        """

    def TopOf(object, path=None):
        """
        TopOf(object, path=None)
        
            Boundary top of specified object
        """

    def Vertical(*args, **kwargs):
        """
        Vertical(at, start, stop)
        Vertical(at)
        
            Boundary at vertical line
        
            Boundary at vertical line
        """

    dim = 2


class Rectangular2D(RectangularBase2D):
    """
    Two-dimensional mesh
    
    Rectangular2D(ordering='01')
        create empty mesh
    
    Rectangular2D(axis0, axis1, ordering='01')
        create mesh with axes supplied as sequences of numbers
    
    Rectangular2D(geometry, ordering='01')
        create coarse mesh based on bounding boxes of geometry objects
    
    ordering can be either '01', '10' and specifies ordering of the mesh points (last index changing fastest).
    """
    def Bottom(*args, **kwargs):
        """
        Bottom() -> Boundary :
            Bottom edge of the mesh for setting boundary conditions
        """

    def BottomOf(object, path=None):
        """
        BottomOf(object, path=None)
        
            Boundary bottom of specified object
        """

    class Boundary(object):
        """
        Generic boundary specification for RectangularBase2D mesh
        """
        def __call__(self, mesh, geometry):
            """
            __call__(self, mesh, geometry)
            
                Get boundary instance for particular mesh
            """


    class BoundaryConditions(object):
        """
        Set of boundary conditions.
        """
        class BoundaryCondition(object):
            class Iterator(object):
                pass

            place = None
            """
            Location of the boundary condition.
            """

            value = None
            """
            Value of the boundary condition.
            """


        class Iterator(object):
            pass

        def append(self, place, value):
            """
            append(self, place, value)
            
                Append new boundary condition to the list.
            """

        def clear(self):
            """
            clear(self)
            
                Clear all boundary conditions.
            """

        def insert(self, index, place, value):
            """
            insert(self, index, place, value)
            
                Insert new boundary condition to the list at specified position.
            """

        def prepend(self, place, value):
            """
            prepend(self, place, value)
            
                Prepend new boundary condition to the list.
            """

        def read_from_xpl(self, xml, manager):
            """
            read_from_xpl(self, xml, manager)
            
                Read boundary conditions from active XPL reader.
                
                This should only be used in the overloaded :meth:`plask.Solver.load_xpl` method.
            """


    class DivideGenerator(Generator2D):
        """
        Generator of Rectilinear2D mesh by simple division of the geometry.
        
        DivideGenerator()
            create generator without initial division of geometry objects
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def add_refinement(*args, **kwargs):
            """
            add_refinement(self, axis, object, path, at)
            add_refinement(self, axis, object, at)
            add_refinement(self, axis, subtree, at)
            add_refinement(self, axis, path, at)
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            """

        aspect = None
        """
        Maximum aspect ratio for the elements generated by this generator.
        """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def clear_refinements(subtree):
            """
            clear_refinements(subtree)
            
                Clear all refining lines
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def get_refinements(self, axis):
            """
            get_refinements(self, axis)
            
                Get list of all the refinements defined for this generator for specified axis
            """

        gradual = None
        """
        Limit maximum adjacent objects size change to the factor of two.
        """

        postdiv = None
        """
        final division of all geometry objects
        """

        prediv = None
        """
        initial division of all geometry objects
        """

        def remove_refinement(*args, **kwargs):
            """
            remove_refinement(self, axis, object, path, at)
            remove_refinement(self, axis, object, at)
            remove_refinement(self, axis, subtree, at)
            remove_refinement(self, axis, path, at)
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            """

        def remove_refinements(*args, **kwargs):
            """
            remove_refinements(self, object, path=None)
            remove_refinements(self, path)
            remove_refinements(self, subtree)
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            """

        warn_missing = None
        """
        Warn if refining path does not point to any object
        """

        warn_multiple = None
        """
        Warn if refining path points to more than one object
        """

        warn_ouside = None
        """
        Warn if refining line is outside of its object
        """


    class Element(object):
        """
        Element (FEM-like, rectangular) of the :py:class:`mesh.Rectangular2D
        """
        area = None
        """
        Area of the element
        """

        bottom = None
        """
        Position of the bottom edge of the element
        """

        box = None
        """
        Bounding box of the element
        """

        center = None
        """
        Position of the element center
        """

        height = None
        """
        Height of the element
        """

        index = None
        """
        Element index
        """

        index0 = None
        """
        Element index in the first axis
        """

        index1 = None
        """
        Element index in the second axis
        """

        left = None
        """
        Position of the left edge of the element
        """

        nodes = None
        """
        Indices of the element vertices on the orignal mesh
        
        Order of the vertices is bottom left, bottom right, top left, and top right.
        """

        right = None
        """
        Position of the right edge of the element
        """

        top = None
        """
        Position of the top edge of the element
        """

        volume = None
        """
        Alias for :attr:`area`
        """

        width = None
        """
        Width of the element
        """


    class Elements(object):
        """
        Element list in the :py:class:`mesh.Rectangular2D
        """
        mesh = None
        """
        Mesh with element centers
        """


    def Horizontal(*args, **kwargs):
        """
        Horizontal(at, start, stop)
        Horizontal(at)
        
            Boundary at horizontal line
        
            Boundary at horizontal line
        """

    def Left(*args, **kwargs):
        """
        Left() -> Boundary :
            Left edge of the mesh for setting boundary conditions
        """

    def LeftOf(object, path=None):
        """
        LeftOf(object, path=None)
        
            Boundary left of specified object
        """

    class RegularGenerator(Generator2D):
        """
        Generator of Rectilinear2D mesh with lines at transverse edges of all objects
        and fine regular division of each object with spacing approximately equal to
        specified spacing.
        
        RegularGenerator(spacing, split=False)
            create generator with equal spacing in all directions
        
        RegularGenerator(spacing0, spacing1, split=False)
            create generator with equal spacing
        
        Args:
           spacing (float): Approximate spacing between mesh lines in all directions.
           spacing0 (float): Approximate spacing between mesh lines in transverse
                             direction.
           spacing1 (float): Approximate spacing between mesh lines in vertical
                             direction.
           split (bool): If ``True``, the mesh lines are split into two at each object
                         boundary.
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """


    def Right(*args, **kwargs):
        """
        Right() -> Boundary :
            Right edge of the mesh for setting boundary conditions
        """

    def RightOf(object, path=None):
        """
        RightOf(object, path=None)
        
            Boundary right of specified object
        """

    class SimpleGenerator(Generator2D):
        """
        Generator of Rectangular2D mesh with lines at edges of all objects.
        
        SimpleGenerator(split=False)
            create generator
        
        Args:
           split (bool): If ``True``, the mesh lines are split into two at each object
                         boundary.
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """


    class SmoothGenerator(Generator2D):
        """
        Generator of Rectilinear2D mesh with dense sampling at edges and smooth change of element size.
        
        SmoothGenerator()
            create generator without initial division of geometry objects
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def add_refinement(*args, **kwargs):
            """
            add_refinement(self, axis, object, path, at)
            add_refinement(self, axis, object, at)
            add_refinement(self, axis, subtree, at)
            add_refinement(self, axis, path, at)
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            """

        aspect = None
        """
        Maximum aspect ratio for the elements generated by this generator.
        """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def clear_refinements(subtree):
            """
            clear_refinements(subtree)
            
                Clear all refining lines
            """

        factor = None
        """
        factor by which element sizes increase along each axis
        """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def get_refinements(self, axis):
            """
            get_refinements(self, axis)
            
                Get list of all the refinements defined for this generator for specified axis
            """

        large = None
        """
        maximum size of mesh elements along each axis
        """

        def remove_refinement(*args, **kwargs):
            """
            remove_refinement(self, axis, object, path, at)
            remove_refinement(self, axis, object, at)
            remove_refinement(self, axis, subtree, at)
            remove_refinement(self, axis, path, at)
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            """

        def remove_refinements(*args, **kwargs):
            """
            remove_refinements(self, object, path=None)
            remove_refinements(self, path)
            remove_refinements(self, subtree)
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            """

        small = None
        """
        small size of mesh elements near object edges along each axis
        """

        warn_missing = None
        """
        Warn if refining path does not point to any object
        """

        warn_multiple = None
        """
        Warn if refining path points to more than one object
        """

        warn_ouside = None
        """
        Warn if refining line is outside of its object
        """


    def Top(*args, **kwargs):
        """
        Top() -> Boundary :
            Top edge of the mesh for setting boundary conditions
        """

    def TopOf(object, path=None):
        """
        TopOf(object, path=None)
        
            Boundary top of specified object
        """

    def Vertical(*args, **kwargs):
        """
        Vertical(at, start, stop)
        Vertical(at)
        
            Boundary at vertical line
        
            Boundary at vertical line
        """

    axis0 = None
    """
    The first (transverse) axis of the mesh
    """

    axis1 = None
    """
    The second (vertical) axis of the mesh
    """

    axis_tran = None
    """
    The first (transverse) axis of the mesh, alias for :attr:`axis0`
    """

    axis_vert = None
    """
    The second (vertical) axis of the mesh, alias for :attr:`axis1`
    """

    def copy(self):
        """
        copy(self)
        
            Make a copy of this mesh
        """

    dim = 2
    elements = None
    """
    Element list in the mesh
    """

    def get_midpoints(self):
        """
        get_midpoints(self)
        
            Get new mesh with points in the middles of elements of this mesh
        """

    def index(self, index0, index1):
        """
        index(self, index0, index1)
        
            Return single index of the point indexed with index0 and index1
        """

    def index0(self, index):
        """
        index0(self, index)
        
            Return index in the first axis of the point with given index
        """

    def index1(self, index):
        """
        index1(self, index)
        
            Return index in the second axis of the point with given index
        """

    index_tran = None
    """
    Alias for :attr:`index0`
    """

    index_vert = None
    """
    Alias for :attr:`index1`
    """

    major_axis = None
    """
    The slower changing axis
    """

    def major_index(self, index):
        """
        major_index(self, index)
        
            Return index in the major axis of the point with given index
        """

    minor_axis = None
    """
    The quicker changing axis
    """

    def minor_index(self, index):
        """
        minor_index(self, index)
        
            Return index in the minor axis of the point with given index
        """

    ordering = None
    """
    Ordering of the points in this mesh
    """

    def set_optimal_ordering(self):
        """
        set_optimal_ordering(self)
        
            Set the optimal ordering of the points in this mesh
        """



class RectangularBase3D(Mesh3D):
    """
    Base class for 3D rectangular meshes.Do not use it directly.
    """
    def Back(*args, **kwargs):
        """
        Back() -> Boundary :
            Back side of the mesh for setting boundary conditions
        """

    def BackOf(object, path=None):
        """
        BackOf(object, path=None)
        
            Boundary back of specified object
        """

    def Bottom(*args, **kwargs):
        """
        Bottom() -> Boundary :
            Bottom side of the mesh for setting boundary conditions
        """

    def BottomOf(object, path=None):
        """
        BottomOf(object, path=None)
        
            Boundary bottom of specified object
        """

    class Boundary(object):
        """
        Generic boundary specification for RectangularBase3D mesh
        """
        def __call__(self, mesh, geometry):
            """
            __call__(self, mesh, geometry)
            
                Get boundary instance for particular mesh
            """


    class BoundaryConditions(object):
        """
        Set of boundary conditions.
        """
        class BoundaryCondition(object):
            class Iterator(object):
                pass

            place = None
            """
            Location of the boundary condition.
            """

            value = None
            """
            Value of the boundary condition.
            """


        class Iterator(object):
            pass

        def append(self, place, value):
            """
            append(self, place, value)
            
                Append new boundary condition to the list.
            """

        def clear(self):
            """
            clear(self)
            
                Clear all boundary conditions.
            """

        def insert(self, index, place, value):
            """
            insert(self, index, place, value)
            
                Insert new boundary condition to the list at specified position.
            """

        def prepend(self, place, value):
            """
            prepend(self, place, value)
            
                Prepend new boundary condition to the list.
            """

        def read_from_xpl(self, xml, manager):
            """
            read_from_xpl(self, xml, manager)
            
                Read boundary conditions from active XPL reader.
                
                This should only be used in the overloaded :meth:`plask.Solver.load_xpl` method.
            """


    def Front(*args, **kwargs):
        """
        Front() -> Boundary :
            Front side of the mesh for setting boundary conditions
        """

    def FrontOf(object, path=None):
        """
        FrontOf(object, path=None)
        
            Boundary in front of specified object
        """

    def Left(*args, **kwargs):
        """
        Left() -> Boundary :
            Left side of the mesh for setting boundary conditions
        """

    def LeftOf(object, path=None):
        """
        LeftOf(object, path=None)
        
            Boundary left of specified object
        """

    def Right(*args, **kwargs):
        """
        Right() -> Boundary :
            Right side of the mesh for setting boundary conditions
        """

    def RightOf(object, path=None):
        """
        RightOf(object, path=None)
        
            Boundary right of specified object
        """

    def Top(*args, **kwargs):
        """
        Top() -> Boundary :
            Top side of the mesh for setting boundary conditions
        """

    def TopOf(object, path=None):
        """
        TopOf(object, path=None)
        
            Boundary top of specified object
        """

    dim = 3


class Rectangular3D(RectangularBase3D):
    """
    Three-dimensional mesh
    
    Rectangular3D(ordering='012')
        create empty mesh
    
    Rectangular3D(axis0, axis1, axis2, ordering='012')
        create mesh with axes supplied as mesh.OrderedAxis
    
    Rectangular3D(geometry, ordering='012')
        create coarse mesh based on bounding boxes of geometry objects
    
    ordering can be any a string containing any permutation of and specifies ordering of the
    mesh points (last index changing fastest).
    """
    def Back(*args, **kwargs):
        """
        Back() -> Boundary :
            Back side of the mesh for setting boundary conditions
        """

    def BackOf(object, path=None):
        """
        BackOf(object, path=None)
        
            Boundary back of specified object
        """

    def Bottom(*args, **kwargs):
        """
        Bottom() -> Boundary :
            Bottom side of the mesh for setting boundary conditions
        """

    def BottomOf(object, path=None):
        """
        BottomOf(object, path=None)
        
            Boundary bottom of specified object
        """

    class Boundary(object):
        """
        Generic boundary specification for RectangularBase3D mesh
        """
        def __call__(self, mesh, geometry):
            """
            __call__(self, mesh, geometry)
            
                Get boundary instance for particular mesh
            """


    class BoundaryConditions(object):
        """
        Set of boundary conditions.
        """
        class BoundaryCondition(object):
            class Iterator(object):
                pass

            place = None
            """
            Location of the boundary condition.
            """

            value = None
            """
            Value of the boundary condition.
            """


        class Iterator(object):
            pass

        def append(self, place, value):
            """
            append(self, place, value)
            
                Append new boundary condition to the list.
            """

        def clear(self):
            """
            clear(self)
            
                Clear all boundary conditions.
            """

        def insert(self, index, place, value):
            """
            insert(self, index, place, value)
            
                Insert new boundary condition to the list at specified position.
            """

        def prepend(self, place, value):
            """
            prepend(self, place, value)
            
                Prepend new boundary condition to the list.
            """

        def read_from_xpl(self, xml, manager):
            """
            read_from_xpl(self, xml, manager)
            
                Read boundary conditions from active XPL reader.
                
                This should only be used in the overloaded :meth:`plask.Solver.load_xpl` method.
            """


    class DivideGenerator(Generator3D):
        """
        Generator of Rectilinear3D mesh by simple division of the geometry.
        
        DivideGenerator()
            create generator without initial division of geometry objects
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def add_refinement(*args, **kwargs):
            """
            add_refinement(self, axis, object, path, at)
            add_refinement(self, axis, object, at)
            add_refinement(self, axis, subtree, at)
            add_refinement(self, axis, path, at)
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            """

        aspect = None
        """
        Maximum aspect ratio for the elements generated by this generator.
        """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def clear_refinements(subtree):
            """
            clear_refinements(subtree)
            
                Clear all refining lines
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def get_refinements(self, axis):
            """
            get_refinements(self, axis)
            
                Get list of all the refinements defined for this generator for specified axis
            """

        gradual = None
        """
        Limit maximum adjacent objects size change to the factor of two.
        """

        postdiv = None
        """
        final division of all geometry objects
        """

        prediv = None
        """
        initial division of all geometry objects
        """

        def remove_refinement(*args, **kwargs):
            """
            remove_refinement(self, axis, object, path, at)
            remove_refinement(self, axis, object, at)
            remove_refinement(self, axis, subtree, at)
            remove_refinement(self, axis, path, at)
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            """

        def remove_refinements(*args, **kwargs):
            """
            remove_refinements(self, object, path=None)
            remove_refinements(self, path)
            remove_refinements(self, subtree)
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            """

        warn_missing = None
        """
        Warn if refining path does not point to any object
        """

        warn_multiple = None
        """
        Warn if refining path points to more than one object
        """

        warn_ouside = None
        """
        Warn if refining line is outside of its object
        """


    class Element(object):
        """
        Element (FEM-like, rectangular) of the :py:class:`mesh.Rectangular3D
        """
        back = None
        """
        Position of the back edge of the element
        """

        bottom = None
        """
        Position of the bottom edge of the element
        """

        box = None
        """
        Bounding box of the element
        """

        center = None
        """
        Position of the element center
        """

        depth = None
        """
        Depth of the element
        """

        front = None
        """
        Position of the front edge of the element
        """

        height = None
        """
        Height of the element
        """

        index = None
        """
        Element index
        """

        index0 = None
        """
        Element index in the first axis
        """

        index1 = None
        """
        Element index in the second axis
        """

        index2 = None
        """
        Element index in the third axis
        """

        left = None
        """
        Position of the left edge of the element
        """

        nodes = None
        """
        Indices of the element vertices on the orignal mesh
        
        Order of the vertices is back bottom left, back  bottom right, top left,
        back top right, front bottom left, front bottom right, front top left,
        and front top right.
        """

        right = None
        """
        Position of the right edge of the element
        """

        top = None
        """
        Position of the top edge of the element
        """

        volume = None
        """
        Volume of the element
        """

        width = None
        """
        Width of the element
        """


    class Elements(object):
        """
        Element list in the :py:class:`mesh.Rectangular3D
        """
        mesh = None
        """
        Mesh with element centers
        """


    def Front(*args, **kwargs):
        """
        Front() -> Boundary :
            Front side of the mesh for setting boundary conditions
        """

    def FrontOf(object, path=None):
        """
        FrontOf(object, path=None)
        
            Boundary in front of specified object
        """

    def Left(*args, **kwargs):
        """
        Left() -> Boundary :
            Left side of the mesh for setting boundary conditions
        """

    def LeftOf(object, path=None):
        """
        LeftOf(object, path=None)
        
            Boundary left of specified object
        """

    class RegularGenerator(Generator3D):
        """
        Generator of Rectilinear3D mesh with lines at transverse edges of all objects
        and fine regular division of each object with spacing approximately equal to
        specified spacing
        
        RegularGenerator(spacing, split=False)
            create generator with equal spacing in all directions
        
        RegularGenerator(spacing0, spacing1, spacing2, split=False)
            create generator with equal spacing
        
        Args:
           spacing (float): Approximate spacing between mesh lines in all directions.
           spacing0 (float): Approximate spacing between mesh lines in longitudinal
                             direction.
           spacing1 (float): Approximate spacing between mesh lines in transverse
                             direction.
           spacing2 (float): Approximate spacing between mesh lines in vertical
                             direction.
           split (bool): If ``True``, the mesh lines are split into two at each object
                         boundary.
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """


    def Right(*args, **kwargs):
        """
        Right() -> Boundary :
            Right side of the mesh for setting boundary conditions
        """

    def RightOf(object, path=None):
        """
        RightOf(object, path=None)
        
            Boundary right of specified object
        """

    class SimpleGenerator(Generator3D):
        """
        Generator of Rectangular3D mesh with lines at edges of all objects.
        
        SimpleGenerator(split=False)
            create generator
        
        Args:
           split (bool): If ``True``, the mesh lines are split into two at each object
                         boundary.
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """


    class SmoothGenerator(Generator3D):
        """
        Generator of Rectilinear3D mesh with dense sampling at edges and smooth change of element size.
        
        SmoothGenerator()
            create generator without initial division of geometry objects
        """
        def __call__(*args, **kwargs):
            """
            __call__(self, geometry)
            __call__(self, object)
            
                Generate mesh for given geometry object or load it from the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def add_refinement(*args, **kwargs):
            """
            add_refinement(self, axis, object, path, at)
            add_refinement(self, axis, object, at)
            add_refinement(self, axis, subtree, at)
            add_refinement(self, axis, path, at)
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            
                Add a refining line inside the object
            """

        aspect = None
        """
        Maximum aspect ratio for the elements generated by this generator.
        """

        def clear_cache(self):
            """
            clear_cache(self)
            
                Clear cache of generated meshes
            """

        def clear_refinements(subtree):
            """
            clear_refinements(subtree)
            
                Clear all refining lines
            """

        factor = None
        """
        factor by which element sizes increase along each axis
        """

        def generate(*args, **kwargs):
            """
            generate(self, geometry)
            generate(self, object)
            
                Generate mesh for given geometry object omitting the cache.
                
                Args:
                    geometry: Geometry to generate mesh at.
                    object: Geometry object to generate mesh at.
            """

        def get_refinements(self, axis):
            """
            get_refinements(self, axis)
            
                Get list of all the refinements defined for this generator for specified axis
            """

        large = None
        """
        maximum size of mesh elements along each axis
        """

        def remove_refinement(*args, **kwargs):
            """
            remove_refinement(self, axis, object, path, at)
            remove_refinement(self, axis, object, at)
            remove_refinement(self, axis, subtree, at)
            remove_refinement(self, axis, path, at)
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            
                Remove the refining line from the object
            """

        def remove_refinements(*args, **kwargs):
            """
            remove_refinements(self, object, path=None)
            remove_refinements(self, path)
            remove_refinements(self, subtree)
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            
                Remove the all refining lines from the object
            """

        small = None
        """
        small size of mesh elements near object edges along each axis
        """

        warn_missing = None
        """
        Warn if refining path does not point to any object
        """

        warn_multiple = None
        """
        Warn if refining path points to more than one object
        """

        warn_ouside = None
        """
        Warn if refining line is outside of its object
        """


    def Top(*args, **kwargs):
        """
        Top() -> Boundary :
            Top side of the mesh for setting boundary conditions
        """

    def TopOf(object, path=None):
        """
        TopOf(object, path=None)
        
            Boundary top of specified object
        """

    axis0 = None
    """
    The first (longitudinal) axis of the mesh
    """

    axis1 = None
    """
    The second (transverse) axis of the mesh
    """

    axis2 = None
    """
    The third (vertical) axis of the mesh
    """

    axis_long = None
    """
    The first (longitudinal) axis of the mesh, alias for :attr:`axis0`
    """

    axis_tran = None
    """
    The second (transverse) axis of the mesh, alias for :attr:`axis1`
    """

    axis_vert = None
    """
    The third (vertical) axis of the mesh, alias for :attr:`axis2`
    """

    def copy(self):
        """
        copy(self)
        
            Make a copy of this mesh
        """

    dim = 3
    elements = None
    """
    Element list in the mesh
    """

    def get_midpoints(self):
        """
        get_midpoints(self)
        
            Get new mesh with points in the middles of of elements of this mesh
        """

    def index(self, index0, index1, index2):
        """
        index(self, index0, index1, index2)
        
            Return single index of the point indexed with index0, index1, and index2
        """

    def index0(self, index):
        """
        index0(self, index)
        
            Return index in the first axis of the point with given index
        """

    def index1(self, index):
        """
        index1(self, index)
        
            Return index in the second axis of the point with given index
        """

    def index2(self, index):
        """
        index2(self, index)
        
            Return index in the third axis of the point with given index
        """

    index_long = None
    """
    Alias for :attr:`index0`
    """

    index_tran = None
    """
    Alias for :attr:`index1`
    """

    index_vert = None
    """
    Alias for :attr:`index2`
    """

    major_axis = None
    """
    The slowest changing axis
    """

    def major_index(self, index):
        """
        major_index(self, index)
        
            Return index in the major axis of the point with given index
        """

    medium_axis = None
    """
    The middle changing axis
    """

    def middle_index(self, index):
        """
        middle_index(self, index)
        
            Return index in the middle axis of the point with given index
        """

    minor_axis = None
    """
    The quickest changing axis
    """

    def minor_index(self, index):
        """
        minor_index(self, index)
        
            Return index in the minor axis of the point with given index
        """

    ordering = None
    """
    Ordering of the points in this mesh
    """

    def set_optimal_ordering(self):
        """
        set_optimal_ordering(self)
        
            Set the optimal ordering of the points in this mesh
        """



class Regular(Axis):
    """
    One-dimesnional regular mesh, used also as rectangular mesh axis
    
    Regular()
        create empty mesh
    
    Regular(start, stop, num)
        create mesh of count points equally distributed between start and stop
    """
    dim = 1
    def get_midpoints(self):
        """
        get_midpoints(self)
        """

    midpoints = None
    """
    Mesh with points in the middles of elements of this mesh
    """

    def resize(self, num):
        """
        resize(self, num)
        
            Change number of points in this mesh
        """

    start = None
    """
    Position of the beginning of the mesh
    """

    step = None

    stop = None
    """
    Position of the end of the mesh
    """



class TriangleGenerator(Generator2D):
    """
    Generator which creates triangular mesh by Triangle library authored by Jonathan Richard Shewchuk.
    
    Triangle generates exact Delaunay triangulations, constrained Delaunay triangulations,conforming Delaunay triangulations, Voronoi diagrams, and high-quality triangular meshes.
    The latter can be generated with no small or large angles,and are thus suitable for finite element analysis.
    
    See: https://www.cs.cmu.edu/~quake/triangle.html
    """
    def __call__(*args, **kwargs):
        """
        __call__(self, geometry)
        __call__(self, object)
        
            Generate mesh for given geometry object or load it from the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """

    def clear_cache(self):
        """
        clear_cache(self)
        
            Clear cache of generated meshes
        """

    def generate(*args, **kwargs):
        """
        generate(self, geometry)
        generate(self, object)
        
            Generate mesh for given geometry object omitting the cache.
            
            Args:
                geometry: Geometry to generate mesh at.
                object: Geometry object to generate mesh at.
        """



class Triangular2D(Mesh2D):
    """
    Two-dimensional triangular mesh
    """
    def Bottom(*args, **kwargs):
        """
        Bottom() -> object :
            Bottom edge of the mesh for setting boundary conditions
        """

    def BottomOf(object, path=None):
        """
        BottomOf(object, path=None)
        
            Boundary bottom of specified object
        """

    class Builder(object):
        """
        Allows for adding triangles to the :py:class:`mesh.Triangular2D effectively
        """
        def add(*args, **kwargs):
            """
            add(self, p1, p2, p3)
            add(self, element)
            
                add a triangle (with given vertices: p1, p2, p3) to the mesh
            
                add a triangle represented by the given element to the mesh
            """


    def Edge(*args, **kwargs):
        """
        Edge() -> object :
            Whole edge (outer and inner) of the mesh for setting boundary conditions
        """

    def EdgeOf(object, path=None):
        """
        EdgeOf(object, path=None)
        
            Edge of specified object (and edge of mesh holes inside the object)
        """

    class Element(object):
        """
        Element (FEM-like, triangle) of the :py:class:`mesh.Triangular2D
        """
        area = None
        """
        Area of the element
        """

        def barycentric(self, arg2):
            """
            barycentric(self, arg2)
            
                barycentric (area) coordinates of given point
            """

        box = None
        """
        bounding box of the element
        """

        center = None
        """
        Position of the element center
        """

        def node(self, index):
            """
            node(self, index)
            
                coordinate of the element (triangle) vertex
            """

        node_indexes = None
        """
        Indices of the element (triangle) vertices on the orignal mesh.
        """

        nodes = None
        """
        coordinates of the element (triangle) vertices
        """

        volume = None
        """
        Alias for :attr:`area`
        """


    class Elements(object):
        """
        Element list in the :py:class:`mesh.Triangular2D
        """

    def Left(*args, **kwargs):
        """
        Left() -> object :
            Left edge of the mesh for setting boundary conditions
        """

    def LeftOf(object, path=None):
        """
        LeftOf(object, path=None)
        
            Boundary left of specified object
        """

    def Right(*args, **kwargs):
        """
        Right() -> object :
            Right edge of the mesh for setting boundary conditions
        """

    def RightOf(object, path=None):
        """
        RightOf(object, path=None)
        
            Boundary right of specified object
        """

    def Top(*args, **kwargs):
        """
        Top() -> object :
            Top edge of the mesh for setting boundary conditions
        """

    def TopOf(object, path=None):
        """
        TopOf(object, path=None)
        
            Boundary top of specified object
        """

    dim = 2
    elements = None
    """
    Element list in the mesh
    """



class Unstructured2D(Mesh2D):
    """
    Unstructured2D(points)
    
    Two-dimensional unstructured mesh.
    
    Args:
        points: List of mesh points. Each element in this list should be
                a two-dimensional vector or sequence of floats with point
                coordinates.
    """
    dim = 2


class Unstructured3D(Mesh3D):
    """
    Unstructured3D(points)
    
    Three-dimensional unstructured mesh.
    
    Args:
        points: List of mesh points. Each element in this list should be
                a three-dimensional vector or sequence of floats with point
                coordinates.
    """
    dim = 3

