# Discretization mesh - Data-Acquisition-and-Processing-Lab/ECTsim GitHub Wiki

# defineMesh

Distributes points (pixels) across the workspace. It creates two variables—matrices X and Y—that store x and y coordinates, representing the grid. The inputs are numbers of points spread along the width and height of the workspace.

`nargin = 3`

-> 2D`nargin = 4`

-> 3D

**Usage:** `[model] = defineMesh(model, varargin);`

`varargin`

-> widthPoints, heightPoints, depthPoints

*model*- structure with a numerical model description*widthPoints*- mesh width*heightPoints*- mesh height*depthPoints*- mesh depth

# findIndexFwdp

Finds indices in a quadtree mesh.

**Usage:** `[index] = findIndexFwdp(model, element_name);`

*model*- structure with a numerical model description*element_name*- the name of the element

# findNeighbors

Finds pixels (four neighbors in 2D and six in 3D) near a pixel with a given index.

**Usage:** `[QT] = findNeighbors(QT, index);`

*QT*- quadtree structure with a numerical model description*index*- the index of the pixel for which neighbors are searched

# fineMesh

Modifies a pattern image used by the meshing algorithm. Generating a pattern in a specific geometrical element creates a finer mesh in that area. A chessboard pattern is generated in the selected element of the space.

**Usage:** `model = fineMesh(model, element, elementSize);`

*model*- structure with a numerical model description*element*- the name of the element*elementSize*- determines the mesh size

# meshing

The meshing function creates and manages a quadtree of an image.

**Usage:** `[model] = meshing(model, pixMin, pixMax);`

*model*- structure with a numerical model description*pixMin*- minimum pixel size in a mesh*pixMax*- maximum pixel size in a mesh

# qtComp

The qtComp function recreates a full matrix from a quadtree sparse with new chosen values.

**Usage:** `[fullMat] = qtComp(model, varargin);`

*fullMat*- full matrix (uniform) with values*QT*- structure with a numerical model description necessary to create a quadtree*varargin*- nonuniform mesh to be represented in a uniform mesh

# qtCut

Function for a single cut in a quadtree structure. Used as a recursive function by *qtDecom*.

**Usage:** `[qt] = qtCut(QT, A, S, param, pixMin, pixMax);`

*qt*- quadtree mesh structure*A*- full matrix to cut*S*- temporary matrix that is part of A*param*- measure of non-uniformity*pixMin*- minimum pixel size in a mesh*pixMax*- maximum pixel size in a mesh

# qtDecom

Function to create a quadtree structure. Used in *meshing*.

**Usage:** `qt = qtDecom(QT, A, param, pixMin, pixMax);`

*QT*- structure with a numerical model description necessary to create a quadtree*A*- a map used for forming a uniform mesh*param*- measure of non-uniformity*pixMin*- minimum pixel size in a mesh*pixMax*- maximum pixel size in a mesh*qt*- quadtree structure with a numerical model description

# recNeighSearch

Recurrent neighbor searching. Used by *findNeighbors*.

**Usage:** `[nList] = recNeighSearch(QT, index, pixSize, nList, plane);`

*QT*- quadtree structure with a numerical model description*index*- the index of the pixel for which the neighbors are searched*pixSize*- size of an element*nList*- structure with the latest list of neighbors in plane*plane*- name of the plane to search: 1 - k, 2 - j, 3 - i